/* ============================================================================
   CONTRAIR — TOKEN CORE
   Source of truth. Framework-free. No build step required to consume this file.
   Mirror: tokens/contrair.tokens.json  (regenerate: node tools/build-tokens.mjs)

   WORLD: DARKROOM. Warm-dark editorial. A lone object floating in warm
   darkness, cream typography the only decoration. Pinned by the brief.

   FOUR LAWS, all measured, all checkable (node tools/contrast.mjs):
   1. ONE TEXT COLOUR PER POLE. Warm Cream on the dark pole, Walnut Shadow on
      the paper pole. There is no muted text colour and no second grey.
      Hierarchy comes from size, weight and case — never from a dimmer value.
      The one chromatic exception is measured: TEAL is ink on paper (5.48).
   2. NEVER PURE. No #fff for text, no #000 for backgrounds. The warm tint IS
      the identity; purity reads as wrong here.
   3. THE ACCENT IS THE ACTION. Ember fills the primary button at weight 700 and
      also sets credit lines. It may be a whole section ground, but it is too
      light for cream, so such a section inverts to walnut ink.
   4. NO SHADOWS, EVER, including as a border trick. Depth is the ground change:
      the walnut canvas steps to a field. No blur, no offset, no opacity lift.
   ========================================================================= */

:root {
  /* ── PIGMENTS ────────────────────────────────────────────────────────────
     Measured against the canvas. Roles are the brief's own, confirmed by the
     numbers rather than assumed.                                            */
  --c-cream:   #ffedd7;  /* ALL text, borders, interactive edges  17.26 walnut */
  --c-walnut:  #100904;  /* page canvas, every section ground — warm near-black*/

  /* ── THE PAPER ───────────────────────────────────────────────────────────
     The reading ground, and the one job cream used to do badly. A 40-point
     R-B spread is warmth when it is a letterform; across a whole A4 sheet it
     is a sepia wash. Paper keeps the world's warmth at a 10-point spread —
     broken white, not cream — and carries walnut at 18.15. Cream stays what
     it always was: ink and edges on the dark pole, never a ground.           */
  --c-paper:   #f8f5ee;  /* the document ground only              walnut 18.15 */

  /* ── THE FIELD SET — section grounds ─────────────────────────────────────
     Dark enough to carry cream body copy, which is the whole point: a section
     can change its ground without the text ever changing colour.             */
  --c-teal:    #256f60;  /* the ground that carries cream          cream 5.21 */

  /* ── THE ACTION SET — buttons, marks, and inverted grounds ───────────────
     Too light to sit under cream (2.72 / 1.60), so these carry WALNUT ink,
     whether they are filling a button or an entire section.                   */
  --c-ember:   #ff5a1f;  /* primary action, accent, inverted ground   ink 6.34 */
  --c-amber:   #ffb01f;  /* secondary action, marks, inverted ground  ink 10.80 */

  --c-vector:  #000000;  /* SVG/vector fills only. Never a ground, never text. */

  /* ── LEGALITY ────────────────────────────────────────────────────────────
     Six working pigments, each with exactly one job — cream is ink and edges
     on the dark pole, paper is the reading ground and nothing else — plus
     vector black, which is a contract for asset authors and is referenced by
     no stylesheet. Bark brown, cork border,
     driftwood and rust were removed: bark's elevated-solid role is now the
     field set, cork and driftwood became cream tints, and rust was a duplicate
     of brick. Fewer values, each measured.
     TEAL is the one ground that carries cream (5.21), and the one chromatic
     value dark enough to be INK on paper (5.48) — which is why the document
     accent is teal and not ember. EMBER and AMBER may also be grounds, but
     they are too light for cream (2.72 / 1.60), so a section in either
     INVERTS TO WALNUT INK (6.34 / 10.80) — the same inversion the amber field
     always used. Ember as text on the canvas is 6.34; on paper it is 2.86 and
     is a ground only. Rules are tints of whichever foreground the context
     uses, not a pigment of their own.                                        */

  /* ── SURFACE LADDER ─────────────────────────────────────────────────────
     Two steps, and only two. Level 0 is the void; level 1 is the single solid.*/
  --ground:        var(--c-walnut);
  --text:          var(--c-cream);
  --text-accent:   var(--c-ember);
  /* Rules are TINTS OF THE FOREGROUND, not pigments of their own. That is why
     cork and driftwood could go: a divider is the text colour, thinned.       */
  /* Consumed by the document blockquote. Defined on BOTH poles so the token can
     never resolve to nothing on a dark surface. */
  --ground-raised: color-mix(in srgb, var(--c-cream) 10%, var(--c-walnut));
  --rule:          color-mix(in srgb, var(--c-cream) 38%, transparent);
  --rule-quiet:    color-mix(in srgb, var(--c-cream) 20%, transparent);
  --rule-hot:      var(--c-amber);   /* a chromatic break; non-text, 10.80    */

  /* ── TYPE ───────────────────────────────────────────────────────────────
     Two typefaces, both loaded as VARIABLE fonts, and one continuous weight
     axis read at five named rungs. Letter-spacing stays normal at every size:
     the geometry does the work, no negative tracking even at display scale.

     Halyard Display is the pinned face and is not web-free. Bricolage Grotesque
     is the substitute that was CHOSEN for it, out of a four-candidate specimen
     (Hanken Grotesk, Archivo, Bricolage Grotesque, Anybody) that has since been
     removed. Both faces here are on Google Fonts, which the artifact CSP
     requires, and both are genuine variable files rather than static instances:

       Bricolage Grotesque  wght 200..800 · wdth 75..100 · opsz 12..96
                            The display voice: idiosyncratic, and the only
                            candidate carrying an OPTICAL SIZE axis, which the
                            browser drives from font-size on its own
                            (`font-optical-sizing: auto` is the default, so
                            nothing declares opsz here). Its width axis only
                            CONDENSES — 100 is already its widest — so the
                            display rungs stay at 100 and take their mass from
                            weight alone.
       Newsreader           wght 200..800 · opsz 6..72
                            The reading voice, and the ONE pairing in the system.
                            Bricolage is a display grotesque and does not want to
                            be prose too, so mode 2 goes to a variable editorial
                            serif carrying the same opsz axis — which is why the
                            two rhyme rather than merely coexist. The case drop
                            already told the reader this is prose; the face change
                            says it louder, and only where prose lives.

     The brief also names Inter and Söhne — Inter reads as neo-grotesque rather
     than geometric, so it is the fallback, not a candidate.                    */
  --face-bricolage:  'Bricolage Grotesque', ui-sans-serif, system-ui, 'Helvetica Neue', Arial, sans-serif;
  --face-newsreader: 'Newsreader', ui-serif, Georgia, 'Times New Roman', serif;
  --face:           var(--face-bricolage);
  /* The conversational voice. It does NOT follow the display face: this is the
     one deliberate pairing in the system. */
  --face-body:      var(--face-newsreader);
  --face-legal:     Arial, ui-sans-serif, system-ui, sans-serif;  /* compliance, not design */

  /* Bricolage has no alternate stylistic set to ask for, and its width axis
     condenses only, so both width settings sit at the face's own widest. */
  --face-features:    normal;
  --wdth-ui:          100;
  --wdth-display:     100;

  /* ── WEIGHT: FIVE RUNGS ON ONE CONTINUOUS AXIS ──────────────────────────
     Weight rises with size, because at monument scale mass is STRUCTURE and at
     16px it is emphasis. The axis is variable, so 650 is a real value and not a
     synthesised one — 500/700 were only ever the two static files we had.
       400 body     — mixed-case prose, the one conversational voice
       500 label    — nav, labels, captions, meta, legal, small UI
       650 heading  — the quiet display rungs: subhead, heading-sm
       700 action   — buttons, and nothing else at this size
       800 display  — monument, display, heading: the loud rungs                */
  --weight-body:    400;
  --weight-label:   500;
  --weight-heading: 650;
  --weight-action:  700;
  --weight-display: 800;

  --text-legal:      8px;   --lead-legal:      1.2;
  --text-caption:   12px;   --lead-caption:    1.2;
  --text-label:     16px;   --lead-label:      1.2;
  --text-action:    20px;   --lead-action:     1.1;   /* buttons run large */
  --text-meta:      16px;   --lead-meta:       1.2;
  --text-subhead:   22px;   --lead-subhead:    1;
  --text-heading-sm:24px;   --lead-heading-sm: 1.09;
  --text-body:      29px;   --lead-body:       1.34;  /* a serif at 29px wants more air than a sans */
  --text-heading:   clamp(41px, 4.6vw, 84px);  --lead-heading: 0.9;
  --text-display:   51px;   --lead-display:    0.9;
  /* The display role at full strength. The brief writes the wordmark as "51px+"
     and the hero as "massive", so 51 is the floor. Leading stays at the 0.9
     signature, where the caps overlap their line boxes and stack as solid form. */
  --text-monument: clamp(51px, 13.5vw, 15rem);  --lead-monument: 0.86;

  /* The signature: 0.9 leading at 41-51px. Unusually tight — the uppercase
     letterforms overlap their line boxes and the display type stops sitting in
     lines and starts stacking as solid form.                                 */

  /* ── SPACING ────────────────────────────────────────────────────────────  */
  --space-6:    6px;
  --space-8:    8px;
  --space-9:    9px;
  --space-10:  10px;
  --space-12:  12px;
  --space-14:  14px;
  --space-18:  18px;   /* the gutter: flanking text to centred object         */
  --space-24:  24px;   /* card padding, page margin                          */
  --space-31:  31px;
  --space-41:  41px;
  --space-45:  45px;
  --space-68:  68px;
  --space-204: 204px;
  --gutter:    var(--space-24);
  --element-gap: var(--space-18);
  --card-pad:    var(--space-24);

  /* ── RADIUS ─────────────────────────────────────────────────────────────
     Four values, and they are the entire vocabulary. Nothing below 12px on a
     container: the geometry is deliberately chunky, never sharp.             */
  --radius-card:     12px;
  --radius-outlined: 22.5px;
  --radius-pill:     36px;
  --radius-full:     9999px;
  --radius-input:    0px;   /* inputs and inline links only */

  /* ── MOTION ─────────────────────────────────────────────────────────────
     The void does not bounce. A reveal rises once, slowly, and settles.      */
  --state-dur: 200ms;

  /* ── BREAKPOINTS ─────────────────────────────────────────────────────────
     Named so the layers stop inventing their own. They are documentation, not
     usable in @media (CSS cannot yet), so the values below are the ONLY ones
     any layer may write. 900 was also appearing as 901; that is now one number. */
  --bp-phone:   560px;   /* below: single column, tables wrap            */
  --bp-tablet:  720px;   /* below: nav wraps, reveals stack              */
  --bp-desk:    900px;   /* at and above: three-column reveal, edge label */
  --bp-wide:   1000px;   /* at and above: document sidenote column       */

  /* ── STATE ───────────────────────────────────────────────────────────────
     This system does NOT encode status in hue. Status is carried by border
     WEIGHT, by a drawn icon, and by words — so it survives colour blindness,
     greyscale printing, and the deck being projected badly. Ember and amber may
     accompany a state, but they may never be the only signal.                 */
  --state-border:  2px;             /* invalid and active raise the border    */
  --icon-stroke:   2px;             /* one stroke weight, everywhere          */

  /* ── THE MASS ────────────────────────────────────────────────────────────
     How present the companion mark is behind a surface. A CREAM lift of the
     canvas — a lighter shade of black, not a tinted shape. At 0.07 the
     composite is #211913, only 1.14 against the canvas: sensed, not seen.
     ONE mass per surface — never one per section. */
  --mass-presence: 0.07;
}

