/* ===========================================================
   ilr_labs.css — IL Research Labs layer
   Sits ALONGSIDE agate-ui.css and depends on it: load
   agate-ui.css first (it defines the :root tokens and the
   [data-brand] switches), then this file. This layer adds
   only what the incubator needs on top of the house system:
   the Labs rider, the experiment-status vocabulary, the
   provisional signal, the dense control-panel register, and
   the dark-mode token overrides.
   =========================================================== */

/* --- the Labs rider -----------------------------------------
   "Labs" is a typographic rider on IL Research, exactly like
   `illumine 27` — never a new mark, never a re-colored interlock. */
.labs-brand { display: flex; align-items: baseline; gap: 10px; }
.labs-brand .interlock { width: 26px; height: 26px; align-self: center; flex: none; }
.labs-brand .wordmark { font-family: var(--font-ui); font-weight: 700; font-size: 20px; letter-spacing: -0.5px; color: var(--ink); }
.labs-tag {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--ink-40); border: 1px solid var(--line);
  padding: 3px 7px; align-self: center;
}

/* --- the provisional signal ---------------------------------
   Every lab surface wears this until an experiment reads VALIDATED.
   The hatch is the house's own "penciled-in" language (see .lw-study)
   — reused here to mean the same honest thing: not final. */
.labs-provisional {
  display: flex; gap: var(--sp-4); align-items: stretch;
  background: var(--card); border: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4);
}
.labs-provisional .hatch {
  width: 8px; flex: none;
  background: repeating-linear-gradient(-45deg,
    transparent 0 5px,
    color-mix(in srgb, var(--ink) 20%, transparent) 5px 7px);
}
.labs-provisional .body {
  font-family: var(--font-ui); font-size: var(--fs-caption);
  color: var(--ink-60); line-height: 1.5; align-self: center;
}
.labs-provisional .body strong { color: var(--ink); }

/* --- experiment-status vocabulary ---------------------------
   Three states, shape-coded AND colored (never color alone):
     draft     ○  hollow      — hatched, quarantined   (≈ study)
     testing   ◑  half        — accent outline          (≈ machine)
     validated ●  filled seal — accent fill, ready      (≈ record)
   The glyph carries the meaning if color is stripped. */
.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 4px 11px; border: 1px solid var(--line); white-space: nowrap;
}
.status .glyph { font-size: 12px; line-height: 1; }
.status--draft { color: var(--ink-60); border-color: var(--line);
  background: repeating-linear-gradient(-45deg,
    transparent 0 5px, color-mix(in srgb, var(--ink) 6%, transparent) 5px 6px); }
.status--testing { color: var(--accent-text); border-color: var(--accent); background: var(--card); }
.status--validated { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

/* --- the working indicator ----------------------------------
   IL Research is calm; the run indicator is a single blinking
   stop, not a spinner. It signals active work, so it may loop —
   but it stops under prefers-reduced-motion (handled globally). */
@keyframes labs-run { 0%,100% { opacity: 0.25; } 50% { opacity: 1; } }
.labs-running { display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-ui); font-size: var(--fs-ui); color: var(--ink-60); }
.labs-running::before { content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); animation: labs-run 1000ms var(--ease) infinite; }

/* --- stat cards (supporting metrics) ------------------------
   The venture rule: only ONE finding wears the vermilion band per
   view. Everything else is an ink stat — reported, not highlighted. */
.stat-card { background: var(--card); border: 1px solid var(--line); padding: var(--sp-4) var(--sp-5); }
.stat-card .eyebrow { margin-bottom: var(--sp-2); }
.stat-card .stat { font-size: 30px; display: block; line-height: 1.05; }
.stat-card .meaning { font-family: var(--font-serif); font-size: var(--fs-caption); color: var(--ink-60); margin-top: 6px; }

/* --- experiment header --------------------------------------- */
.exp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-5); flex-wrap: wrap; }
.exp-head .meta { display: flex; gap: var(--sp-5); font-family: var(--font-ui); font-size: var(--fs-caption); color: var(--ink-60); }
.exp-head .meta b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- state blocks (empty / error) ---------------------------- */
.state-block { border: 1px dashed var(--line); background: var(--card); padding: var(--sp-6); text-align: center; }
.state-block .eyebrow { margin-bottom: var(--sp-2); }
.state-block p { margin: 0 auto; max-width: 40ch; font-size: var(--fs-caption); color: var(--ink-60); font-family: var(--font-ui); }
.state-block.is-error { border-style: solid; border-left: 4px solid var(--accent); text-align: left; }

