/* =============================================================================
   Every Language — Bible audio portal
   Field Atlas ("vellum & ink") — the dashboard's identity, public edition.
   Same tokens as langquest-dashboard/src/styles/tokens.css: aged-paper canvas,
   deep-ink text, Bricolage Grotesque names, Archivo UI, JetBrains Mono data,
   one saturated blue (--sea) that is a FILL, with --sea-deep carrying blue text.
   Fonts load with display:swap over strong system fallbacks — the page reads
   fine before (or without) a single webfont byte. Light-only by design:
   the paper IS the identity.
   ========================================================================== */

:root {
  /* Palette — byte-aligned with dashboard tokens.css (light) */
  --vellum:      #f3efe6;   /* aged paper canvas          (--background)  */
  --vellum-lit:  #fbf8f0;   /* lit paper                  (--card)        */
  --ink:         #1c1a14;   /* deep ink text              (--foreground)  */
  --graphite:    #69624f;   /* muted ink — AA on vellum   (--muted-foreground) */
  --faint:       #6f6958;   /* lightest permitted ink     (--text-faint)  */
  --paper-dim:   #e9e6dd;   /* subdued paper              (--secondary)   */
  --border:      #d5cfc2;   /* warm hairline              (--border)      */
  --card-border: #cbc4b3;   /* card edges                 (--card-border) */
  --sea:         #0099e5;   /* brand blue — fills + focus (--primary/--sea) */
  --sea-deep:    #005f8f;   /* deep sea — text-carrying   (--primary-deep) */
  --sea-wash:    #d9effc;   /* accent surface             (--accent)      */
  --success-soft:    #bfe6cd;
  --success-ink: #1f6b40;   /* --success-soft-foreground */
  --danger-ink:  #8e1f28;   /* --danger-soft-foreground  */
  --danger-wash: #f3c9cd;   /* --danger-soft             */

  /* Type — the Field Atlas families, with honest system fallbacks */
  --font-display: 'Bricolage Grotesque', 'Avenir Next', 'Segoe UI', system-ui,
                  -apple-system, sans-serif;
  --font-name: var(--font-display);
  --font-ui:   'Archivo', 'Avenir Next', 'Segoe UI', system-ui, -apple-system,
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas,
               'Liberation Mono', monospace;

  /* Materiality + rhythm — dashboard values */
  --rule-ink: 1.5px solid rgba(28, 26, 20, 0.8);
  --shadow-sm: 0 2px 8px rgba(26, 26, 22, 0.06), 0 1px 2px rgba(26, 26, 22, 0.04);
  --shadow-md: 0 6px 20px rgba(26, 26, 22, 0.08), 0 2px 4px rgba(26, 26, 22, 0.04);
  --shadow-focus: 0 0 0 3px rgba(0, 153, 229, 0.35);
  --edge-light: inset 0 1.5px 0 rgba(255, 255, 255, 0.7);
  --radius: 10px;      /* --radius-lg: cards, dialogs, buttons */
  --radius-md: 8px;    /* badges, chips, inputs */
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* --ease-standard */
  --dur-instant: 90ms;
  --dur-fast: 150ms;
  --dur-normal: 240ms;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--vellum);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
}

/* Faint paper grain — one inline SVG, no requests, pointer-inert. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, header, footer, section { position: relative; z-index: 1; }

[hidden] { display: none !important; }

a { color: var(--sea-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: 4px;
}

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

/* ---- Type voices (dashboard §4.1) --------------------------------------- */
.eyebrow {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0;
}
.name { font-family: var(--font-name); font-weight: 500; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); font-size: 0.86em; }
.num  { font-variant-numeric: tabular-nums; }

/* ---- Masthead ----------------------------------------------------------- */
.masthead {
  border-bottom: var(--rule-ink);
  background: var(--vellum);
}
.masthead-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
}
.wordmark { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.wordmark:hover { text-decoration: none; }
.wordmark-symbol { width: 36px; height: auto; display: block; }
.wordmark-eyebrow { display: block; color: var(--sea-deep); }
.wordmark-title { display: block; font-size: 21px; line-height: 1.1; }
.site-nav { display: flex; gap: 16px; margin-left: auto; }
.site-nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--graphite);
  padding: 4px 2px;
}
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--sea);
}
.trust-slot { min-height: 22px; flex-basis: 100%; }
@media (min-width: 640px) { .trust-slot { flex-basis: auto; } }

