/* ═══════════════════════════════════════════════════════════════════════════
   Altaha — tokens.css
   "Navy and Cognac". The one place a colour, a font or a size is written down.

   Every page loads this file first. Every other stylesheet, and every script
   that draws, names a token from here; scripts/check-theme fails the build on
   a raw hex, an rgb() or a font size that is not one of these. THEME.md says
   what each token is for.

   Light is "Ivory and Navy", dark is "Midnight and Cognac". The theme is the
   data-theme attribute on <html>, set before first paint by theme.js.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Fonts, self-hosted ─────────────────────────────────────────────────────
   Fraunces for headings and hero figures, Inter for everything read, and
   JetBrains Mono for ticker symbols only. Variable files, so 400 to 600 is
   one request per family; each page preloads the three latin files, so no
   text changes face after the first paint. The -ext files carry the rupee
   sign and are only fetched by a page that prints one. */
@font-face{
  font-family:'Fraunces'; font-style:normal; font-weight:400 500; font-display:swap;
  src:url(fonts/fraunces-latin.woff2) format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face{
  font-family:'Fraunces'; font-style:normal; font-weight:400 500; font-display:swap;
  src:url(fonts/fraunces-latin-ext.woff2) format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face{
  font-family:'Inter'; font-style:normal; font-weight:400 600; font-display:swap;
  src:url(fonts/inter-latin.woff2) format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face{
  font-family:'Inter'; font-style:normal; font-weight:400 600; font-display:swap;
  src:url(fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face{
  font-family:'JetBrains Mono'; font-style:normal; font-weight:400 500; font-display:swap;
  src:url(fonts/jetbrains-mono-latin.woff2) format('woff2');
}
/* Metric-matched stand-ins: until the real file arrives the fallback takes up
   the same room, so the swap moves nothing. */
@font-face{
  font-family:'Inter Fallback'; src:local('Arial');
  ascent-override:90.49%; descent-override:22.56%; line-gap-override:0%; size-adjust:107.06%;
}
@font-face{
  font-family:'Fraunces Fallback'; src:local('Georgia');
  ascent-override:92.4%; descent-override:24.1%; line-gap-override:0%; size-adjust:101.2%;
}

:root{
  color-scheme:light;

  /* ── Colour: Ivory and Navy ──────────────────────────────────────────── */
  --bg:#F7F3EC;                /* the page */
  --surface:#FFFFFF;           /* cards */
  --surface-raised:#FBF8F3;    /* hover rows, inputs, dropdowns, modals */
  --border:#E2D8C8;            /* hairlines */
  --border-strong:#CDBFA8;     /* focused borders, the rule under a heading */
  --text-primary:#0F1A30;      /* deep navy, never black */
  --text-secondary:#5E6472;
  --text-muted:#676C77;        /* spec #8A8E98 measured 3.0:1; this is 4.8:1 */
  --accent:#14213D;            /* primary button, active nav, logo */
  --accent-hover:#1E2F55;
  --on-accent:#F7F3EC;
  --highlight:#A8642C;         /* cognac: hero figures, underlines, icons */
  --highlight-text:#8F5322;    /* cognac at reading sizes: links, chips, tabs */
  --highlight-subtle:#F3E6D6;
  --gain:#2A7253;              /* spec #2E7D5B measured 4.3:1 on its own chip */
  --gain-bg:#E3F1EA;
  --loss:#B03A2E;
  --loss-bg:#F6E3E0;
  --warning:#8F5E12;           /* spec #B7791F measured 3.3:1 as text */
  --warning-bg:#F6EBD6;
  --info:#2F5D8A;
  --info-bg:#E3ECF4;
  --focus-ring:#A8642C;

  /* Chart series, in this order. */
  --chart-1:#A8642C;           /* cognac */
  --chart-2:#14213D;           /* navy */
  --chart-3:#6E8B74;           /* sage */
  --chart-4:#A88752;           /* sand; spec #C9A97A measured 2.2:1 on white */
  --chart-5:#5E6B85;           /* slate */
  --chart-6:#8C3B2E;           /* rust */

  /* Mixed from the tokens above, so they follow the theme by themselves. */
  --grid:color-mix(in srgb, var(--border) 50%, transparent);
  --wash:color-mix(in srgb, var(--text-primary) 4%, transparent);
  --wash-strong:color-mix(in srgb, var(--text-primary) 8%, transparent);
  --scrim:color-mix(in srgb, var(--text-primary) 45%, transparent);
  --ring:0 0 0 3px color-mix(in srgb, var(--focus-ring) 20%, transparent);

  /* The one shadow. Raised things only: a menu, a modal, a card on hover. */
  --shadow-raised:0 1px 2px rgba(15,26,48,.04), 0 8px 24px rgba(15,26,48,.06);

  /* ── Type ─────────────────────────────────────────────────────────────── */
  --font-display:'Fraunces','Fraunces Fallback',Georgia,'Times New Roman',serif;
  --font-sans:'Inter','Inter Fallback',system-ui,-apple-system,'Segoe UI',sans-serif;
  --font-mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;

  --fs-display:40px;   /* hero metrics            Fraunces 400 */
  --fs-h1:30px;        /* page titles             Fraunces 500 */
  --fs-h2:22px;        /* section headings        Fraunces 500 */
  --fs-h3:16px;        /* card titles             Inter 600    */
  --fs-body:14px;      /* text                    Inter 400    */
  --fs-small:13px;     /* secondary text          Inter 400    */
  --fs-label:11px;     /* UPPERCASE labels        Inter 500    */
  --fs-input:14px;     /* 16px on a phone, below: iOS zooms a smaller field */

  --lh-display:1.1; --lh-h1:1.2; --lh-h2:1.25; --lh-h3:1.3;
  --lh-body:1.55;   --lh-small:1.5; --lh-label:1.4; --lh-none:1;

  --ls-heading:-.01em;  /* headings of 22px and up */
  --ls-label:.08em;     /* uppercase labels */

  /* ── Shape and space ──────────────────────────────────────────────────── */
  --r-card:12px;       /* cards, modals, tooltips, dropdowns */
  --r-control:8px;     /* inputs, buttons */
  --r-xs:4px;          /* marks too small to be a control: a bar, a swatch */
  --r-pill:999px;      /* primary action, chips */

  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px;
  --sp-8:32px; --sp-10:40px; --sp-12:48px; --sp-16:64px;
  --card-pad:24px;
  --gutter:32px;
  --row-h:48px;
  --control-h:40px;

  /* ── Motion ───────────────────────────────────────────────────────────── */
  --ease:cubic-bezier(.22,.61,.36,1);
  --ease-soft:cubic-bezier(.16,1,.3,1);
  --ease-out:cubic-bezier(.16,1,.3,1);
  --t-fast:150ms; --t:280ms; --t-slow:460ms;
}

:root[data-theme="dark"]{
  color-scheme:dark;

  /* ── Colour: Midnight and Cognac ─────────────────────────────────────── */
  --bg:#080D1A;
  --surface:#101828;
  --surface-raised:#172136;
  --border:#222E45;
  --border-strong:#33415E;
  --text-primary:#F2EADF;      /* warm ivory, never white */
  --text-secondary:#A3AAB8;
  --text-muted:#8791A3;        /* spec #6F788A measured 3.6:1 on a raised surface */
  --accent:#C47A3A;
  --accent-hover:#D58C4C;
  --on-accent:#080D1A;
  --highlight:#E3A869;
  --highlight-text:#E3A869;
  --highlight-subtle:rgba(196,122,58,.12);
  --gain:#6FCF97;
  --gain-bg:rgba(111,207,151,.12);
  --loss:#E8705E;
  --loss-bg:rgba(232,112,94,.12);
  --warning:#E0B054;
  --warning-bg:rgba(224,176,84,.12);
  --info:#7FA7D9;
  --info-bg:rgba(127,167,217,.12);
  --focus-ring:#E3A869;

  --chart-1:#E3A869;           /* cognac */
  --chart-2:#7FA7D9;           /* steel blue */
  --chart-3:#8FB89A;           /* sage */
  --chart-4:#D9C3A0;           /* sand */
  --chart-5:#9AA6BF;           /* slate */
  --chart-6:#E0826B;           /* rust */

  --scrim:rgba(3,6,14,.66);
  --shadow-raised:none;        /* no shadows at night: the border does the lifting */
}

/* A field under 16px makes iOS zoom the page when it takes focus, so fields
   are 16px at phone width and under any finger. */
@media (max-width:720px){
  :root{ --gutter:16px; --card-pad:16px; --fs-input:16px; }
}
@media (hover:none) and (pointer:coarse){
  :root{ --fs-input:16px; }
}

/* ── The page itself ────────────────────────────────────────────────────── */
html{ background:var(--bg); }
body{
  background:var(--bg); color:var(--text-primary);
  font-family:var(--font-sans); font-size:var(--fs-body); line-height:var(--lh-body);
  font-variant-numeric:tabular-nums;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}

/* The theme changes colour over 200ms when the reader asks for it, and not
   when a page loads: theme.js puts this class on for the length of a switch. */
html.theme-switching, html.theme-switching *,
html.theme-switching *::before, html.theme-switching *::after{
  transition:background-color 200ms ease, color 200ms ease, border-color 200ms ease,
             fill 200ms ease, stroke 200ms ease !important;
}
@media (prefers-reduced-motion:reduce){
  html.theme-switching, html.theme-switching *,
  html.theme-switching *::before, html.theme-switching *::after{ transition:none !important; }
}
