/*
  Hadithi web platform — theme tokens matching packages/theme/lib/src/
  tokens/*.dart exactly, so the public website can switch between the
  same three rooms (Jua/Pulse/Karatasi) as the Flutter apps instead of
  being locked to one. Karatasi ("paper") stays the default/fallback —
  see docs/PROGRESS.md for the history of why the site started
  single-themed and what changed. Every rule elsewhere in this file reads
  colors through these custom properties, so a theme switch is just
  swapping the block below via [data-theme] on <html> — see
  initThemeSwitcher() in web.js and the data-theme read server-side in
  layout.blade.php (avoids a flash of the wrong theme on navigation).
*/

:root,
:root[data-theme="karatasi"] {
  --background: #FBF6EC;
  --background-rgb: 251, 246, 236;
  --surface: #F3EBDB;
  --surface-strong: #ECE0C9;
  --text: #241F19;
  --text-muted: #8A7F6E;
  --hairline: #DCCFAF;
  --accent: #7A2E2A;
  --accent-rgb: 122, 46, 42;
  --accent-strong: #5E2320;
  --on-accent: #FBF6EC;
  --radius-card: 6px;
  --radius-sm: 4px;
  --radius-pill: 999px;
  /* Fraunces (Bunny Fonts, loaded in layout.blade.php — same privacy-
     friendly Google Fonts mirror the Filament admin already uses): a
     warm, slightly literary display serif that gives Karatasi an actual
     typographic signature instead of falling back to whatever serif the
     visitor's OS ships. Georgia stays as the fallback chain. */
  --font-title: 'Fraunces', Georgia, 'Times New Roman', serif;
  --shadow-sm: 0 1px 3px rgba(36, 31, 25, 0.07);
  --shadow-md: 0 8px 24px -4px rgba(36, 31, 25, 0.14);
  --shadow-lg: 0 24px 48px -12px rgba(36, 31, 25, 0.22);
  --hero-glow: radial-gradient(closest-side, rgba(var(--accent-rgb), 0.09), transparent);
}

/* Jua ("sun") — the fireside room. Warm, oral, unhurried. Values match
   packages/theme/lib/src/tokens/jua.dart. */
:root[data-theme="jua"] {
  --background: #241812;
  --background-rgb: 36, 24, 18;
  --surface: #2E2016;
  --surface-strong: #3A2A1B;
  --text: #F3E7D6;
  --text-muted: #B29B80;
  --hairline: #453424;
  --accent: #E0762F;
  --accent-rgb: 224, 118, 47;
  --accent-strong: #B85A1F;
  --on-accent: #241209;
  --radius-card: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font-title: 'Fraunces', Georgia, 'Times New Roman', serif;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
  --hero-glow: radial-gradient(closest-side, rgba(var(--accent-rgb), 0.2), transparent);
}

/* Pulse — the platform room. Familiar, fast, confident. Built on Roote
   Technologies' own logo gradient (purple -> blue -> teal). Values match
   packages/theme/lib/src/tokens/pulse.dart. */
:root[data-theme="pulse"] {
  --background: #0B0E1A;
  --background-rgb: 11, 14, 26;
  --surface: #131A2E;
  --surface-strong: #182140;
  --text: #EDEFF7;
  --text-muted: #7C86A6;
  --hairline: #232C48;
  --accent: #7C6CF0;
  --accent-rgb: 124, 108, 240;
  --accent-strong: #5D50C7;
  --on-accent: #FFFFFF;
  --radius-card: 10px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  /* Pulse's titleFontFamily is null in the Dart token (system sans, no
     serif) — reuses --font-body rather than Fraunces. */
  --font-title: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.55);
  --hero-glow:
    radial-gradient(closest-side at 35% 30%, rgba(130, 84, 255, 0.22), transparent 70%),
    radial-gradient(closest-side at 65% 45%, rgba(13, 120, 226, 0.18), transparent 70%),
    radial-gradient(closest-side at 50% 65%, rgba(0, 194, 220, 0.14), transparent 70%);
}

:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 0.45s;
}
/* A theme switch recolors html/body instantly by default (CSS custom
   properties don't animate on their own) — this crossfades the two
   surfaces every page sits on so switching rooms reads as a deliberate
   transition rather than a hard snap. Per-component hover transitions
   elsewhere in this file are unaffected. */
