/* CONTINUUM Tools — shared design layer (see DESIGN.md).
   Loaded by every page AFTER its own <style>, so these tokens and base components win; each page's
   <style> keeps only what is specific to it. Visual only: no IDs, classes or behaviour depend on this file. */

/* ── 2. Colour tokens ─────────────────────────────────────────────────────── */
:root {
  --blue: #0070C0;  --blue-rgb: 0 112 192;
  --green: #3B7D23; --green-rgb: 59 125 35;
  --orange: #C04F15; --orange-rgb: 192 79 21;
  --purple: #7a4fb5; --teal: #00838f; --pink: #b0306a;

  --bg: #f5f5f7;        --bg-rgb: 245 245 247;
  --surface: #ffffff;   --surface-rgb: 255 255 255;
  --surface-2: #f9f9fb;
  --fill: rgb(118 118 128 / .12);
  --fill-2: rgb(118 118 128 / .20);
  --line: rgb(60 60 67 / .13);
  --line-2: rgb(60 60 67 / .24);
  --text: #1d1d1f; --text-2: #6e6e73; --text-3: #8e8e93;

  --accent: var(--blue); --on-accent: #ffffff;
  --go: #3e8a26; --on-go: #ffffff;
  --warn: var(--orange);
  --danger: #d70015; --danger-rgb: 215 0 21;
  --done: rgb(var(--green-rgb) / .10);
  --warn-soft: rgb(var(--orange-rgb) / .10);

  --shadow-1: 0 1px 2px rgb(0 0 0 / .04), 0 1px 1px rgb(0 0 0 / .03);
  --shadow-2: 0 2px 6px rgb(0 0 0 / .05), 0 12px 28px rgb(0 0 0 / .07);
  --shadow-3: 0 10px 40px rgb(0 0 0 / .18);
  --ring: 0 0 0 3px rgb(var(--blue-rgb) / .35);
  --ease: cubic-bezier(.2, .8, .2, 1);

  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  /* old token names used by the pages' own rules */
  --panel: var(--surface); --panel2: var(--surface-2); --txt: var(--text); --muted: var(--text-2);
  --chip: var(--fill); --ink: var(--on-accent); --accent-ink: var(--on-accent);
  --run: var(--go); --run-ink: var(--on-go); --timed: var(--accent); --accent2: var(--green);
  --code: var(--fill); --note: var(--warn-soft);

  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue: #3d9be0; --blue-rgb: 61 155 224;
    --green: #5fa843; --green-rgb: 95 168 67;
    --orange: #e0743c; --orange-rgb: 224 116 60;
    --purple: #a383d8; --teal: #4fb8c2; --pink: #e0709d;
    --bg: #000000; --bg-rgb: 0 0 0;
    --surface: #1c1c1e; --surface-rgb: 28 28 30;
    --surface-2: #2c2c2e;
    --fill: rgb(118 118 128 / .24); --fill-2: rgb(118 118 128 / .36);
    --line: rgb(255 255 255 / .10); --line-2: rgb(255 255 255 / .20);
    --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #6e6e73;
    --accent: #2a7fc9; --on-accent: #ffffff; --go: #5fa843; --on-go: #08160a;
    --danger: #ff453a; --danger-rgb: 255 69 58;
    --shadow-1: 0 0 0 transparent; --shadow-2: 0 8px 28px rgb(0 0 0 / .5); --shadow-3: 0 10px 40px rgb(0 0 0 / .6);
    --ring: 0 0 0 3px rgb(var(--blue-rgb) / .45);
  }
}
@media (prefers-contrast: more) {
  :root { --line: rgb(60 60 67 / .45); --line-2: rgb(60 60 67 / .65); --text-2: #3a3a3c; }
  @media (prefers-color-scheme: dark) { :root { --line: rgb(255 255 255 / .35); --line-2: rgb(255 255 255 / .55); --text-2: #d1d1d6; } }
}

/* ── 3. Typography ────────────────────────────────────────────────────────── */
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}
h1 { letter-spacing: -.02em; line-height: 1.15; }
h2 { letter-spacing: -.01em; }
code, pre, kbd, .mono { font-family: var(--mono); }
.mono, .t, .time, .big-time, #clock { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
a { color: var(--accent); text-underline-offset: 2px; }
::selection { background: rgb(var(--blue-rgb) / .22); }

/* ── 4. Header (translucent material) ─────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 30;
  background: rgb(var(--surface-rgb) / .72);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top { background: transparent; }
.top header { position: static; }                    /* .top is the sticky part on those pages */
.top:has(header) { position: sticky; top: 0; z-index: 30; }
header h1 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
header .sub, header .app span { color: var(--text-2); font-size: 12.5px; letter-spacing: .005em; }
header .brand .app, header .app { border-left-width: 1px; }
.brandbar { height: 3px; }

/* header links: tinted text buttons */
.nav-link, .guide-link, .alt {
  color: var(--accent); background: transparent; border: 1px solid var(--line); border-radius: 10px;
  font: 600 13px/1.3 var(--font); padding: 7px 12px; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s ease-out, box-shadow .15s;
}
.nav-link:hover, .guide-link:hover, .alt:hover { background: var(--fill); border-color: var(--line-2); }
.nav-link:active, .guide-link:active, .alt:active { transform: scale(.97); }
.nav-link:focus-visible, .guide-link:focus-visible, .alt:focus-visible { outline: none; box-shadow: var(--ring); }
.open {
  background: var(--accent); color: var(--on-accent); border-radius: 10px; font: 600 13px/1.3 var(--font);
  padding: 8px 14px; transition: background-color .15s, transform .1s ease-out, box-shadow .15s;
}
.open:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.open:active { transform: scale(.97); }
.open:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── 4. Buttons ───────────────────────────────────────────────────────────── */
button {
  font-family: var(--font); font-weight: 500; color: var(--text); background: var(--fill);
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s ease-out, box-shadow .15s, filter .15s;
}
button:hover { background: var(--fill-2); border-color: transparent; }
button:active { transform: scale(.97); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled, button:disabled:hover { opacity: .4; cursor: not-allowed; transform: none; background: var(--fill); }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: transparent; filter: none; }
button.go { background: var(--go); border-color: var(--go); color: var(--on-go); font-weight: 600; }
button.go:hover { background: color-mix(in srgb, var(--go) 86%, #000); border-color: transparent; filter: none; }
button.warn { background: transparent; border-color: rgb(var(--orange-rgb) / .5); color: var(--warn); }
button.warn:hover { background: var(--warn-soft); border-color: var(--warn); }
button.danger { background: transparent; border-color: rgb(var(--danger-rgb) / .45); color: var(--danger); }
button.danger:hover { background: rgb(var(--danger-rgb) / .08); border-color: var(--danger); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--fill); }
button.primary:disabled, button.go:disabled { background: var(--fill); border-color: transparent; color: var(--text-2); }
button.mini { border-radius: 7px; }
button.nav-link { background: transparent; }

/* ── 4. Inputs ────────────────────────────────────────────────────────────── */
input, select, textarea {
  font-family: var(--font); color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / .2); }
input:disabled, select:disabled { opacity: .5; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); box-shadow: none; }
input[type=range] { background: transparent; border: none; }
label.fld, label.inl { color: var(--text-2); }

/* ── 4. Cards ─────────────────────────────────────────────────────────────── */
.card, main > section {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-1);
}
.card h2, main > section > h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.card h2::before, main > section > h2::before { display: none; }

