/* Shared styles for quiz pages. Load after styles.css. */

:root {
  --right: #16a34a;
  --right-bg: #dcfce7;
  --wrong: #dc2626;
  --wrong-bg: #fee2e2;
  --select: #f59e0b;
  --track: #94a3b8;
  --tile: #fef3c7;
  --tile-text: #78350f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --right: #4ade80;
    --right-bg: #14532d;
    --wrong: #f87171;
    --wrong-bg: #7f1d1d;
    --select: #fbbf24;
    --track: #475569;
    --tile: #78350f;
    --tile-text: #fef3c7;
  }
}

/* Compact hero for category and quiz pages */
.hero--slim { padding: 28px 0 24px; }
.hero--trains { background: linear-gradient(135deg, #b91c1c, #7c2d12); }
.hero--aircraft { background: linear-gradient(135deg, #0369a1, #1e3a8a); }
.theme-aircraft { --qz-accent: var(--aircraft); }
.crumbs { margin: 0 0 8px; font-size: 0.95rem; }
.crumbs a { color: #fff; opacity: 0.85; }
.crumbs a:hover { opacity: 1; }

/* Category page quiz cards */
.quiz-list--big { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.quiz__emoji { font-size: 2.2rem; line-height: 1; }
.quiz__levels { font-size: 0.85rem; font-weight: 600; color: var(--topic); }

/* Quiz app */
.quiz-app { max-width: 720px; padding-top: 20px; }

.qz-card {
  margin-top: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 6px solid var(--qz-accent, var(--trains));
  border-radius: var(--radius);
}

.qz-start { text-align: center; }
.qz-start__emoji { font-size: 4rem; line-height: 1; }
.qz-intro { font-size: 1.2rem; margin: 12px 0 4px; }
.qz-sub { margin: 20px 0 12px; font-size: 1.2rem; }

.qz-levels { display: grid; gap: 12px; }
.qz-level {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "emoji name" "emoji blurb" "emoji best";
  column-gap: 14px;
  align-items: center;
  text-align: left;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.qz-level:hover, .qz-level:focus-visible { border-color: var(--qz-accent, var(--trains)); transform: translateY(-2px); }
.qz-level__emoji { grid-area: emoji; font-size: 2.4rem; }
.qz-level__name { grid-area: name; font-weight: 800; font-size: 1.2rem; }
.qz-level__blurb { grid-area: blurb; color: var(--muted); font-size: 0.95rem; }
.qz-level__best { grid-area: best; font-size: 0.9rem; font-weight: 600; }
.qz-level--easy { border-left: 8px solid #22c55e; }
.qz-level--medium { border-left: 8px solid #f59e0b; }
.qz-level--hard { border-left: 8px solid #a855f7; }

/* Progress track with a little train */
.qz-hud { margin-top: 8px; }
.qz-track {
  position: relative;
  height: 34px;
  margin: 0 22px 0 4px;
  background: repeating-linear-gradient(90deg, var(--track) 0 4px, transparent 4px 14px) bottom 6px left / 100% 6px no-repeat;
  border-bottom: 3px solid var(--track);
}
.qz-track__train {
  position: absolute;
  bottom: 4px;
  font-size: 1.7rem;
  line-height: 1;
  transform: translateX(-50%) scaleX(-1);
  transition: left 0.6s ease-out;
}
.qz-track__station { position: absolute; right: -24px; bottom: 4px; font-size: 1.4rem; line-height: 1; }
.qz-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  margin-top: 8px;
  font-weight: 700;
}
.qz-streak { color: #ea580c; }

/* The aircraft track: a plane flying to the runway instead of a train */
.qz-track--sky { background: none; border-bottom-style: dashed; }
.qz-track__plane { transform: translateX(-50%); }

/* Photos and credits */
.qz-photo { margin: 0 0 12px; }
.qz-photo img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  background: #0f172a;
  border-radius: 12px;
}
.qz-photo--small img { max-height: 220px; }
.qz-credit { margin-top: 4px; font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; }
.qz-credit a { color: inherit; }

.qz-prompt { margin: 8px 0 14px; font-size: 1.35rem; line-height: 1.3; }
.qz-prompt--statement {
  padding: 14px 16px;
  background: var(--bg);
  border-left: 6px solid var(--select);
  border-radius: 10px;
  font-size: 1.25rem;
  font-weight: 600;
}
.qz-context { margin: 0 0 6px; font-weight: 700; color: var(--muted); }

/* Mystery zoom: a close-up that zooms out once answered */
.qz-zoom__frame {
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: #0f172a;
  border-radius: 12px;
}
.qz-zoom__frame img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  border-radius: 0;
  transition: transform 0.8s ease-out;
}
.qz-row--tight { margin: 0 0 8px; }
.qz-prompt--center { text-align: center; }

/* Head to head: tap one of two aircraft */
.qz-duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.qz-duel__vs { font-weight: 900; font-size: 1.3rem; color: var(--muted); }
.qz-duel__pick {
  display: grid;
  gap: 6px;
  padding: 6px 6px 10px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.qz-duel__pick:hover:not(:disabled) { border-color: var(--qz-accent, var(--trains)); transform: translateY(-2px); }
.qz-duel__pick:disabled { cursor: default; }
.qz-duel__pick img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #0f172a; }
.qz-duel__name { font-weight: 800; font-size: 1.05rem; }
.qz-duel__stat:empty { display: none; }
.qz-duel__stat { font-weight: 700; font-size: 0.95rem; }
.qz-duel__pick.is-right { background: var(--right-bg); border-color: var(--right); }
.qz-duel__pick.is-wrong { background: var(--wrong-bg); border-color: var(--wrong); }
.qz-duel__pick.is-right .qz-duel__name::after { content: " ✔"; }
.qz-duel__pick.is-wrong .qz-duel__name::after { content: " ✘"; }
@media (max-width: 420px) {
  .qz-duel { gap: 6px; }
  .qz-duel__vs { font-size: 1rem; }
  .qz-duel__name { font-size: 0.95rem; }
}

/* Answer buttons */
.qz-options { display: grid; gap: 10px; }
@media (min-width: 560px) {
  .qz-options { grid-template-columns: 1fr 1fr; }
}
.qz-options--many { grid-template-columns: 1fr 1fr; }
.qz-options--tf { grid-template-columns: 1fr 1fr; }
.qz-options--tf .qz-option { font-size: 1.4rem; padding: 18px; }

.qz-option, .qz-btn {
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.qz-option:hover:not(:disabled), .qz-btn:hover { border-color: var(--qz-accent, var(--trains)); transform: translateY(-1px); }
.qz-option:disabled { cursor: default; opacity: 0.7; }
.qz-option.is-right, .qz-pair-name.is-right { opacity: 1; background: var(--right-bg); border-color: var(--right); }
.qz-option.is-wrong, .qz-pair-name.is-wrong { opacity: 1; background: var(--wrong-bg); border-color: var(--wrong); }
.qz-option.is-right::after { content: " ✔"; }
.qz-option.is-wrong::after { content: " ✘"; }

.qz-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.qz-btn--go { background: var(--qz-accent, var(--trains)); border-color: var(--qz-accent, var(--trains)); color: #fff; }
.qz-btn--go:hover { filter: brightness(1.08); }

.qz-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.qz-row--center { justify-content: center; }

.qz-feedback:empty { display: none; }
.qz-feedback { margin-top: 16px; }
.qz-verdict { margin: 0 0 6px; font-size: 1.3rem; font-weight: 800; }
.qz-verdict.is-right { color: var(--right); }
.qz-verdict.is-wrong { color: var(--wrong); }
.qz-explain { margin: 0 0 12px; }
.qz-muted { color: var(--muted); }

/* Anagram */
.qz-anagram { display: flex; flex-wrap: wrap; gap: 14px 22px; justify-content: center; margin: 8px 0 18px; }
.qz-word { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.qz-slot, .qz-tile {
  width: 44px;
  height: 52px;
  padding: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  cursor: pointer;
}
.qz-slot { border: 2px dashed var(--track); background: var(--bg); color: inherit; }
.qz-slot.is-filled { border-style: solid; border-color: var(--select); }
.qz-slot.is-locked { border-style: solid; border-color: var(--right); background: var(--right-bg); cursor: default; }
.qz-slot:disabled { color: inherit; }
.qz-anagram.is-solved .qz-slot { border-color: var(--right); background: var(--right-bg); }
.qz-anagram.is-revealed .qz-slot { border-color: var(--select); }
.qz-tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.qz-tile {
  border: 2px solid #d97706;
  background: var(--tile);
  color: var(--tile-text);
  box-shadow: 0 3px 0 #d97706;
}
.qz-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 #d97706; }
.qz-tile:disabled { visibility: hidden; }
@media (max-width: 420px) {
  .qz-slot, .qz-tile { width: 36px; height: 44px; font-size: 1.25rem; }
}
.shake { animation: qz-shake 0.4s; }
@keyframes qz-shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Match the pairs */
.qz-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.qz-pairs__photos { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) {
  .qz-pairs__photos { grid-template-columns: 1fr 1fr; }
}
.qz-pairs__names { display: grid; gap: 8px; }
.qz-pair-photo {
  position: relative;
  padding: 0;
  border: 4px solid transparent;
  border-radius: 12px;
  background: #0f172a;
  cursor: pointer;
  overflow: hidden;
}
.qz-pair-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.qz-pair-photo.is-selected { border-color: var(--select); transform: scale(1.03); }
.qz-pair-photo.is-right { border-color: var(--right); cursor: default; }
.qz-pair-num, .qz-pair-tag {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--select);
  color: #1e1b4b;
  font-weight: 800;
  font-size: 0.9rem;
}
.qz-pair-num { position: absolute; top: 6px; left: 6px; }
.qz-pair-photo.is-right .qz-pair-num { background: var(--right); color: #fff; }
.qz-pair-tag { margin-right: 6px; background: var(--right); color: #fff; }
.qz-pair-name {
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.qz-pair-name:disabled { cursor: default; }
.qz-credits { margin-top: 16px; font-size: 0.8rem; color: var(--muted); }
.qz-credits ol { padding-left: 20px; }
.qz-credits > p { margin: 0 0 4px; font-weight: 700; }
.qz-credits .qz-credit { margin: 0 0 4px; }

/* Word search (board from /assets/word-search.js) */
.ws { display: grid; gap: 14px; }
.ws-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--ws-n), 1fr);
  width: 100%;
  max-width: min(560px, 68vh);
  margin: 0 auto;
  aspect-ratio: 1;
  padding: 4px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
  /* Letters scale with the grid: about half a cell tall. */
  font-size: calc(min(100vw - 72px, 552px, 68vh - 14px) / var(--ws-n) * 0.55);
}
.ws-grid:focus-visible { outline: 3px solid var(--qz-accent, var(--trains)); outline-offset: 2px; }
.ws-grid.is-done { cursor: default; }
.ws-cell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  font-weight: 800;
  line-height: 1;
  border-radius: 50%;
}
.ws-cell.is-anchor { background: var(--select); color: #1e1b4b; }
.ws-cell.is-cursor { box-shadow: inset 0 0 0 2px var(--qz-accent, var(--trains)); }
.ws-cell.is-hint { animation: ws-glow 1s ease-in-out infinite alternate; }
@keyframes ws-glow {
  from { background: transparent; }
  to { background: var(--select); color: #1e1b4b; }
}
.ws-marks { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); pointer-events: none; }
.ws-marks line { stroke-width: 0.78; stroke-linecap: round; }
.ws-mark { opacity: 0.45; }
.ws-mark--shown { stroke: var(--muted); opacity: 0.3; stroke-dasharray: 0.01 0.25; }
.ws-live { stroke: var(--select); opacity: 0.55; }
.ws-miss { animation: qz-shake 0.35s; }

.ws-words { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0; padding: 0; list-style: none; }
.ws-word {
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-weight: 800;
  letter-spacing: 0.04em;
}
.ws-word.is-found { border-color: var(--right); background: var(--right-bg); text-decoration: line-through; text-decoration-thickness: 3px; }
.ws-word.is-found::before { content: "✔ "; }
.ws-word.is-shown { border-style: dashed; color: var(--muted); }
/* Fun facts pile up under the grid as words are found. Turn off scroll
   anchoring on word search pages, or the browser scrolls the grid away. */
html:has(.ws-app) { overflow-anchor: none; }
.ws-log { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.ws-log li { padding: 8px 12px; border-left: 5px solid var(--right); border-radius: 8px; background: var(--bg); }
.ws-log b { letter-spacing: 0.04em; }
.ws-log .is-hinted { border-left-color: var(--select); }
.ws-log .is-shown { border-left-color: var(--track); color: var(--muted); }

/* End screen */
.qz-end { text-align: center; }
.qz-end__stars { font-size: 3rem; letter-spacing: 6px; color: #f59e0b; }
.qz-end__title { margin: 8px 0; font-size: 1.7rem; }
.qz-end__score { font-size: 1.3rem; font-weight: 700; }
.qz-end__best { font-weight: 800; color: var(--right); }

/* Confetti */
.qz-confetti {
  position: fixed;
  top: -40px;
  z-index: 10;
  pointer-events: none;
  animation: qz-fall 2.2s ease-in forwards;
}
@keyframes qz-fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  .qz-track__train { transition: none; }
  .qz-zoom__frame img { transition: none; }
  .shake, .ws-miss, .ws-cell.is-hint { animation: none; }
  .ws-cell.is-hint { background: var(--select); color: #1e1b4b; }
}

/* Rockets: purple accent, a rocket flying to the Moon, and tall photos */
.hero--rockets { background: linear-gradient(135deg, #6d28d9, #0f172a); }
.theme-rockets { --qz-accent: var(--rockets); }
.qz-track--space { background: radial-gradient(circle, var(--track) 1.5px, transparent 2px) bottom 8px left / 18px 6px repeat-x; border-bottom: none; }
.qz-track__rocket { transform: translateX(-50%) rotate(45deg); }
.theme-rockets .qz-duel__pick img { aspect-ratio: 3 / 4; object-fit: cover; }
.qz-duel--four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) {
  .qz-duel--four { grid-template-columns: 1fr 1fr; }
}

/* Height chart: two rockets next to a 9-year-old */
.qz-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 18px;
  height: 220px;
  margin: 8px 0 16px;
  padding: 0 8px;
}
.qz-bars__col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 84px; }
.qz-bars__bar { width: 34px; background: var(--qz-accent, var(--rockets)); border-radius: 17px 17px 4px 4px; transition: height 0.8s ease-out; }
.qz-bars__bar--kid { width: 18px; background: var(--select); border-radius: 9px 9px 2px 2px; }
.qz-bars__value { font-weight: 800; font-size: 0.9rem; margin-bottom: 4px; }
.qz-bars__label { margin-top: 6px; font-size: 0.8rem; font-weight: 700; text-align: center; line-height: 1.2; min-height: 2.4em; border-top: 3px solid var(--track); padding-top: 4px; width: 100%; }