/* ---- Trust badge --------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
}
.badge-verified { background: var(--success-soft); color: var(--success-ink); }
.badge-check { display: inline-flex; }
.badge-quiet {
  background: var(--paper-dim);
  color: var(--graphite);
  font-weight: 500;
}

/* ---- Hero (.brand-wash) -------------------------------------------------- */
.hero {
  border-bottom: 1px solid var(--border);
  background-image:
    radial-gradient(ellipse 1200px 600px at 10% -10%, rgba(173, 223, 255, 0.35), transparent 55%),
    radial-gradient(ellipse 800px 500px at 90% 0%, rgba(0, 153, 229, 0.08), transparent 60%);
}
.hero-inner { max-width: 880px; margin: 0 auto; padding: 48px 20px 40px; }
.hero-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 7vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.lede { margin: 0; max-width: 34em; font-size: 17px; color: var(--graphite); }
.hero-stat {
  margin: 18px 0 0;
  min-height: 22px;
  font-size: 14px;
  color: var(--graphite);
}
.hero-stat strong {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ---- Main sections ------------------------------------------------------- */
main.container { padding-top: 28px; padding-bottom: 64px; min-height: 40vh; }
.loading { color: var(--faint); padding: 32px 0; }

/* Toolbar: section label + live count + search, one ruled line (.ink-rule) */
.list-toolbar {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  border-bottom: var(--rule-ink);
  padding-bottom: 12px;
  margin: 0 0 24px;
}
.section-label { margin: 0; }
.list-count {
  margin: 0;
  font-size: 13px;
  color: var(--faint);
}
.search-input {
  margin-left: auto;
  flex: 0 1 260px;
  min-width: 180px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--vellum-lit);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.search-input::placeholder { color: var(--faint); opacity: 1; }
.search-input:focus-visible { border-color: var(--sea); box-shadow: var(--shadow-focus); }
@media (max-width: 560px) {
  .search-input { flex-basis: 100%; margin-left: 0; }
}
.search-empty { color: var(--graphite); padding: 24px 0; }

.section-eyebrow {
  border-bottom: var(--rule-ink);
  padding-bottom: 6px;
  margin: 28px 0 18px;
}

.lang-group { margin-bottom: 36px; }
.lang-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.lang-name { margin: 0; font-size: 24px; line-height: 1.15; }
.autonym { color: var(--graphite); font-size: 19px; }
.lang-count { margin: 0; font-size: 13px; color: var(--faint); }

/* ---- Cards (.atlas-paper) ------------------------------------------------ */
.t-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.card {
  display: block;
  background: var(--vellum-lit);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--edge-light);
  padding: 16px;
  color: var(--ink);
  transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
a.card:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md), var(--edge-light);
  transform: translateY(-2px);
}
.t-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.abbr {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--sea-deep);
  background: var(--sea-wash);
  border-radius: 5px;
  padding: 2px 7px;
}
.t-id { color: var(--faint); font-size: 12px; }
.t-name { margin: 10px 0 2px; font-size: 21px; line-height: 1.15; }
.t-autonym { margin: 0 0 2px; font-size: 15px; color: var(--graphite); }
.t-meta { margin: 4px 0 0; font-size: 12px; color: var(--graphite); }
.t-cta { margin: 12px 0 0; font-weight: 600; font-size: 14px; color: var(--sea-deep); }
.t-card-muted { opacity: 0.65; pointer-events: none; }

/* Language card as a flex column so the CTA pins to the bottom edge and card
   heights align across a row regardless of autonym lines. */
.lang-grid { margin-bottom: 8px; }
.lang-grid .t-card { display: flex; flex-direction: column; }
.lang-grid .t-cta, .lang-grid .t-rows { margin-top: auto; padding-top: 12px; }

/* Multi-translation card rows */
.t-rows { list-style: none; margin: 0; padding: 0; }
.t-rows li { border-top: 1px solid var(--border); }
.t-row-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 600;
}
.t-row-link:hover { text-decoration: none; }
.t-row-link:hover .t-row-name { text-decoration: underline; }
.t-row-name { flex: 1; min-width: 0; }
.t-row-cta { color: var(--sea-deep); }
.t-row-muted { color: var(--faint); font-weight: 400; }
.t-row-muted .t-row-cta { color: var(--faint); font-size: 12px; }
.abbr-sm { font-size: 11px; padding: 1px 6px; }

/* ---- Listen page --------------------------------------------------------- */
.crumb { margin: 0 0 18px; font-size: 13px; }
.t-head { margin-bottom: 8px; }
.t-title {
  margin: 4px 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}
.t-stats { margin: 0 0 10px; color: var(--graphite); }
.t-verified { margin: 0 0 14px; }
.t-downloads-link { margin: 0; }

