/* Harbinger Horizon brand: royal blue + deep navy + silver, serif display (echoes the wordmark). */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --text: #1b1f3b;
  --muted: #555c72;
  --border: #d8dbe6;
  --accent: #3539a0;        /* Harbinger royal blue */
  --accent-strong: #262a7d;
  --accent-soft: #eceefa;
  --navy: #1c1f4d;
  --silver: #8a8d93;
  --accent-ink: #ffffff;
  --font-display: Georgia, "Times New Roman", "Liberation Serif", serif;
  --good: #1e7a46;
  --good-bg: #e6f4ec;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --mixed: #8a5a00;
  --mixed-bg: #fff4dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); color: var(--navy);
  border-bottom: 3px solid var(--accent); box-shadow: 0 1px 0 var(--silver), 0 2px 10px rgba(28, 31, 77, .06);
  position: sticky; top: 0; z-index: 5;
}
.brand-logo { height: 58px; width: auto; display: block; }
.title-block { flex: 1 1 260px; min-width: 0; }
.app-title { font: 700 1.1rem/1.25 var(--font-display); margin: 0; color: var(--navy); }
.status { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.topbar-actions { display: flex; gap: 8px; }

.site-footer { max-width: 1100px; margin: 8px auto 32px; padding: 16px 24px 0; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; }
.site-footer img { height: 28px; width: auto; }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---------- cards & type ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.hero h2 { margin-top: 0; font-family: var(--font-display); color: var(--navy); font-size: 1.6rem; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); font-weight: 600; }
.scene-title { margin: 4px 0 16px; font: 700 1.55rem/1.25 var(--font-display); color: var(--navy); }
.scene-title:focus { outline: none; }
h3 { font-size: 1.05rem; margin: 24px 0 10px; }
.card > h3:first-child { margin-top: 0; }