html, body {
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

/* A visitor's very first paint before web.js has run is only ever this
   one class — the loading bar below reads html.is-navigating, added on
   internal link clicks, purely a decorative "the site is alive" cue
   during the brief moment before the browser unloads the page. */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.5s var(--ease);
  pointer-events: none;
}
html.is-navigating body::before { width: 72%; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* Scroll-reveal — see public/js/web.js's IntersectionObserver. Falls
   back to fully visible with no JS (progressive enhancement, not a
   dependency the page requires to be usable). */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: calc(var(--i, 0) * 70ms);
}
.reveal-stagger > *.is-visible { opacity: 1; transform: none; }
:root:has(html.no-js) .reveal,
:root:has(html.no-js) .reveal-stagger > * { opacity: 1; transform: none; }

/* Signature decorative motif — a minimal line+leaf flourish standing in
   for Karatasi's "tree-branch line art" (see docs/design's UI direction
   review), never actually built into the real site until now. Reused as
   a section divider wherever a hard rule would otherwise sit. */
.branch-divider {
  display: block;
  width: 130px;
  height: 15px;
  margin: 0 auto;
  color: var(--hairline);
  overflow: visible;
}
.branch-divider.accent { color: var(--accent); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Nav */
.site-nav {
  border-bottom: 1px solid var(--hairline);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: box-shadow var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
/* .is-scrolled toggled by web.js past an 8px scroll threshold — a
   plain sticky border reads fine at rest, but a hairline alone
   disappears against busy hero imagery once content scrolls under it. */
.site-nav.is-scrolled {
  box-shadow: var(--shadow-sm);
  background: rgba(var(--background-rgb), 0.92);
  backdrop-filter: blur(8px);
}
.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.site-nav .logo {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.site-nav nav {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}
.site-nav nav a {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  position: relative;
  transition: color var(--duration) var(--ease);
}
.site-nav nav a.active,
.site-nav nav a:hover {
  color: var(--accent);
  text-decoration: none;
}
/* An animated underline instead of instant text-decoration — the kind
   of small polish that separates "styled" from "designed". */
.site-nav nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -4px;
  height: 1.5px;
  background: var(--accent);
  transition: right var(--duration) var(--ease);
}
.site-nav nav a.active::after,
.site-nav nav a:hover::after { right: 0; }
.site-nav form {
  display: flex;
  flex: 1 1 160px;
  min-width: 0;
  max-width: 260px;
}
.site-nav .search-input {
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  min-width: 0;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.site-nav .search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Theme switcher — Jua/Pulse/Karatasi, the same three rooms as the
   Flutter apps' Settings > Appearance screen. See the token blocks at
   the top of this file and initThemeSwitcher() in web.js. */
.theme-switcher { position: relative; flex-shrink: 0; }
.theme-switcher-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.theme-switcher-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.theme-swatch--karatasi { background: linear-gradient(135deg, #7A2E2A 50%, #FBF6EC 50%); }
.theme-swatch--jua { background: linear-gradient(135deg, #E0762F 50%, #241812 50%); }
.theme-swatch--pulse { background: linear-gradient(135deg, #7C6CF0 50%, #0B0E1A 50%); }
.theme-switcher-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 190px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 20;
}
.theme-switcher.is-open .theme-switcher-menu { display: flex; }
.theme-switcher-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background-color var(--duration) var(--ease);
}
.theme-switcher-option:hover { background: var(--surface-strong); }
.theme-switcher-option .name { flex: 1; }
.theme-switcher-option .desc { display: block; color: var(--text-muted); font-size: 11px; margin-top: 1px; }
.theme-switcher-option .check { opacity: 0; color: var(--accent); flex-shrink: 0; }
.theme-switcher-option[aria-pressed="true"] .name { color: var(--accent); font-weight: 600; }
.theme-switcher-option[aria-pressed="true"] .check { opacity: 1; }

/* Hamburger toggle — hidden on desktop, shown once the nav links can no
   longer fit a single row comfortably (see the 768px query below). */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav-toggle:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .site-nav .container { flex-wrap: wrap; justify-content: space-between; }
  .site-nav nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    flex-basis: 100%;
    gap: 2px;
    padding: 12px 0 16px;
    justify-content: flex-start;
  }
  .site-nav nav.is-open { display: flex; }
  .site-nav nav a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--hairline);
  }
  .site-nav nav a::after { display: none; }
  .site-nav form { max-width: none; order: 0; margin-top: 6px; }
  .theme-switcher { width: 100%; order: 0; }
  .theme-switcher-toggle { width: 100%; justify-content: center; }
  .theme-switcher-menu {
    position: static;
    box-shadow: none;
    border: 1px solid var(--hairline);
    width: 100%;
    margin-top: 6px;
    transform: none;
  }
}

/* Hero */
.hero {
  padding: 88px 0 64px;
  text-align: center;
  border-bottom: 1px solid var(--hairline);
  position: relative;
  overflow: hidden;
}
/* A soft radial wash behind the headline — the only "imagery" the hero
   needs when there's no photography to lean on. --hero-glow is themed
   (see the token blocks at the top of this file): a plain accent wash
   for Karatasi/Jua, Pulse's own three-color gradient for Pulse. */
.hero::before {
  content: '';
  position: absolute;
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 720px;
  height: 420px;
  background: var(--hero-glow);
  pointer-events: none;
}
.hero .eyebrow {
  position: relative;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 16px;
}
.hero h1 {
  position: relative;
  font-family: var(--font-title);
  font-size: 52px;
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
}
.hero p {
  position: relative;
  color: var(--text-muted);
  font-size: 17px;
  max-width: 500px;
  margin: 0 auto 32px;
}
.hero .cta-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 40px;
}
.hero .branch-divider { margin-top: 8px; }

@media (max-width: 640px) {
  .hero { padding: 64px 0 44px; }
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease),
    background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-strong);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-secondary {
  background: transparent;
  border-color: var(--hairline);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:active { transform: translateY(0); box-shadow: none; }

/* Sections */
.section { padding: 48px 0; }
.section-label {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 18px;
}

/* Browse filters row — category chips + a country <select>, side by side
   on desktop and stacked on narrow screens (see the @media block below). */
.browse-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}
.country-filter select {
  padding: 8px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
}
.country-filter select:hover,
.country-filter select:focus { outline: none; border-color: var(--accent); }

/* Category chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.chip {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--text-muted);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease),
    background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.chip.active, .chip:hover {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  text-decoration: none;
}
.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* Story grid */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.story-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: block;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.story-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}
.story-card .cover {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--surface-strong), var(--accent));
  overflow: hidden;
}
/* Real thumbnail, when a story has one — the gradient div underneath
   stays as the fallback for stories without one, so this rule alone
   covers every ".cover" context (story-card/featured-story/hero) rather
   than repeating the same img styling per context. */
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  transition: transform 0.6s var(--ease);
}
.story-card:hover .cover img { transform: scale(1.08); }
.story-card .body { padding: 14px; }
.story-card .eyebrow {
  font-size: 10px;
  letter-spacing: 0.6px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 4px;
}
.story-card h3 {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 400;
  margin: 0 0 4px;
}
.story-card .meta { font-size: 12.5px; color: var(--text-muted); margin: 0; }

