/* ==========================================================================
   Design tokens. Single source of truth. Owner: design-keeper.
   Rules and reasons live in brief.md. Do not add one-off tokens.

   STATUS, 3 October 2026: APPROVED by Fran (violet accent, lime highlight,
   two themes by surface, italic serif). Surfaces adopt it via ui-builder.

   TWO THEMES, chosen by surface, never by OS setting:
     product    light, warm. Web app and extension side panel.
                Default: applies on :root with no attribute.
     marketing  dark. landing-page/index.html only.
   Set the attribute once on <html>:  <html data-theme="marketing">
   Only colour (and the card shadow) differ between themes. Type, space,
   shape and motion are shared on purpose: they are the bridge that makes the
   dark landing and the light app read as one product. Surfaces must use
   tokens only, never raw hex, so the theme switch is a single attribute.

   5 Oct 2026: added --size-target, --size-icon, --focus-ring, --focus-offset
   for the "Your applications" patterns (brief.md P7 to P12). No new colour.
   Copies: web/app/tokens.css and landing-page/tokens.css were refreshed
   byte-for-byte on 6 Oct 2026. extension/tokens.css was not refreshed (the
   extension ships separately) and is stale until it is.

   9 Oct 2026: added --container-app (72rem) for every signed-in page. Search
   field, setting row, section index, stats row and four week chart (brief.md
   P19 to P23) use existing tokens only. All three copies must be refreshed
   byte for byte (web/app, extension, landing-page).

   The product name is undecided. No token here is named after the product.
   ========================================================================== */

