/*
  Recovery timeline (/tools/recovery). Source for site/public/tools/recovery/recovery.css,
  copied by scripts/build-recovery.js. Mobile first; most visitors are on phones.

  No web fonts: the page loads nothing from third parties, so the brand faces
  are used only when installed locally, over system fallbacks. State is never
  carried by color alone — every state has a text badge and a glyph; color and
  border style only reinforce them.
*/

:root {
  --bg: #0A1628;
  --bg-raised: #10203a;
  --bg-sunk: #0d1b31;
  --gold: #C9A961;
  --ink: #E8E4DC;
  --ink-dim: #A8B0BD;
  --line: #2a3a55;
  --f-display: Fraunces, Georgia, "Times New Roman", serif;
  --f-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* State accents: reinforcement only, never the sole signal. */
  --st-wait: #A8B0BD;
  --st-block: #E38B7A;
  --st-assess: #8FB8E8;
  --st-clear: #8CCB9B;
  --st-md: #C9A961;
  --st-out: #E3B25C;

  --radius: 10px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.55;
}

a { color: var(--gold); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

h1, h2, h3 { font-family: var(--f-display); font-weight: 500; line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; font-family: var(--f-body); font-weight: 600; }
h1:focus { outline: none; }
p { margin: 0 0 0.6rem; }
ul, ol { margin: 0 0 0.6rem; padding-left: 1.2rem; }
code { font-family: var(--f-mono); font-size: 0.85em; word-break: break-all; }

.rc-top, .rc-main, .rc-foot { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.rc-top { padding-top: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.rc-home { font-family: var(--f-display); color: var(--ink); text-decoration: none; font-size: 1rem; }
.rc-main { padding-top: 20px; padding-bottom: 32px; }
.rc-main:focus { outline: none; }
.rc-foot { color: var(--ink-dim); font-size: 0.85rem; padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 44px; padding: 10px 16px; margin: 0 8px 8px 0;
  font: inherit; font-weight: 600; color: var(--ink); text-decoration: none; text-align: left;
  background: transparent; border: 1px solid var(--ink-dim); border-radius: var(--radius); cursor: pointer;
}
.btn:hover { border-color: var(--gold); }
.btn-primary { background: var(--gold); color: var(--bg); border-color: var(--gold); }
.btn-primary:hover { background: #d6ba78; }
.btn-small { min-height: 44px; padding: 8px 12px; font-size: 0.9rem; font-weight: 500; }
.btn-title { font-size: 1.05rem; }
.btn-sub { font-weight: 400; font-size: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; margin-top: 12px; }
.actions-quiet .btn { color: var(--ink-dim); border-color: var(--line); }
.choices { list-style: none; padding: 0; }

.date-form label, .code-form label, .rec-form label, .card-form label { display: block; font-weight: 600; margin: 10px 0 6px; }
.date-form input, .code-form input, .rec-form input[type="date"], .rec-form input[type="text"], .rec-form textarea, .card-form select {
  font: inherit; font-size: 1.1rem; min-height: 48px; width: 100%; max-width: 20rem;
  padding: 8px 12px; color: var(--ink); background: var(--bg-raised);
  border: 1px solid var(--ink-dim); border-radius: var(--radius); color-scheme: dark;
}
.rec-form textarea { font-size: 1rem; max-width: 100%; min-height: 4.5rem; resize: vertical; }
.code-form { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.code-form input { font-family: var(--f-mono); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 10px; margin: 10px 0; }
legend { font-weight: 600; padding: 0 4px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.choice input { width: 22px; height: 22px; margin: 0; accent-color: var(--gold); flex: none; }
.choice label { margin: 0; font-weight: 500; }
.date-form input[aria-invalid="true"] { border: 2px solid var(--st-block); }
.hint { color: var(--ink-dim); font-size: 0.9rem; margin-top: 6px; }
.field-error { color: var(--ink); border-left: 4px solid var(--st-block); padding-left: 10px; font-weight: 600; }

/* ------------------------------------------------------------ screens + notes */

.screen, .plan, .now, .preop { margin-bottom: 24px; }
.lead { font-size: 1.1rem; }
.screen-error .lead { border-left: 4px double var(--st-block); padding-left: 12px; }
.error-detail { color: var(--ink-dim); font-size: 0.9rem; }
.error-detail dt { font-weight: 600; margin-top: 8px; }
.error-detail dd { margin: 2px 0 0; }

.confirm-sentence { font-family: var(--f-display); font-size: 1.4rem; line-height: 1.3; }
.confirm-question { font-weight: 600; font-size: 1.1rem; }

.plan-label { font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); margin-top: 12px; }
.plan-sentence { font-family: var(--f-display); font-size: 1.2rem; }
.plan-details { color: var(--ink-dim); }
.plan-date { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.plan-date .btn { margin: 0; }

.note { font-size: 0.9rem; color: var(--ink-dim); }
.note-defaults, .note-storage {
  color: var(--ink); background: var(--bg-raised); border: 1px solid var(--gold);
  border-radius: var(--radius); padding: 10px 12px;
}
.note-storage { border-style: dashed; }

.now { background: var(--bg-raised); border-radius: var(--radius); padding: 12px 14px; border-left: 4px solid var(--gold); }
.now h2 { font-family: var(--f-mono); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.now-label { font-family: var(--f-display); font-size: 1.3rem; }

.countdown { font-family: var(--f-display); font-size: 1.5rem; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 10px 0 10px 28px; border-bottom: 1px solid var(--line); position: relative; }
.checklist li::before { content: "☐"; position: absolute; left: 0; color: var(--gold); }

/* ------------------------------------------------------------ overview */

.overview { margin: 0 0 24px; padding: 10px 8px; background: var(--bg-sunk); border-radius: var(--radius); }
.overview svg { display: block; width: 100%; max-width: 640px; height: auto; }
.ov-lane { font-family: var(--f-mono); font-size: 8px; fill: var(--ink-dim); letter-spacing: 0.06em; text-transform: uppercase; }
.ov-axis { font-family: var(--f-mono); font-size: 8px; fill: var(--ink-dim); }
.ov-tick { stroke: var(--ink-dim); stroke-width: 0.6; }
.ov-restriction { fill: var(--ink); }
.ov-restriction.ov-ended { fill: var(--line); }
.ov-hatch { fill: url(#hatch); }
.ov-hatch-stroke { fill: var(--ink-dim); }
.ov-time { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.ov-gate { fill: var(--st-assess); stroke: var(--bg); stroke-width: 0.6; }
.ov-education { fill: var(--ink-dim); }
.ov-bio { fill: var(--line); }
.ov-now { stroke: var(--gold); stroke-width: 1.4; stroke-dasharray: 3 2; }
.ov-now-label { font-family: var(--f-mono); font-size: 8px; font-weight: 600; fill: var(--gold); }
.legend { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.8rem; color: var(--ink-dim); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend span { color: var(--ink); font-family: var(--f-mono); }
.legend .lg-gate { color: var(--st-assess); }

/* ------------------------------------------------------------ lanes */

.lane { margin-bottom: 28px; }
.lane > h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.lane-note { color: var(--ink-dim); font-size: 0.9rem; }
.rows { list-style: none; padding: 0; margin: 0; }
.row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row-when { font-family: var(--f-mono); font-size: 0.8rem; color: var(--ink-dim); }
.row-body > :last-child { margin-bottom: 0; }
.item-text { color: var(--ink-dim); font-size: 0.92rem; }
.window { color: var(--ink-dim); font-size: 0.9rem; }

/* Biology: a shared reference. Muted, neutral, identical for everyone. */
.lane-reference { background: var(--bg-sunk); border-radius: var(--radius); padding: 12px 14px; }
.lane-reference > h2 { font-size: 1.05rem; color: var(--ink-dim); }
.lane-reference .row { border-bottom-style: dotted; }
.lane-reference h3 { font-weight: 500; color: var(--ink-dim); }

/* You are here */
.row-marker { border-bottom: none; padding: 8px 0; }
.row-marker:focus { outline: 3px solid var(--gold); outline-offset: 2px; }
.marker-label {
  display: block; font-family: var(--f-mono); font-size: 0.85rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--bg); background: var(--gold); border-radius: 999px; padding: 6px 12px;
}

/* Badges: text + glyph, reinforced by border style. */
.badge {
  display: inline-block; font-family: var(--f-mono); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.03em; padding: 3px 8px; border-radius: 6px; margin-bottom: 6px;
  border: 1px solid var(--ink-dim); color: var(--ink);
}
.state-not_yet_eligible.badge { border-style: dotted; border-color: var(--st-wait); }
.state-blocked_by_restriction.badge { border-width: 2px; border-color: var(--st-block); }
.state-awaiting_assessment.badge { border-style: dashed; border-color: var(--st-assess); }
.state-cleared.badge { border-width: 2px; border-style: double; border-color: var(--st-clear); border-width: 3px; }
.state-clinician_directed.badge { border-color: var(--st-md); }
.state-out_of_scope.badge { border-width: 2px; border-color: var(--st-out); }

.row-permission { border-left: 4px solid transparent; padding-left: 10px; }
.row-permission.state-blocked_by_restriction { border-left-color: var(--st-block); }
.row-permission.state-cleared { border-left-color: var(--st-clear); }
.row-permission.state-awaiting_assessment { border-left-color: var(--st-assess); border-left-style: dashed; }
.row-permission.state-clinician_directed { border-left-color: var(--st-md); border-left-style: dotted; }
.state-text { font-weight: 500; }
.blockers li, .needed li { margin-bottom: 4px; }

.badge-restriction { border-radius: 2px; }
.badge-restriction.restriction-in_force { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge-restriction.restriction-ended { text-decoration: none; border-style: dotted; }
.badge-gate { color: var(--bg); background: var(--st-assess); border-color: var(--st-assess); }

/* Time markers and gates never look alike. */
.mk { font-size: 0.9rem; }
.mk-glyph { font-family: var(--f-mono); }
.mk-tag {
  font-family: var(--f-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 999px; margin-right: 2px;
}
.mk-time .mk-tag { border: 1px solid var(--ink-dim); }
.mk-gate .mk-tag { background: var(--st-assess); color: var(--bg); border-radius: 2px; }
.mk-note { color: var(--ink-dim); }
.not-a-pass { border-left: 3px solid var(--st-assess); padding-left: 10px; }

.criteria summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; list-style: none; }
.criteria summary::-webkit-details-marker { display: none; }
.criteria summary::before { content: "▸"; font-family: var(--f-mono); margin-right: 8px; }
.criteria[open] summary::before { content: "▾"; }
.criteria ul { color: var(--ink-dim); font-size: 0.92rem; }

/* Cleared, but restrictions still apply. */
.in-force { border: 2px solid var(--gold); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; background: var(--bg-raised); }
.in-force-heading { color: var(--gold); }
.in-force ul { margin-bottom: 0; }

/* ------------------------------------------------------------ phase sections */

.sec { margin-bottom: 16px; border-radius: var(--radius); }
details.sec { border: 1px solid var(--line); background: var(--bg-sunk); }
details.sec > summary {
  cursor: pointer; list-style: none; min-height: 44px; padding: 10px 14px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
}
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: "▸"; font-family: var(--f-mono); color: var(--gold); }
details.sec[open] > summary::before { content: "▾"; }
details.sec[open] > summary { border-bottom: 1px solid var(--line); }
details.sec > :not(summary) { margin-left: 14px; margin-right: 14px; }
.sec-range { font-family: var(--f-mono); font-size: 0.8rem; color: var(--ink-dim); }
.sec-label { font-family: var(--f-display); font-size: 1.1rem; }
.sec-desc { color: var(--ink-dim); font-size: 0.9rem; }
.sec-counts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--f-mono); font-size: 0.75rem; color: var(--ink-dim); }
.sec-now { border: 2px solid var(--gold); padding: 12px 14px; background: var(--bg-raised); }
.sec-now > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sec-tag { font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); flex-basis: 100%; }
.sec-lane { margin-top: 12px; }
.sec-lane-title { font-family: var(--f-mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 0; }
.sub { font-family: var(--f-body); font-size: 1rem; font-weight: 700; margin-top: 16px; }
.carried { border-left: 3px solid var(--ink); padding-left: 10px; margin-top: 12px; }
.sec-reference > .lane { margin: 0; background: none; }

/* Prompts: questions for the surgeon, never a change of state. */
.prompts { border: 1px dashed var(--gold); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; }
.prompts .sub { margin-top: 0; color: var(--gold); }
.prompts ul { list-style: none; padding: 0; margin: 0; }
.prompt { padding: 8px 0; border-top: 1px solid var(--line); }
.prompt .btn { margin: 8px 0 0; }

/* ------------------------------------------------------------ records */

.rec-panel { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.rec-panel > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; padding: 0 12px; font-weight: 600; color: var(--gold); list-style: none; }
.rec-panel > summary::-webkit-details-marker { display: none; }
.rec-panel > summary::before { content: "✎"; margin-right: 8px; }
.rec-panel > :not(summary) { margin-left: 12px; margin-right: 12px; }
.rec-form { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.rec-lead { margin-bottom: 4px; }
.saved { color: var(--st-clear); font-weight: 600; margin-top: 8px; }
.saved:focus { outline: none; }
.field-error:focus { outline: none; }
.recorded { list-style: none; padding: 0; }
.recorded li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.recorded .btn { margin: 6px 0 0; }
.btn-quiet { color: var(--ink-dim); border-color: var(--line); }
.note-exposure { color: var(--ink); border-left: 3px solid var(--st-assess); padding-left: 10px; }
.sec-recorded > p, .sec-recorded > ul { margin-left: 14px; margin-right: 14px; }

.tools { margin: 24px 0; }
.tools h3 { margin-top: 16px; }

/* ------------------------------------------------------------ return-to-work sheet */

.work-sheet .ws-name { display: flex; gap: 8px; align-items: flex-end; }
.ws-blank { display: inline-block; flex: 1; max-width: 22rem; border-bottom: 1px solid var(--ink-dim); height: 1.2em; }
.ws-preamble { border-left: 3px solid var(--gold); padding-left: 10px; }
.ws-items { list-style: none; padding: 0; }
.ws-item { border-bottom: 1px solid var(--line); padding: 8px 0; break-inside: avoid; }
.ws-why { font-weight: 600; margin-bottom: 2px; }
.ws-small, .ws-footer { font-size: 0.85rem; color: var(--ink-dim); }
.ws-clearance { font-weight: 700; }

/* ------------------------------------------------------------ staff cards */

.card-form fieldset { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.card-form select { font-size: 1rem; max-width: 100%; }
.card-confirm { background: var(--bg-raised); border-radius: var(--radius); padding: 12px 14px; margin: 16px 0; }
.card-sample { margin: 16px 0; }
.card-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 12px; }
.card {
  display: grid; grid-template-columns: 1.3in 1fr; gap: 10px; align-items: center;
  width: 3.5in; min-height: 2in; padding: 0.12in; background: #fff; color: #000; border: 1px dashed #888;
  font-family: var(--f-body); break-inside: avoid;
}
.card .qr { width: 1.3in; height: 1.3in; display: block; }
.card p { margin: 0 0 4px; }
.card-title { font-family: var(--f-display); font-size: 12pt; font-weight: 600; }
.card-how { font-size: 7.5pt; line-height: 1.3; }
.card-code { font-family: var(--f-mono); font-size: 10pt; font-weight: 700; letter-spacing: 0.02em; word-break: break-all; }
.card-staff { font-size: 6.5pt; line-height: 1.25; color: #333; word-break: break-word; }
.card .btn { grid-column: 1 / -1; color: #000; border-color: #888; }

/* ------------------------------------------------------------ wider screens */

@media (min-width: 640px) {
  h1 { font-size: 2rem; }
  .card-form fieldset { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: 9rem 1fr; gap: 16px; }
  .row-marker { grid-template-columns: 1fr; }
  .marker-label { display: inline-block; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (forced-colors: active) {
  .badge, .marker-label, .in-force, .note-defaults, .note-storage { border: 2px solid CanvasText; }
}

/* ------------------------------------------------------------ print (last, so it wins) */

@media print {
  @page { margin: 0.5in; }
  body { background: #fff; color: #000; font-size: 10pt; line-height: 1.35; }
  .rc-top, .rc-foot, .no-print { display: none !important; }
  .rc-main { max-width: none; padding: 0; }
  h1 { font-size: 16pt; } h2 { font-size: 11.5pt; margin-top: 8pt; } h3 { font-size: 10pt; margin-bottom: 2pt; }
  p, li { color: #000; }
  .ws-preamble, .note-exposure { border-color: #000; }
  .ws-small, .ws-footer, .hint { color: #333; font-size: 8.5pt; }
  .ws-restrictions { font-size: 9pt; }
  .ws-item { border-color: #999; padding: 4pt 0; }
  .ws-item p, .ws-item ul { margin-bottom: 1pt; }
  .ws-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18pt; }
  .ws-blank { border-color: #000; }
  .card-sheet { display: grid; grid-template-columns: 3.5in 3.5in; gap: 0.1in; justify-content: center; }
  .card { border: 1px dashed #999; }
  .recovery-cards .screen { display: none; }
}