/* home + guides hub: link cards (lift, press, spotlight) */
.cards > .card {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-1);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.cards > .card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
}
.cards > .card > * { position: relative; }
@media (hover: hover) {
  .cards > .card:hover::before { opacity: 1; }
  a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
}
a.card:active { transform: translateY(0) scale(.99); }
a.card:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow-2); }
.cards > .card .icon { border-radius: 12px; }
.card a.primary, .card a.secondary { border-radius: 10px; transition: background-color .15s, transform .1s ease-out, box-shadow .15s; }
.card a.primary { color: var(--on-accent); }
.card a.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.card a.secondary { border: 1px solid var(--line); }
.card a.secondary:hover { background: var(--fill); }
.card a:active { transform: scale(.97); }
.card a:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── 4. Tables ────────────────────────────────────────────────────────────── */
th { color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
th, td { border-color: var(--line); }
td { font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: rgb(118 118 128 / .06); }
.tbl-wrap { border-color: var(--line); border-radius: 12px; }
/* guide tables: hairline grid, soft header */
main .table table { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); border-collapse: separate; border-spacing: 0; }
main .table th { background: var(--fill); text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
main .table th, main .table td { border: 0; border-bottom: 1px solid var(--line); }
main .table th + th, main .table td + td { border-left: 1px solid var(--line); }
main .table tr:last-child td { border-bottom: 0; }

/* ── 4. Pills, keys, notes, toast ─────────────────────────────────────────── */
.pill { background: var(--fill); border-color: transparent; color: var(--text-2); }
.kbd, kbd { background: var(--surface); border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--text); }
.note, .callout { border-radius: 10px; }
.note { background: var(--fill); }
.callout { background: var(--warn-soft); }
.callout.blue { background: var(--fill); }
code { background: var(--fill); border-radius: 5px; }
pre { background: var(--fill); border-radius: 12px; }
nav.toc { border-radius: 16px; border-color: var(--line); box-shadow: var(--shadow-1); }
figure img { border-radius: 12px; border-color: var(--line); }
.toast {
  background: var(--text); color: var(--bg); border-radius: 12px; box-shadow: var(--shadow-3);
  transform: translate(-50%, 8px); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { transform: translate(-50%, 0); }

/* video frames, plots, wells */
.camwrap, .vidwrap { border-radius: 12px; }
.plotbox canvas, .sensplot canvas, .timeline { border-color: var(--line); border-radius: 12px; }

/* ── 7. Motion (L1): page entrance ────────────────────────────────────────── */
@keyframes ct-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card, main > section:not(.hidden), .hero, main > h1, main > .lead { animation: ct-rise .32s var(--ease) both; }
.cards > .card:nth-child(2), .wrap .card:nth-child(2) { animation-delay: 40ms; }
.cards > .card:nth-child(3), .wrap .card:nth-child(3) { animation-delay: 80ms; }
.cards > .card:nth-child(4), .wrap .card:nth-child(4) { animation-delay: 120ms; }
.cards > .card:nth-child(5), .wrap .card:nth-child(5) { animation-delay: 160ms; }
.cards > .card:nth-child(6) { animation-delay: 200ms; }

/* ── 9. Responsive ────────────────────────────────────────────────────────── */
.meta-grid input, .meta-grid select { width: 100%; min-width: 0; }
@media (max-width: 600px) {
  header { padding-left: 16px; padding-right: 16px; flex-wrap: wrap; }
  header .actions, header .right { flex-wrap: wrap; }
  main > section { overflow-x: auto; }          /* wide tables (Clinical Log protocol) scroll inside their card */
}
@media (pointer: coarse) {
  button.primary, button.go, button.warn, button.danger, .nav-link, .guide-link, .alt, .open { min-height: 44px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select { min-height: 44px; }
}

/* ── 7. Accessibility ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  button:active, a:active, a.card:hover { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  header { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media print {
  header, .top:has(header) { position: static; backdrop-filter: none; background: none; }
  .card, main > section { box-shadow: none; animation: none; }
}