/* Featured story card (home page) — like .story-card but wide, with the
   cover and body side by side on desktop, stacked on narrow screens. */
.featured-story {
  display: grid;
  grid-template-columns: 280px 1fr;
  max-width: 100%;
}
.featured-story .cover {
  border-radius: var(--radius-card) 0 0 var(--radius-card);
  aspect-ratio: auto;
}
.featured-story .body { padding: 24px; }
.featured-story h3 { font-size: 24px; }
@media (max-width: 640px) {
  .featured-story { grid-template-columns: 1fr; }
  .featured-story .cover { border-radius: var(--radius-card) var(--radius-card) 0 0; aspect-ratio: 16/9; }
}
.featured-story:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* Centered section heading with the branch-divider motif underneath —
   used for the marketing sections of Home (stats, storytellers) where
   .section-label's plain left-aligned eyebrow reads too utilitarian. */
.section-heading { text-align: center; margin-bottom: 40px; }
.section-heading .eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 10px;
}
.section-heading h2 {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 30px;
  margin: 0 0 16px;
}
.section-heading .branch-divider { margin-top: 4px; }

/* Stats band — real counts (App\Http\Controllers\Web\HomeController),
   count-up animated via web.js's [data-count-to] observer. */
.stats-band {
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 32px;
  text-align: center;
  padding: 56px 0;
}
.stat-figure {
  font-family: var(--font-title);
  font-size: 40px;
  font-weight: 500;
  color: var(--accent);
  margin: 0 0 6px;
  font-variant-numeric: tabular-nums;
}
.stat-caption {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* Storytellers strip — real verified creators (HomeController), a
   horizontally-scrollable row so it degrades gracefully on mobile
   without needing a carousel library. */
.storyteller-row {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
.storyteller-card {
  flex: 0 0 168px;
  scroll-snap-align: start;
  text-align: center;
  padding: 20px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.storyteller-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.storyteller-card .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--surface-strong), var(--accent));
  overflow: hidden;
}
.storyteller-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.storyteller-card .name {
  font-family: var(--font-title);
  font-size: 15px;
  color: var(--text);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.storyteller-card .count { color: var(--text-muted); font-size: 12px; }

/* Page header — Browse/Search's left-aligned counterpart to Home's
   centered .section-heading; a functional page gets a title + live
   result count instead of marketing copy. */
.page-header { margin-bottom: 28px; }
.page-header .eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 8px;
}
.page-header h1 {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 34px;
  margin: 0 0 8px;
}
.page-header p { color: var(--text-muted); margin: 0; font-size: 15px; }