/* ---- Theme: product (light, warm). Default. ----------------------------- */
:root,
:root[data-theme="product"] {
  /* Surfaces */
  --color-bg:            #FAF7F2;  /* page. warm near-white */
  --color-surface:       #FFFFFF;  /* cards, panel body */
  --color-surface-sunk:  #F3EFE8;  /* wells, table stripes, disabled fields */
  --color-border:        #E6E1D8;  /* the one hairline rule. decorative only */
  --color-border-strong: #8A8697;  /* input outlines, UI boundaries (3:1+) */

  /* Text */
  --color-text:          #1D1B26;  /* 15.9:1 on bg, 17.0:1 on surface */
  --color-text-muted:    #5E5B6B;  /* 6.2:1 on bg, 6.6:1 on surface */
  --color-text-inverse:  #FFFFFF;  /* text on accent. 7.5:1 */

  /* Accent: deep violet (approved). One accent only. */
  --color-accent:          #4538D6;  /* 7.0:1 on bg, 7.5:1 white text on it */
  --color-accent-hover:    #382CB5;  /* 9.6:1 white text on it */
  --color-accent-soft:     #EEEBFB;  /* chip and selected-row fill */
  --color-accent-on-soft:  #4538D6;  /* 6.2:1 on soft */
  --color-focus-ring:      #4538D6;  /* 2px ring plus 2px offset, always visible */

  /* Highlight: lime marker (approved). Fill behind ink text only, at most
     one per screen. Never text, line, icon or button. Same value in both
     themes. Text inside it is ALWAYS --color-text-on-highlight. */
  --color-highlight:          #DFFF3A;
  --color-text-on-highlight:  #1D1B26;  /* 14.9:1 on highlight */

  /* Status. No red, no orange. Icon plus plain words first, tone second. */
  --color-status-done:      var(--color-accent);      /* check icon + "Done" */
  --color-status-needs-you: #7A4500;                  /* dot icon + "Needs you". warm amber-brown, 7.3:1 on bg (6 Oct: was ink) */
  --color-status-closed:    var(--color-text-muted);  /* dash icon + "Closed" */
  /* --color-status-done is kept for existing surfaces. New work uses
     --color-status-sent (same meaning, word is now "Sent"). */

  /* ---- Role row status pills (APPROVED DIRECTION, 3 Oct 2026) -------------
     One pill set for side panel, dashboard and landing tracker. Words, in
     the product's own language: On your list, Filling, Sent, Needs you,
     Closed. Every pill is icon plus words. Colour is only the second signal.
     Each state has a -bg and a text colour; both resolve per theme, so the
     marketing block below needs no override. No red, no orange.
       sent       check icon,        soft accent fill
       filling    half-filled icon,  soft accent fill, icon pulses
       needs-you  solid dot icon,    surface fill, 1px ink outline, bold
       closed     dash icon,         sunk fill, muted text
       waiting    empty ring icon,   no fill, 1px border-strong outline     */
  /* 6 Oct 2026 (Fran: pills colour coded; amends "no orange"): each flag has
     its own calm hue. Needs you warm amber, Sent muted green, On your list
     violet, Closed and Not checked neutral. Pill text on pill fill, light:
       needs-you #7A4500 on #FCEFD6  6.9:1    sent #1B5E3A on #E3F3E9  6.7:1
       waiting/filling #4538D6 on #EEEBFB 6.2:1
       closed #5E5B6B on #F3EFE8 5.7:1        unchecked #5E5B6B on bg 6.2:1
     waiting also takes a 1px --color-accent outline so it holds on the
     tinted on-list card. unchecked: 1px DASHED --color-border-strong.      */
  --color-status-sent:         #1B5E3A;
  --color-status-sent-bg:      #E3F3E9;
  --color-status-filling:      var(--color-accent-on-soft);
  --color-status-filling-bg:   var(--color-accent-soft);
  --color-status-needs-you-bg: #FCEFD6;
  --color-status-closed-bg:    var(--color-surface-sunk);
  --color-status-waiting:      var(--color-accent-on-soft);
  --color-status-waiting-bg:   var(--color-accent-soft);
  --color-status-unchecked:    var(--color-text-muted);
  --color-status-unchecked-bg: transparent;

  --shadow-card: 0 1px 2px rgba(29, 27, 38, 0.05);

  /* ---- Shared by both themes (the bridge) ------------------------------ */

  /* Type. Sans for UI and numerals. Serif, italic allowed, for the human
     moments only: emphasised phrase in a headline, reassurance lines.
     Newsreader is web-loaded on the landing page and web app. The extension
     cannot load web fonts, so it falls back to Georgia unless Newsreader is
     bundled with the extension. The fallback must look right on its own. */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-mono:  ui-monospace, 'SF Mono', Menlo, monospace;

  --text-xs:   0.75rem;    /* 12px. FLOOR. nothing smaller, anywhere */
  --text-sm:   0.8125rem;  /* 13px */
  --text-base: 0.9375rem;  /* 15px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.5rem;     /* 24px */
  --text-2xl:  2.25rem;    /* 36px, serif headlines */
  --text-3xl:  3.5rem;     /* 56px, landing hero */
  --text-numeral: 3rem;    /* 48px, large light stat numerals */
  --text-numeral-sm: 2.5rem; /* 40px, the same numeral where width is tight:
                                side panel (~360px) counts such as "2 of 5".
                                Light weight, --leading-tight. APPROVED
                                DIRECTION, 3 Oct 2026. */

  --weight-light:   300;   /* numerals */
  --weight-regular: 400;
  --weight-medium:  500;
  --weight-bold:    650;

  --leading-tight: 1.15;
  --leading-body:  1.55;

  /* Space (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 5rem;

  /* Shape. Pills and rounded cards on every surface. */
  --radius-control: 10px;
  --radius-card:    16px;
  --radius-pill:    999px;

  /* Targets, icons and focus (APPROVED DIRECTION, 5 Oct 2026). Used by every
     pattern on "Your applications" (top bar, chips, row menu, note cell,
     row buttons) and by anything else with a tap target.
       --size-target  minimum height and width of any link or button (44px)
       --size-icon    inline SVG icon beside words: pills, chips, menu (14px)
       --focus-ring   the one focus style: outline: var(--focus-ring);
                      outline-offset: var(--focus-offset). Always visible.
                      Inside a menu or a cell that clips, use a negative
                      offset (-2px) so the ring is not cut off.            */
  --size-target: 2.75rem;
  --size-icon:   0.875rem;
  --focus-ring:  2px solid var(--color-focus-ring);
  --focus-offset: 2px;

  /* Layout widths (APPROVED DIRECTION, 3 Oct 2026). Containers centre with
     inline padding --space-5. The two-column hero and side-by-side steps
     start at a 60rem (960px) viewport: @media (min-width: 60rem). Custom
     properties cannot be used inside a media query, so that number is
     written out there. */
  --container-text: 40rem;   /* 640px: reading column, pricing card */
  --container-wide: 60rem;   /* 960px: two-column hero, side-by-side steps.
                                Landing page only from 9 Oct 2026; signed-in
                                pages use --container-app. */
  --container-app:  72rem;   /* 1152px: the width of EVERY signed-in page
                                (Applications, Roles, Answers, Profile,
                                Documents, Find, Upload, Onboarding shell),
                                9 Oct 2026, Fran. Prose inside a page keeps
                                65ch or --container-text. The top bar content
                                aligns to this width. Same value in both
                                themes. Media queries stay written out
                                (40rem, 60rem). */

  /* Motion. Calm, not urgent: one thing moves at a time, once, ease-out,
     nothing over 1s per element (APPROVED DIRECTION, 3 Oct 2026).
     Hero sequence on load: marker sweep starts at --delay-sweep and runs
     --motion-sweep; the serif phrase fades in at --delay-fade for
     --motion-fade; the mockup typing starts at --delay-handoff. */
  --ease-calm:      cubic-bezier(0.22, 0.61, 0.36, 1);
  --motion-fast:    120ms ease-out;
  --motion-fade:    400ms var(--ease-calm);
  --motion-sweep:   700ms var(--ease-calm);
  --delay-sweep:    300ms;
  --delay-fade:     1000ms;   /* = --delay-sweep + sweep duration */
  --delay-handoff:  1500ms;   /* after the fade has finished */
  --duration-pulse: 2400ms;   /* one slow breath of the "Filling" icon */
  --pulse-low:      0.45;     /* lowest opacity of the pulse (icon only) */
}

