/*
 * Async Digital — Brand tokens
 *
 * Single source of truth for brand-level CSS custom properties consumed
 * by every stylesheet in this repo. Palette is documented in
 * brand/colour.md; typography in brand/typography.md.
 *
 * Do NOT ship component-level styles here — only design tokens.
 *
 * Colour
 *   Brand
 *     --primary   Deep brick. Buttons, accent bars, logo mark.
 *     --primary-fill  Brick under a label. Equals --primary in light mode.
 *     --accent    Charcoal navy. Headings and secondary emphasis.
 *     --tertiary  Deep teal. Third brand colour; rationale at its declaration.
 *   Neutrals
 *     --bg        Page background.
 *     --card      Surface for cards and tiles.
 *     --border    Hairline borders and separators.
 *     --text      Body and heading text.
 *     --muted     Supporting / secondary text.
 *   Surfaces (tool and product surfaces only; see brand/colour.md, Surfaces and tints)
 *     --well           Recessed region inside a card, one step below --card.
 *     --sunken         Translucent overlay for a code or command block.
 *     --border-strong  Stronger edge: a focused card, a Copy button.
 *   Status
 *     --success   Success indicators.
 *     --warning   Warning indicators. Use dark text (var(--text)) on top.
 *     --error     Error indicators.
 *   State tints (tool and product surfaces only)
 *     --success-tint / -border / -ink   A region in the success state.
 *     --primary-tint / -border          A region marked in brick.
 *     --warning-tint / -border / -ink   A region in the warning state.
 *   Aurora
 *     --aurora-stop-1   Coral peach. Aurora hero — warm blob (audient.async-digital.com).
 *     --aurora-stop-2   Dusty plum.  Aurora hero — mid blob.
 *     --aurora-stop-3   Muted teal.  Aurora hero — cool blob.
 *     Aurora only; never as solid fills, text, or component accents.
 *
 * Typography
 *   Families
 *     --font-sans    Web system stack.
 *   Sizes
 *     --size-h1      Hero headline (responsive).
 *     --size-h2      Section heading.
 *     --size-h3      Card / tile heading.
 *     --size-intro   Hero supporting paragraph.
 *     --size-body    Default body text.
 *     --size-small   Footer, meta, fine print.
 *   Line heights
 *     --lh-tight     1.12 — hero headline.
 *     --lh-snug      1.3  — section headings.
 *     --lh-normal    1.4  — tight prose.
 *     --lh-relaxed   1.55 — body and intro.
 *     --lh-loose     1.7  — dense bullet lists.
 *   Weights
 *     --weight-regular  400
 *     --weight-medium   600
 *     --weight-bold     700
 *
 * Layout
 *   Spacing scale
 *     --space-xs/sm/md/lg/xl/2xl   4 / 8 / 16 / 24 / 44 / 48 px.
 *   Radius scale
 *     --radius-sm/-/-lg/-pill      4 / 10 / 16 / 999 px.
 *   Measure
 *     --measure-h1     Hero headline measure (30ch).
 *     --measure-intro  Intro / lede measure (68ch).
 *     --measure-prose  Long-form body measure (72ch).
 *   Container
 *     --wrap           Page max width (960px).
 *   Border
 *     --border-hairline   1px solid --border.
 *
 * Motion
 *   --ease-out, --dur-1, --dur-2, --dur-3.
 *
 * Focus
 *   --focus-ring, --focus-offset.
 *
 * Dark palette
 *   Every colour role resolves through light-dark(), and this file sets
 *   `color-scheme: light dark` on screen, so a page that links it follows the
 *   system appearance with nothing of its own to add (#763). Print stays
 *   light. data-theme="dark" on <html> forces dark on screen. A colour a
 *   page writes as a literal does not follow: use the tokens, which
 *   scripts/verify-colour-tokens.py enforces. See brand/colour.md, Dark
 *   palette.
 */

