/* ===== CALIBRATOR - module styles =====
   Same architectural pattern as Bias Lab / Jury: thin top progress bar,
   two-column layout (sidebar + main card), reveal panel below options.
   Results screen carries the calibration curve and per-bin breakdown.
   Built on top of /css/app.css design tokens. */

/* Identity: cool precision cyan → teal. Reads as "measurement / dial" -
   the right vibe for a calibration test. Distinct from the indigo of
   Bias Lab and the violet-magenta of Where You Stand. */
:root {
  --accent: #0891b2;             /* cyan-600 */
  --accent-dim: rgba(8,145,178,0.10);
  --accent-2: #14b8a6;           /* teal-500 */
  --glow: 0 0 40px rgba(8,145,178,0.14);

  --cb-card-bg: var(--bg-elevated);
  --cb-card-border: var(--border);
  --cb-track-bg: rgba(0,0,0,0.06);
  --cb-correct: #34c759;
  --cb-wrong: #ff453a;
  /* Calibrator visual signature: monospace digits ("07 / 15") for an
     instrument-readout feel + the room's accent for grid/reticle. */
  --cb-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
  --cb-grid-color: rgba(8,145,178,0.05);
}
[data-theme="dark"] {
  --accent: #22d3ee;             /* cyan-400 */
  --accent-dim: rgba(34,211,238,0.18);
  --accent-2: #2dd4bf;           /* teal-400 */
  --glow: 0 0 40px rgba(34,211,238,0.22);

  --cb-track-bg: rgba(255,255,255,0.06);
  --cb-grid-color: rgba(34,211,238,0.06);
}

.is-fading {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ===================================================================
   PROGRESS BAR
   =================================================================== */
.cb-progress-bar {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0;
  height: 3px;
  z-index: 100;
  pointer-events: none;
  background: rgba(0,0,0,0.05);
}
[data-theme="dark"] .cb-progress-bar { background: rgba(255,255,255,0.06); }
.cb-progress-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(to right, var(--accent), var(--accent-2));
  transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ===================================================================
   INTRO
   =================================================================== */
.cb-intro {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 16px 64px;
  text-align: center;
}

/* Hero image sits above the title - wide letterbox photograph (a vintage
   dial gauge, archery target, or similar calibration motif). If the file
   isn't present at /images/calibrator/intro-hero.webp, the <img> removes
   itself in JS and the SVG fallback below takes over. */
.cb-hero-img {
  display: block;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 16 / 6;
  object-fit: cover;
  margin: 0 auto 28px;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(20,40,60,0.16);
}
[data-theme="dark"] .cb-hero-img {
  box-shadow: 0 18px 48px rgba(0,0,0,0.55);
}
/* Concentric-target reticle SVG - calibration metaphor in one figure. */
.cb-hero-svg {
  display: block;
  width: 110px;
  height: auto;
  margin: 0 auto 18px;
  color: var(--accent);
  opacity: 0.78;
}
.cb-hero-svg.is-hidden { display: none; }
[data-theme="dark"] .cb-hero-svg { opacity: 0.88; }

.cb-intro h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 24px;
}
.cb-intro-lead {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 auto 40px;
  max-width: 540px;
}
.cb-intro-cta {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  padding: 14px 32px;
  border-radius: var(--radius-pill);
  box-shadow: 0 12px 28px rgba(8,145,178,0.30);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.cb-intro-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(8,145,178,0.36);
}

/* ===================================================================
   QUESTION STAGE
   =================================================================== */
.cb-stage {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(28px, 4vh, 56px) clamp(20px, 3vw, 40px) 64px;
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
}
.cb-layout {
  display: flex;
  gap: clamp(32px, 4vw, 56px);
  align-items: flex-start;
}
.cb-sidebar {
  width: 180px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-h) + 32px);
}
/* Instrument-readout step counter: "07 / 15" in monospace, accent
   color. This is the room's visual signature in the sidebar. */