.btn-primary, .btn-secondary {
  display: inline-block;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-md);
  padding: 9px 16px;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn-primary { background: var(--sea-deep); color: #fff; }
.btn-primary:hover { text-decoration: none; background: #00506f; }
.btn-secondary {
  background: var(--vellum-lit);
  color: var(--sea-deep);
  border-color: var(--card-border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { text-decoration: none; border-color: var(--sea-deep); }

.book {
  background: var(--vellum-lit);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--edge-light);
  margin-bottom: 10px;
}
.book-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.book-summary::-webkit-details-marker { display: none; }
.book-summary::before {
  content: "▸";
  color: var(--faint);
  font-size: 12px;
  margin-right: 2px;
  transition: transform var(--dur-fast) var(--ease);
  display: inline-block;
}
details[open] > .book-summary::before { transform: rotate(90deg); }
.book-name { font-size: 18px; flex: 1; }
.book-stats { font-size: 12px; color: var(--graphite); white-space: nowrap; }

.ch-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.ch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-top: 1px solid var(--border);
}
.ch-row:first-child { border-top: 1px solid rgba(28, 26, 20, 0.35); }
.play-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--vellum);
  color: var(--sea-deep);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-instant) var(--ease), color var(--dur-instant) var(--ease);
}
.play-btn:hover { background: var(--sea-wash); }
.play-btn.playing { background: var(--sea-deep); color: #fff; border-color: var(--sea-deep); }
.ch-name { flex: 1; font-size: 14px; }
.ch-duration { font-size: 12px; color: var(--graphite); }
.dl-link { font-size: 12px; white-space: nowrap; }

/* ---- Sticky player (.glass) ---------------------------------------------- */
body.has-player { padding-bottom: 96px; }
.player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: rgba(248, 247, 243, 0.88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: var(--rule-ink);
  box-shadow: 0 -6px 20px rgba(26, 26, 22, 0.08);
}
.player-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 20px 10px;
}
.player-label {
  margin: 2px 0 6px;
  font-family: var(--font-name);
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-bar audio { width: 100%; height: 36px; }

/* ---- Downloads page ------------------------------------------------------ */
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 6vw, 40px);
  margin: 0 0 10px;
  letter-spacing: -0.03em;
  line-height: 1.08;
}
.notice {
  background: var(--sea-wash);
  color: var(--sea-deep);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
}
.dl-group { margin-bottom: 36px; }
.pack-card h3 { margin: 0; font-size: 17px; font-weight: 600; }
.pack-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pack-card-full { border-color: var(--sea-deep); }
.pack-version { color: var(--faint); font-size: 12px; white-space: nowrap; }
.pack-meta { margin: 6px 0 12px; font-size: 13px; color: var(--graphite); }
.pack-parts { list-style: none; margin: 0; padding: 0; }
.pack-part { margin-bottom: 10px; }
.pack-part:last-child { margin-bottom: 0; }
.pack-hash {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--faint);
  word-break: break-all;
}
.pack-card-soon { background: var(--paper-dim); border-style: dashed; box-shadow: none; }
.soon-badge {
  display: inline-block;
  margin: 10px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--graphite);
  background: var(--vellum);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}
.dl-listen-link { font-size: 14px; margin: 10px 0 0; }

/* No-packs-yet state: one panel + a compact listen-now directory */
.packs-soon-panel { max-width: 42em; }
.packs-soon-panel h2 { margin: 0; font-size: 18px; font-weight: 600; }
.packs-soon-panel p:last-child { margin-bottom: 0; color: var(--graphite); }
.listen-now-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 20px;
}
.listen-now-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.listen-now-link:hover { text-decoration: none; background: var(--sea-wash); }
.listen-now-name { flex: 1; min-width: 0; color: var(--ink); }

.howto { margin-top: 40px; }
.howto h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; font-size: 20px; margin: 0 0 8px; }
.howto h2 + p, .howto ol { margin-top: 0; }
.howto ol { padding-left: 20px; margin-bottom: 22px; }
.howto li { margin-bottom: 6px; }

/* ---- Panels + errors ------------------------------------------------------ */
.panel {
  background: var(--vellum-lit);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--edge-light);
  padding: 18px 20px;
}
.panel-error { background: var(--danger-wash); border-color: var(--danger-ink); }
.panel-error h2 { margin: 0 0 6px; font-size: 18px; color: var(--danger-ink); }
.error-detail {
  color: var(--danger-ink);
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  word-break: break-word;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--paper-dim);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---- Footer --------------------------------------------------------------- */
.site-footer {
  border-top: var(--rule-ink);
  padding: 22px 0 30px;
  font-size: 13px;
  color: var(--graphite);
  background: var(--vellum);
}
.site-footer p { margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