/* Search */
.browse-search {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  position: relative;
  align-items: center;
}
.browse-search .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.browse-search input[type="text"] {
  flex: 1;
  padding: 14px 18px 14px 44px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.browse-search input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}
.browse-search .btn-primary { border-radius: var(--radius-pill); white-space: nowrap; }

@media (max-width: 480px) {
  .browse-search { flex-wrap: wrap; }
  .browse-search input[type="text"] { flex-basis: 100%; }
  .browse-search .btn-primary { flex: 1 1 100%; text-align: center; }
}

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-state .branch-divider { margin-bottom: 20px; }
.empty-state h3 { font-family: var(--font-title); color: var(--text); font-weight: 400; margin: 0 0 6px; }
.empty-state p { margin: 0; }

/* Story detail */
.story-detail-hero {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  padding: 48px 0;
  align-items: start;
}
.story-detail-hero .cover {
  aspect-ratio: 1;
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, var(--surface-strong), var(--accent));
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.story-detail-hero .eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 10px;
}
.story-detail-hero h1 {
  font-family: var(--font-title);
  font-size: 34px;
  font-weight: 400;
  margin: 0 0 8px;
}
.story-detail-hero .byline { color: var(--text-muted); font-size: 15px; margin-bottom: 16px; }
.story-detail-hero .byline a { color: var(--accent); }
.story-detail-hero .byline a:hover { text-decoration: underline; }
.story-detail-hero .tags { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.story-detail-hero .description { line-height: 1.7; color: var(--text); margin-bottom: 24px; }

/* Decorative waveform framing the native <audio> player. Purely visual
   (a fixed sine-based bar pattern, not real amplitude data — there's no
   Web Audio analysis here) so it never claims to represent the actual
   track; it just makes the player feel like part of an audio product
   rather than a bare browser control. */
.waveform {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
  margin-bottom: 12px;
  opacity: 0.45;
}
.waveform span {
  flex: 1;
  background: var(--accent);
  border-radius: 2px;
  min-width: 2px;
}
.story-detail-hero audio { width: 100%; accent-color: var(--accent); }
.audio-unavailable {
  padding: 14px 18px;
  background: var(--surface);
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Favorite heart — a little life on hover, and a one-shot "pop" when the
   page reloads into the favorited state (this is a server-rendered MPA,
   no client-side toggle, so the animation plays on load rather than
   on click). */
.heart-btn .heart-icon { display: inline-block; transition: transform 0.2s var(--ease); }
.heart-btn:hover .heart-icon { transform: scale(1.2); }
.heart-btn:active .heart-icon { transform: scale(0.9); }
.heart-btn.is-favorited .heart-icon { animation: heart-pop 0.5s var(--ease); }
@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Share button — brief accent flash while the "Link copied!" label shows. */
.js-copy-link.is-copied {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

@media (max-width: 640px) {
  .story-detail-hero { grid-template-columns: 1fr; }
  .story-detail-hero .cover { max-width: 220px; }
  .hero h1 { font-size: 32px; }
}

/* Creator profile */
.creator-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 48px 0 28px;
}
.creator-header .avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface-strong), var(--accent));
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.creator-header .avatar img { width: 100%; height: 100%; object-fit: cover; }
.creator-header h1 {
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 500;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.verified-badge {
  font-size: 11px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.creator-header .sub { color: var(--text-muted); font-size: 13.5px; }
.creator-bio { color: var(--text); line-height: 1.7; max-width: 640px; margin-bottom: 24px; }

@media (max-width: 480px) {
  .creator-header { flex-direction: column; text-align: center; padding: 36px 0 24px; }
  .creator-header h1 { justify-content: center; flex-wrap: wrap; }
}

/* Follow button — like the favorite heart on the story page, this is a
   full-page-reload MPA action, so the "pop" plays once on load into the
   new state rather than on click. */
.follow-btn.is-following { animation: follow-pop 0.4s var(--ease); }
@keyframes follow-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Static pages */
.prose { max-width: 680px; padding: 48px 0; line-height: 1.8; }
.prose .eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1.5px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 8px;
}
.prose h1 { font-family: var(--font-title); font-weight: 400; font-size: 32px; }
.prose h2 { font-family: var(--font-title); font-weight: 400; font-size: 22px; margin-top: 32px; }
.prose .branch-divider { margin: 32px auto; }

/* Contact page */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 48px;
  padding-bottom: 64px;
  align-items: start;
}
.contact-form { max-width: 520px; }
.contact-side {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 28px 24px;
}
.contact-details dt { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 16px; }
.contact-details dt:first-child { margin-top: 0; }
.contact-details dd { margin: 4px 0 0; font-size: 16px; }
.contact-details dd a { color: var(--accent); }
/* Honeypot — visually and structurally hidden from real visitors (and
   skipped by screen readers via aria-hidden in the markup), but still
   present in the DOM for bots that fill every input blindly. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 720px) {
  .contact-layout { grid-template-columns: 1fr; }
}

/* Auth forms */
.auth-form {
  max-width: 400px;
  margin: 48px auto;
  padding: 40px 36px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}
