/*
 * AskScripture Web — design tokens
 * ---------------------------------------------------------------------------
 * Spec:   docs/design/WEB-DESIGN.md (v1)
 * Parent: docs/design/DESIGN.md (v4) — the app system, source of truth
 *
 * Inheritance is one-directional: foundations come from the app and are copied
 * here verbatim. Web-tier tokens (marked WEB-TIER) are derived from those
 * foundations for surfaces the app has no equivalent of. Nothing here flows
 * back into constants/designSystem.ts.
 *
 * This file is the ONLY place raw hex values may appear. A literal color in a
 * page stylesheet is a bug.
 *
 * Contrast ratios in comments were computed, not estimated (2026-08-11).
 */

/* ===========================================================================
   Fonts — self-hosted, subset from the same TTFs the app bundles.
   Regenerate with the pyftsubset command in WEB-DESIGN.md §10.
   =========================================================================== */

@font-face {
  font-family: 'Literata';
  src: url('fonts/literata-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Literata';
  src: url('fonts/literata-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Literata';
  src: url('fonts/literata-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Literata';
  src: url('fonts/literata-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ===========================================================================
   Tokens
   =========================================================================== */

:root {
  /* -- Color: foundations (DESIGN.md §3, verbatim) ------------------------ */
  --ink: #1c2129;              /* 15.11:1 on paper */
  --ink-soft: #4a5261;         /*  7.35:1 on paper */
  --paper: #faf7f0;
  --paper-raised: #ffffff;
  --gilt: #b8912f;             /*  2.75:1 — DECORATION ONLY, never text */
  --redletter: #9e2b25;        /*  6.95:1 — Scripture only */
  --cedar: #2e4036;            /* 10.32:1 — insights, Parent mode */
  --error: #b4552d;            /*  4.59:1 on paper; FAILS on paper-deep (4.24) */

  --divider: rgba(28, 33, 41, 0.10);
  --cedar-tint: rgba(46, 64, 54, 0.06);
  --gilt-tint: rgba(184, 145, 47, 0.10);

  /* -- Color: WEB-TIER ---------------------------------------------------- */
  /* Half-step below paper on the same warm cast; paces long pages without
     introducing a hue the app doesn't have. Do not put error text on it. */
  --paper-deep: #f3eee3;

  /* Text on an ink ground (CTA band, footer). Derived from `paper` at reduced
     opacity — the inverse of the ink/ink-soft pair, not a new hue. All three
     clear AA on --ink: 15.11, 12.6, and 10.4 to 1 respectively. */
  --on-ink: #faf7f0;
  --on-ink-soft: rgba(250, 247, 240, 0.82);
  --on-ink-faint: rgba(250, 247, 240, 0.66);
  --on-ink-divider: rgba(250, 247, 240, 0.16);

  /* Pressed state of the primary (ink) button — ink deepened, same cast. */
  --ink-deep: #10151c;

  /* -- Type: families ----------------------------------------------------- */
  /* Serif = the page speaking as a printed page. Sans = the interface. */
  --font-serif: 'Literata', 'Iowan Old Style', 'Palatino Linotype', Palatino,
    Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;

  /* -- Type: scale (app steps + WEB-TIER display tier) -------------------- */
  --fs-xs: 13px;               /* captions, disclosures, badges */
  --fs-sm: 15px;               /* secondary body, meta, nav */
  --fs-md: 17px;               /* UI body, buttons */
  --fs-lg: 20px;               /* article body */
  --fs-xl: 24px;               /* h3, card titles */
  --fs-2xl: 30px;              /* h2 */
  --fs-3xl: clamp(34px, 4vw, 44px);      /* WEB-TIER — article h1 */
  --fs-display: clamp(40px, 6.5vw, 68px); /* WEB-TIER — hero only */

  --lh-display: 1.08;
  --lh-heading: 1.2;
  --lh-prose: 1.65;
  --lh-ui: 1.5;

  /* Uppercase + tracking stands in for small caps: the Literata cuts carry no
     `smcp` feature, and this is exactly how the app renders eyebrows. */
  --tracking-caps: 0.08em;

  /* -- Space: 4pt grid (app steps + WEB-TIER section rhythm) -------------- */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-3xl: 64px;           /* WEB-TIER */
  --space-4xl: 96px;           /* WEB-TIER */
  --space-5xl: 128px;          /* WEB-TIER */

  /* -- Layout ------------------------------------------------------------- */
  --measure: 66ch;
  --w-article: 720px;
  --w-wide: 1140px;
  --w-full: 1320px;
  --gutter: 20px;              /* matches the app's 20px screen margin */

  /* -- Surfaces ----------------------------------------------------------- */
  --radius-card: 12px;
  --radius-sheet: 24px;
  --radius-pill: 999px;
  --hairline: 1px;
  --shadow-card: 0 1px 3px rgba(28, 33, 41, 0.08);
  --rail: 2px;                 /* the gilt ribbon rail on verse cards */

  /* -- Motion (DESIGN.md §7 — restraint is the brand) --------------------- */
  --dur-hover: 120ms;
  --dur-accordion: 200ms;
  --dur-reveal: 250ms;
  --stagger-reveal: 60ms;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);
}

@media (min-width: 720px) {
  :root { --gutter: 32px; }
}

@media (min-width: 1140px) {
  :root { --gutter: 48px; }
}

/*
 * Dark mode — documented, NOT shipped at launch (WEB-DESIGN.md §2).
 * Values are the app's warm-lamplight palette verbatim. Enabling this is
 * uncommenting plus a full AA re-check, not a redesign.
 *
 * @media (prefers-color-scheme: dark) {
 *   :root:not([data-theme='light']) {
 *     --ink: #ede7da;
 *     --ink-soft: #a89e8f;
 *     --paper: #1c1713;
 *     --paper-raised: #2a231b;
 *     --paper-deep: #231c16;
 *     --gilt: #cda84b;
 *     --redletter: #d4736c;
 *     --cedar: #7fa08d;
 *     --error: #d07a52;
 *     --divider: rgba(237, 231, 218, 0.14);
 *     --cedar-tint: rgba(127, 160, 141, 0.10);
 *     --gilt-tint: rgba(205, 168, 75, 0.12);
 *   }
 * }
 */

/* ===========================================================================
   Base layer
   =========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* -- Prose: the printed page ---------------------------------------------- */

.prose {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: var(--lh-prose);
  max-width: var(--measure);
}

/* Reset browser margins at :where() specificity (0,0,1,0) so the sibling rule
   below can still win. A plain `.prose p { margin: 0 }` out-specifies
   `.prose > * + *` and silently removes every paragraph gap. */
.prose :where(p, ul, ol, blockquote, figure) {
  margin: 0;
}

.prose > * + * {
  margin-top: var(--space-md);
}

.prose p {
  text-wrap: pretty;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: var(--lh-heading);
  text-wrap: balance;
  margin: 0;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

.prose > h2 { margin-top: var(--space-xxl); }
.prose > h3 { margin-top: var(--space-xl); }

/* Eyebrows, verse references, accordion titles. Uppercase + tracking. */
.eyebrow {
  font-family: var(--font-serif);
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

/* Print-native, and it signals "page" rather than "post". One per article. */
.dropcap::first-letter {
  float: left;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 3.4em;
  line-height: 0.84;
  padding: 0.06em var(--space-sm) 0 0;
  color: var(--ink);
}

/* -- Links ---------------------------------------------------------------- */

a {
  color: var(--ink);
  text-decoration-color: var(--gilt);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-thickness var(--dur-hover) var(--ease);
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--gilt);
  outline-offset: 2px;
  border-radius: 2px;
}

/* -- Signature: the key verse card (DESIGN.md §6, ported) ----------------- */

.verse-card {
  background: var(--paper-raised);
  border: var(--hairline) solid var(--divider);
  border-left: var(--rail) solid var(--gilt);   /* the ribbon marker */
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.verse-card__text {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: 1.6;
  color: var(--redletter);
  margin: 0;
}

.verse-card__ref {
  font-family: var(--font-serif);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.verse-card__note {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}

/* Parent-mode variant: cedar rail, no translation tag. */
.verse-card--parent {
  border-left-color: var(--cedar);
}

.verse-card--parent .verse-card__text {
  color: var(--ink);
}

/* -- Insight card (cedar) ------------------------------------------------- */

.insight-card {
  background: var(--cedar-tint);
  border: var(--hairline) solid var(--divider);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.insight-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.insight-card__name {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--cedar);
  margin: 0;
}

/* Roman, never italic — italic fights readability past five lines. */
.insight-card__body {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.6;
  font-style: normal;
  color: var(--ink);
  margin: 0;
}

/* -- Chips ---------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  line-height: 1;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-pill);
  border: var(--hairline) solid currentColor;
  color: var(--ink-soft);
}

/* Premium / Verified: thin gilt outline, ink label. Never a filled gold pill,
   and never a gilt label — gilt fails contrast on text. */
.chip--gilt {
  color: var(--ink);
  border-color: var(--gilt);
  background: var(--gilt-tint);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-card);
  border: var(--hairline) solid transparent;
  cursor: pointer;
  transition: background-color var(--dur-hover) var(--ease),
              border-color var(--dur-hover) var(--ease);
}

/* Primary mirrors the app's footer action: ink fill, thin inset gilt keyline. */
.btn--primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px var(--gilt);
}

.btn--primary:hover {
  background: var(--ink-deep);
}

.btn--quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--divider);
}

.btn--quiet:hover {
  border-color: var(--gilt);
}

/* -- Layout helpers ------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--w-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--article {
  max-width: calc(var(--w-article) + var(--gutter) * 2);
}

.container--full {
  max-width: var(--w-full);
}

.band {
  padding-block: var(--space-4xl);
}

.band--deep {
  background: var(--paper-deep);
}

.band--ink {
  background: var(--ink);
  color: var(--paper);
}

.rule {
  border: 0;
  border-top: var(--hairline) solid var(--gilt);
  opacity: 0.5;
  margin: 0;
}

/* Wide content never scrolls the page sideways. */
.scroll-x {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

/* -- Motion --------------------------------------------------------------- */

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