/* ==========================================================================
   Deconstructing Design — Design Tokens
   Brand palette + WCAG 2.1 AA verified semantic assignments.

   RAW PALETTE (the six approved colors)
   --------------------------------------------------------------------------
   teal        #367373   sage        #568C87
   sand        #D9C7A7   ochre       #A65712
   terracotta  #A63117   espresso    #261810

   VERIFIED CONTRAST RATIOS (sRGB relative-luminance method, WCAG 2.1)
   AA needs 4.5:1 for normal text, 3:1 for large text (>=24px, or >=18.66px bold)
   and 3:1 for UI component / graphical-object boundaries.

     espresso on sand ......... 10.39:1   AA normal  <- primary body
     espresso on white ........ 17.21:1   AA normal  <- primary body (light)
     sand on espresso ......... 10.39:1   AA normal  <- body on dark
     white on espresso ........ 17.21:1   AA normal  <- body on dark
     white on teal ............  5.45:1   AA normal  <- text on teal panels
     white on ochre ...........  5.26:1   AA normal  <- text on ochre panels
     white on terracotta ......  6.83:1   AA normal  <- text on terracotta
     espresso on sage .........  4.50:1   AA normal  <- text on sage panels
     teal on sand .............  3.29:1   AA large / UI only (headings, borders)
     sand on ochre ............  3.17:1   AA large / UI only
     terracotta on sand .......  4.13:1   AA large / UI only (accents, headings)
     white on sage ............  3.82:1   AA large only

   RULE OF THUMB baked into this file: normal body copy uses only pairings
   at >=4.5:1. The 3.x:1 pairings are reserved for large headings, icons,
   dividers, and focus rings — never small body text.
   ========================================================================== */