/* "Filling" pulse. Apply to the status ICON only, never the words, so the
   text keeps full contrast on every frame:
     animation: status-pulse var(--duration-pulse) ease-in-out infinite;
   Reduced motion makes --pulse-low 1, so nothing visibly changes; the icon
   shape (half-filled) and the word "Filling" still carry the state. */
@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: var(--pulse-low); }
}

/* ---- Theme: marketing (dark). Landing page only. -------------------------
   Same hues as product. Accent lightens to keep contrast, so buttons take
   dark text (--color-text-inverse flips to near-black).
   Contrast, computed by hand from the WCAG formula (accurate to about 0.1):
     text  #EDEBF4 on bg #14121C        15.7:1     on surface 14.4:1
     muted #A6A2B5 on bg                 7.5:1     on surface  6.8:1
     accent #A79BFF on bg                7.7:1     on surface  7.1:1
     dark text #14121C on accent         7.7:1     on hover #BDB4FF 9.8:1
     accent on soft #26223F              6.3:1     on-soft #C9C2FF 9.2:1
     border-strong #7C7890 on bg         4.4:1     on surface  4.0:1 (UI 3:1)
     highlight #DFFF3A on bg            16.3:1     (a bright slab; keep it small)
     #14121C text on highlight          16.3:1
   Status pills (3 Oct 2026 additions resolve through the tokens above, so
   this block defines no new colour; values listed so the pairs are checked):
     sent/filling #C9C2FF on soft #26223F   9.2:1
     needs-you    #EDEBF4 on surface        14.4:1
     closed       #A6A2B5 on sunk #0F0D15   about 8:1
     waiting      #A6A2B5 on bg             7.5:1   (on surface 6.8:1)
   Light theme: sent/filling 6.2:1; needs-you 17.0:1; closed about 5.7:1;
   waiting 6.2:1 on bg, 6.6:1 on surface.                                    */