.notice { background: var(--mixed-bg); border-left: 4px solid var(--mixed); padding: 12px 16px; border-radius: 6px; }
.disclaimer { color: var(--muted); font-size: .85rem; margin-top: 16px; }
.error { color: var(--bad); margin: 6px 0 0; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 10px 18px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.topbar .btn { background: var(--surface); color: var(--navy); border-color: var(--border); }
.topbar .btn-exit { background: #b3261e; border-color: #b3261e; color: #fff; font-weight: 600; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

/* ---------- start options ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 24px; }
legend { font: 700 1.15rem var(--font-display); color: var(--navy); margin-bottom: 12px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.option-card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 14px 14px 42px; cursor: pointer;
}
.option-card input { position: absolute; left: 14px; top: 17px; }
.option-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.option-card.is-disabled { opacity: .55; cursor: not-allowed; }
.option-title { font-weight: 700; }
.option-sub { font-size: .85rem; color: var(--muted); }
.option-desc { font-size: .92rem; }
.ack-row label { display: flex; gap: 10px; align-items: flex-start; }
.ack-row input { margin-top: 5px; }

.cast { padding-left: 20px; }

/* ---------- play ---------- */
.play-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.play-grid .card { margin-bottom: 0; }
.meters { position: sticky; top: 76px; }
.panel-title { font-size: 1rem; margin: 0 0 12px; }

.scene-text p, .feedback p { margin: 0 0 14px; }
.choices-title { margin-top: 24px; }
.choices { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.choice {
  width: 100%; text-align: left; font: inherit; cursor: pointer;
  padding: 14px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fafbfc; color: var(--text);
}
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }

.your-choice { background: #f1f3f7; border-radius: 8px; padding: 10px 14px; }
.feedback { border-left: 4px solid var(--accent); padding-left: 16px; }

/* ---------- meters ---------- */
.meter { margin-bottom: 16px; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
.meter-label { font-weight: 600; }
.meter-value { color: var(--muted); white-space: nowrap; }
.meter-track { height: 10px; background: #e7eaf0; border-radius: 99px; overflow: hidden; margin: 4px 0; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
.meter-invert .meter-fill {
  background: repeating-linear-gradient(45deg, var(--bad), var(--bad) 6px, #c94a42 6px, #c94a42 12px);
}
.meter-help { margin: 0; font-size: .78rem; color: var(--muted); line-height: 1.4; }

.deltas { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 6px; }
.deltas li { padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.delta-good { color: var(--good); background: var(--good-bg); }
.delta-bad { color: var(--bad); background: var(--bad-bg); }
.delta-word { font-weight: 400; }
.deltas-none { color: var(--muted); }

/* ---------- debrief ---------- */
.ending { border-left: 6px solid var(--muted); }
.ending-positive { border-left-color: var(--good); }
.ending-negative { border-left-color: var(--bad); }
.culture-reveal { background: #f1f3f7; padding: 10px 14px; border-radius: 8px; }

.score-card { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.score-number { font-size: 3.4rem; font-weight: 800; line-height: 1; margin: 0; }
.score-number span { font-size: 1.1rem; font-weight: 500; color: var(--muted); }
.score-band { margin: 8px 0 0; }
.score-mark { color: var(--muted); font-size: .85rem; }
.pass { color: var(--good); font-weight: 700; }
.fail { color: var(--bad); font-weight: 700; }
.score-detail p { margin: 0 0 8px; }
.score-counts { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 14px; }
.learner input { font: inherit; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; min-width: 220px; }
.completed { color: var(--muted); font-size: .9rem; }
@media (max-width: 800px) { .score-card { grid-template-columns: 1fr; } }

.meter-table { width: 100%; border-collapse: collapse; }
.meter-table th, .meter-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.meter-table td.delta-good, .meter-table td.delta-bad { background: none; font-weight: 700; }

.timeline { padding-left: 20px; }
.timeline li { margin-bottom: 16px; }
.timeline p { margin: 2px 0; }
.timeline-choice { font-style: italic; }
.timeline-tag { font-size: .88rem; color: var(--muted); }
.timeline-lesson { font-size: .92rem; }
.timeline-better { margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--good); background: var(--good-bg); border-radius: 0 6px 6px 0; font-size: .92rem; }
.timeline-better ul { margin: 2px 0 0; padding-left: 18px; }

.print-only { display: none; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; vertical-align: middle; }
.badge-strong { color: var(--good); background: var(--good-bg); }
.badge-mixed  { color: var(--mixed); background: var(--mixed-bg); }
.badge-weak   { color: var(--bad); background: var(--bad-bg); }

.panel { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.panel summary { font-weight: 600; cursor: pointer; }
.panel ul { margin: 10px 0 0; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: var(--radius); max-width: 560px; width: calc(100% - 32px); padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.dlg-wide { max-width: 900px; max-height: calc(100vh - 48px); overflow: auto; }
a.btn { display: inline-block; text-decoration: none; }
dialog::backdrop { background: rgba(20, 25, 35, .55); }
dialog h2 { margin-top: 0; font-family: var(--font-display); color: var(--navy); }
.resources { padding-left: 20px; }
.resources li { margin-bottom: 10px; }

/* ---------- people: avatars, cast, speaker ---------- */
.avatar { border-radius: 50%; flex: none; display: block; background: var(--accent-soft); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }
.avatar-sm { width: 40px; height: 40px; }
.avatar-md { width: 56px; height: 56px; }
.avatar-lg { width: 72px; height: 72px; }

.option-card.has-avatar { padding-left: 42px; }
.option-card .avatar { margin-bottom: 6px; }

.cast-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cast-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cast-card.is-you { border-color: var(--accent); background: var(--accent-soft); }
.cast-name { margin: 0; font: 700 1rem/1.3 var(--font-display); color: var(--navy); }
.cast-role { margin: 2px 0 4px; font-size: .85rem; color: var(--muted); }
.cast-bio { margin: 0; font-size: .9rem; }
.you-tag { display: inline-block; margin-left: 6px; font: 700 .7rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink); background: var(--accent); border-radius: 99px; padding: 1px 7px; vertical-align: middle; }

.speaker { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; color: var(--muted); font-size: .9rem; }
.speaker strong { color: var(--navy); }

.people-link { margin-top: 14px; }

/* ---------- hosted version: license pages and status (js/license.js, js/license-pages.js) ---------- */
.license-status { font-size: .8rem; line-height: 1.35; text-align: right; color: var(--muted); }
.license-status strong { color: var(--navy); }
.license-status.soon { color: var(--mixed); }
main.narrow { max-width: 680px; }
main.narrow > .notice { margin-bottom: 16px; }
.page-title { font: 700 1.6rem/1.25 var(--font-display); color: var(--navy); margin: 8px 0 16px; }
.lic-form h2 { margin-top: 0; font-family: var(--font-display); color: var(--navy); }
label.field { display: block; font-weight: 600; margin: 14px 0 4px; }
label.field:first-of-type { margin-top: 0; }
.lic-form input[type=text], .lic-form input[type=email], .lic-form input[type=password] {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; width: min(100%, 26rem); background: var(--surface); color: var(--text); }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }
.lic-form .notice { margin-top: 16px; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.terms-box { border: 2px solid var(--mixed); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; background: var(--mixed-bg); }
.terms-box p { margin: 0 0 8px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
label.check input { width: 1.2rem; height: 1.2rem; margin-top: 3px; flex: none; accent-color: var(--accent); }
.form-error { color: var(--bad); font-weight: 600; margin-top: 14px; }
.key-card { text-align: center; }
.actions.center { justify-content: center; }
.license-key { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: .06em;
  background: var(--accent-soft); border-radius: 8px; padding: 12px; user-select: all; word-break: break-all; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.kv ul { margin: 0; padding-left: 18px; }
.valid-mark { font-weight: 700; color: var(--good); margin-top: 0; }
.learner-locked { margin: 8px 0 0; }
.lic-footer { line-height: 1.5; }
#licenses .card h3 { margin-top: 0; }

/* ---------- responsive ---------- */
@media (max-width: 800px) {
  main { padding: 16px; }
  .play-grid { grid-template-columns: 1fr; }
  .meters { position: static; order: -1; }
  .meter-help { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .meter-fill { transition: none; }
}

/* ---------- print (debrief summary) ---------- */
@media print {
  body { background: #fff; }
  .topbar, .no-print, .skip-link, #screen-start, #screen-intro, #screen-play { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  details.panel { border: 0; padding: 0; }
  .learner, .learner-locked, .score-detail > p:first-child { display: none; }
  .print-only { display: block; }
  .record { border: 2px solid var(--navy); border-top: 6px solid var(--accent); border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; break-inside: avoid; }
  .record-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
  .record-logo { height: 56px; width: auto; }
  .record, .record-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .record-title { font: 700 1.35rem var(--font-display); color: var(--navy); margin: 0; }
  .record dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0 0; }
  .record dt { font-weight: 700; }
  .record dd { margin: 0; }
  .badge, .timeline-better, .delta-good, .delta-bad { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
