/* Revise 360 design tokens. Loaded FIRST on every page.

   One system, two surfaces. Everything a page is drawn with - colour, type,
   radius, spacing, shadow, focus - is named here once. The stylesheets after
   this one read these names and set no brand colour of their own.

     light   the public pages, the pupil dashboard and the teacher pages
             (:root, the default)
     dark    the 360 rooms (body.player: experience.html, revise.html), the
             Explain window wherever it appears (the home page's live
             explainer, .xdemo), the dark bands and the footer of the public
             pages, and the developer page pydiag.html (body.surface-dark)

   Both surfaces have the same names. A component asks for var(--accent) and
   gets cobalt on a light page and a light cobalt in a room; it never asks
   which surface it is on. docs/DESIGN-SYSTEM.md has the usage rules and the
   contrast of every pair defined here.

   Not here, on purpose: the Python token colours (css/pytok.css, which
   tools/tests/smoketok.py keeps the only copy of) and the colours painted into
   the room textures and the 2D diagrams (js/diagrams.js and friends). Those
   are content, not interface. */

:root {
  /* ---- 1. Raw palette ---------------------------------------------------
     The brand (BRAND.md) and the few steps either side of it the interface
     needs. Components never read these directly: they read section 3. */
  --c-ink:#101828;          /* brand Ink */
  --c-canvas:#F7F7F4;       /* brand Canvas */
  --c-cobalt:#2D63FF;       /* brand Cobalt: primary on light */
  --c-teal:#08A6A6;         /* brand Teal: occasional secondary */
  --c-amber:#F4B942;        /* brand Amber: highlight and feedback */
  --c-slate:#667085;        /* brand Slate: supporting text */
  --c-border:#D9DEE7;       /* brand Border */
  --c-white:#FFFFFF;

  --c-cobalt-50:#EAF0FF;    /* wash behind a closing call, a glyph */
  --c-cobalt-200:#A9C1FF;   /* labels and codes on navy; hover on dark */
  --c-cobalt-300:#7EA2FF;   /* primary on dark: 6.7:1 on the room navy */
  --c-cobalt-550:#2556D8;   /* links and small accent text on light */
  --c-cobalt-600:#184DDB;   /* primary hover on light */
  --c-cobalt-700:#163FAF;   /* link hover on light */

  --c-amber-50:#FFF6DF;
  --c-amber-100:#FFF0CB;
  --c-amber-400:#FFD046;    /* the brighter amber the rooms are painted in */
  --c-amber-600:#B37B00;    /* an amber signal dot on white */
  --c-amber-800:#745314;
  --c-amber-900:#4D3A10;
  --c-amber-950:#2A2410;
  --c-amber-200:#FFE2A3;

  --c-slate-300:#B8C3D1;    /* quiet control outline on light */
  --c-slate-350:#7B8AA1;
  --c-slate-400:#8A95A4;    /* not-yet / unavailable text */
  --c-slate-600:#536174;
  --c-slate-700:#475467;    /* body copy on the public pages */
  --c-slate-900:#35445A;

  --c-mist-50:#FAFBFC;      /* an off-white row */
  --c-mist-100:#F3F5F9;     /* a tint band, a quiet card */
  --c-mist-200:#EBEEF3;     /* hover, a table head, a raised strip */

  --c-navy-950:#0B1424;     /* footer, dark bands */
  --c-navy-925:#0B1322;     /* code wells in the rooms */
  --c-navy-900:#0E1628;
  --c-navy-850:#121E34;     /* the room navy */
  --c-navy-800:#14223A;
  --c-navy-750:#15223B;     /* a raised panel in a room */
  --c-navy-700:#1C2C4A;     /* the window panel in a room */
  --c-navy-600:#23314B;     /* a rule on navy */
  --c-navy-500:#3C5A87;     /* a line in a room */
  --c-navy-400:#5A7BAB;     /* a control outline in a room */
  --c-navy-300:#8A9BB8;
  --c-navy-200:#B4C4DC;     /* supporting text in a room */
  --c-navy-100:#C9D5EA;
  --c-navy-50:#F0F4FA;      /* text in a room */

  --c-green-50:#DDF4E9;  --c-green-600:#18866C; --c-green-800:#176348;
  --c-green-200:#9FF0CF; --c-green-400:#50DC96; --c-green-900:#164335;
  --c-red-50:#FCE4E7;    --c-red-600:#BF364A;   --c-red-800:#9D233A;
  --c-red-200:#FFC9D1;   --c-red-400:#FF5F5F;   --c-red-900:#4A202B;
  --c-sky-400:#5AB4FF;
  --c-teal-200:#A6ECE6;  --c-teal-700:#1D706B;

  /* The visual identity pilot (section 5). Read only through section 5's
     semantic names, and only where that pilot is switched on. */
  --c-deep-950:#0B1320;     /* deep ink: the room behind everything */
  --c-deep-925:#0E1622;     /* a code well */
  --c-deep-900:#121B29;     /* a field, an answer option set into a panel */
  --c-deep-800:#1A2433;     /* the raised surface: windows, slabs, panels */
  --c-deep-700:#263447;     /* the secondary surface: a strip set into a panel */
  --c-deep-600:#2E3B4F;     /* a quiet rule */
  --c-deep-450:#66768E;     /* a control's outline: 3.4:1 on the raised surface */
  --c-deep-350:#8592A6;     /* not yet available */
  --c-text-50:#E6EAF0;      /* warm off-white text */
  --c-text-100:#CDD3DD;
  --c-text-300:#A7B1C2;     /* muted slate: supporting text */
  --c-blue-950:#15233A;     /* a selected row */
  --c-blue-600:#245FC0;
  --c-blue-500:#2A70DE;     /* Revise360 blue: a fill under white text (4.7:1) */
  --c-blue-300:#6EA4F4;     /* Revise360 blue as text and focus on the dark surfaces */
  --c-blue-200:#A3C4F8;
  --c-amber-500:#F59E0B;    /* the learning amber: Starter, Predict, EXPLAIN, the current stage */
  --c-amber-975:#2A2111;  --c-amber-150:#FCD9A0;
  --c-green-450:#4CC38A;  --c-green-975:#13291F; --c-green-150:#A6E6C6;
  --c-red-450:#EF5D60;    --c-red-975:#33191D;   --c-red-150:#F6B3B5;

  /* ---- 2. Type, shape, space, depth ------------------------------------ */
  /* IBM Plex is served from this site (css/fonts.css, vendor/fonts/ibm-plex),
     on every page and in the rooms, so no font comes from a third party. */
  --font-sans:'IBM Plex Sans','Segoe UI',system-ui,-apple-system,sans-serif;
  --font-mono:'IBM Plex Mono',ui-monospace,'Cascadia Mono',Consolas,'DejaVu Sans Mono',monospace;

  --fs-xs:12px;   /* mono labels, tags */
  --fs-sm:13px;   /* metadata, captions */
  --fs-ui:14px;   /* nav, small controls, table text */
  --fs-btn:15px;  /* buttons, compact body */
  --fs-body:16px;
  --fs-lead:18px;
  --fs-h3:19px;
  --fs-h2:clamp(28px,3.2vw,43px);
  --fs-h1:clamp(34px,4vw,52px);
  --fs-display:clamp(46px,5.4vw,80px);

  --fw-regular:400; --fw-medium:500; --fw-semibold:600; --fw-bold:700;
  --lh-control:1.3; --lh-body:1.45; --lh-read:1.6;
  --ls-label:.06em;      /* uppercase mono labels */
  --ls-tight:-.035em;    /* headings */

  --r-xs:4px;        /* code chips */
  --r-sm:6px;        /* thumbnails, small tags */
  --r-control:8px;   /* buttons, inputs, toolbar buttons, nav items */
  --r-card:10px;     /* cards, panels, answer options */
  --r-window:14px;   /* dialogs, the task window, Explain, drawers */
  --r-pill:999px;    /* badges, chips */

  --s0:4px; --s1:8px; --s2:16px; --s3:24px; --s4:32px; --s5:48px; --s6:64px; --s7:96px; --s8:120px;

  --shadow-sm:0 6px 24px rgba(16,24,40,.08);
  --shadow-md:0 16px 38px rgba(16,24,40,.13);
  --shadow-lg:0 25px 80px rgba(16,24,40,.3);
  --shadow-dark:0 20px 60px rgba(0,0,0,.5);

  --focus-w:3px; --focus-offset:2px;
  --btn-py:11px; --btn-px:17px;   /* outer padding: a border is taken from it */

  /* ---- 3. Semantic tokens: the LIGHT surface ---------------------------- */
  --bg:var(--c-white);
  --bg2:var(--c-mist-200);
  --panel:var(--c-white);
  --raise:var(--c-mist-100);       /* a strip or callout set into a panel */
  --sunk:var(--c-mist-200);        /* a code well, a key */
  --line:var(--c-border);
  --line-strong:var(--c-slate-350);/* the outline of a ghost button or input: 3.5:1 on white, the 3:1 a control boundary needs (WCAG 1.4.11) */
  --fg:var(--c-ink);
  --fg2:var(--c-slate-700);        /* reading copy a step below the headline */
  --soft:var(--c-slate);           /* supporting text: 4.97:1 on white */
  --quiet:var(--c-slate-400);      /* not yet available; never body text */

  --accent:var(--c-cobalt);        /* primary actions, current state, rules */
  --accent-hover:var(--c-cobalt-600);
  --accent-fg:var(--c-white);      /* text on an --accent fill */
  --accent-soft:var(--c-cobalt-50);
  --accent-text:var(--accent);     /* the accent as text: a selected label, a count */
  --info:var(--c-cobalt-550);      /* small accent text, kickers */
  --link:var(--c-cobalt-550);
  --link-hover:var(--c-cobalt-700);
  --focus:var(--c-cobalt);

  --highlight:var(--c-amber);      /* a fill or a rule; never text on white */
  --highlight-fg:var(--c-ink);     /* text on a --highlight fill */
  --highlight-text:var(--c-amber-800);
  --amber:var(--highlight);
  --edge:var(--highlight);         /* old name; see the dark surface */

  --ok:var(--c-green-600);   --ok-soft:var(--c-green-50);   --ok-strong:var(--c-green-800);
  --bad:var(--c-red-600);    --bad-soft:var(--c-red-50);    --bad-strong:var(--c-red-800);
  --amber-soft:var(--c-amber-100); --amber-strong:var(--c-amber-800);
  --neutral-soft:var(--c-mist-200); --neutral-strong:var(--c-slate-600);

  --field-bg:var(--c-white);
  --ghost-hover:var(--c-mist-200);
  --glass:rgba(255,255,255,.92);
  --shadow-pop:var(--shadow-md);
  --control-bw:1px;

  color-scheme:light;
}