:root[data-theme="marketing"] {
  --color-bg:            #14121C;
  --color-surface:       #1D1B27;
  --color-surface-sunk:  #0F0D15;
  --color-border:        #2C2938;  /* decorative only */
  --color-border-strong: #7C7890;

  --color-text:          #EDEBF4;
  --color-text-muted:    #A6A2B5;
  --color-text-inverse:  #14121C;  /* text on the lighter accent */

  --color-accent:          #A79BFF;
  --color-accent-hover:    #BDB4FF;
  --color-accent-soft:     #26223F;
  --color-accent-on-soft:  #C9C2FF;
  --color-focus-ring:      #A79BFF;

  /* Highlight is unchanged. Text inside it must stay dark, NOT light,
     even on this dark theme (light text on lime is about 1.1:1). */
  --color-highlight:          #DFFF3A;
  --color-text-on-highlight:  #14121C;

  /* Status hues for the dark theme (6 Oct 2026), pill text on pill fill:
       needs-you #F3C77A on #3A2B12  8.6:1    sent #8FD9AE on #16301F  8.6:1
     waiting, filling, closed, unchecked resolve through the tokens above. */
  --color-status-needs-you:    #F3C77A;
  --color-status-needs-you-bg: #3A2B12;
  --color-status-sent:         #8FD9AE;
  --color-status-sent-bg:      #16301F;

  --shadow-card: none;
}

/* Reduced motion: every movement collapses to its finished state at first
   paint. Build animations with fill-mode "both" so a 0ms run ends on the
   finished frame (marker fully drawn, phrase visible, pulse still). */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast:   0ms;
    --motion-fade:   0ms;
    --motion-sweep:  0ms;
    --delay-sweep:   0ms;
    --delay-fade:    0ms;
    --delay-handoff: 0ms;
    --pulse-low:     1;
  }
}

/* ==========================================================================
   AUDIT: values found in surfaces on 3 October 2026. Kept so nothing is lost.
   Not live. Delete a line only when ui-builder has migrated that surface.

   landing-page/index.html (dark)
     --bg #0b0b0b  --bg2 #141414  --bg3 #1c1c1c
     --border rgba(255,255,255,0.1)  --border2 rgba(255,255,255,0.06)
     --white #fff  --gray1 .75  --gray2 .45  --gray3 .20 (white alphas)
     --accent #fff (no colour accent at all)
     font Inter 300-700, body 16px/1.6
     note: --gray2 (.45 white on #0b0b0b) is about 4.5:1, borderline; --gray3 is decorative only

   ApplyAI-Commercial/web/app/app.css (light, cool grey)
     --accent #5b52e8  --accent-dark #4840c9  --ink #16181d  --muted #646b78
     --line #e3e5ea  --bg #f7f8fa
     --ok #1a7f4b  --ok-bg #eaf7f0  --bad #b4232b  --bad-bg #fdeced
     font system sans, 1.55
     note: --bad / --bad-bg is a red callout pair, against the standing rule

   ApplyAI-Commercial/extension/sidepanel.html (light and dark, teal)
     light: --ink #15191c --muted #697279 --faint #8d959b --line #e1e5e7
            --paper #f6f7f7 --card #fff --ok #1c5a4e --soft #e6efec
     dark:  --ink #e7eaec --muted #99a1a7 --faint #7b838a --line #262b2f
            --paper #101315 --card #181c1f --ok #74c4b0 --soft #17302b
     font system sans 14.5px; 10.5px type in 5 places (.ver .state .proof .k
     .proof code .foot); a.btn and button share one rule (no primary)
   ========================================================================== */