.auth-form h1 {
  font-family: var(--font-title);
  font-weight: 400;
  font-size: 28px;
  text-align: center;
  margin: 0 0 8px;
}
.auth-form .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0 0 28px;
}

@media (max-width: 480px) {
  .auth-form { margin: 24px auto; padding: 32px 22px; }
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}
/* The auth card itself sits on --surface now, so its fields need to read
   against --background instead or they'd blend into the card. */
.auth-form .field input,
.auth-form .field textarea,
.auth-form .field select { background: var(--background); }
.field-error { color: #A33; font-size: 12px; margin-top: 5px; }
.radio-group { display: flex; flex-direction: column; gap: 10px; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  font-weight: normal;
  cursor: pointer;
}
.form-error {
  background: var(--surface);
  border: 1px solid #C99;
  color: #A33;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.form-status {
  background: var(--surface);
  border: 1px solid #9C9;
  color: #3A6;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.btn-block { width: 100%; text-align: center; border: none; font: inherit; }
.auth-form .switch { text-align: center; margin-top: 20px; font-size: 13.5px; color: var(--text-muted); }
.auth-form .switch a { color: var(--accent); font-weight: 600; }

/* Account area */
.account-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.account-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.account-tabs a {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--text-muted);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease),
    background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.account-tabs a:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.account-tabs a.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.list-row:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateX(3px); }
.list-row .title { font-weight: 600; font-size: 14.5px; }
.list-row .meta { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.list-row a.title-link { color: var(--text); }
.list-row a.title-link:hover { color: var(--accent); text-decoration: none; }
.list-row form { margin: 0; }
.link-btn {
  background: none;
  border: none;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { color: var(--accent); text-decoration: underline; }
.link-btn.danger:hover { color: #A33; }
.inline-form { display: inline; }
.notification-row { align-items: flex-start; }
.notification-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}
.notification-row .dot.read { background: transparent; }
.notification-row .title.unread { font-weight: 700; }
.notification-row .body-text { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.notification-row .time { color: var(--text-muted); font-size: 11px; margin-top: 6px; }
.account-tabs .badge {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px;
  line-height: 16px;
  text-align: center;
}

.new-playlist-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.new-playlist-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.new-playlist-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--hairline);
  padding: 32px 0;
  margin-top: 48px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }
