/* Motyw: kartka egzaminacyjna. Granatowy nagłówek, żółty "ołówek" jako akcent akcji,
   niebieski "długopis" dla zaznaczeń, odpowiedzi jako kwadratowe pola do zamalowania. */

:root {
  --navy: #121b3a;
  --navy-soft: #b9c2e6;
  --paper: #f3f5fb;
  --sheet: #ffffff;
  --ink: #151d38;
  --muted: #5b6685;
  --line: #d9deec;
  --blue: #2f4bdb;
  --blue-ink: #ffffff;
  --blue-soft: #e8ecff;
  --pencil: #ffc83d;
  --pencil-edge: #e0a800;
  --pencil-ink: #2a2100;
  --ok: #0f7a55;
  --ok-bg: #ddf4ea;
  --bad: #c22b2b;
  --bad-bg: #fde4e2;
  --miss: #8a5a00;
  --miss-bg: #fff0cc;
  --c1: #2f4bdb;
  --c2: #0e9f8e;
  --c3: #7a4de0;
  --c4: #f08a24;
  --shadow: 0 1px 2px rgb(18 27 58 / 0.06), 0 10px 28px rgb(18 27 58 / 0.09);
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #0a0f22;
    --navy-soft: #a9b4de;
    --paper: #0d1226;
    --sheet: #161d3a;
    --ink: #eaeeff;
    --muted: #a3adcf;
    --line: #2b3566;
    --blue: #8da2ff;
    --blue-ink: #0c1536;
    --blue-soft: #1f2a5e;
    --ok: #5fd39a;
    --ok-bg: #12301f;
    --bad: #ff8f84;
    --bad-bg: #3a1714;
    --miss: #f2c265;
    --miss-bg: #33270b;
    --c1: #8da2ff;
    --c2: #4fd6c4;
    --c3: #b39bff;
    --c4: #ffa94d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 28px rgb(0 0 0 / 0.35);
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 var(--sans);
  min-height: 100vh;
}

.wrap { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0 0 0.75rem; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.loading { color: var(--muted); }

.section-title { font-size: 1.05rem; font-weight: 700; margin: 2rem 0 0.75rem; }

/* ---------- Nagłówek i hero ---------- */

.top { background: var(--navy); }
.top .brand {
  display: block;
  max-width: 52rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.hero { background: var(--navy); color: #fff; }
.hero .wrap { padding-top: 1rem; padding-bottom: 2.75rem; }
.hero-in { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}
.hero .lead { color: var(--navy-soft); font-size: 1.1rem; max-width: 30rem; margin-bottom: 1.25rem; }

.stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.stats li {
  padding: 0.3rem 0.8rem;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Motyw: karta odpowiedzi z kilkoma zamalowanymi polami. */
.hero-art {
  display: grid;
  grid-template-columns: repeat(4, 2.1rem);
  gap: 0.6rem;
  flex: none;
  transform: rotate(-4deg);
}
.hero-art span { width: 2.1rem; height: 2.1rem; border-radius: 0.5rem; border: 2px solid rgb(255 255 255 / 0.4); }
.hero-art span.on { background: var(--pencil); border-color: var(--pencil); }

/* ---------- Przyciski ---------- */

.btn {
  font: inherit;
  font-weight: 650;
  min-height: 2.9rem;
  padding: 0.65rem 1.2rem;
  border-radius: 0.75rem;
  border: 2px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { border-color: var(--blue); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--pencil);
  border-color: var(--pencil-edge);
  color: var(--pencil-ink);
  box-shadow: 0 2px 0 var(--pencil-edge);
}
.btn.primary:hover:not(:disabled) { background: #ffd35f; border-color: var(--pencil-edge); }
.btn.big { min-height: 3.4rem; padding: 0.8rem 1.8rem; font-size: 1.1rem; }
.btn.ghost { background: transparent; }

.link {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--blue);
  text-decoration: underline;
  cursor: pointer;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; align-items: center; }
.actions .spacer { flex: 1; }
.start-actions { margin-top: 2rem; }

/* ---------- Ekran startowy: zestawy, tryby, opcje ---------- */

.sets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }

.setcard,
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  background: var(--sheet);
  border: 2px solid var(--line);
  border-radius: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.setcard { padding-left: 1.5rem; --accent: var(--blue); }
.setcard::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 0.9rem;
  bottom: 0.9rem;
  width: 0.3rem;
  border-radius: 999px;
  background: var(--accent);
}
.setcard.c1 { --accent: var(--c1); }
.setcard.c2 { --accent: var(--c2); }
.setcard.c3 { --accent: var(--c3); }
.setcard.c4 { --accent: var(--c4); }
.setcard.all { --accent: var(--ink); }
.setcard.wide { grid-column: 1 / -1; }

.setcard:hover,
.tile:hover { border-color: var(--blue); }
.setcard:has(input:checked),
.tile:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: var(--shadow);
}
.setcard:has(input:focus-visible),
.tile:has(input:focus-visible),
.toggle:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 3px; }

