/* ============ NeuroCompass styles ============ */
/* Design principles: calm palette, generous spacing, large touch targets,
   one focus per screen, WCAG AA contrast, reduced-motion respect. */

:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #22312e;
  --text-soft: #52645f;
  --accent: #2a6b6b;
  --accent-strong: #1d4f4f;
  --accent-soft: #d8eae7;
  --lavender: #e8e4f3;
  --amber: #b45f06;
  --amber-soft: #fdf1dc;
  --green: #2e6b3e;
  --green-soft: #e2f0e4;
  --red: #a33a3a;
  --red-soft: #f7e3e3;
  --border: #d5dedb;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(34, 49, 46, 0.07);
  --fs-base: 17px;
  --maxw: 980px;
}

[data-theme="dark"] {
  --bg: #15201e;
  --surface: #1d2b28;
  --surface-2: #243530;
  --text: #e6edeb;
  --text-soft: #a8bbb5;
  --accent: #6fc2b8;
  --accent-strong: #8fd6cd;
  --accent-soft: #234441;
  --lavender: #2e2a44;
  --amber: #e6ad5c;
  --amber-soft: #3a2f1c;
  --green: #7cc48c;
  --green-soft: #21382a;
  --red: #e08e8e;
  --red-soft: #402626;
  --border: #354944;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

[data-fontsize="large"] { --fs-base: 20px; }
[data-fontsize="xlarge"] { --fs-base: 23px; }

* { box-sizing: border-box; }
html { font-size: var(--fs-base); }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: 0.6em 1em; z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

a { color: var(--accent); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.55rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 0.45rem;
  text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.1rem;
}
.brand-mark { font-size: 1.3rem; }
.site-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.site-nav a, .nav-drop-btn {
  text-decoration: none; color: var(--text-soft); font-weight: 600; font-size: 1rem;
  padding: 0.5em 0.7em; border-radius: 8px; min-height: 44px; display: inline-flex; align-items: center;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.site-nav a:hover, .nav-drop-btn:hover,
.site-nav .nav-top.active { background: var(--accent-soft); color: var(--accent-strong); }
.caret { font-size: 0.75em; margin-left: 0.35em; transition: transform 0.15s ease; }
.nav-item.open .caret { transform: rotate(180deg); }

/* Dropdown panels */
.nav-item { position: relative; }
.nav-panel {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  flex-direction: column; min-width: 240px; max-height: 72vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(34, 49, 46, 0.16); padding: 0.4rem;
}
.nav-item:last-child .nav-panel { left: auto; right: 0; }
.nav-item.open .nav-panel { display: flex; }
.nav-panel a {
  min-height: 42px; padding: 0.45em 0.75em; border-radius: 8px;
  color: var(--text); font-size: 0.97rem; white-space: nowrap;
}
.nav-panel a:hover { background: var(--accent-soft); color: var(--accent-strong); }
.nav-panel hr { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0.3rem; width: auto; align-self: stretch; }
.nav-burger { display: none; font-size: 1.25rem; }
.header-tools { display: flex; gap: 0.4rem; }
.tool-btn {
  min-width: 44px; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1rem; font-weight: 700; cursor: pointer;
}
.tool-btn:hover { background: var(--surface-2); }
.tool-plus { font-size: 0.75em; vertical-align: super; }

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 720px; margin: 0 auto; }
.view { animation: fadein 0.35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

h1 { font-size: 1.85rem; line-height: 1.25; margin: 0.6em 0 0.4em; }
h2 { font-size: 1.28rem; margin: 1.4em 0 0.4em; }
h3 { font-size: 1.1rem; margin: 0.9em 0 0.3em; }
.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 0.45em 0; }

.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  background: var(--lavender); color: var(--text); border-radius: 999px;
  padding: 0.25em 0.8em; vertical-align: middle;
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 2.2rem 0.5rem 1.4rem; }
.hero-eyebrow {
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  font-size: 0.78rem; color: var(--accent); margin: 0;
}
.hero h1 { font-size: 2.2rem; margin: 0.35em 0; }
.hero-sub { max-width: 620px; margin: 0 auto 1.4rem; color: var(--text-soft); font-size: 1.06rem; }
.hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.hero-resume { margin-top: 1rem; color: var(--text-soft); font-size: 0.95rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0.65em 1.4em; border-radius: 12px;
  font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none;
  border: 2px solid transparent; transition: background 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
[data-theme="dark"] .btn-primary { color: #10201d; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--accent-strong); border-color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-quiet { background: var(--surface-2); color: var(--text); }
.btn-quiet:hover { background: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-lg { font-size: 1.08rem; min-height: 54px; padding: 0.7em 1.7em; }
.link-btn {
  background: none; border: none; color: var(--accent); text-decoration: underline;
  cursor: pointer; font-size: inherit; padding: 0.2em;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem; margin: 1.5rem 0;
}
.info-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.info-card h2, .info-card h3 { margin: 0 0 0.4em; font-size: 1.05rem; }
.info-card p { margin: 0; color: var(--text-soft); font-size: 0.95rem; }
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover { border-color: var(--accent); }

/* ---------- Notices ---------- */
.notice {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 6px solid var(--accent); border-radius: var(--radius);
  padding: 1rem 1.3rem; margin: 1.5rem 0; box-shadow: var(--shadow);
}
.notice h2 { margin-top: 0.2em; }
.notice-important { border-left-color: var(--amber); }
.notice-crisis { border-left-color: var(--red); background: var(--red-soft); }
.success-text { color: var(--green); font-weight: 600; }

/* ---------- Check flow ---------- */
.check-container { max-width: 680px; margin: 0 auto; }
.progress-wrap { margin: 1.2rem 0 0.4rem; }
.progress-label {
  display: flex; justify-content: space-between; font-size: 0.85rem;
  color: var(--text-soft); font-weight: 600; margin-bottom: 0.35rem;
}
.progress-bar {
  height: 10px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 0.3s ease;
}

.q-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem 1.4rem; margin: 1rem 0;
}
.q-section {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 0.5em;
}
.q-text { font-size: 1.22rem; font-weight: 700; line-height: 1.45; margin: 0 0 1.1em; }
.q-hint { color: var(--text-soft); font-size: 0.92rem; margin: -0.6em 0 1.1em; }

.opt-list { display: flex; flex-direction: column; gap: 0.55rem; margin: 0; padding: 0; list-style: none; }
.opt-btn {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left;
  background: var(--surface-2); border: 2px solid var(--border); border-radius: 12px;
  padding: 0.8em 1em; font-size: 1.02rem; font-weight: 600; color: var(--text);
  cursor: pointer; min-height: 54px; transition: border-color 0.12s ease, background 0.12s ease;
}
.opt-btn:hover { border-color: var(--accent); }
.opt-btn[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong);
}
.opt-dot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-soft);
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
}
.opt-btn[aria-pressed="true"] .opt-dot { border-color: var(--accent-strong); }
.opt-btn[aria-pressed="true"] .opt-dot::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--accent-strong);
}

