/*
 * Geoquiz stylesheet.
 *
 * Plain CSS, no frameworks, no web fonts (nothing is loaded from other
 * sites, which the Content-Security-Policy would block anyway).
 * Colours are defined once as custom properties and redefined for dark mode.
 * The look is loosely "atlas page": warm paper, ink-blue text, a sea-teal
 * accent.
 */

:root {
  --paper: #f5f0e6;
  --card: #fffdf8;
  --ink: #1d2740;
  --muted: #5b6478;
  --line: #ddd4c2;
  --accent: #17676a;
  --accent-ink: #ffffff;
  --accent-soft: #e2efee;
  --right: #1f7a3d;
  --right-soft: #e5f3e8;
  --wrong: #a23b22;
  --wrong-soft: #f8e8e3;
  --focus: #c7861b;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161f;
    --card: #1a202c;
    --ink: #e9e4d8;
    --muted: #a3abbd;
    --line: #2e3647;
    --accent: #4fb3ad;
    --accent-ink: #0e1a1a;
    --accent-soft: #1d3132;
    --right: #6fcf8c;
    --right-soft: #193022;
    --wrong: #f0907a;
    --wrong-soft: #3a211b;
  }
}

*, *::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(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
}

/* ---- header / footer ---------------------------------------------- */

header.site, footer.site {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .01em;
}
.brand .mark { color: var(--accent); }
.tag { color: var(--muted); font-size: .95rem; }

footer.site { margin-top: auto; color: var(--muted); font-size: .875rem; }

main {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---- card ---------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  box-shadow: 0 1px 0 var(--line), 0 12px 32px -24px rgba(0, 0, 0, .35);
}

h1, h2 { font-family: var(--serif); line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: clamp(1.45rem, 4.5vw, 1.9rem); }
h2 { font-size: 1.25rem; margin-top: 2rem; }

.eyebrow {
  margin: 0 0 .5rem;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.lede { font-size: 1.05rem; }

/* ---- progress ------------------------------------------------------ */

.progress-row { margin-bottom: 1.25rem; }

progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: .5rem;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ---- images -------------------------------------------------------- */

.q-image { margin: 0 0 1.25rem; }
.q-image img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid var(--line);
}
.q-image.small img { max-height: 14rem; width: auto; }
.q-image figcaption { color: var(--muted); font-size: .8rem; text-align: center; margin-top: .4rem; }

/* ---- question form ------------------------------------------------- */

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; width: 100%; }
.prompt { font-size: clamp(1.3rem, 4vw, 1.65rem); }

.choices { display: grid; gap: .65rem; margin-top: .5rem; }

.choice {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.choice:hover { border-color: var(--accent); }

/* Hide the native radio visually but keep it focusable and accessible. */
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice .letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid var(--line);
  font-weight: 700;
  font-size: .9rem;
  color: var(--muted);
}

.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:checked) .letter { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.error {
  color: var(--wrong);
  background: var(--wrong-soft);
  border-radius: 8px;
  padding: .5rem .75rem;
  font-weight: 600;
}

/* ---- buttons ------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.5rem;
}
.actions form { margin: 0; }

.button {
  display: inline-block;
  padding: .75rem 1.35rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button:hover { filter: brightness(1.08); }
.button:focus-visible, .brand:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---- feedback ------------------------------------------------------ */

.verdict {
  display: inline-block;
  font-weight: 800;
  font-size: 1.1rem;
  padding: .35rem .9rem;
  border-radius: 999px;
  margin: 0 0 1rem;
}
.verdict.right { color: var(--right); background: var(--right-soft); }
.verdict.wrong { color: var(--wrong); background: var(--wrong-soft); }

.answers { margin: 0 0 1rem; display: grid; gap: .5rem; }
.answers .row {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  padding: .7rem 1rem;
  border-radius: 10px;
  border-left: 5px solid;
}
.answers .row.right { border-color: var(--right); background: var(--right-soft); }
.answers .row.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.answers dt { font-weight: 700; min-width: 8rem; }
.answers dd { margin: 0; }

.explanation {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  white-space: pre-line; /* explanations may contain line breaks */
}
.running { color: var(--muted); }

/* ---- results ------------------------------------------------------- */

.score {
  font-family: var(--serif);
  margin: .25rem 0 .5rem;
  font-size: 3.5rem;
  line-height: 1;
}
.score strong { color: var(--accent); }
.score span { color: var(--muted); font-size: 2rem; }

.review { padding-left: 1.4rem; margin: 0; }
.review li { margin-bottom: .9rem; }
.review .q { margin: 0; font-weight: 600; }
.review .a { margin: .15rem 0 0; color: var(--muted); }
.review .right .mark { color: var(--right); }
.review .wrong .mark { color: var(--wrong); }

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