/* ==========================================================================
   737 Technical Exam
   Tokens → base → layout → components → views
   ========================================================================== */

/* Tokens ------------------------------------------------------------------ */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dbe1e8;
  --border-strong: #c3ccd7;
  --text: #0f1823;
  --text-muted: #566273;
  --accent: #1a56c4;
  --accent-hover: #1647a3;
  --accent-soft: #e5edfb;
  --on-accent: #ffffff;
  --correct: #0f7a52;
  --correct-soft: #e3f4ec;
  --wrong: #c0322b;
  --wrong-soft: #fbe9e8;
  --focus: #1a56c4;
  --shadow: 0 1px 2px rgba(15, 24, 35, .05), 0 4px 16px rgba(15, 24, 35, .04);

  --radius: 10px;
  --radius-sm: 6px;
  --container: 760px;
  --gutter: 16px;

  color-scheme: light;
}

/* Dark: glass-cockpit inspired */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e13;
    --surface: #11171f;
    --surface-2: #18202a;
    --border: #232d39;
    --border-strong: #33404f;
    --text: #e4eaf1;
    --text-muted: #8c99a9;
    --accent: #38c8de;
    --accent-hover: #5ad6e8;
    --accent-soft: rgba(56, 200, 222, .12);
    --on-accent: #041318;
    --correct: #3ccf85;
    --correct-soft: rgba(60, 207, 133, .12);
    --wrong: #ff6a5c;
    --wrong-soft: rgba(255, 106, 92, .12);
    --focus: #38c8de;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0e13;
  --surface: #11171f;
  --surface-2: #18202a;
  --border: #232d39;
  --border-strong: #33404f;
  --text: #e4eaf1;
  --text-muted: #8c99a9;
  --accent: #38c8de;
  --accent-hover: #5ad6e8;
  --accent-soft: rgba(56, 200, 222, .12);
  --on-accent: #041318;
  --correct: #3ccf85;
  --correct-soft: rgba(60, 207, 133, .12);
  --wrong: #ff6a5c;
  --wrong-soft: rgba(255, 106, 92, .12);
  --focus: #38c8de;
  --shadow: none;
  color-scheme: dark;
}

/* Base -------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ol, ul, dl, dd, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
ol, ul { list-style: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

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

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 .35em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 500 .8em/1.5 var(--font-mono);
  text-align: center;
}

.data { font-variant-numeric: tabular-nums; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  z-index: 10;
}
.skip-link:focus { top: 8px; }

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

/* Layout ------------------------------------------------------------------ */

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main { flex: 1; padding-block: 32px 48px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -.01em;
}
.brand__accent { color: var(--text-muted); font-weight: 500; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  padding-block: 20px;
}
.made-in { display: inline-flex; align-items: center; gap: 6px; }

/* Components -------------------------------------------------------------- */

