/* ============================================================
   Care-Ready Scorecard — application layer.
   Everything here is built from Bluehex design-system tokens
   (bluehex/styles.css). No raw hex values below except where a
   token genuinely doesn't exist yet — and those are flagged.
   ============================================================ */

/* ---- App-level semantic aliases → Bluehex tokens ------------
   The markup uses short names (.card, --ink, --rule). These map
   them onto the design system so the rest of the file reads
   cleanly and dark theme comes for free. ---------------------- */
:root {
  --ink:        var(--text-strong);
  --body:       var(--text-body);
  --muted:      var(--text-muted);
  --faint:      var(--text-subtle);
  --blue:       var(--brand);
  --blue-deep:  var(--brand-hover);
  --blue-tint:  var(--brand-soft);
  --green:      var(--success);
  --green-tint: var(--success-bg);
  --amber:      var(--warning);
  --amber-tint: var(--warning-bg);
  --red:        var(--danger);
  --red-tint:   var(--danger-bg);
  --rule:       var(--border-subtle);
  --rule-soft:  var(--gray-100);
  --surface:    var(--surface-card);
  --surface-2:  var(--surface-sunken);
  --ground:     var(--surface-page);
}
[data-theme="dark"] {
  --rule-soft: rgba(255, 255, 255, 0.06);
}

body {
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--lh-relaxed);
  color: var(--text-body);
  background: var(--surface-page);
}

h1, h2, h3 { font-family: var(--font-display); color: var(--text-strong); margin: 0; text-wrap: balance; }
h1 { font-size: clamp(var(--text-2xl), 1.4rem + 1.8vw, var(--text-3xl)); font-weight: var(--fw-extra); line-height: var(--lh-tight); letter-spacing: var(--ls-tighter); }
h2 { font-size: clamp(var(--text-xl), 1.2rem + .9vw, var(--text-2xl)); font-weight: var(--fw-extra); line-height: var(--lh-snug); letter-spacing: var(--ls-tighter); }
h3 { font-size: var(--text-lg); font-weight: var(--fw-bold); line-height: 1.35; letter-spacing: var(--ls-tight); }
p { margin: 0; }
a { color: var(--text-link); }
a:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 3px; }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: var(--ls-wider);
  color: var(--brand);
}
.eyebrow--muted { color: var(--text-muted); }

:where(button, input, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-xs);
}

/* ---------- shell ---------- */
.shell { max-width: var(--container-md); margin: 0 auto; padding: 0 var(--space-5) var(--space-11); }

.masthead {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding: var(--space-5) 0 var(--space-4);
}
.logo-link { display: inline-flex; align-items: center; text-decoration: none; }
.logo { display: block; height: 26px; width: auto; }
.logo--light { display: none; }
[data-theme="dark"] .logo--dark { display: none; }
[data-theme="dark"] .logo--light { display: block; }
.masthead .eyebrow { text-align: right; line-height: 1.35; }

/* progress rail */
.rail { position: sticky; top: 0; z-index: 30; background: var(--surface-page); padding-bottom: var(--space-3); }
.rail-track { height: 5px; background: var(--border-subtle); border-radius: var(--radius-pill); overflow: hidden; }
.rail-fill {
  height: 100%; background: var(--brand); border-radius: var(--radius-pill);
  width: 0%; transition: width var(--dur-slow) var(--ease-out);
}
.rail-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--space-3); padding-top: var(--space-2);
  font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: clamp(var(--space-5), 4vw, var(--space-6));
}
.stack   { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-s { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-l { display: flex; flex-direction: column; gap: var(--space-5); }

/* ---------- intro ---------- */
.intro-note {
  display: flex; gap: var(--space-3); padding: var(--space-4);
  background: var(--brand-soft); border-radius: var(--radius-md);
  font-size: var(--text-sm); line-height: var(--lh-relaxed); color: var(--text-strong);
}
.intro-note b { font-weight: var(--fw-bold); }

.facts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--border-subtle);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-md); overflow: hidden;
}
.fact { background: var(--surface-card); padding: var(--space-4); }
.fact dt { font-size: var(--text-2xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--ls-wider); color: var(--text-muted); }
.fact dd {
  margin: var(--space-1) 0 0; font-family: var(--font-display);
  font-size: var(--text-xl); font-weight: var(--fw-extra); color: var(--text-strong);
  font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: var(--ls-tight);
}
.fact dd small { font-family: var(--font-body); font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-muted); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body); font-size: var(--text-sm); font-weight: var(--fw-bold);
  cursor: pointer; border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  border: var(--border-width-thick) solid transparent;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--text-onbrand); }