/* ── THE PAPER POLE ─────────────────────────────────────────────────────────
   The document medium turns the world over: walnut ink on paper, the same
   17.26-class ratio read the other way up. Nothing about the vocabulary
   changes — same two faces, same dashed hairlines, same radii, same absent
   shadows — but WHICH pigment may be ink does change, and it is measured:

     walnut on paper   18.15   ink, everywhere
     teal   on paper    5.48   the accent ink: AA at any size, and the one
                               chromatic value dark enough to be text here
     ember  on paper    2.86   FAILS the 3:1 non-text bar. GROUND ONLY.
     amber  on paper    1.68   FAILS by a mile.               GROUND ONLY.

   This is the Ground-Or-Action Rule reading in the other direction: on the
   dark pole ember and amber were too LIGHT to take cream ink, so they became
   grounds that invert. On the light pole they are too light to BE ink at all,
   so they stay grounds — a document gets its ember and amber as callout and
   band fills carrying walnut, never as a line or a word.

   `.on-cream` is the former name of this pole and is kept as an alias so
   documents already in the wild keep rendering. New surfaces write `.on-paper`. */
.on-paper, .on-cream {
  --ground:        var(--c-paper);
  --ground-raised: color-mix(in srgb, var(--c-walnut) 6%, var(--c-paper));
  --text:          var(--c-walnut);
  --text-accent:   var(--c-teal);    /* 5.48 — ember is 2.86 here and cannot be ink */
  /* 55% was set against cream and reads as a hard grey rule on paper; a
     document carries many more lines than a web section, so the structural
     tint drops to 50% (3.64, clears the 3:1 bar) and the quiet tint to 22%. */
  --rule:          color-mix(in srgb, var(--c-walnut) 50%, transparent);
  --rule-quiet:    color-mix(in srgb, var(--c-walnut) 22%, transparent);
  --rule-hot:      var(--c-teal);    /* amber is 1.68 on paper: not a mark here */
}

@media (prefers-reduced-motion: reduce) {
  :root { --state-dur: 1ms; }
}
