/* ==========================================================================
   JoyHab — the one shared stylesheet (docs/13-joyhab-rebrand-brief.md).

   WHY ONE FILE. docs/12-design-system.md found the rot was structural: every
   page carried its own <style> block and the same concept had drifted to three
   values on three pages. So the tokens, the type, the controls, the focus ring
   and the motion live HERE, once, and every page links this file. Page <style>
   blocks keep layout only. JS-injected UI (challengeUI.js, progressUI.js, the
   inline styles in ui.js) reads the same custom properties.

   TWO FAMILIES, chosen by <html data-family="dark|light">:
     dark  — the working surfaces: app, prescribe, coach (the default).
     light — the clinician portal: index, feedback, guide, cheatsheet.
   The printable report (src/report.js) is its own document: the "Clinical"
   edition, ink plus the gold point only.

   Visual only. Nothing in this file can change what is measured or recorded.
   ========================================================================== */

/* ---------- fonts: self-hosted, the app runs offline (latin subsets, OFL) ---------- */
@font-face { font-family:"Bricolage Grotesque"; src:url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight:200 800; font-style:normal; font-display:swap; }
@font-face { font-family:"Geist"; src:url("fonts/geist.woff2") format("woff2");
  font-weight:100 900; font-style:normal; font-display:swap; }
@font-face { font-family:"Geist Mono"; src:url("fonts/geist-mono.woff2") format("woff2");
  font-weight:100 900; font-style:normal; font-display:swap; }
@font-face { font-family:"Outfit"; src:url("fonts/outfit-600.woff2") format("woff2");
  font-weight:600; font-style:normal; font-display:swap; }

/* ---------- tokens shared by both families ---------- */
:root {
  --font-display:"Bricolage Grotesque", "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body:"Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:"Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-word:"Outfit", "Geist", system-ui, sans-serif;

  /* motion: the brand moves one way */
  --ease-out:cubic-bezier(.22,1,.36,1);
  --ease-spring:cubic-bezier(.34,1.56,.64,1);
  --t-quick:180ms;     /* hover / press */
  --t-std:480ms;       /* reveals */
  --t-sig:1050ms;      /* sweep to target */

  /* metrics (doc 12 decision 7: one set, not three) */
  --tap:44px;
  --r-card:16px; --r-btn:12px; --r-input:10px; --r-pill:999px;
  --r:var(--r-card);

  /* the brand constants, family-independent */
  --brand-green:#12a272; --brand-deep:#0b6b4c; --brand-gold:#ffb92e;
  --brand-ink:#0f1f19; --brand-cream:#fbf8f3; --brand-coral:#b23c1b;
}

/* ---------- DARK family: the working surfaces (doc 12 decision 1: app's palette, family-wide) ---------- */
:root, [data-family="dark"] {
  color-scheme:dark;
  --bg:#0a0f14;
  --card:#111a21;
  --well:#0d151b;          /* inputs, tracks, insets */
  --inset:#0e171d;         /* a card inside a card */
  --line:#1f2c36;
  --line-2:#2a3a46;
  --text:#eef5f9;
  --text-2:#b9c9d3;        /* dim */
  --text-3:#93a8b6;        /* faint — 6.6:1 on --card, clears AA at 12px */
  --go:#2ee6a6;
  --go-deep:#19a374;
  --go-ink:#06281e;        /* text on a go fill */
  --go-soft:rgba(46,230,166,.12);
  --gold:#ffcf5a;
  --gold-ink:#2a1f00;
  --gold-soft:rgba(255,207,90,.13);
  --warn:#ffb454;          /* amber: "check this" (doc 12 decision 2) */
  --warn-soft:rgba(255,180,84,.12);
  --coral:#ff8c6f;         /* errors / what's going wrong, only (decisions 2 + 3) */
  --coral-soft:rgba(255,140,111,.12);
  --link:var(--go);        /* decision 4: no light-portal blue on a dark page */
  --focus:var(--gold);     /* decision 10: one visible focus token */
  --btn-bg:var(--go); --btn-ink:var(--go-ink);
  --shadow:0 10px 30px rgba(0,0,0,.35);
  --glass:rgba(10,15,20,.82);

  /* the mark's colourway on dark: "reversed" */
  --mark-wedge:var(--go); --mark-arc:var(--text); --mark-joint:var(--text); --mark-target:var(--gold);
  --word:var(--text);

  /* legacy names the JS and page layout still use — aliases, not new values */
  --panel:var(--card); --panel2:var(--well); --line2:var(--line-2);
  --txt:var(--text); --dim:var(--text-2); --faint:var(--text-3);
  --err:var(--coral); --blue:var(--text-2); --item:var(--inset);
}

