/* The brand, as variables. A tenant pack (/tenant/<key>/tokens.css) loads AFTER this
   file and overrides the --c-* block only. Nothing else in the app may name a hex.

   Two rules make a tenant swap actually work, and both were learned the hard way:
   1. A color is named for the JOB it does, not for where it sits. --c-forest is a FILL.
      --c-mark is the same green used as INK or a LINE on a light surface. They part
      company the moment the substrate goes dark, which is what room mode is.
   2. Room mode reads the tenant's --c-dark-* facts (tenants/brc/tokens.css ships them)
      and only falls back to the values below, so a second tenant can move the dark
      palette without touching this file. */
:root {
  /* Brand. Forest fills, leaf accents only, one sanctioned gradient. */
  --c-forest: #0B361B;
  --c-leaf:   #346D35;
  --c-path-a: #497F39;
  --c-path-b: #1B4B28;
  --c-paper:  #FCFBF7;
  --c-mist:   #EEF2EB;
  --c-card:   #FFFFFF;
  --c-ink:    #1E2B25;
  --c-ink70:  rgba(30, 43, 37, .74);   /* 6.3:1 on card */
  --c-ink50:  rgba(30, 43, 37, .55);   /* 3.5:1. DECORATION ONLY. Never a word. */
  --c-hair:   #E4E7DE;
  --c-amber:  #9E6B25;
  --c-alert:  #8C2F24;
  --c-info:   #2D5A73;

  /* The jobs the greens do. --c-mark is forest when the surface is light and the
     lifted accent when it is dark, because deep forest disappears on dark.
     --c-on-forest is the ink that sits ON a forest fill. Every rule that puts a word,
     a picture, a rule or a focus ring on a surface uses one of these two, never
     --c-forest, or room mode drops it to 1.3:1 and the first-day hire is blind. */
  --c-mark: var(--c-forest);
  --c-on-forest: var(--c-paper);

  /* Brand amber is a FILL: 4.4:1 on paper, under AA for a word. The tenant packs ship
     --c-amber-text, the same hue darkened until it clears AA. Any amber WORD uses it.
     --c-amber-ink is the old design-lane name for the same thing, kept as an alias. */
  --c-amber-text: #8A5D20;
  --c-amber-ink: var(--c-amber-text);

  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans:  'Source Sans 3', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:  'Source Code Pro', ui-monospace, Menlo, monospace;

  --radius: 16px;
  --gutter: 24px;

  /* Derived, never brand. Radii follow the shipped print and site system. */
  --r-pill: 999px;
  --r-tile: 14px;
  --r-card: var(--radius);
  --r-input: 10px;

  /* Spacing, a 4pt rhythm. Type and boxes both land on it. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Touch. A primary tile is 180 on iPad, 88 is the floor, 44 is the absolute floor. */
  --tile: 180px;
  --touch: 88px;
  --touch-min: 44px;
  --bar-h: 88px;

  /* Type. rem based so Dynamic Type and browser zoom both work. */
  --t-eyebrow: .72rem;
  --t-fine: .82rem;
  --t-label: .94rem;
  --t-body: 1.0625rem;   /* 17px, the floor for a shared iPad held across a room */
  --t-lead: 1.1875rem;
  --t-h3: 1.25rem;
  --t-h2: clamp(1.5rem, 3vw, 2.125rem);
  --t-h1: clamp(2rem, 4.6vw, 3.25rem);
  --t-num: 1.5rem;
  --t-clock: 3.5rem;

  /* Motion. Travel along a path: forward, never past the mark. */
  --d-fast: 120ms;
  --d-mid: 200ms;
  --d-slow: 320ms;
  --d-room: 600ms;       /* the one slow motion: into and out of room mode */
  --e-travel: cubic-bezier(.22, .9, .26, 1);
  --e-out: cubic-bezier(.16, .84, .44, 1);
  --e-in: cubic-bezier(.5, 0, .84, .3);

  /* Semantic pairs. Resting is colorless: only exceptions carry a hue. */
  --fill-due:  #F6EDDA;  --line-due:  #E0C489;
  --fill-stop: #F6E2DD;  --line-stop: #E0A99C;
  --fill-info: #E3EDF2;

  /* The undo toast is the one surface that inverts against the page, so it carries
     its own pair rather than borrowing ink and paper, which swap in room mode. */
  --c-toast: var(--c-ink);
  --c-on-toast: var(--c-paper);
  /* Brand leaf on the toast slab is 2.4:1: the draining rule was all but invisible.
     Lifted toward the toast's own ink it reads in both modes and stays the same green. */
  --c-toast-rule: color-mix(in srgb, var(--c-leaf) 55%, var(--c-on-toast));

  /* Surfaces built from the brand, so a tenant swap carries them. */
  --glow-lit: 0 0 0 3px color-mix(in srgb, var(--c-mark) 26%, transparent);
  --hair: 1px solid var(--c-hair);
  --scrim: color-mix(in srgb, var(--c-forest) 38%, transparent);
  --sheet-shadow: 0 -18px 48px rgba(11, 54, 27, .18);
}