.btn--primary:hover { background: var(--brand-hover); box-shadow: var(--shadow-brand); }
.btn--ghost { background: transparent; color: var(--text-muted); border-color: var(--border-default); }
.btn--ghost:hover { color: var(--brand); border-color: var(--brand); }
.btn--quiet {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-family: var(--font-body); font-size: var(--text-sm); font-weight: var(--fw-semibold);
  padding: var(--space-2) var(--space-1);
  text-decoration: underline; text-underline-offset: 3px;
}
.btn--quiet:hover { color: var(--brand); }
.btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.actions .spacer { flex: 1 1 auto; }

/* ---------- question ---------- */
.q-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.q-text {
  font-family: var(--font-display);
  font-size: clamp(var(--text-lg), 1rem + .5vw, var(--text-xl));
  font-weight: var(--fw-bold); color: var(--text-strong);
  line-height: 1.38; letter-spacing: var(--ls-tight); text-wrap: pretty;
}
.q-help { font-size: var(--text-sm); line-height: var(--lh-relaxed); color: var(--text-muted); }
.q-help b { color: var(--text-body); font-weight: var(--fw-semibold); }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
@media (max-width: 540px) { .choices { grid-template-columns: 1fr; } }
.choice {
  font-family: var(--font-body); cursor: pointer; text-align: left;
  background: var(--surface-sunken);
  border: var(--border-width-thick) solid var(--border-subtle);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.choice:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.choice strong { font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--fw-bold); color: var(--text-strong); letter-spacing: var(--ls-tight); }
.choice span { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.4; }
.choice[aria-pressed="true"] { transform: none; box-shadow: none; border-color: var(--brand); background: var(--brand-soft); }
.choice[aria-pressed="true"] strong { color: var(--brand-soft-fg); }
.choice[data-v="2"][aria-pressed="true"] { border-color: var(--success); background: var(--success-bg); }
.choice[data-v="2"][aria-pressed="true"] strong { color: var(--success); }
.choice[data-v="1"][aria-pressed="true"] { border-color: var(--warning); background: var(--warning-bg); }
.choice[data-v="1"][aria-pressed="true"] strong { color: var(--warning); }
.choice[data-v="0"][aria-pressed="true"] { border-color: var(--danger); background: var(--danger-bg); }
.choice[data-v="0"][aria-pressed="true"] strong { color: var(--danger); }

/* ---------- drill-down ---------- */
.drill {
  border: var(--border-width-thick) solid var(--border-brand);
  border-radius: var(--radius-md);
  background: var(--brand-soft); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
  animation: drop var(--dur-base) var(--ease-out);
}
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .drill { animation: none; }
  .rail-fill { transition: none; }
  .choice:hover { transform: none; }
}
.drill-title { font-family: var(--font-display); font-size: var(--text-md); font-weight: var(--fw-bold); color: var(--text-strong); letter-spacing: var(--ls-tight); }
.drill-sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

.tick {
  display: flex; gap: var(--space-3); align-items: flex-start; cursor: pointer;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  transition: border-color var(--dur-fast) var(--ease-out);
  font-size: var(--text-sm); line-height: var(--lh-normal);
}
.tick:hover { border-color: var(--border-strong); }
.tick input { margin: 4px 0 0; accent-color: var(--brand); width: 17px; height: 17px; flex: none; cursor: pointer; }
.tick:has(input:checked) { border-color: var(--border-brand); }
.tick span { color: var(--text-body); }

.verdict {
  font-size: var(--text-sm); font-weight: var(--fw-semibold);
  padding: var(--space-3); border-radius: var(--radius-sm);
  display: flex; gap: var(--space-2); align-items: flex-start;
}
.verdict--good { background: var(--success-bg); color: var(--success); }
.verdict--part { background: var(--warning-bg); color: var(--warning); }
.verdict--none { background: var(--danger-bg); color: var(--danger); }