.eyebrow,
.card__label {
  font: 500 13px/1.4 var(--font-sans);
  color: var(--text-muted);
}
.eyebrow { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.button--primary { background: var(--accent); color: var(--on-accent); }
.button--primary:hover { background: var(--accent-hover); }
.button--ghost { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.button--ghost:hover { border-color: var(--text-muted); }
.button--block { width: 100%; }
.button:disabled { opacity: .4; cursor: not-allowed; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row--center { justify-content: center; }
.button-row--end { justify-content: flex-end; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-button:hover { color: var(--text); background: var(--surface-2); }

/* Theme toggle shows the theme you would switch to */
.icon--sun { display: none; }
:root[data-theme="dark"] .icon--sun { display: block; }
:root[data-theme="dark"] .icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon--sun { display: block; }
  :root:not([data-theme="light"]) .icon--moon { display: none; }
}

/* Segmented control */
.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.segmented__option {
  position: relative;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  font: 500 15px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.segmented__option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented__option:has(input:checked),
.segmented__option[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.segmented__option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
label.segmented__option { display: grid; place-items: center; }
.segmented--small { display: inline-grid; grid-template-columns: auto auto; }
.segmented--small .segmented__option { min-height: 32px; font-size: 13px; }

/* Progress bar with 10% tick marks */
.progress {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--bg) calc(10% - 1px) 10%);
}
.progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .25s ease;
}

/* Dialogs */
.dialog {
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(5, 9, 14, .55); }
.dialog--narrow { width: min(420px, calc(100vw - 2 * var(--gutter))); }
.dialog h2 { font-size: 18px; letter-spacing: -.01em; }
.dialog p { color: var(--text-muted); margin: 8px 0 20px; }
.dialog__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog__footer { padding-top: 16px; }

/* Views ------------------------------------------------------------------- */

/* Start */

/* Hero: the photo sits behind the intro at roughly native size (770px source),
   its edges faded into the page background; colours are left untouched. */
.hero {
  position: relative;
  isolation: isolate;
  min-height: 320px;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.hero__image {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: calc(-1 * var(--gutter));
  width: 70%;
  height: auto;
  transform: translateY(-50%);
  pointer-events: none;
  user-select: none;
  --fade-x: linear-gradient(to right, transparent, #000 60%, #000 80%, transparent);
  --fade-y: linear-gradient(to bottom, transparent, #000 60%, #000 20%, transparent);
  -webkit-mask-image: var(--fade-x), var(--fade-y);
  -webkit-mask-composite: source-in;
  mask-image: var(--fade-x), var(--fade-y);
  mask-composite: intersect;
}
.hero .intro { max-width: 50%; }

.intro { margin-bottom: 28px; }
.intro h1 {
  margin: 8px 0 12px;
  font-size: clamp(32px, 6vw, 44px);
  line-height: 1.1;
  letter-spacing: -.025em;
}
.lead { max-width: 60ch; color: var(--text-muted); font-size: 17px; }

#view-start > * + * { margin-top: 16px; }

.resume-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-color: var(--accent);
}
.load-error { display: grid; justify-items: start; gap: 8px; border-color: var(--wrong); }
.load-error__title { font-weight: 600; color: var(--wrong); }
.load-error__text { color: var(--text-muted); margin-bottom: 8px; }

.resume-card__meta { margin-top: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }

.setup { display: grid; gap: 20px; }
.setup__lengths legend { margin-bottom: 10px; }
.setup__facts { display: grid; gap: 8px; color: var(--text-muted); font-size: 14px; }
.setup__facts li { padding-left: 18px; position: relative; }
.setup__facts li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .6em;
  width: 6px;
  height: 6px;
  border: 1.5px solid var(--accent);
  transform: rotate(45deg);
}
.setup__facts .data { color: var(--text); }

.disclaimer { color: var(--text-muted); font-size: 13px; }

/* Exam */
.exam-bar {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.exam-bar__readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 14px;
}
.readout { display: inline-flex; align-items: baseline; gap: 6px; }
.readout__label {
  font: 500 13px/1.4 var(--font-sans);
  color: var(--text-muted);
}
.readout .data { font-size: 15px; font-weight: 600; }
.readout--correct .data { color: var(--correct); }
.readout--wrong .data { color: var(--wrong); }
.readout:last-child { margin-left: auto; }

.question__position { margin-bottom: 6px; }
.question__text {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -.01em;
  margin-bottom: 20px;
}

.answers { display: grid; gap: 10px; }
.answer {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.answer:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.answer:disabled { cursor: default; }
.answer__key {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font: 600 13px/1 var(--font-sans);
  color: var(--text-muted);
}
.answer__text { padding-top: 2px; }
.answer__status {
  margin-left: auto;
  flex: none;
  padding-top: 4px;
  font: 600 13px/1.4 var(--font-sans);
}
.answer.is-correct { border-color: var(--correct); background: var(--correct-soft); }
.answer.is-correct .answer__key { border-color: var(--correct); background: var(--correct); color: var(--surface); }
.answer.is-correct .answer__status { color: var(--correct); }
.answer.is-wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.answer.is-wrong .answer__key { border-color: var(--wrong); background: var(--wrong); color: var(--surface); }
.answer.is-wrong .answer__status { color: var(--wrong); }
.answer.is-muted { opacity: .6; }

.explanation {
  margin-top: 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-size: 15px;
}

.exam-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  margin-top: 16px;
}
.exam-nav [data-action="prev"] { justify-self: start; }
.exam-nav [data-action="next"] { justify-self: end; }

/* Overview */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
.swatch--correct { background: var(--correct); border-color: var(--correct); }
.swatch--wrong { background: var(--wrong); border-color: var(--wrong); }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: min(50vh, 420px);
  overflow-y: auto;
  padding: 2px;
}
.overview-item {
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  font: 500 14px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.overview-item:hover { border-color: var(--accent); }
.overview-item.is-correct { background: var(--correct); border-color: var(--correct); color: var(--surface); }
.overview-item.is-wrong { background: var(--wrong); border-color: var(--wrong); color: var(--surface); }
.overview-item[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Results */
.results { text-align: center; padding-block: 32px; }
.results__title { margin-top: 8px; font-size: 28px; letter-spacing: -.02em; }
.results__score { margin: 4px 0 24px; font-size: 56px; font-weight: 600; line-height: 1.1; color: var(--accent); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.stat { padding: 12px 8px; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat dt { font: 500 13px/1.4 var(--font-sans); color: var(--text-muted); }
.stat dd { margin-top: 4px; font-size: 20px; font-weight: 600; }
.stat--correct dd { color: var(--correct); }
.stat--wrong dd { color: var(--wrong); }

.review { margin-top: 32px; }
.review__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.review__header h2 { font-size: 20px; letter-spacing: -.01em; }
.review__list { display: grid; gap: 12px; }
.review__empty { color: var(--text-muted); text-align: center; padding: 24px; }

.review-item { padding: 18px; }
.review-item__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.review-item__status { font: 600 13px/1.4 var(--font-sans); }
.review-item__status--correct { color: var(--correct); }
.review-item__status--wrong { color: var(--wrong); }
.review-item__status--skipped { color: var(--text-muted); }
.review-item__question { font-weight: 600; margin-bottom: 10px; }
.review-item__line { font-size: 15px; display: flex; gap: 8px; }
.review-item__line + .review-item__line { margin-top: 4px; }
.review-item__line dt { flex: none; width: 96px; color: var(--text-muted); font-size: 13px; padding-top: 2px; }
.review-item__line--wrong dd { color: var(--wrong); text-decoration: line-through; text-decoration-thickness: 1px; }
.review-item__line--correct dd { color: var(--correct); }
.review-item .explanation { margin-top: 10px; }

/* Responsive -------------------------------------------------------------- */

@media (max-width: 760px) {
  .hero { display: block; min-height: 0; }
  .hero__image {
    position: static;
    display: block;
    width: calc(100% + 2 * var(--gutter));
    max-width: none;
    margin: -12px calc(-1 * var(--gutter)) -8px;
    transform: none;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 15%, #000 55%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 15%, #000 55%, transparent);
  }
  .hero .intro { max-width: none; }
}

@media (max-width: 600px) {
  main { padding-block: 20px 32px; }
  .card { padding: 18px; }
  .question__text { font-size: 17px; }
  .answer { padding: 12px; gap: 12px; }
  .exam-bar__readouts { gap: 6px 14px; }
  .exam-nav .button { padding: 0 12px; }
  .exam-nav .button span { display: none; }
  .exam-nav [data-action="open-overview"] span { display: inline; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .results__score { font-size: 44px; }
  .review-item__line { flex-direction: column; gap: 0; }
  .review-item__line dt { width: auto; }
  .resume-card .button-row { width: 100%; }
  .resume-card .button { flex: 1; }
}

/* Results celebration */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}