/* Room mode: the chair-side iPad during a dosing session. A patient under esketamine
   is dissociating 60cm from this screen, so luminance is capped, nothing is pure white,
   ink tops out at #C7D2CA, and motion.js kills every animation except the timer ring.
   Surfaces and the accent come from the tenant's --c-dark-* facts. */
html[data-room="dim"] {
  --c-paper:  var(--c-dark-paper, #0B120E);
  --c-mist:   var(--c-dark-mist, #131B16);
  --c-card:   var(--c-dark-card, #1A2420);
  --c-hair:   var(--c-dark-hair, #26302B);
  --c-ink:    #C7D2CA;                           /* the cap, below the tenant dark ink */
  --c-ink70:  var(--c-dark-ink70, #94A199);
  --c-ink50:  var(--c-dark-ink50, #63706A);

  /* Deep forest disappears on dark, so every mark lifts to the accent. The forest FILL
     itself does not move: the green bar is still the green bar, it just carries light ink. */
  --c-mark:      var(--c-dark-accent, #79C98D);
  --c-on-forest: #C7D2CA;
  --c-leaf:      var(--c-dark-accent, #79C98D);
  --c-path-a:    var(--c-dark-accent, #79C98D);
  /* 65 percent, not 55: at 55 the dark end of the ring drops under 3:1 once the ten
     second brighten lifts the card underneath it. */
  --c-path-b:    color-mix(in srgb, var(--c-dark-accent, #79C98D) 65%, var(--c-dark-card, #1A2420));

  --c-amber:      var(--c-dark-amber, #B08A4A);
  --c-amber-text: var(--c-dark-amber, #B08A4A);
  --c-alert:      var(--c-dark-alert, #E08A72);
  --c-info:       var(--c-dark-info, #7FB3CE);

  --fill-due:  #241F14;  --line-due:  #4A3C22;
  --fill-stop: #261713;  --line-stop: #4A2A22;
  --fill-info: #15242B;

  /* The toast stays a dark chip lifted off the dark card, so the draining leaf rule
     still reads. Inverting it to a light slab would be the brightest thing in the room. */
  --c-toast:    color-mix(in srgb, var(--c-dark-ink, #E9EFEA) 12%, var(--c-dark-card, #1A2420));
  --c-on-toast: #C7D2CA;

  --scrim: rgba(0, 0, 0, .62);
  --sheet-shadow: 0 -18px 48px rgba(0, 0, 0, .55);
}

/* The ten second helper. Held, the room lifts to the full dark-mode ink, which is the
   one time the cap is allowed to move, because a cuff a clinician over forty cannot
   read is its own clinical problem. */
html[data-room="dim"][data-bright="yes"] {
  --c-ink:       var(--c-dark-ink, #E9EFEA);
  --c-on-forest: var(--c-dark-ink, #E9EFEA);
  --c-card:      color-mix(in srgb, var(--c-dark-ink, #E9EFEA) 6%, var(--c-dark-card, #1A2420));
  --c-mist:      color-mix(in srgb, var(--c-dark-ink, #E9EFEA) 4%, var(--c-dark-mist, #131B16));
  --c-hair:      color-mix(in srgb, var(--c-dark-ink, #E9EFEA) 10%, var(--c-dark-hair, #26302B));
}
