/* KidNews Earth: one stylesheet for every page.
   Readable for grades 6-8, works on phones, light and dark mode. */

:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --text: #1f2a2e;
  --muted: #55636a;
  --accent: #1d6b75;
  --accent-soft: #e0f0ef;
  --border: #dcd8cc;
  --good: #1f7a3d;
  --good-soft: #e3f4e8;
  --bad: #a3361f;
  --bad-soft: #fbe7e2;
  --radius: 14px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181b;
    --surface: #1b2428;
    --text: #e8eef0;
    --muted: #a3b2b8;
    --accent: #6cc4cc;
    --accent-soft: #1f3a3e;
    --border: #2f3c41;
    --good: #7bd69a;
    --good-soft: #1d3626;
    --bad: #f29a85;
    --bad-soft: #3d221c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.65;
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

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

img { max-width: 100%; height: auto; display: block; }

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--surface); padding: 0.5rem 1rem; z-index: 10;
}
.skip-link:focus { left: 1rem; }

/* --- Header and footer ---------------------------------------------------- */

.site-header { background: var(--accent); color: #fff; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 0.9rem; }
.site-header a { color: #fff; text-decoration: none; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: 0.01em; }
.site-header nav a { font-size: 1rem; opacity: 0.95; }
.site-header nav a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) {
  .site-header { background: #163f45; }
}

.site-footer { margin-top: 3rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.95rem; }
.site-footer .wrap { padding-block: 1.5rem 2.5rem; }
.site-footer p { margin: 0.4rem 0; }

main { padding-block: 1.5rem; }

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 5vw, 2.4rem); margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1.4rem; margin: 2.25rem 0 0.75rem; }

.intro { color: var(--muted); margin-top: 0; }

/* --- Story cards (home page) ---------------------------------------------- */

.cards { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 1.25rem; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.card a.card-link { color: inherit; text-decoration: none; display: flex; flex-direction: column; height: 100%; }
.card a.card-link:hover h2 { text-decoration: underline; }
.card .media { aspect-ratio: 16 / 9; background: var(--accent-soft); }
.card .media img { width: 100%; height: 100%; object-fit: cover; }
.card .content { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }
.card h2 { font-size: 1.2rem; margin: 0; }
.card p { margin: 0; font-size: 1rem; }
.card .credit { color: var(--muted); font-size: 0.8rem; margin-top: auto; padding-top: 0.4rem; }

.tag {
  display: inline-block; align-self: flex-start; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 0.1rem 0.7rem; font-size: 0.85rem; font-weight: 600;
}

.notice {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 1.25rem; color: var(--muted); text-align: center;
}

/* --- Story page ----------------------------------------------------------- */

.meta { color: var(--muted); font-size: 0.95rem; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; }

figure { margin: 1.25rem 0; }
figure img { width: 100%; border-radius: var(--radius); background: var(--accent-soft); }
figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }

.lead { font-size: 1.25rem; font-weight: 500; }

.box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; box-shadow: var(--shadow);
}
.box dl { margin: 0; }
.box dt { font-weight: 700; margin-top: 0.75rem; }
.box dt:first-child { margin-top: 0; }
.box dd { margin: 0.15rem 0 0; }

.credit-box { border-left: 5px solid var(--accent); font-size: 1rem; }
.credit-box p { margin: 0.35rem 0; }

.back { display: inline-block; margin-bottom: 0.5rem; font-size: 1rem; }

/* --- Quiz ----------------------------------------------------------------- */

.question {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 1rem 1.1rem 1.1rem; margin: 0 0 1rem; box-shadow: var(--shadow);
}
.question legend { font-weight: 700; padding: 0 0.25rem; float: left; width: 100%; margin-bottom: 0.6rem; }
.question legend + * { clear: both; }

.options { display: grid; gap: 0.5rem; }

.option {
  display: flex; gap: 0.6rem; align-items: flex-start; width: 100%; text-align: left;
  font: inherit; font-size: 1.05rem; color: var(--text); background: var(--bg);
  border: 2px solid var(--border); border-radius: 10px; padding: 0.65rem 0.8rem; cursor: pointer;
  min-height: 48px;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option .letter { font-weight: 700; color: var(--muted); min-width: 1.4em; }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option .mark { margin-left: auto; font-weight: 700; }
.option.correct .mark { color: var(--good); }
.option.wrong .mark { color: var(--bad); }

.feedback { margin: 0.75rem 0 0; font-size: 1rem; }
.feedback strong.good { color: var(--good); }
.feedback strong.bad { color: var(--bad); }

.score { font-weight: 700; font-size: 1.15rem; }
.score-box { text-align: center; }

.button {
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 10px; padding: 0.6rem 1.2rem; cursor: pointer; min-height: 44px;
}
@media (prefers-color-scheme: dark) { .button { color: #0d1a1c; } }
.button:hover { filter: brightness(1.08); }

a.button { display: inline-block; text-decoration: none; }
.quiz-jump { margin-top: 0.9rem; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
#quiz-heading { scroll-margin-top: 1rem; }

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