:root {
  /* Raw brand colors */
  --c-teal:       #367373;
  --c-sage:       #568C87;
  --c-sand:       #D9C7A7;
  --c-ochre:      #A65712;
  --c-terracotta: #A63117;
  --c-espresso:   #261810;
  /* A mid shade of the base ink — the same hue lightened, not a new one. It
     exists because the coverage field needs a fourth kind of record that is
     legible at 8px: sage sits at deltaE 10.4 from teal, which is invisible as
     a distinction, while this sits at 28.6 from teal and 36.2 from espresso.
     5.19:1 on white. */
  --c-espresso-mid: #7A6A5C;

  /* The one colour outside the brand families, and it is outside them on
     purpose. It marks evidence that was MADE rather than found, on the
     coverage field, and that mark must not read as one more source: the four
     sources are all earth tones, so anything within that family sat too close
     to one of them (terracotta measured deltaE 21.4 from ochre). This sits at
     deltaE 42.9 from the nearest of the four and 5.91:1 on white.

     ENRICHED 2026-10-07. The reading was that the made cells looked as if
     their opacity had been reduced along with the record's. It had not --
     they render at opacity 1 -- but the perception was right about something
     real: at chroma 35.5 this was the LEAST saturated thing on the plate,
     against an ochre at 57.1. Once agency receded the four sources to make
     room for it, a low-chroma purple on a pale field read as one more faded
     thing rather than as the one thing at full strength.

     The fix is to enrich it rather than push the sources down further, which
     would have cost the kinds -- the separation between them is already down
     to deltaE 12.6 in that state.

     Same hue family, chroma 35.5 -> 57.0, which is exactly the ochre's and so
     the palette's own ceiling: rich, never neon. 7.19:1 on white (was 5.91)
     and deltaE 64.0 from the nearest source at full strength (was 42.9). The
     contrast matters as contrast, not only as colour: the legend entry "Made
     where nothing was recorded" is TEXT in this token. */
  --c-made:         #6545A1;
  --c-white:      #ffffff;

  /* Tints/shades derived only for surfaces & shadows (not brand-defining) */
  --c-sand-050:   #f4eee2;   /* very light sand wash for page background */
  --c-sand-100:   #ece2cf;
  --c-espresso-080: rgba(38, 24, 16, 0.08);
  --c-espresso-160: rgba(38, 24, 16, 0.16);
  --c-espresso-400: rgba(38, 24, 16, 0.40);

  /* --- Semantic surface tokens --- */
  --surface-page:      var(--c-sand-050);   /* espresso text = ~15:1 */
  --surface-raised:    var(--c-white);       /* espresso text = 17.2:1 */
  --surface-ink:       var(--c-espresso);    /* sand/white text */
  --surface-teal:      var(--c-teal);        /* white text */
  --surface-sage:      var(--c-sage);        /* espresso text 4.5:1 */
  --surface-ochre:     var(--c-ochre);       /* white text */
  --surface-terracotta:var(--c-terracotta);  /* white text */

  /* --- Semantic text tokens (paired to compliant surfaces) --- */
  --text-strong:   var(--c-espresso);   /* on sand / white / sage */
  --text-body:     #33261c;             /* espresso lightened; still >12:1 on sand */
  --text-on-dark:  var(--c-sand);       /* on espresso: 10.4:1 */
  --text-on-teal:  var(--c-white);      /* 5.45:1 */
  --text-on-ochre: var(--c-white);      /* 5.26:1 */
  --text-on-terra: var(--c-white);      /* 6.83:1 */
  --text-on-sage:  var(--c-espresso);   /* 4.50:1 */

  /* --- Accent / interactive (used at large sizes or as UI boundaries) --- */
  --accent:        var(--c-terracotta);
  --accent-warm:   var(--c-ochre);

  /* Ochre is a dark hue: 3.27:1 on the espresso hero, which fails AA for the
     small mono labels used there. This is the same hue lightened for dark
     ground — 6.61:1 on espresso, 7.56:1 on the dark scheme's ink. It is the
     value the dark scheme already uses for --accent-warm, so no new color
     enters the palette. Use it for small warm text on ANY dark surface. */
  --accent-warm-on-dark: #D9913F;

  --link:          #1f4f4f;            /* deepened teal for AA on light: 6.1:1 */
  --link-hover:    var(--c-terracotta);

  /* The same problem --accent-warm-on-dark solves, for links. --link is a
     DEEPENED teal, tuned to clear AA on sand and white; on the espresso page
     heads it measures 1.88:1, which is not a dim link, it is an invisible
     one — and --link-hover lands at 2.52:1, so the hover that was meant to
     rescue it fails too. (Same sweep as the eyebrow fix above: panels were
     given overrides, the hero and page heads never were.)

     These are the LIGHTENED teal and terracotta the dark scheme already
     uses, so no new color enters the palette:
         #7cc0bb on espresso .....  8.29:1   AA normal   <- links on dark
         #e2694a on espresso .....  5.20:1   AA normal   <- their hover

     Why teal-lightened and not the ochre the eyebrow uses (6.61:1, which
     also passes): the eyebrow is a LABEL and the link is a CONTROL, and on
     this site teal means "you can follow this" while terracotta means "you
     are on it". Painting the link in the eyebrow's ochre would make the two
     read as the same kind of thing. It is also the weaker choice on a warm
     ground: espresso, ochre eyebrow and sand headline are all warm, so a
     warm link separates by lightness alone, while the cool teal separates by
     hue as well — and measures two stops higher while doing it. */
  --link-on-dark:   #7cc0bb;
  --accent-on-dark: #e2694a;
  --focus-ring:    var(--c-terracotta);

  /* --- Lines & borders (UI, 3:1 rule) --- */
  --border-soft:   var(--c-espresso-160);
  --border-strong: var(--c-espresso);
  --rule-warm:     var(--c-ochre);

  /* --- Typography --- */
  --font-display: "Fraunces", "Hoefler Text", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Fluid type scale (major third-ish, clamped) */
  --step--1: clamp(0.83rem, 0.79rem + 0.20vw, 0.94rem);
  --step-0:  clamp(1.00rem, 0.94rem + 0.30vw, 1.15rem);
  --step-1:  clamp(1.25rem, 1.14rem + 0.55vw, 1.55rem);
  --step-2:  clamp(1.56rem, 1.36rem + 1.00vw, 2.10rem);
  --step-3:  clamp(1.95rem, 1.61rem + 1.70vw, 2.90rem);
  --step-4:  clamp(2.44rem, 1.88rem + 2.80vw, 4.10rem);
  --step-5:  clamp(3.05rem, 2.10rem + 4.75vw, 5.90rem);

  /* Spacing scale */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;   --sp-6: 2rem;     --sp-7: 3rem;     --sp-8: 4.5rem;
  --sp-9: 7rem;

  /* Layout */
  --measure: 68ch;
  --wrap: 1200px;
  --wrap-wide: 1400px;
  --radius: 2px;          /* restrained, near-square; the brand is earthen, not glossy */
  --radius-lg: 4px;
  --shadow-1: 0 1px 2px var(--c-espresso-080);
  --shadow-2: 0 6px 24px var(--c-espresso-160);

  --dur: 480ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ==========================================================================
   DARK COLOR SCHEME
   --------------------------------------------------------------------------
   The palette above is the light scheme and remains the default. This block
   redefines ONLY the semantic tokens, so every component inherits the dark
   scheme without a single component rule being duplicated.

   The brand hues do not change identity here — the surfaces move to the
   espresso end of the palette, and the accents are the same teal / ochre /
   terracotta lightened until they clear AA against those darker surfaces.
   Terracotta at #A63117 is 2.4:1 on a dark ground and would have failed;
   #E2694A is the same hue at 5.6:1.

   VERIFIED CONTRAST RATIOS (sRGB relative-luminance method, WCAG 2.1)
     sand-050 on page-dark ........ 16.11:1   AA normal  <- primary body
     sand on page-dark ............ 11.24:1   AA normal
     body-dark on page-dark ....... 12.95:1   AA normal  <- default body copy
     muted-dark on page-dark ......  8.58:1   AA normal
     sand-050 on raised-dark ...... 14.97:1   AA normal  <- body on cards
     body-dark on raised-dark ..... 12.04:1   AA normal
     terracotta-lt on page-dark ...  5.63:1   AA normal  <- accent / eyebrow
     ochre-lt on page-dark ........  7.16:1   AA normal  <- warm accent
     teal-lt on page-dark .........  8.97:1   AA normal  <- links
     sage-lt on page-dark ......... 10.83:1   AA normal
     sand-050 on teal-dark ........  6.26:1   AA normal  <- text on teal panels
     sand-050 on sage-dark ........  6.09:1   AA normal  <- text on sage panels
     sand-050 on ochre-dark .......  5.92:1   AA normal  <- text on ochre panels
     sand-050 on terra-dark .......  7.29:1   AA normal  <- text on terracotta

   NOTE the one demotion: plain --c-sand on the teal/sage/ochre panels lands at
   4.1-4.4:1 in dark mode, so panel body copy uses sand-050 there instead. That
   is why --text-on-teal and friends are redefined below rather than inherited.
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root {
    /* Surfaces move to the espresso end; the brand hues are darkened to match */
    --c-sand-050:   #f4eee2;              /* stays: it is now a FOREGROUND */
    --c-sand-100:   #2e2018;              /* the "slightly raised" fill */

    --surface-page:      #1a1109;
    --surface-raised:    #241811;
    --surface-ink:       #100a05;
    --surface-teal:      #2b5f5f;
    --surface-sage:      #3d5f5b;
    --surface-ochre:     #8a4a10;
    --surface-terracotta:#8f2913;

    /* Foregrounds */
    --text-strong:   #f4eee2;
    --text-body:     #e2d6c0;
    --text-on-dark:  var(--c-sand);
    --text-on-teal:  #f4eee2;
    --text-on-ochre: #f4eee2;
    --text-on-terra: #f4eee2;
    --text-on-sage:  #f4eee2;

    /* Accents: same hues, lightened to clear AA on the dark ground */
    --accent:      #e2694a;
    --accent-warm: #d9913f;
    --link:        #7cc0bb;
    --link-hover:  #e2694a;
    --focus-ring:  #e2694a;

    /* Lines: light-on-dark, so the alphas invert */
    --c-espresso-080: rgba(244, 238, 226, 0.08);
    --c-espresso-160: rgba(244, 238, 226, 0.18);
    --c-espresso-400: rgba(244, 238, 226, 0.40);
    --border-soft:   var(--c-espresso-160);
    --border-strong: var(--c-sand);
    --rule-warm:     #d9913f;

    /* MADE EVIDENCE NEEDED A DARK TWIN AND DID NOT HAVE ONE (fixed
       2026-10-07). Every other brand colour that lands on the dark ground was
       lightened for it; this one was left at its light value and used as TEXT
       for the legend entry "Made where nothing was recorded" -- 2.93:1 on the
       dark row, a straight AA failure, while every other label on that legend
       sat at 12.04:1. Same hue family, same chroma 57.0, 5.66:1 here. */
    --c-made:        #9F83E7;

    /* Shadows read as depth only against light. On dark they become a subtle
       lift instead of a drop. */
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 6px 24px rgba(0, 0, 0, 0.55);
  }
}