/* ---------- LIGHT family: the clinician portal ---------- */
[data-family="light"] {
  color-scheme:light;
  --bg:#fbf8f3;
  --card:#ffffff;
  --well:#f3eee5;
  --inset:#f7f3ec;
  --line:#e6dfd3;
  --line-2:#d6cdbd;
  --text:#0f1f19;
  --text-2:#3c4f47;
  --text-3:#56665e;        /* 5.9:1 on cream */
  --go:#12a272;            /* fills and marks; too light for small text on cream */
  --go-deep:#0b6b4c;       /* green TEXT on light: 6.9:1 */
  --go-ink:#ffffff;
  --go-soft:#dcf5ea;
  --gold:#ffb92e;          /* the target point; never text on cream */
  --gold-ink:#5a3d00;      /* amber note text: 8.4:1 on --gold-soft */
  --gold-soft:#fff1d1;
  --warn:#8a5a00;
  --warn-soft:#fff1d1;
  --coral:#b23c1b;         /* 5.6:1 on white */
  --coral-soft:#fbe9e3;
  --link:var(--go-deep);
  --focus:var(--go-deep);  /* gold on cream is 1.8:1; the ring must be seen */
  --btn-bg:var(--text); --btn-ink:var(--bg);
  --shadow:0 1px 0 rgba(15,31,25,.05), 0 24px 60px -28px rgba(15,31,25,.3);
  --glass:rgba(251,248,243,.86);

  --mark-wedge:var(--go); --mark-arc:var(--text); --mark-joint:var(--text); --mark-target:var(--gold);
  --word:var(--text);

  --ink:var(--text); --soft:var(--text-2); --err:var(--coral);
  --panel:var(--card); --txt:var(--text); --dim:var(--text-2); --faint:var(--text-3);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; background:var(--bg); }
body { margin:0; background:var(--bg); color:var(--text);
  font:16px/1.55 var(--font-body); -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  font-feature-settings:"ss01" 0; }
