/* ==========================================================================
   Matura-Trainer styles
   Sections: tokens · base · layout · header · topic picker · progress
   register · tabs · sheet · answer · buttons · stamp · recall · quiz ·
   oral · listen · responsive
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --paper: #EEF0EA;
  --surface: #FAFBF7;
  --ink: #1C2630;
  --muted: #5A6570;
  --line: #D3D8CE;
  --accent: #2E6A4E;
  --accent-soft: #DCE9E0;
  --red: #B0362D;
  --red-soft: #F3DEDA;
  --amber: #9A6A12;
  --amber-soft: #F2E7CF;
  --shadow: 0 1px 0 rgba(28, 38, 48, .06), 0 8px 24px -12px rgba(28, 38, 48, .18);
  --stamp-blend: multiply;

  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* Dark tokens: the same values are needed twice, once for the system
   setting and once for an explicit data-theme="dark". Keep them in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #12171B;
    --surface: #1A2126;
    --ink: #E4E8E1;
    --muted: #98A2AB;
    --line: #2E383F;
    --accent: #72B791;
    --accent-soft: #1E3329;
    --red: #E3786D;
    --red-soft: #3A2220;
    --amber: #D9A94A;
    --amber-soft: #352B17;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --stamp-blend: normal;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #12171B;
  --surface: #1A2126;
  --ink: #E4E8E1;
  --muted: #98A2AB;
  --line: #2E383F;
  --accent: #72B791;
  --accent-soft: #1E3329;
  --red: #E3786D;
  --red-soft: #3A2220;
  --amber: #D9A94A;
  --amber-soft: #352B17;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --stamp-blend: normal;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
  padding-inline: 16px;
  padding-block: 20px 48px;
}

h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.label {
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

/* ---------- Layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Header ---------- */
header { display: flex; flex-direction: column; gap: 6px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
h1 { font-size: clamp(30px, 6vw, 44px); font-weight: 800; font-stretch: 78%; letter-spacing: -.01em; line-height: 1; }
h1 span { color: var(--accent); }

/* ---------- Topic picker ---------- */
.picker { display: flex; flex-direction: column; gap: 8px; }

.current {
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: inset 0 -4px 0 var(--accent);
}
.cur-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cur-text b {
  font-family: var(--f-display);
  font-weight: 780;
  font-stretch: 84%;
  font-size: clamp(20px, 4vw, 26px);
  line-height: 1.1;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.cur-text small { font-size: 13px; color: var(--muted); }
.cur-text .label { color: var(--accent); }

.switch {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
}
.current[aria-expanded="true"] .switch svg { transform: rotate(180deg); }
.current:hover .switch { border-color: var(--ink); color: var(--ink); }

.pickerlist { padding: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.subj > .label { display: block; padding: 8px 16px 4px; }
.subj ul { list-style: none; margin: 0; padding: 0; }

.trow {
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name count" "info info" "bar bar";
  column-gap: 12px;
  row-gap: 3px;
}
.trow:hover { background: var(--paper); }
.trow[aria-current="true"] { background: var(--accent-soft); }
.tname { grid-area: name; font-weight: 700; }
.tinfo { grid-area: info; font-size: 13px; color: var(--muted); }
.tcount { grid-area: count; font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tprog { grid-area: bar; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.tprog i { display: block; height: 100%; background: var(--accent); }

/* ---------- Progress register (question tiles) ---------- */
.register { display: grid; grid-template-columns: repeat(var(--cols, 9), minmax(0, 1fr)); gap: 6px; }

.reg {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 4px;
  padding: 6px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.reg b { font-family: var(--f-display); font-stretch: 80%; font-size: 18px; line-height: 1; }
.reg i {
  font-style: normal;
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.reg[data-s="2"] { background: var(--accent-soft); border-color: var(--accent); }
.reg[data-s="2"] i { color: var(--accent); }
.reg[data-s="1"] { background: var(--amber-soft); border-color: var(--amber); }
.reg[data-s="1"] i { color: var(--amber); }
.reg:hover { border-color: var(--ink); }

.reglegend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.reglegend .label b { color: var(--ink); }

.reset {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sync { font-family: var(--f-mono); font-size: 11px; letter-spacing: .04em; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.sync[data-s="synced"]::before { background: var(--accent); }
.sync[data-s="saving"]::before { background: var(--amber); }
.sync[data-s="error"]::before { background: var(--red); }

/* ---------- Tabs ---------- */
nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
nav button {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 10px 10px 9px;
  font-family: var(--f-display);
  font-weight: 650;
  font-stretch: 88%;
  font-size: 15.5px;
  color: var(--muted);
  white-space: nowrap;
  margin-bottom: -1px;
}
nav button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

/* ---------- Sheet (card-like panel) ---------- */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.sheet-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 18px; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.sheet-body { padding: 20px 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.qtext { font-family: var(--f-display); font-weight: 650; font-stretch: 92%; font-size: clamp(20px, 3.6vw, 25px); line-height: 1.25; }

/* ---------- Answer content ---------- */
.answer { border-top: 2px solid var(--ink); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.answer.plain { border: 0; padding-top: 10px; }
.answer p { margin: 0; max-width: 65ch; }
.answer ol, .answer ul { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 7px; }
.answer li::marker { font-family: var(--f-mono); font-size: .85em; color: var(--muted); }
.answer li b { color: var(--accent); }

.tip { background: var(--amber-soft); border-left: 3px solid var(--amber); padding: 9px 12px; border-radius: 0 4px 4px 0; font-size: 14.5px; }
.tip .label { color: var(--amber); display: block; margin-bottom: 2px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
.tablewrap table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14px; }
.tablewrap th, .tablewrap td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.tablewrap thead th { font-family: var(--f-display); font-stretch: 88%; background: var(--paper); }
.tablewrap tbody th { font-weight: 700; color: var(--muted); font-size: 13px; width: 28%; }
.tablewrap tr:last-child > * { border-bottom: 0; }

details > summary.label { cursor: pointer; }

/* ---------- Buttons and toggles ---------- */
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1.5px solid var(--ink);
  background: var(--surface);
  border-radius: 4px;
  padding: 9px 16px;
  font-family: var(--f-display);
  font-weight: 650;
  font-stretch: 90%;
  font-size: 15px;
}
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.good { border-color: var(--accent); color: var(--accent); }
.btn.good:hover { background: var(--accent); color: var(--surface); }
.btn.bad { border-color: var(--red); color: var(--red); }
.btn.bad:hover { background: var(--red); color: var(--surface); }
.btn:disabled { opacity: .4; cursor: default; }
.btn kbd { font-family: var(--f-mono); font-size: 11px; opacity: .6; margin-left: 6px; }

.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.toggle button {
  background: var(--surface);
  border: 0;
  padding: 6px 10px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.toggle button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.feedback { min-height: 1.5em; font-size: 14.5px; color: var(--muted); }
.feedback.ok { color: var(--accent); }
.feedback.no { color: var(--red); }

/* ---------- Stamp ("GEWUSST" / "NOCHMAL" on a card) ---------- */
.stamp {
  position: absolute;
  right: 18px;
  top: 48px;
  font-family: var(--f-display);
  font-weight: 800;
  font-stretch: 70%;
  font-size: 26px;
  letter-spacing: .08em;
  padding: 4px 12px;
  border: 3px solid currentColor;
  border-radius: 6px;
  transform: rotate(-9deg);
  opacity: .85;
  pointer-events: none;
  mix-blend-mode: var(--stamp-blend);
}
.stamp.good { color: var(--accent); }
.stamp.bad { color: var(--red); }
.stamp.anim { animation: stamp .28s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes stamp {
  from { transform: rotate(-9deg) scale(1.9); opacity: 0; }
  to { transform: rotate(-9deg) scale(1); opacity: .85; }
}

/* ---------- Recall (Aufzählen) ---------- */
.sets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .n { font-family: var(--f-mono); font-size: 11px; opacity: .7; margin-left: 5px; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.slot { border: 1.5px dashed var(--line); border-radius: 4px; padding: 9px 12px; min-height: 46px; display: flex; gap: 10px; align-items: baseline; }
.slot .no { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); }
.slot.hit { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.slot.given { border-style: solid; border-color: var(--red); background: var(--red-soft); }
.slot .t { font-weight: 700; }

.entry { display: flex; gap: 8px; }
.entry input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.shake { animation: shake .3s; }
@keyframes shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- Quiz ---------- */
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--paper); border-radius: 4px; padding: 11px 14px; display: flex; gap: 12px; align-items: baseline; }
.opt .k { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--accent); background: var(--accent-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }

.explain { margin: 0; font-size: 14.5px; color: var(--muted); max-width: 65ch; }
.explain + .btn { margin-top: 12px; }
.verdict-right { color: var(--accent); }
.verdict-wrong { color: var(--red); }

.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.score { font-family: var(--f-display); font-weight: 800; font-stretch: 75%; font-size: 64px; line-height: 1; }
.score small { font-size: .45em; color: var(--muted); }

/* ---------- Oral exam (Mündlich) ---------- */
.timer { display: flex; align-items: center; gap: 14px; }
.clock { font-family: var(--f-mono); font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.clock.over { color: var(--red); }

.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.checks label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checks input { margin-top: 4px; accent-color: var(--accent); width: 17px; height: 17px; flex: none; }

.kind {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--surface);
}
.kind.fall { background: var(--amber); color: var(--surface); }

/* ---------- Listen (Anhören) ---------- */
.scrub { display: flex; align-items: center; gap: 10px; }
.scrub input { flex: 1; min-width: 0; accent-color: var(--accent); }
.clock.small { font-size: 13px; color: var(--muted); min-width: 3.2em; text-align: center; }

.controls { display: flex; justify-content: center; align-items: center; gap: 14px; }
.btn.round { width: 48px; height: 48px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 17px; }
.btn.round.big { width: 64px; height: 64px; font-size: 22px; }

.tracks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.tracks li + li { border-top: 1px solid var(--line); }
.track { width: 100%; background: none; border: 0; text-align: left; padding: 10px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: baseline; }
.track .tn { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); min-width: 2.2em; }
.track .tt { font-weight: 700; }
.track .ts { display: block; font-weight: 400; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .td { font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.track > span:nth-child(2) { min-width: 0; }
.track[aria-current="true"] { background: var(--accent-soft); }
.track[aria-current="true"] .tn { color: var(--accent); }
.track:hover { background: var(--paper); }

.transcript { padding: 12px 18px; }
.transcript .answer { border: 0; margin-top: 8px; }

/* ---------- Responsive and motion ---------- */
@media (max-width: 520px) {
  nav button { padding-inline: 8px; font-size: 14.5px; }
  .register { gap: 4px; }
  .current { padding: 10px 12px; }
  .switch span { display: none; }
  .reg i { display: none; }
  .stamp { font-size: 20px; top: 44px; right: 12px; }
}

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