/* ---------- device tally ---------- */
.tally { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
@media (max-width: 540px) { .tally { grid-template-columns: 1fr; } }

/* ---------- results ---------- */
/* The signature Bluehex moment: navy gradient field + hex glow. */
.score-hero, .cta {
  position: relative; overflow: hidden;
  background:
    radial-gradient(460px 340px at 100% 0%, rgba(96, 168, 248, .22), rgba(96, 168, 248, 0) 70%),
    linear-gradient(160deg, var(--navy-800) 0%, var(--navy-900) 100%);
  border-radius: var(--radius-xl);
  padding: clamp(var(--space-5), 4vw, var(--space-7));
  box-shadow: var(--shadow-lg);
}
/* The hexagon motif, once: a faint mark bleeding off the hero's edge. */
.score-hero::after {
  content: ""; position: absolute; right: -34px; bottom: -46px;
  width: 190px; height: 190px;
  clip-path: var(--hex-clip);
  background: rgba(96, 168, 248, .05);
  pointer-events: none;
}
.score-hero { display: flex; flex-direction: column; gap: var(--space-1); color: var(--blue-100); }
.score-hero .eyebrow { color: var(--accent); }
.score-num {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 2.4rem + 4vw, var(--text-5xl));
  font-weight: var(--fw-extra); line-height: var(--lh-tight); color: var(--white);
  font-variant-numeric: tabular-nums; letter-spacing: var(--ls-tighter);
}
.score-num small { font-family: var(--font-body); font-size: .3em; font-weight: var(--fw-bold); color: var(--accent); letter-spacing: 0; }
.band { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--fw-extra); letter-spacing: var(--ls-tight); }
.band-note { font-size: var(--text-sm); line-height: var(--lh-relaxed); color: var(--blue-200); max-width: 54ch; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 640px) { .split { grid-template-columns: 1fr; } }

.flag-list { display: flex; flex-direction: column; gap: var(--space-2); }
.flag {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  font-size: var(--text-sm); line-height: var(--lh-normal);
  background: var(--danger-bg); color: var(--text-strong);
  border-left: 3px solid var(--danger);
}
.flag--warn { background: var(--warning-bg); border-left-color: var(--warning); }
.flag b { font-weight: var(--fw-bold); }

.review { display: flex; flex-direction: column; gap: 0; }
.review-row {
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-4); align-items: baseline;
  padding: var(--space-3) 0; border-bottom: var(--border-width) solid var(--rule-soft);
  font-size: var(--text-sm); line-height: var(--lh-normal);
}
.review-row:last-child { border-bottom: none; }
.pill {
  font-size: var(--text-2xs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: var(--ls-wide);
  padding: 4px var(--space-2); border-radius: var(--radius-pill); white-space: nowrap;
}
.pill--2 { background: var(--success-bg); color: var(--success); }
.pill--1 { background: var(--warning-bg); color: var(--warning); }
.pill--0 { background: var(--danger-bg); color: var(--danger); }

/* ---------- send to Bluehex ---------- */
.privacy {
  font-size: var(--text-sm); line-height: var(--lh-relaxed); color: var(--text-body);
  background: var(--surface-sunken);
  border: var(--border-width) solid var(--border-subtle);
  border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4);
}
.privacy b { color: var(--text-strong); font-weight: var(--fw-bold); }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: var(--text-xs); font-weight: var(--fw-bold); color: var(--text-strong); }
.field label span { font-weight: var(--fw-medium); color: var(--text-muted); }
.field input, .field textarea {
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--text-strong);
  background: var(--surface-card);
  border: var(--border-width-thick) solid var(--border-subtle);
  border-radius: var(--radius-md); padding: var(--space-3); width: 100%;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.field textarea { resize: vertical; min-height: 78px; }
.field input:hover, .field textarea:hover { border-color: var(--border-strong); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--border-brand); box-shadow: var(--shadow-focus); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-subtle); }


.send-state {
  font-size: var(--text-sm); font-weight: var(--fw-semibold); line-height: var(--lh-normal);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
}
.send-state--ok   { background: var(--success-bg); color: var(--success); }
.send-state--err  { background: var(--warning-bg); color: var(--warning); }
.send-state--busy { background: var(--surface-sunken); color: var(--text-muted); }


/* ---------- cta ---------- */
.cta { display: flex; flex-direction: column; gap: var(--space-4); color: var(--blue-100); }
.cta h2 { color: var(--white); }
.cta .q-help { color: var(--blue-200); }
.cta .btn--primary { align-self: flex-start; background: var(--brand); color: var(--text-onbrand); text-decoration: none; }
.cta .btn--primary:hover { background: var(--blue-400); }

.foot {
  display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-5) 0 0; margin-top: var(--space-6);
  border-top: var(--border-width) solid var(--border-subtle);
  font-size: var(--text-xs); color: var(--text-subtle);
}