.q-nav { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 1.3rem; flex-wrap: wrap; }
.q-nav .btn { flex: 1 1 auto; }
.q-pause {
  text-align: center; color: var(--text-soft); font-size: 0.88rem; margin-top: 1.2rem;
}

.interstitial { text-align: center; padding: 1rem 0; }
.interstitial .big-emoji { font-size: 3rem; display: block; margin-bottom: 0.4rem; }

/* ---------- Results ---------- */
.result-banner {
  border-radius: var(--radius); padding: 1.4rem 1.5rem; margin: 1.2rem 0;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.result-banner h2 { margin: 0 0 0.4em; font-size: 1.35rem; }
.result-strong { background: var(--amber-soft); border-left: 8px solid var(--amber); }
.result-moderate { background: var(--lavender); border-left: 8px solid var(--accent); }
.result-low { background: var(--green-soft); border-left: 8px solid var(--green); }

.score-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0; }
.score-chip {
  flex: 1 1 180px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.9rem 1.1rem; box-shadow: var(--shadow);
}
.score-chip .num { font-size: 1.8rem; font-weight: 800; color: var(--accent-strong); }
.score-chip .lbl { font-size: 0.85rem; color: var(--text-soft); font-weight: 600; }

.detail-toggle { margin: 1rem 0; }
.answer-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 0.8rem 0; }
.answer-table th, .answer-table td { text-align: left; padding: 0.5em 0.6em; border-bottom: 1px solid var(--border); vertical-align: top; }
.answer-table .flagged { color: var(--amber); font-weight: 700; }