/* ---- 4. Semantic tokens: the DARK surface --------------------------------
   Declared on <html> too when the page is a room, because the headset panels
   and the Python screen (js/vr.js, js/pyscreen.js) read their palette off
   document.documentElement. */
:root:has(> body.player), :root:has(> body.surface-dark),
body.player, .surface-dark, .xdemo, footer.site, .band.dark, .vr-band {
  --bg:var(--c-navy-850);
  --bg2:var(--c-navy-900);
  --panel:var(--c-navy-700);
  --raise:var(--c-navy-750);
  --sunk:var(--c-navy-925);
  --line:var(--c-navy-500);
  --line-strong:var(--c-navy-400);
  --fg:var(--c-navy-50);
  --fg2:var(--c-navy-100);
  --soft:var(--c-navy-200);
  --quiet:var(--c-navy-300);

  --accent:var(--c-cobalt-300);    /* 6.7:1 on --bg, 5.6:1 on --panel */
  --accent-hover:var(--c-cobalt-200);
  --accent-fg:var(--c-ink);        /* 7.2:1 on --accent */
  --accent-soft:#22335A;
  --accent-text:var(--accent);
  --info:var(--c-sky-400);
  --link:var(--c-sky-400);
  --link-hover:var(--c-cobalt-200);
  --focus:var(--c-cobalt-300);

  --highlight:var(--c-amber-400);  /* matches the painted walls */
  --highlight-fg:var(--c-ink);
  --highlight-text:var(--c-amber-400);
  --amber:var(--highlight);
  /* --edge is the name the headset panels, the Python screen and the 2D
     activities read from <html> for their amber heading colour. It stays the
     highlight on purpose; interface CSS reads --accent or --highlight. */
  --edge:var(--highlight);

  --ok:var(--c-green-400);   --ok-soft:var(--c-green-900);  --ok-strong:var(--c-green-200);
  --bad:var(--c-red-400);    --bad-soft:var(--c-red-900);   --bad-strong:var(--c-red-200);
  --amber-soft:var(--c-amber-900); --amber-strong:var(--c-amber-200);
  --neutral-soft:#2A3A55; --neutral-strong:var(--c-navy-100);

  --field-bg:var(--c-navy-900);
  --ghost-hover:rgba(126,162,255,.12);
  --glass:rgba(10,16,30,.9);
  --shadow-pop:var(--shadow-dark);
  --control-bw:2px;

  color-scheme:dark;
}
/* The public pages' dark bands and footer are navy all the way down. */
footer.site, .band.dark, .vr-band { --bg:var(--c-navy-950); --panel:var(--c-navy-800); --line:var(--c-navy-600); }