.cb-sidebar-step {
  font-family: var(--cb-mono);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 10px;
}
/* Reticle SVG divider between step and title - bullseye flanked by
   thin rules. Echoes the room's target metaphor. */
.cb-reticle {
  display: block;
  width: 80px;
  height: 14px;
  color: var(--accent-2);
  opacity: 0.75;
  margin-bottom: 12px;
}
/* Category label - small caps, accent color, acts as topic orientation
   for the question shown in the main card. */
.cb-sidebar-category {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
}
/* Ghost-pill restart button - same visual family as the result-page
   "Back to lobby" / "Start over" buttons, just sized down for sidebar. */
.cb-sidebar-restart {
  margin-top: 22px;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: border-color var(--transition), color var(--transition);
  align-self: flex-start;
}
.cb-sidebar-restart:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cb-main { flex: 1; min-width: 0; }

@media (max-width: 860px) {
  .cb-layout { flex-direction: column; gap: 16px; }
  .cb-sidebar {
    width: 100%;
    position: static;
    display: flex; align-items: baseline; gap: 16px;
    flex-wrap: wrap;
  }
  .cb-sidebar-step { margin-bottom: 0; }
  .cb-sidebar-category { margin-bottom: 0; }
  .cb-reticle { display: none; }
}

/* ---- Card ---- */
/* The card has a very faint cyan graph-paper grid - gives a "lab
   notebook / instrument panel" texture that matches the Calibrator's
   precision-measurement identity, without competing with the text. */
.cb-card {
  background:
    linear-gradient(to right,  var(--cb-grid-color) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(to bottom, var(--cb-grid-color) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--cb-card-bg);
  border: 1px solid var(--cb-card-border);
  border-radius: 20px;
  padding: clamp(24px, 4vw, 36px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.04);
}
[data-theme="dark"] .cb-card { box-shadow: 0 8px 32px rgba(0,0,0,0.30); }

/* Per-question hero image at the top of the card. Optional - if the file
   at /images/calibrator/questions/<question-id>.webp isn't present, the
   <img> removes itself and the card opens straight into the question. */
.cb-question-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 22px;
  box-shadow: 0 10px 28px rgba(8,40,60,0.10);
}
[data-theme="dark"] .cb-question-img {
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}

.cb-question {
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.4;
  margin-bottom: 24px;
}