.next-list { counter-reset: step; list-style: none; padding: 0; }
.next-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.2rem 1rem 3.4rem; margin: 0.7rem 0; position: relative; box-shadow: var(--shadow);
}
.next-list li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 1rem; top: 1rem;
  width: 1.7em; height: 1.7em; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
[data-theme="dark"] .next-list li::before { color: #10201d; }

/* ---------- Game ---------- */
.game-stage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 340px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 1.5rem;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.game-shape { font-size: 7rem; line-height: 1; display: block; }
.game-fix { font-size: 2.2rem; color: var(--text-soft); }
.game-feedback { min-height: 1.6em; font-weight: 700; margin-top: 0.6rem; }
.game-feedback.good { color: var(--green); }
.game-feedback.bad { color: var(--red); }
.game-progress { font-size: 0.85rem; color: var(--text-soft); margin-top: 0.8rem; }

/* ---------- Checks hub / new components ---------- */
.check-status {
  margin-top: 0.5rem !important;
  font-weight: 700;
  font-size: 0.85rem !important;
  color: var(--text-soft);
}
.check-status.done { color: var(--green); }

.opt-check {
  width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--text-soft);
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--accent-strong); font-size: 0.95rem;
}
.opt-btn[aria-pressed="true"] .opt-check { border-color: var(--accent-strong); background: var(--accent-soft); }

.small-sources { font-size: 0.85rem; color: var(--text-soft); }
.small-sources li { margin: 0.35em 0; }

.faq-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: 0.7rem 0; padding: 0.2rem 1.2rem;
}
.faq-item summary {
  cursor: pointer; font-weight: 700; padding: 0.8rem 0; font-size: 1.02rem;
  list-style-position: outside;
}
.faq-item summary:hover { color: var(--accent-strong); }
.faq-item[open] { border-color: var(--accent); }
.faq-item p { margin-top: 0; }

.footer-links a { margin: 0 0.15em; }

/* ---------- Appointment pack & quotes ---------- */
.pack-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.3rem; margin: 1rem 0;
}
.pack-section h2 { margin-top: 0.2em; font-size: 1.15rem; }
.pack-meta { color: var(--text-soft); font-size: 0.92rem; }
.pack-lines div {
  border-bottom: 1px solid var(--border); height: 2em;
}
.felt-quote {
  margin: 0.8em 0; padding: 0.6em 1em; border-left: 4px solid var(--accent);
  background: var(--surface-2); border-radius: 0 10px 10px 0;
  font-style: italic; color: var(--text);
}

/* ---------- Share note & read-aloud ---------- */
.share-box { margin: 1.2rem 0; }
.share-box summary { font-weight: 700; cursor: pointer; padding: 0.4em 0; }
.share-text {
  width: 100%; margin: 0.6rem 0; padding: 0.8em; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 0.95rem; line-height: 1.5;
}
.speak-btn { float: right; margin: -0.3rem -0.3rem 0.3rem 0.6rem; font-size: 1rem; }

/* ---------- Print (appointment pack & results) ---------- */
@media print {
  .site-header, .site-footer, .no-print, .q-nav, .hero-actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .pack-section, .q-card, .result-banner, .notice { box-shadow: none; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .view { animation: none; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 1.2rem 1rem 2rem; text-align: center; color: var(--text-soft); font-size: 0.85rem;
}
.site-footer p { max-width: var(--maxw); margin: 0.4em auto; }

/* ---------- Small screens ---------- */
/* Collapse nav into burger menu on narrow screens */
@media (max-width: 900px) {
  .nav-burger { display: inline-flex; }
  .site-nav { display: none; }
  .site-nav.open {
    display: flex; flex-direction: column; align-items: stretch;
    order: 4; width: 100%; margin: 0.4rem 0 0.2rem; gap: 0.1rem;
    border-top: 1px solid var(--border); padding-top: 0.4rem;
  }
  .site-nav.open a, .site-nav.open .nav-drop-btn { width: 100%; justify-content: flex-start; }
  .nav-panel {
    position: static; box-shadow: none; border: none; border-left: 3px solid var(--accent-soft);
    border-radius: 0; margin: 0 0 0.3rem 0.9rem; min-width: 0; max-height: none; padding: 0.1rem 0.2rem;
  }
  .nav-panel a { white-space: normal; }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 1.7rem; }
  .header-inner { gap: 0.5rem; }
  .q-text { font-size: 1.1rem; }
}