/* ---- 5. The visual identity pilot: the DARK surface, refined -------------
   PILOT, local only (docs/VISUAL-IDENTITY-PILOT.md). The same names as
   section 4 with new values, so no component asks which identity it is in.
   It applies only when <html data-identity="v2">, which js/identity.js sets
   on this computer, on request, for four pilot surfaces. Everywhere else
   this block matches nothing.

   Colour says what something does:
     blue    navigation, standard interaction, selected, links, system actions
     amber   Starter, Predict, EXPLAIN, the current learning stage, attention
     green   success, Secure, complete; nothing else
     red     an error or a marked mistake; never an exploratory prediction
   Shape is quieter: smaller radii, one-pixel outlines, one shadow for a
   window over the room, no glow. */
:root[data-identity="v2"]:has(> body.player), :root[data-identity="v2"] body.player {
  --bg:var(--c-deep-950);
  --bg2:var(--c-deep-900);
  --panel:var(--c-deep-800);
  --raise:var(--c-deep-700);
  --sunk:var(--c-deep-925);
  --line:var(--c-deep-600);
  --line-strong:var(--c-deep-450);
  --fg:var(--c-text-50);
  --fg2:var(--c-text-100);
  --soft:var(--c-text-300);
  --quiet:var(--c-deep-350);

  --accent:var(--c-blue-500);      /* a fill: white text on it is 4.7:1 */
  --accent-hover:var(--c-blue-600);
  --accent-fg:var(--c-white);
  --accent-soft:var(--c-blue-950);
  --accent-text:var(--c-blue-300); /* 6.1:1 on --panel, 5.0:1 on --raise */
  --info:var(--c-blue-300);
  --link:var(--c-blue-300);
  --link-hover:var(--c-blue-200);
  --focus:var(--c-blue-300);

  --highlight:var(--c-amber-500);
  --highlight-fg:var(--c-deep-950);  /* 8.6:1 on --highlight */
  --highlight-text:var(--c-amber-500);/* 7.3:1 on --panel */
  --amber:var(--highlight);
  --edge:var(--highlight);

  --ok:var(--c-green-450);   --ok-soft:var(--c-green-975);  --ok-strong:var(--c-green-150);
  --bad:var(--c-red-450);    --bad-soft:var(--c-red-975);   --bad-strong:var(--c-red-150);
  --amber-soft:var(--c-amber-975); --amber-strong:var(--c-amber-150);
  --neutral-soft:var(--c-deep-700); --neutral-strong:var(--c-text-100);

  --field-bg:var(--c-deep-900);
  --ghost-hover:rgba(110,164,244,.10);
  --glass:rgba(18,27,41,.96);
  --shadow-dark:0 18px 48px rgba(0,0,0,.45);
  --shadow-pop:var(--shadow-dark);
  --control-bw:1px;

  --r-xs:3px; --r-sm:4px; --r-control:6px; --r-card:8px; --r-window:10px;
}
