/* ==========================================================================
   Components — header/nav, buttons, cards, tags, forms, carousel, footer
   ========================================================================== */

/* ---------- Header & primary nav (always visible, book-tab style) ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 4vw;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 560px) {
  .site-header { gap: 20px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: .05em;
  color: var(--text);
  flex-shrink: 0;
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 9px;
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.brand-name {
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 40px; /* matches .brand-mark's 40px height */
  line-height: 1;
}

/* Below 560px, the wordmark yields its space to the nav — the icon alone
   still identifies the brand and keeps every nav tab reachable without a
   long horizontal scroll. */
@media (max-width: 559px) {
  .brand-name { display: none; }
}

.primary-nav {
  /* Size to its own content and dock to the right, next to the theme
     toggle — leaving open space next to the brand rather than stretching
     across the header. Shrinks (and its ul scrolls internally) if the
     header gets too narrow to fit everything. */
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}
.primary-nav ul {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.primary-nav ul::-webkit-scrollbar { display: none; }
.primary-nav a {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 9px 11px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

@media (min-width: 560px) {
  .primary-nav a { padding: 9px 14px; font-size: 14px; }
  /* On mobile the tabs stay left-aligned so "Home" is never scrolled out of
     view on load; once there's room, push the whole group to sit near the
     theme toggle on the right, with the brand anchored on the left. */
  .primary-nav ul { justify-content: flex-end; }
}
.primary-nav a:hover { color: var(--text); background: var(--surface); }
.primary-nav a[aria-current="page"] {
  color: var(--accent-text);
  background: var(--accent);
}

.theme-toggle {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.theme-toggle:hover { border-color: var(--border-strong); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Page transition host ---------- */

#main {
  position: relative;
  min-height: 60vh;
}
.page {
  animation: page-fade-in var(--dur-slow) var(--ease) both;
}
@keyframes page-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Page-turn (book) navigation ---------- */

.page-turn[hidden] { display: none; }
.page-turn {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.page-turn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 5vw;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.page-turn-btn:hover { background: var(--surface); }
.page-turn-btn:disabled {
  opacity: 0;
  pointer-events: none;
}
.page-turn-btn.next { text-align: right; align-items: flex-end; }
.page-turn-eyebrow {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint);
}
.page-turn-title {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.page-turn-btn.next .page-turn-title { flex-direction: row-reverse; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 14px;
  letter-spacing: .03em;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-strong); box-shadow: var(--shadow-md); color: var(--accent-text); }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--accent); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }

.btn-muted { background: transparent; color: var(--text-faint); border-color: var(--border); }
.btn-muted:hover { color: var(--text-muted); border-color: var(--border-strong); }

/* ---------- Cards (rounded, soft shadow, hover lift) ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-med) var(--ease), box-shadow var(--dur-med) var(--ease);
}
.card.is-interactive:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.card-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: transform var(--dur-med) var(--ease), border-color var(--dur-med) var(--ease);
}
.card-outline.is-interactive:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.card-outline.is-accent { border-color: var(--accent); }

/* ---------- Tags / pills ---------- */

.tag {
  display: inline-flex;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--text-muted);
}

/* ---------- Chapter heading block ---------- */

.chapter-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 48px;
}
.chapter-num {
  font-family: var(--font-display);
  font-size: clamp(48px, 13vw, 96px);
  line-height: 1;
  font-weight: 500;
  color: var(--surface-2);
  max-width: 120px;
}
.chapter-eyebrow {
  font-size: 13px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent-strong); margin: 0 0 8px;
}
.chapter-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 52px);
  font-weight: 500;
  color: var(--text);
}
.chapter-note { font-size: 13px; color: var(--text-faint); margin: 8px 0 0; }

/* ---------- Timeline ---------- */

.timeline-item { display: flex; gap: 20px; padding-bottom: 26px; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; width: 14px; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.timeline-line { width: 1px; flex: 1; background: var(--border-strong); margin-top: 4px; }
.timeline-stage {
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
  color: var(--quote); margin: 0 0 4px;
}
.timeline-text { font-size: 14.5px; line-height: 1.7; color: var(--text-muted); }

/* ---------- Quote carousel ---------- */

.quote-carousel {
  text-align: center;
}
.quote-stage {
  min-height: 160px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.quote-stage blockquote {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(22px, 3.2vw, 34px); line-height: 1.5;
  color: var(--quote); margin: 0;
  animation: quote-in var(--dur-slow) var(--ease) both;
}
@keyframes quote-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.quote-dots { display: flex; justify-content: center; gap: 10px; margin-top: 28px; }
.quote-dot {
  width: 8px; height: 8px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: var(--border-strong);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.quote-dot.is-active { background: var(--link); transform: scale(1.2); }

/* ---------- Forms ---------- */

.field {
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  width: 100%;
}
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 25%, transparent);
}
.field::placeholder { color: var(--text-faint); }
textarea.field { resize: vertical; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 200px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-row[hidden], .form-stack[hidden] { display: none; }

.form-success {
  font-size: 14px; color: var(--success);
  padding: 14px 16px;
  background: color-mix(in oklch, var(--success) 12%, transparent);
  border-radius: var(--radius-sm);
  animation: page-fade-in var(--dur-med) var(--ease) both;
}

/* ---------- Review submission form ---------- */

.review-form-wrap { max-width: 480px; }
.field-label {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint);
}
.star-input { display: flex; gap: 6px; margin: 4px 0 2px; }
.star-btn {
  background: none; border: none; cursor: pointer;
  font-size: 26px; line-height: 1; padding: 2px;
  color: var(--border-strong);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.star-btn:hover { transform: scale(1.12); }
.star-btn.is-filled { color: var(--accent-strong); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 48px 5vw 40px;
}
.footer-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 32px;
  text-align: center;
}
.footer-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.footer-brand img { width: 34px; height: 34px; object-fit: contain; }
.footer-brand span { font-family: var(--font-display); font-weight: 500; font-size: 34px; line-height: 1; color: var(--text); }
.footer-copy { font-size: 13px; color: var(--text-faint); margin: 0; }
.footer-right { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.footer-socials { display: flex; gap: 10px; }
.footer-legal-link { font-size: 13px; color: var(--text-faint); text-decoration: underline; }
.footer-legal-link:hover { color: var(--text); }

.social-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-muted);
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.social-btn:hover { border-color: var(--accent); color: var(--text); }
.social-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