:root {
  /* Brand */
  --primary: #8B3A2A;
  --accent:  #2A3A4A;
  /* Third brand colour, added 2026-08-20 for category coding where --primary,
     --accent and --success are already spoken for. Needed because --accent is
     1.46:1 against --text: as a category rail it was indistinguishable from the
     body copy beside it. Teal is the only hue gap left once brick, navy and
     green are taken. 5.18:1 on --card, so it is safe as small text and not only
     as a rule.

     Deliberately NOT --aurora-stop-3 (#5E97A8), which is lighter, fails as small
     text, and is barred from component use. Do not reconcile the two.

     Also deliberately NOT named --accent-2. That name belonged to a pre-brand.css
     gradient stop and brand/colour.md, Token naming, still carries a standing
     instruction to delete it. Reviving the name would hand the next reader a
     documented reason to remove this token. */
  --tertiary: #3D6E7D;
  /* Brick under a label (a button, a filled node). In light mode it equals
     --primary; it diverges only in the dark palette, where one brick cannot
     serve both as text and as a fill (#604). Navy does not split. */
  --primary-fill: #8B3A2A;

  /* Neutrals */
  --bg:      #FDFBF7;
  --card:    #F8F5EE;
  --border:  #E8E4DC;
  --text:    #1F1C18;
  --muted:   #6B6560;

  /* Surfaces, ruled by Rob 2026-10-29, for tool and product surfaces only
     (page kit, Artifact pages, apps). The apex, /notes/ and /case-studies/
     keep the flat printed-page rule in DESIGN.md. Only --text on a --sunken
     nested in a --well or a tint: --muted there is 4.25:1 or less. */
  --well:          #F1ECE2;
  --sunken:        rgba(31, 28, 24, 0.07);
  --border-strong: #CDC5B7;

  /* Status */
  --success: #3E7A4A;
  --warning: #C48B2C;
  --error:   #CC2222;

  /* State tints, ruled by Rob 2026-10-29, same scope as the surfaces above.
     A tint marks the state of a region, never a card for being current or
     linked to. There is no accent tint: mark an accent region with a navy
     border on a --well. */
  --success-tint:   #E7EADF;
  --success-border: #9CB49A;
  --success-ink:    #346A40;
  --primary-tint:   #F1EAE2;
  --primary-border: #C3A095;
  --warning-tint:   #F2E8D7;
  --warning-border: #D4B37B;
  --warning-ink:    #7A5923;

  /* Aurora — three-stop palette for the animated hero on
     audient.async-digital.com. ONE STOP PER BLOB, not a gradient ramp.
     Aurora only; never as solid fills, text, or component accents. */
  --aurora-stop-1: #E89B7E;
  --aurora-stop-2: #A77398;
  --aurora-stop-3: #5E97A8;

  /* Typography — families */
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Editorial / long-form only (articles, sustained reading) on the default
     surfaces. Not for marketing heroes, nav, cards, or any surface on Audient.
     This declaration is the only one of --font-serif in the repo (#469). See
     DESIGN.md, Typography. */
  --font-serif: "Spectral", Georgia, "Times New Roman", serif;
  /* Code, package names, and the technical-label voice on the default
     surfaces. This declaration is the only one of --font-mono in the repo
     (#558); before it, all ten call sites in styles.css spelled the stack out
     as a var() fallback, so the fallback was the definition. The
     /case-studies/ pages use it for code too (#694). See DESIGN.md,
     Typography. */
  --font-mono:  ui-monospace, "SF Mono", Menlo, monospace;

  /* Typography — sizes */
  --size-h1:    44px;
  --size-h2:    20px;
  --size-h3:    16px;
  --size-intro: 19px;
  --size-body:  16px;
  --size-small: 14px;

  /* Typography — line heights */
  --lh-tight:   1.12;
  --lh-snug:    1.3;
  --lh-normal:  1.4;
  --lh-relaxed: 1.55;
  --lh-loose:   1.7;

  /* Typography — weights */
  --weight-regular: 400;
  --weight-medium:  600;
  --weight-bold:    700;

  /* On-coloured-surface text */
  --on-primary: #FFFFFF;
  --on-accent:  #FFFFFF;

  /* Spacing scale (rhythm) */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  44px;
  --space-2xl: 48px;

  /* Radius scale */
  --radius-sm:   4px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-pill: 999px;

  /* Hairline border helper */
  --border-hairline: 1px solid var(--border);

  /* Layout */
  --measure-h1:    30ch;
  --measure-intro: 68ch;
  --measure-prose: 72ch;
  --wrap:          960px;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur-1:    120ms;
  --dur-2:    200ms;
  --dur-3:    320ms;

  /* Focus */
  /* 70% measures 3.71:1 on --bg and 3.61:1 on --card (WCAG 1.4.11 needs 3:1); 35% was 1.81:1 (#649). */
  --focus-ring:   3px solid color-mix(in srgb, var(--primary) 70%, transparent);
  --focus-offset: 3px;
}

/* H1 steps down on narrower viewports so it stays within the measure. */
@media (max-width: 900px) {
  :root { --size-h1: 36px; }
}

@media (max-width: 480px) {
  :root { --size-h1: 32px; }
}

/* Dark palette (#604), ruled 2026-10-25. Since Rob's ruling of the same day
   the apex follows the system appearance with it.

   Each colour role is written twice. The plain light value in :root above is
   what a browser without light-dark() gets. The declaration below pairs that
   same light value with its dark value in light-dark(), which picks by the
   color-scheme of the element that uses the token. Since #763 this file sets
   `color-scheme: light dark` itself, on screen, so every page that links it
   follows the system; data-theme="dark" forces dark. Print has no
   color-scheme from here, so it computes light. Keep the light half of each
   pair identical to the plain value.

   Why the @supports. A browser that does not know light-dark() does not drop
   it from a custom property, because a custom property accepts any tokens.
   It would store the light-dark(...) text, every var() reading it would fail
   at computed-value time, and the page would lose its colours (transparent
   grounds, default text) rather than stay light. The test keeps such a
   browser on the plain values above, and the color-scheme below sits behind
   the same test, so a browser that cannot resolve the tokens is never told
   to render dark either.

   Ratios are WCAG contrast of the dark value on bg #1B1916 / card #24211D;
   every one is recorded with its GitHub-canvas figure in brand/colour.md. */
@supports (color: light-dark(#000, #fff)) {
  :root {
    /* Brand. Brick has two roles: --primary is for text, bars, lines and
       diagram paths; --primary-fill sits under a label. Since 2026-11-20 both
       hold #E0907B in dark, and a label on the dark fill takes ink, as a
       label on navy does. Navy stays one value for text and fills alike. */
    --primary:      light-dark(#8B3A2A, #E0907B);  /* 7.05 / 6.44 */
    --primary-fill: light-dark(#8B3A2A, #E0907B);  /* 7.05 / 6.44, a fill: --on-primary on it is 7.05 */
    --accent:       light-dark(#2A3A4A, #9DB1C6);  /* 7.97 / 7.28, --on-accent on it is 7.97 */
    --tertiary:     light-dark(#3D6E7D, #7FAEBB);  /* 7.25 / 6.62 */

    /* Neutrals. Warm, never pure black or white. The dark card is raised by
       lightening, never by shadow; the border is for hairlines only. */
    --bg:     light-dark(#FDFBF7, #1B1916);
    --card:   light-dark(#F8F5EE, #24211D);
    --border: light-dark(#E8E4DC, #3A352F);
    --text:   light-dark(#1F1C18, #EFE9E0);  /* 14.54 / 13.28 */
    --muted:  light-dark(#6B6560, #B8AFA4);  /* 8.11 / 7.41, also diagram outlines */

    /* Surfaces (2026-10-29). The dark well is 1.01:1 from the dark page, so
       it reads only inside a card. --border-strong is under 3:1 in both
       modes, so it is never the sole identifier of a control. */
    --well:          light-dark(#F1ECE2, #1A1815);
    --sunken:        light-dark(rgba(31, 28, 24, 0.07), rgba(0, 0, 0, 0.32));
    --border-strong: light-dark(#CDC5B7, #5C544A);

    /* Status. In dark, small marks only (dots, icons), never body text or
       fills, except the measured tints below. Dark --error is 1.22:1 from
       dark --primary, so never tell them apart by colour. */
    --success: light-dark(#3E7A4A, #7DB88A);  /* 7.60 / 6.94 */
    --warning: light-dark(#C48B2C, #D59E3E);  /* 7.34 / 6.71 */
    --error:   light-dark(#CC2222, #EF6A60);  /* 5.76 / 5.27 */

    /* State tints (2026-10-29). Ratios are --text / --muted on the tint, light
       then dark; the ink rows are the ink on its own tint. In dark the ink is
       the status colour itself. */
    --success-tint:   light-dark(#E7EADF, #2F332A);  /* 13.92, 4.71 / 10.69, 5.13 */
    --success-border: light-dark(#9CB49A, #587058);
    --success-ink:    light-dark(#346A40, #7DB88A);  /* 5.25 / 5.59 */
    --primary-tint:   light-dark(#F1EAE2, #382821);  /* 14.23, 4.82 / 11.65, 5.59 */
    --primary-border: light-dark(#C3A095, #774336);
    --warning-tint:   light-dark(#F2E8D7, #393021);  /* 13.98, 4.73 / 10.75, 5.16 */
    --warning-border: light-dark(#D4B37B, #886A37);
    --warning-ink:    light-dark(#7A5923, #D59E3E);  /* 5.27 / 5.43 */

    /* On-coloured-surface text. Dark: ink on brick and ink on navy, because
       both dark fills are mid tones; never pure white or pure black. */
    --on-primary: light-dark(#FFFFFF, #1B1916);
    --on-accent:  light-dark(#FFFFFF, #1B1916);

    /* Aurora stops brighten slightly in dark to keep their glow against the
       darker base. The pool itself (the dark canvas the blobs sit on) is set
       by the consumer, not here. Until #763 these followed
       prefers-color-scheme in a rule of their own; they now follow
       color-scheme like every other role, so forced dark and print agree. */
    --aurora-stop-1: light-dark(#E89B7E, #F4A98B);
    --aurora-stop-2: light-dark(#A77398, #B881A6);
    --aurora-stop-3: light-dark(#5E97A8, #6DAABC);
  }

  /* The default (#763): every page that links this file follows the system
     appearance. Screen only, so a printed page computes light whatever the
     system says, because browsers drop backgrounds when printing and dark
     tokens would put cream type on white paper. data-theme="dark" on <html>
     forces dark (#604), also screen only. */
  @media screen {
    :root { color-scheme: light dark; }
    :root[data-theme="dark"] { color-scheme: dark; }
  }
}