/* ============================================================
   THE CONTROL-PANEL REGISTER  (sanctioned override)
   The house default is editorial, not a control panel — but a
   calculator whose job is fine-tuning needs live, dense controls.
   So this register is deliberately tighter. It stays family by
   obeying the non-negotiables: hairlines, square corners, no
   shadows, tabular numbers, and exactly one accent spent on the
   live input the user is tuning.
   ============================================================ */
.console { display: grid; grid-template-columns: 340px 1fr; gap: 0; border: 1px solid var(--line); background: var(--card); }
@media (max-width: 820px) { .console { grid-template-columns: 1fr; } }

.console .panel { border-right: 1px solid var(--line); padding: var(--sp-5); background: var(--shelf); }
@media (max-width: 820px) { .console .panel { border-right: 0; border-bottom: 1px solid var(--line); } }
.console .readout { padding: var(--sp-5) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }

.control { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.control:last-child { border-bottom: 0; }
.control .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.control label { font-family: var(--font-ui); font-size: var(--fs-caption); font-weight: 700; color: var(--ink); }
.control .val { font-family: var(--font-ui); font-variant-numeric: tabular-nums; font-weight: 700;
  font-size: var(--fs-ui); color: var(--accent-text); }   /* the live input — vermilion */

/* the slider: an ink rod, a vermilion bead for the value the user moves */
.labs-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: var(--ink); outline-offset: 6px; cursor: pointer; margin: 4px 0; }
.labs-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); border: none; transition: transform var(--t-fast) var(--ease); }
.labs-slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.labs-slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: none; }
.labs-slider::-moz-range-track { height: 4px; background: var(--ink); }

/* the big live answer — ink, tabular, with its meaning in serif underneath */
.answer .num { font-size: clamp(34px, 5vw, 52px); line-height: 1; display: block; }
.answer .meaning { font-family: var(--font-serif); font-size: var(--fs-body); color: var(--ink-80);
  line-height: 1.6; margin-top: var(--sp-3); max-width: 46ch; }

/* graduation demo: three swatches of the same result card, accent swapped */
.grad-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
@media (max-width: 820px) { .grad-row { grid-template-columns: 1fr; } }

/* ============================================================
   DARK MODE — an accommodation, not a WCAG requirement.
   Token overrides ONLY. No component is restyled; every surface
   flips because it reads from these variables. Set data-theme="dark"
   on <html>. The accent stays vermilion; only its small-text variant
   lightens so links and figures stay legible on the dark register.
   Charts hold their colors as JS constants, so lwCharts.tokens must
   be flipped in script alongside this (see the page's init).
   ============================================================ */
[data-theme="dark"] {
  --paper: #1B1B19;   /* the dark register becomes the page */
  --card:  #24231F;   /* raised panels — brighter, since no shadows */
  --shelf: #201F1B;   /* control panels, secondary surfaces */
  --line:  #3A3833;   /* hairlines on dark */

  --ink:    #F1EDE3;  /* text, marks, and strong rules are now light */
  --ink-80: #D8D3C6;  /* body */
  --ink-60: #A9A497;  /* secondary, captions */
  --ink-40: #8A8578;  /* labels, eyebrows (unchanged — reads on both) */

  --accent-text: #E8734D;  /* lightened vermilion: ~5.7:1 on the dark card */
  color-scheme: dark;
}

/* One calm cross-fade when the theme flips (killed by reduced-motion). */
body { transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease); }

/* The interlock ships with ink (#1B1B19) fills baked in as attributes.
   On dark, flip only the ink strokes to cream — a CSS `fill` beats the
   presentation attribute. The vermilion path (#D6552B) is not matched,
   so it stays vermilion in both themes. */
[data-theme="dark"] .interlock path[fill="#1B1B19"] { fill: #F1EDE3; }

/* --- the theme toggle ---------------------------------------
   Quiet, Helvetica, hairline — it is not the primary action. */
.theme-toggle {
  font-family: var(--font-ui); font-size: var(--fs-caption); font-weight: 700;
  letter-spacing: 0.2px; color: var(--ink-60);
  background: transparent; border: 1px solid var(--line);
  padding: 6px 12px; cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-40); }