/* ---- Options ---- */
.cb-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cb-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
}
.cb-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-1px);
}
.cb-option:disabled { cursor: default; }
.cb-option.is-chosen {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.cb-option.is-faded { opacity: 0.5; }
.cb-option-marker {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.cb-option.is-chosen .cb-option-marker {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.cb-option-label { flex: 1; line-height: 1.4; }

/* ---- Confidence panel ---- */
.cb-confidence {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.4s ease, margin-top 0.4s ease;
}
.cb-confidence.is-shown {
  max-height: 500px;
  opacity: 1;
}
.cb-confidence-prompt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.cb-confidence-eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.cb-confidence-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cb-confidence-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.cb-confidence-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font: inherit;
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.cb-confidence-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-1px);
}
.cb-confidence-btn:disabled { cursor: default; }
.cb-confidence-btn.is-chosen {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.cb-confidence-btn.is-faded { opacity: 0.45; }
.cb-confidence-sub {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cb-confidence-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.2;
}

@media (max-width: 600px) {
  .cb-confidence-row { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .cb-confidence-btn { padding: 10px 4px; }
  .cb-confidence-sub { font-size: 0.8rem; }
  .cb-confidence-label { font-size: 0.66rem; }
}

/* ===================================================================
   REVEAL
   =================================================================== */
.cb-reveal {
  margin-top: 32px;
  padding: 26px clamp(20px, 4vw, 32px);
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.cb-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.cb-reveal-flag {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}
.cb-reveal-flag.is-correct {
  color: var(--cb-correct);
  background: rgba(52,199,89,0.10);
}
.cb-reveal-flag.is-wrong {
  color: var(--cb-wrong);
  background: rgba(255,69,58,0.10);
}
.cb-reveal-correct {
  font-size: 0.98rem;
  margin-bottom: 14px;
}
.cb-reveal-correct-eyebrow {
  color: var(--text-tertiary);
}
.cb-reveal-correct-label {
  font-weight: 600;
  color: var(--text);
}
.cb-reveal-explanation {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 14px;
}
.cb-reveal-citation {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-bottom: 22px;
}
.cb-reveal-citation a {
  color: var(--accent);
  font-weight: 500;
}

.cb-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.cb-next {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  padding: 12px 26px;
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 24px rgba(8,145,178,0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.cb-next:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(8,145,178,0.34);
}

/* ===================================================================
   RESULTS
   =================================================================== */
.cb-results {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.cb-results-header {
  text-align: center;
  padding: 8px 0;
}
.cb-results-title {
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
}
.cb-results-sub {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* ---- Hero card ----
   The single most-important element of the results page. Contains: the
   one-line headline ("Notably overconfident."), a 2-sentence story, an
   actionable "try this next time" line, and three at-a-glance stats. */
.cb-hero {
  background: var(--cb-card-bg);
  border: 1px solid var(--cb-card-border);
  border-radius: 22px;
  padding: clamp(24px, 4vw, 36px);
  box-shadow: 0 18px 40px rgba(20,16,40,0.05);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cb-hero-eyebrow {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.cb-hero-headline {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}
.cb-hero-story {
  font-size: clamp(1rem, 1.6vw, 1.1rem);
  line-height: 1.55;
  color: var(--text);
  margin: 0;
}
.cb-hero-advice {
  font-size: clamp(1rem, 1.6vw, 1.1rem);
  line-height: 1.55;
  color: var(--text);
  margin: 4px 0 0;
  padding: 14px 18px;
  background: var(--accent-dim);
  border-radius: 12px;
  border-left: 3px solid var(--accent);
}
.cb-hero-advice strong {
  color: var(--accent);
  font-weight: 600;
}
.cb-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 12px;
  padding-top: 22px;
  border-top: 1px solid var(--cb-card-border);
}
.cb-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cb-hero-stat-num {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cb-hero-stat-num.is-over { color: #ef9b3c; }
.cb-hero-stat-num.is-under { color: #5ac8fa; }
.cb-hero-stat-num.is-good { color: var(--cb-correct); }
.cb-hero-stat-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}
@media (max-width: 600px) {
  .cb-hero-stats { grid-template-columns: 1fr; gap: 12px; }
}

/* ---- Standouts ---- */
.cb-standouts {
  background: var(--cb-card-bg);
  border: 1px solid var(--cb-card-border);
  border-radius: 18px;
  padding: 22px 24px;
}
.cb-standouts h3 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.cb-standouts-sub {
  font-size: 0.88rem;
  color: var(--text-tertiary);
  margin-bottom: 14px;
}
.cb-standouts ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cb-standouts li {
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: 12px;
  border-left: 3px solid var(--accent);
}
.cb-standout-q {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.cb-standout-body {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.cb-standout-yours {
  font-weight: 500;
}
.cb-standout-correct {
  color: var(--cb-correct);
  font-weight: 600;
}

/* ---- Actions ---- */
.cb-results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.cb-action {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.cb-action--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 10px 26px rgba(8,145,178,0.30);
}
.cb-action--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(8,145,178,0.36);
}
.cb-action--ghost {
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.cb-action--ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
  text-decoration: none;
}

/* ===================================================================
   RESPONSIVE / REDUCED MOTION
   =================================================================== */
@media (max-width: 600px) {
  .cb-stage { padding: 32px 16px 56px; }
  .cb-results { padding: 32px 12px 64px; }
  .cb-option { padding: 14px 16px; font-size: 0.96rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cb-progress-bar-fill, .cb-confidence { transition: none; }
  .is-fading, .cb-reveal { transition: none; }
}