.setcard input,
.tile input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

/* Znacznik wyboru, dubluje kolor ramki. */
.setcard:has(input:checked)::after,
.tile:has(input:checked)::after {
  content: "✓";
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: var(--blue-ink);
  font-size: 0.85rem;
  font-weight: 800;
}

.setcard .title,
.tile .title { font-weight: 700; font-size: 1.1rem; padding-right: 2rem; }
.setcard .meta,
.tile .meta { color: var(--muted); font-size: 0.9rem; }

.chip {
  align-self: flex-start;
  margin-top: 0.35rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}
.setcard:has(input:checked) .chip { background: var(--sheet); }
.chip.solid { background: var(--navy); border-color: var(--navy); color: #fff; margin: 0; }

.toggles { background: var(--sheet); border: 2px solid var(--line); border-radius: 1rem; overflow: hidden; }
.toggle { display: flex; gap: 0.85rem; align-items: flex-start; padding: 0.9rem 1.1rem; cursor: pointer; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle input { margin: 0.3rem 0 0; width: 1.15rem; height: 1.15rem; accent-color: var(--blue); flex: none; }
.toggle-text { display: flex; flex-direction: column; }
.toggle .title { font-weight: 650; }
.toggle .meta { color: var(--muted); font-size: 0.9rem; }

.notice {
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  background: var(--miss-bg);
  color: var(--ink);
  border-left: 4px solid var(--miss);
  margin: 1.5rem 0 0;
  font-size: 0.925rem;
}
.notice.bad { background: var(--bad-bg); border-left-color: var(--bad); }
.notice.info { background: var(--sheet); border: 1px solid var(--line); border-left: 4px solid var(--blue); box-shadow: var(--shadow); }
.notice.resume { margin: 0 0 0.5rem; }
.notice p:last-child { margin-bottom: 0; }
.notice .actions { margin-top: 0.75rem; }

.history { list-style: none; padding: 0; margin: 0; font-size: 0.925rem; background: var(--sheet); border: 1px solid var(--line); border-radius: 1rem; }
.history li { display: flex; gap: 1rem; padding: 0.65rem 1rem; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history .when { color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ---------- Pytanie ---------- */

.session-bar { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.session-bar .where { font-weight: 700; }
.session-bar .link { margin-left: auto; font-size: 0.9rem; }

.bar { height: 0.55rem; background: var(--line); border-radius: 999px; overflow: hidden; margin: 0.7rem 0 1.25rem; }
.bar > span { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width 0.25s; }

.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.chip-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.qid { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.question {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.45;
  font-weight: 650;
  margin: 0 0 0.5rem;
  max-width: 40rem;
}
.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }

.answers { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.65rem; }

.answer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: start;
  padding: 0.85rem 1rem;
  background: var(--sheet);
  border: 2px solid var(--line);
  border-radius: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.answer:hover { border-color: var(--blue); background: var(--blue-soft); }
.answer:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 3px; }
.answer input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

.bubble {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.5rem;
  border: 2px solid var(--muted);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
  background: transparent;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.answer .text { padding-top: 0.25rem; overflow-wrap: anywhere; }
.answer .tag { font-size: 0.8rem; font-weight: 700; padding-top: 0.35rem; white-space: nowrap; }

/* :where() zeruje specyficzność, żeby stany wyniku (poniżej) zawsze wygrywały. */
.answer:where(:has(input:checked)) { border-color: var(--blue); background: var(--blue-soft); }
.answer:where(:has(input:checked)) .bubble { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }

.answer.locked { cursor: default; }
.answer.locked:hover { background: var(--sheet); border-color: var(--line); }

/* Kolor zawsze jest dublowany etykietą tekstową (Poprawna / Błędna / Pominięta). */
.answer.is-correct,
.answer.is-correct:hover { border-color: var(--ok); background: var(--ok-bg); }
.answer.is-correct .bubble { background: var(--ok); border-color: var(--ok); color: var(--sheet); }
.answer.is-correct .tag { color: var(--ok); }
.answer.is-wrong,
.answer.is-wrong:hover { border-color: var(--bad); background: var(--bad-bg); }
.answer.is-wrong .bubble { background: var(--bad); border-color: var(--bad); color: var(--sheet); }
.answer.is-wrong .tag { color: var(--bad); }
.answer.is-missed,
.answer.is-missed:hover { border-color: var(--miss); background: var(--miss-bg); border-style: dashed; }
.answer.is-missed .bubble { border-color: var(--miss); color: var(--miss); }
.answer.is-missed .tag { color: var(--miss); }

.verdict { margin-top: 1.1rem; padding: 0.85rem 1rem; border-radius: 0.85rem; font-weight: 700; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict .detail { display: block; font-weight: 400; color: var(--ink); margin-top: 0.15rem; font-size: 0.925rem; }

.map { margin-top: 1.75rem; }
.map summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.map-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.map-grid button {
  font: inherit;
  font-size: 0.85rem;
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.55rem;
  border: 2px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.map-grid button.answered { border-color: var(--blue); }
.map-grid button.current { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }
.map-grid button.done-ok { border-color: var(--ok); color: var(--ok); }
.map-grid button.done-bad { border-color: var(--bad); color: var(--bad); }
.map-grid button.current.done-ok,
.map-grid button.current.done-bad { color: var(--blue-ink); }

/* ---------- Wyniki ---------- */

.result {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.ring-box { position: relative; width: 9rem; height: 9rem; flex: none; --tone: var(--blue); }
.ring-box.good { --tone: var(--ok); }
.ring-box.mid { --tone: var(--miss); }
.ring-box.low { --tone: var(--bad); }
.ring { width: 100%; height: 100%; display: block; }
.ring-track { stroke: var(--line); }
.ring-fill { stroke: var(--tone); }
.ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--tone);
}
.result-title { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; margin: 0.1rem 0 0.25rem; }
.result-score { font-size: 1.1rem; margin-bottom: 0.75rem; }

.tally { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; font-size: 0.9rem; }
.tally li { padding: 0.2rem 0.75rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.tally b { font-variant-numeric: tabular-nums; }

.filter { display: flex; gap: 1.25rem; margin: 2rem 0 0.75rem; flex-wrap: wrap; align-items: center; }
.filter label { display: inline-flex; gap: 0.45rem; align-items: center; cursor: pointer; font-weight: 600; }
.filter input { accent-color: var(--blue); width: 1.05rem; height: 1.05rem; }

.review { display: grid; gap: 0.6rem; }
.review details { background: var(--sheet); border: 2px solid var(--line); border-radius: 1rem; }
.review details[open] { box-shadow: var(--shadow); }
.review summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.8rem 1rem;
  cursor: pointer;
  list-style: none;
}
.review summary::-webkit-details-marker { display: none; }
.review summary::before { content: "+"; font-weight: 700; color: var(--muted); width: 0.8rem; }
.review details[open] summary::before { content: "−"; }
.review .rid { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.review .rq { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review .status { font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.review .status.correct { color: var(--ok); }
.review .status.wrong { color: var(--bad); }
.review .status.unanswered { color: var(--miss); }
.review .status.pending { color: var(--muted); }
.review .body { padding: 0.25rem 1rem 1.1rem; }
.review .body .question { font-size: 1.1rem; margin-bottom: 0.85rem; }

/* ---------- Dialog ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--sheet);
  color: var(--ink);
  padding: 1.5rem;
  max-width: min(28rem, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(10 14 34 / 0.6); }
dialog h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
dialog .actions { margin-top: 1.25rem; justify-content: flex-end; }

/* ---------- Małe ekrany ---------- */

@media (max-width: 38rem) {
  .hero-art { display: none; }
  .sets, .tiles { grid-template-columns: 1fr; }
  .sheet { padding: 1.25rem; border-radius: 1.25rem; }
  .question { font-size: 1.2rem; }
  .actions .btn { flex: 1 1 100%; }
  .actions .spacer { display: none; }
  .answer { grid-template-columns: auto 1fr; }
  .answer .tag { grid-column: 2; padding-top: 0; }
  .result { flex-direction: column; text-align: center; gap: 1.25rem; }
  .tally { justify-content: center; }
  .review summary { grid-template-columns: auto auto minmax(0, 1fr); }
  .review .status { grid-column: 2 / -1; }
}

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