.hidden { display: none !important; }



/* ==========================================================================
   The printed report
   --------------------------------------------------------------------------
   Built as its own document by buildPrintReport(), appended to <body>, and
   only made visible when printing. The app UI is hidden entirely, so what
   comes out is a report rather than a picture of a web page.

   Ink on paper is its own context: this block pins the light palette and uses
   millimetres and points, because a printed page has no theme and no viewport.
   ========================================================================== */

.print-report { display: none; }

@media print {
  @page { size: A4; margin: 16mm 14mm; }

  /* Hide the app, show the report. */
  body > *:not(.print-report) { display: none !important; }

  html, body {
    background: #fff;
    color: #16202c;
    font-family: var(--font-body);
    font-size: 10.5pt;
    line-height: 1.45;
  }

  .print-report { display: block; }

  .pr-head {
    display: flex; align-items: baseline; justify-content: space-between;
    border-bottom: 2pt solid #102840; padding-bottom: 6pt; margin-bottom: 14pt;
  }
  .pr-brand {
    font-family: var(--font-display); font-weight: 800;
    font-size: 16pt; letter-spacing: -0.01em; color: #102840;
  }
  .pr-brand span { color: #2860e8; }
  .pr-head-meta { text-align: right; }
  .pr-title { font-family: var(--font-display); font-weight: 700; font-size: 11pt; color: #102840; }
  .pr-date { font-size: 9pt; color: #5b6879; }

  .pr-who { margin-bottom: 12pt; font-size: 10pt; }
  .pr-who strong { display: block; font-size: 12pt; color: #102840; }

  /* Score band */
  .pr-score {
    display: flex; gap: 16pt; align-items: center;
    border: 1pt solid #cfd9e6; border-left: 4pt solid #2860e8;
    padding: 10pt 14pt; margin-bottom: 16pt; break-inside: avoid;
  }
  .pr-score-num {
    font-family: var(--font-display); font-weight: 800;
    font-size: 30pt; line-height: 1; color: #102840; white-space: nowrap;
  }
  .pr-score-num span { font-size: 12pt; color: #5b6879; }
  .pr-band { font-family: var(--font-display); font-weight: 700; font-size: 13pt; color: #102840; }
  .pr-band-note { font-size: 9.5pt; color: #3c4a5c; margin-top: 2pt; }
  .pr-parts { font-size: 9pt; color: #5b6879; margin-top: 5pt; }

  .pr-section { margin-bottom: 14pt; break-inside: avoid; }
  .pr-h2 {
    font-family: var(--font-display); font-weight: 700; font-size: 11.5pt;
    color: #102840; margin: 0 0 5pt;
    border-bottom: 0.75pt solid #cfd9e6; padding-bottom: 3pt;
  }
  .pr-lead { font-size: 9.5pt; color: #3c4a5c; margin: 0 0 6pt; }

  .pr-list { margin: 0 0 0 12pt; padding: 0; }
  .pr-list li { margin-bottom: 3pt; font-size: 9.5pt; }
  .pr-list--tight li { margin-bottom: 1pt; color: #3c4a5c; }

  .pr-block { margin-bottom: 9pt; break-inside: avoid; }
  .pr-block-h {
    font-weight: 700; font-size: 10pt; color: #102840;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .pr-q { font-size: 9.5pt; color: #3c4a5c; margin: 1pt 0 3pt; }

  .pr-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .pr-table th {
    text-align: left; font-size: 8pt; text-transform: uppercase;
    letter-spacing: 0.06em; color: #5b6879; font-weight: 700;
    border-bottom: 0.75pt solid #cfd9e6; padding: 3pt 4pt;
  }
  .pr-table td { padding: 3pt 4pt; border-bottom: 0.5pt solid #e4ebf3; vertical-align: top; }
  .pr-table tr { break-inside: avoid; }
  .pr-tag { font-weight: 700; color: #102840; white-space: nowrap; width: 26%; }
  .pr-ans { white-space: nowrap; font-weight: 700; text-align: right; width: 12%; }
  .pr-ans--2 { color: #0f7a52; }
  .pr-ans--1 { color: #9a6206; }
  .pr-ans--0 { color: #b3252f; }

  .pr-foot {
    margin-top: 16pt; padding-top: 6pt; border-top: 0.75pt solid #cfd9e6;
    font-size: 8.5pt; color: #5b6879;
  }
  .pr-foot p { margin: 0 0 2pt; }

  a[href]::after { content: none; }
}