h1, h2, h3, .display { font-family:var(--font-display); letter-spacing:-.025em; }
h1 { font-weight:750; line-height:1.08; }
h2, h3 { font-weight:700; }
a { color:var(--link); text-underline-offset:.18em; text-decoration-thickness:1px; }
a:hover { text-decoration-thickness:2px; }
code, pre, kbd, .mono { font-family:var(--font-mono); }
::selection { background:var(--gold); color:#0f1f19; }
.tnum { font-variant-numeric:tabular-nums; }

/* doc 12 decision 10 — ONE visible focus treatment, everywhere, keyboard only */
:focus-visible { outline:2px solid var(--focus); outline-offset:3px; border-radius:6px; }
button:focus-visible, .btn:focus-visible, a.ghost:focus-visible { border-radius:var(--r-btn); }

/* eyebrow: the small mono label above a heading */
.eyebrow { font-family:var(--font-mono); font-size:12px; font-weight:500; letter-spacing:.14em;
  text-transform:uppercase; color:var(--go-deep); }
:root:not([data-family="light"]) .eyebrow { color:var(--go); }

/* ---------- controls ---------- */
button, select, input, textarea { font:inherit; }
button, .btn { display:inline-flex; align-items:center; justify-content:center; gap:8px;
  background:var(--btn-bg); color:var(--btn-ink); border:1px solid transparent;
  padding:10px 18px; border-radius:var(--r-btn); min-height:var(--tap);
  font-family:var(--font-body); font-weight:650; letter-spacing:-.005em; cursor:pointer; text-decoration:none; white-space:nowrap;
  transition:background-color var(--t-quick) var(--ease-out), border-color var(--t-quick) var(--ease-out),
             color var(--t-quick) var(--ease-out), transform var(--t-quick) var(--ease-out),
             box-shadow var(--t-quick) var(--ease-out); }
button:hover, .btn:hover { filter:brightness(1.06); }
/* PRESS PHYSICS (polish #7): a quick press (scale .97 over 120ms), a soft
   spring back (220ms), and a 1px inner highlight on solid buttons. Calm and
   reduced motion keep the press visible but drop the movement. */
button:not(.link), .btn { transition:background-color var(--t-quick) var(--ease-out), border-color var(--t-quick) var(--ease-out),
  color var(--t-quick) var(--ease-out), box-shadow var(--t-quick) var(--ease-out),
  transform 220ms cubic-bezier(.34,1.56,.64,1); }
button:active, .btn:active { transform:scale(.97); transition-duration:120ms; transition-timing-function:ease-out; }
button:not(.ghost):not(.link):not(:disabled), .btn:not(.ghost) { box-shadow:inset 0 1px 0 rgba(255,255,255,.18); }
html.calm button:active, html.calm .btn:active { transform:none; }
@media (prefers-reduced-motion: reduce) { button:active, .btn:active { transform:none; } button, .btn { transition-duration:0s; } }
[data-family="light"] button:not(.ghost):not(.link):hover,
[data-family="light"] .btn:not(.ghost):hover { background:var(--go-deep); filter:none; }
button.ghost, .btn.ghost, a.ghost { background:transparent; color:var(--text); border:1px solid var(--line-2);
  font-weight:600; }
button.ghost:hover, .btn.ghost:hover, a.ghost:hover { border-color:var(--go); filter:none; }
button.warn { background:var(--warn); color:#3a2400; }
button.link { background:none; border:0; padding:0; min-height:0; color:var(--link); font-weight:500;
  text-decoration:underline; text-underline-offset:.18em; }
button:disabled, .btn[aria-disabled="true"] { opacity:.42; cursor:not-allowed; transform:none; filter:none; }
a.ghost { display:inline-flex; align-items:center; gap:8px; min-height:var(--tap); padding:8px 14px;
  border-radius:var(--r-btn); text-decoration:none; transition:border-color var(--t-quick) var(--ease-out); }

select, input[type=text], input[type=number], input[type=email], input[type=password], input:not([type]), textarea {
  background:var(--well); color:var(--text); border:1px solid var(--line-2); border-radius:var(--r-input);
  padding:10px 12px; min-height:var(--tap);
  transition:border-color var(--t-quick) var(--ease-out); }
[data-family="light"] select, [data-family="light"] input[type=text], [data-family="light"] input[type=number],
[data-family="light"] input[type=email], [data-family="light"] input[type=password],
[data-family="light"] input:not([type]), [data-family="light"] textarea { background:var(--card); }
select:hover, input:hover, textarea:hover { border-color:var(--text-3); }
select { font-weight:550; }
input[type=range], input[type=checkbox], input[type=radio] { accent-color:var(--go); }
[data-family="light"] input[type=checkbox], [data-family="light"] input[type=radio] { accent-color:var(--go-deep); }
input[type=checkbox], input[type=radio] { width:18px; height:18px; }
::placeholder { color:var(--text-3); opacity:1; }

/* every <summary> opens the same way: a small chevron that turns */
summary { list-style:none; cursor:pointer; display:flex; align-items:center; gap:10px; min-height:28px; }
summary::-webkit-details-marker { display:none; }
summary::before { content:""; flex:none; width:7px; height:7px; border-right:2px solid currentColor; border-bottom:2px solid currentColor;
  transform:rotate(-45deg); opacity:.7; transition:transform var(--t-quick) var(--ease-out); }
details[open] > summary::before { transform:rotate(45deg) translate(-2px,-1px); }
html.calm summary::before { transition:none; }

/* ---------- surfaces ---------- */
.card, .panel { background:var(--card); border:1px solid var(--line); border-radius:var(--r-card); }
.callout { border-radius:12px; padding:12px 16px; border:1px solid var(--line); background:var(--inset); }
.callout.amber, .note-amber { background:var(--gold-soft); border:1px solid color-mix(in oklab, var(--gold) 40%, transparent);
  border-left:4px solid var(--gold); color:var(--gold-ink); }
:root:not([data-family="light"]) .callout.amber { color:var(--text); }
.callout.ok { background:var(--go-soft); border-color:color-mix(in oklab, var(--go) 40%, transparent); }
.callout.err { background:var(--coral-soft); border-color:color-mix(in oklab, var(--coral) 45%, transparent); color:var(--coral); }
.errtext { color:var(--coral); }

/* ---------- the lockup (mark + "joyhab"), rendered by src/brand.js ---------- */
.jh-lockup { display:inline-flex; align-items:flex-end; gap:.32em; color:var(--word); text-decoration:none;
  line-height:1; --s:30px; font-size:var(--s); }
.jh-lockup:hover { text-decoration:none; }
.jh-lockup .jh-mark { width:calc(var(--s) * .93); height:var(--s); overflow:visible; flex:none; }
.jh-word { font-family:var(--font-word); font-weight:600; letter-spacing:-.035em; font-size:.84em; line-height:.8;
  color:var(--word); white-space:nowrap; }
/* the j's dot is ours, drawn in gold: the target */
.jh-j { position:relative; display:inline-block; }
.jh-j > span { display:inline-block; clip-path:inset(37% -20% -20% -20%); }
.jh-j > i { position:absolute; left:38%; top:13%; width:.15em; height:.15em; border-radius:50%;
  background:var(--mark-target); }
.jh-sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* mark parts (any .jh-mark svg) */
.jh-mark .w { fill:var(--mark-wedge); }
.jh-mark .a { fill:none; stroke:var(--mark-arc); stroke-width:5; }
.jh-mark .j { fill:var(--mark-joint); }
.jh-mark .t { fill:var(--mark-target); }
.jh-mark .h { fill:var(--mark-target); opacity:.22; }

/* ---------- icons: one line + the gold dot (src/brand.js icon()) ---------- */
.jh-i { width:1.2em; height:1.2em; flex:none; vertical-align:-.24em; overflow:visible; }
.jh-i .s { fill:none; stroke:currentColor; stroke-width:2.25; stroke-linecap:round; stroke-linejoin:round; }
.jh-i .d { fill:var(--gold); }
.jh-i .c { fill:var(--coral); }
.jh-i.lg { width:28px; height:28px; }
.jh-i.xl { width:40px; height:40px; }

/* ---------- motion primitives ---------- */
/* the gold ring pulse at a target */
.jh-ring { position:absolute; width:var(--ring, 46px); height:var(--ring, 46px); margin:calc(var(--ring, 46px) / -2) 0 0 calc(var(--ring, 46px) / -2);
  border:2px solid var(--gold); border-radius:50%; pointer-events:none; opacity:0;
  animation:jh-ring 900ms var(--ease-out) forwards; }
@keyframes jh-ring { 0% { opacity:.95; transform:scale(.3); } 100% { opacity:0; transform:scale(1.9); } }
/* a point of light rising from the target */
.jh-spark { position:absolute; width:var(--d, 8px); height:var(--d, 8px); margin:calc(var(--d, 8px) / -2) 0 0 calc(var(--d, 8px) / -2);
  border-radius:50%; pointer-events:none; opacity:0; background:var(--c, var(--gold));
  box-shadow:0 0 10px var(--c, var(--gold));
  animation:jh-spark var(--dur, 1100ms) var(--ease-out) forwards; }
@keyframes jh-spark { 0% { opacity:0; transform:translate(0,0) scale(.6); } 14% { opacity:1; }
  100% { opacity:0; transform:translate(var(--dx, 0), var(--dy, -80px)) scale(.4); } }
/* a reveal: rises in on the brand ease */
.jh-rise { animation:jh-rise var(--t-std) var(--ease-out) both; animation-delay:var(--delay, 0ms); }
@keyframes jh-rise { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* ---------- micro-interactions (src/brand.js enhance()) ---------- */
/* the sliding tab pill: glides to whichever tab is on */
.jh-tabs { position:relative; isolation:isolate; }
.jh-tabpill { position:absolute; top:4px; bottom:4px; left:0; z-index:0; border-radius:var(--r-pill);
  background:var(--go); box-shadow:0 6px 18px -6px rgba(46,230,166,.55), inset 0 1px 0 rgba(255,255,255,.25);
  pointer-events:none; opacity:0; }
.jh-tabs-ready .jh-tabpill { transition:transform var(--t-std) var(--ease-out), width var(--t-std) var(--ease-out), opacity var(--t-quick); }
.jh-tabs button { position:relative; z-index:1; }
.jh-tabs button.on { background:transparent !important; }

/* a counter that grew: a small spring and a gold glint */
.jh-bump { animation:jh-bump 620ms var(--ease-spring); }
@keyframes jh-bump { 0% { transform:scale(1); } 30% { transform:scale(1.14); color:var(--gold); text-shadow:0 0 24px rgba(255,207,90,.45); }
  100% { transform:scale(1); } }
[data-jh-count] { display:inline-block; transform-origin:50% 60%; }

/* the pointer-follow light on cards (position set by enhance()) */
.panel, .card { position:relative; }
.panel::after, .card::after { content:""; position:absolute; inset:0; border-radius:inherit; pointer-events:none; opacity:0;
  background:radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(46,230,166,.07), transparent 45%);
  transition:opacity var(--t-std) var(--ease-out); }
[data-family="light"] .panel::after, [data-family="light"] .card::after {
  background:radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(18,162,114,.07), transparent 45%); }
.panel:hover::after, .card:hover::after { opacity:1; }

/* interactive cards lift */
a.card, .card.interactive { transition:transform var(--t-quick) var(--ease-out), box-shadow var(--t-std) var(--ease-out),
  border-color var(--t-quick) var(--ease-out); }
a.card:hover, .card.interactive:hover { transform:translateY(-3px); border-color:color-mix(in oklab, var(--go) 45%, var(--line));
  box-shadow:var(--shadow); }

/* native <details> that opens smoothly (progressive: Chrome 131+, others just open) */
:root { interpolate-size:allow-keywords; }
details::details-content { block-size:0; overflow:clip;
  transition:block-size var(--t-std) var(--ease-out), content-visibility var(--t-std) allow-discrete; }
details[open]::details-content { block-size:auto; }

/* paper grain, so flat colour feels like a surface, not plastic */
body::before { content:""; position:fixed; inset:0; pointer-events:none; z-index:-1; opacity:.035;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
[data-family="light"] body::before { opacity:.05; }
body { position:relative; isolation:isolate; }

/* the one big Start: a gold halo breathes around it, inviting the press */
.jh-invite { position:relative; }
.jh-invite::after { content:""; position:absolute; inset:-6px; border-radius:inherit; border:2px solid var(--gold);
  opacity:0; pointer-events:none; animation:jh-breathe 2.8s var(--ease-out) infinite; }
.jh-invite:disabled::after { animation:none; }
@keyframes jh-breathe { 0% { opacity:0; transform:scale(.97); } 35% { opacity:.55; } 100% { opacity:0; transform:scale(1.06); } }

/* a chart that draws itself in, left to right */
.jh-draw { animation:jh-draw 900ms var(--ease-out) both; }
@keyframes jh-draw { from { clip-path:inset(0 100% 0 0); } to { clip-path:inset(0 0 0 0); } }
html.calm .jh-draw { animation:none; }
@media (prefers-reduced-motion: reduce) { .jh-draw { animation:none; } }

/* Calm mode + prefers-reduced-motion: every brand animation switches off. */
html.calm .jh-ring, html.calm .jh-spark { display:none; }
html.calm .jh-rise { animation:none; }
html.calm button, html.calm .btn, html.calm a.ghost { transition:none; }
html.calm .jh-bump, html.calm .jh-invite::after { animation:none; }
html.calm .jh-tabs-ready .jh-tabpill, html.calm a.card, html.calm .card.interactive { transition:none; }
html.calm a.card:hover, html.calm .card.interactive:hover { transform:none; }
html.calm details::details-content { transition:none; }
@media (prefers-reduced-motion: reduce) {
  .jh-ring, .jh-spark { display:none; }
  .jh-rise { animation:none; }
  button, .btn, a.ghost { transition:none; }
  .jh-bump, .jh-invite::after { animation:none; }
  .jh-tabs-ready .jh-tabpill, a.card, .card.interactive { transition:none; }
  a.card:hover, .card.interactive:hover { transform:none; }
  details::details-content { transition:none; }
}

/* ---------- print: ink only ---------- */
@media print {
  [data-family] { --bg:#fff; }
  body { background:#fff; }
  button, .btn { display:none !important; }
}
