/* ==========================================================
   Međuratne godine: stilovi
   Bez vanjskih fontova i resursa (CSP: font-src 'self').
   Tema: tiskana ploča iz 1920-ih/30-ih; ultramarin, tinta, žuti marker.
   ========================================================== */

:root {
  --paper: #ebeef2;
  --surface: #ffffff;
  --ink: #131a29;
  --ink-2: #4b556a;
  --line: #c7ced9;
  --blue: #2335b8;
  --blue-ink: #ffffff;
  --blue-soft: #dfe4fb;
  --yellow: #f4c430;
  --hl: #fbe7a0;
  --hl-soft: #fdf3cf;
  --green: #14764d;
  --green-soft: #dcf1e6;
  --red: #b8243a;
  --red-soft: #f9e0e4;
  --focus: #1b6fe0;

  --font-head: "Bahnschrift", "DIN Alternate", "Franklin Gothic Medium", "Segoe UI Semibold", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f131b;
    --surface: #182030;
    --ink: #e8ebf2;
    --ink-2: #a6afc0;
    --line: #2b3447;
    --blue: #8fa0ff;
    --blue-ink: #0f131b;
    --blue-soft: #1d2650;
    --yellow: #f2c94c;
    --hl: #5b4b12;
    --hl-soft: #2b2610;
    --green: #55cc92;
    --green-soft: #12301f;
    --red: #ff8090;
    --red-soft: #3a1820;
    --focus: #7db0ff;
  }
}

:root[data-theme="dark"] {
  --paper: #0f131b;
  --surface: #182030;
  --ink: #e8ebf2;
  --ink-2: #a6afc0;
  --line: #2b3447;
  --blue: #8fa0ff;
  --blue-ink: #0f131b;
  --blue-soft: #1d2650;
  --yellow: #f2c94c;
  --hl: #5b4b12;
  --hl-soft: #2b2610;
  --green: #55cc92;
  --green-soft: #12301f;
  --red: #ff8090;
  --red-soft: #3a1820;
  --focus: #7db0ff;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

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

[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 56rem; margin-inline: auto; padding-inline: 1rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.spacer { flex: 1 1 auto; }

.skip {
  position: absolute; left: 0.5rem; top: -4rem;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 0.9rem; z-index: 50; font-family: var(--font-head);
}
.skip:focus { top: 0.5rem; }

/* ---------- zaglavlje ---------- */
.head { padding-top: 1.5rem; }
.head-row { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(2.1rem, 6.4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.sub { color: var(--ink-2); margin-top: 0.5rem; max-width: 36rem; }

/* ---------- ravnalo godina ---------- */
.ruler { margin-top: 1.4rem; }
.ruler-cap { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.4rem; }
.cap { font-family: var(--font-head); font-weight: 600; font-size: 1rem; }
.ruler-grid {
  display: grid;
  grid-template-columns: repeat(22, minmax(0, 1fr));
  gap: 2px;
  border-bottom: 3px solid var(--ink);
}
.yr {
  position: relative;
  height: 2.6rem;
  padding: 0;
  border: 0;
  background: transparent;
}
.yr::before {
  content: "";
  position: absolute; inset: 0 1px 0 1px;
  background: var(--line);
  opacity: 0.55;
}
.yr-fill {
  position: absolute; left: 1px; right: 1px; bottom: 0;
  height: 0;
  background: var(--blue);
  transition: height 0.35s ease;
}
.yr[data-level="1"] .yr-fill { height: 25%; opacity: 0.55; }
.yr[data-level="2"] .yr-fill { height: 50%; opacity: 0.75; }
.yr[data-level="3"] .yr-fill { height: 75%; opacity: 0.9; }
.yr[data-level="4"] .yr-fill { height: 100%; }
.yr[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 1; }
.yr-lbl {
  position: absolute; top: calc(100% + 0.3rem); left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-head);
  font-size: 0.75rem; line-height: 1;
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.ruler-hint { margin-top: 1.5rem; }

/* ---------- kartice za navigaciju (tabovi) ---------- */
.tabbar {
  position: sticky; top: 0; z-index: 20;
  margin-top: 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 0.8rem 0.9rem 0.7rem;
  background: none; border: 0;
  border-bottom: 4px solid transparent;
  font-family: var(--font-head); font-weight: 600; font-size: 1.05rem;
  color: var(--ink-2);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--blue); }

.main { padding-block: 1.5rem 3rem; outline: none; }
.noscript { padding: 1rem; border: 2px solid var(--red); }

/* ---------- gumbi i kontrole ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 3px;
  font-family: var(--font-head); font-weight: 600; font-size: 1rem; line-height: 1.2;
  min-height: 2.75rem;
}
.btn:hover:not(:disabled) { background: var(--blue-soft); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--blue); color: var(--blue-ink); border-color: var(--blue); }
.btn.primary:hover:not(:disabled) { background: var(--blue); filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { padding: 0.35rem 0.75rem; min-height: 2.25rem; font-size: 0.9rem; }

.link {
  background: none; border: 0; padding: 0.25rem 0.1rem;
  color: var(--blue);
  font-family: var(--font-head); font-weight: 600; font-size: 0.95rem;
  text-decoration: underline; text-underline-offset: 3px;
}
.link.small { font-size: 0.85rem; }

.input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 3px;
  min-height: 2.75rem;
}
textarea.input { resize: vertical; line-height: 1.5; }

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field.grow { flex: 1 1 14rem; }
.lbl { font-family: var(--font-head); font-weight: 600; font-size: 0.9rem; color: var(--ink-2); }

.check { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.95rem; max-width: 26rem; }
.check input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--blue); flex: 0 0 auto; }

.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 3px; overflow: hidden; align-self: flex-end; }
.seg-btn {
  padding: 0.55rem 0.85rem; background: var(--surface); border: 0;
  font-family: var(--font-head); font-weight: 600; font-size: 0.95rem;
  min-height: 2.75rem;
}
.seg-btn + .seg-btn { border-left: 2px solid var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.9rem 1.2rem; align-items: flex-end; }
.statusline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem;
  margin: 1rem 0 0.5rem;
  font-family: var(--font-head); font-size: 0.95rem; color: var(--ink-2);
}
.year-filter { color: var(--ink); font-weight: 600; }

/* ---------- popis tema ---------- */
.topics { border-bottom: 2px solid var(--ink); }
.topic { border-top: 2px solid var(--ink); }
.topic-sum {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: baseline;
  padding: 0.9rem 0.25rem;
  cursor: pointer;
  list-style: none;
}
.topic-sum::-webkit-details-marker { display: none; }
.topic-sum:hover .topic-title { text-decoration: underline; text-underline-offset: 4px; }
.topic-yrs {
  font-family: var(--font-head); font-weight: 700; font-size: 1.35rem; line-height: 1.2;
  color: var(--blue); font-variant-numeric: tabular-nums;
}
.topic-title {
  font-family: var(--font-head); font-weight: 600; font-size: 1.2rem; line-height: 1.3;
}
.topic-where { display: block; font-family: var(--font-head); font-weight: 400; font-size: 0.85rem; color: var(--ink-2); }
.topic-state {
  font-family: var(--font-head); font-weight: 600; font-size: 0.9rem;
  color: var(--green);
  display: inline-flex; align-items: center; gap: 0.3rem;
  min-width: 5.5rem; justify-content: flex-end;
}
.topic-state::before {
  content: ""; width: 0.55rem; height: 0.55rem; border: 2px solid currentColor; border-radius: 50%;
  display: inline-block;
}
.topic-state[data-on="true"]::before { background: currentColor; }
.topic-state[data-on="false"] { color: var(--ink-2); }

.topic-body { padding: 0.25rem 0.25rem 1.5rem 10.25rem; }
.topic-body > * + * { margin-top: 1rem; }
.pts { max-width: 40rem; }
.pts li { position: relative; padding-left: 1.2rem; }
.pts li + li { margin-top: 0.6rem; }
.pts li::before {
  content: ""; position: absolute; left: 0; top: 0.72em;
  width: 0.45rem; height: 0.45rem; background: var(--blue);
}
.pts strong, .model strong, .qtext strong, .tl-text strong {
  font-weight: 700;
  background: linear-gradient(transparent 58%, var(--hl) 58%);
}
.trap {
  max-width: 40rem;
  padding: 0.6rem 0.9rem;
  background: var(--hl-soft);
  border-left: 5px solid var(--yellow);
}
.trap b { font-family: var(--font-head); font-weight: 700; margin-right: 0.35rem; }
.topic-actions { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; }

.empty { padding: 2rem 0; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* ---------- vremenska crta ---------- */
.timeline { margin-top: 1.25rem; border-bottom: 2px solid var(--ink); }
.tl-group {
  display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0 1rem;
  border-top: 2px solid var(--ink);
  padding: 0.85rem 0.25rem;
}
.tl-y {
  font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; line-height: 1.2;
  color: var(--blue); font-variant-numeric: tabular-nums;
  background: none; border: 0; padding: 0; text-align: left;
}
button.tl-y { cursor: pointer; }
.is-masked .tl-y { filter: blur(7px); user-select: none; }
.is-masked .tl-group.revealed .tl-y { filter: none; }
.tl-items > li + li { margin-top: 0.8rem; }
.tl-head { display: flex; flex-wrap: wrap; gap: 0.1rem 0.7rem; align-items: baseline; }
.tl-title { font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; }
.tl-when { font-family: var(--font-head); font-size: 0.9rem; color: var(--ink-2); }
.tl-tag {
  font-family: var(--font-head); font-size: 0.8rem; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.tl-tag::before { content: ""; width: 0.6rem; height: 0.6rem; background: var(--ink-2); }
.tl-tag[data-s="hr"]::before { background: var(--blue); }
.tl-tag[data-s="sv"]::before { border-radius: 50%; }
.tl-text { max-width: 40rem; }

/* ---------- kartice za učenje ---------- */
.deck { margin-top: 1.5rem; max-width: 40rem; }
.deck-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; font-family: var(--font-head); font-size: 0.95rem; color: var(--ink-2); margin-bottom: 0.75rem; }
.card {
  display: block; width: 100%;
  min-height: 15rem;
  padding: 1.5rem 1.4rem;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 6px 6px 0 var(--ink);
}
.card-side { font-family: var(--font-head); font-weight: 600; font-size: 0.9rem; color: var(--ink-2); display: block; margin-bottom: 0.6rem; }
.card-text { display: block; font-size: 1.3rem; line-height: 1.45; }
.card-text.is-term { font-family: var(--font-head); font-weight: 700; font-size: 2rem; line-height: 1.2; color: var(--blue); }
.card-foot { display: block; margin-top: 1rem; font-family: var(--font-head); font-size: 0.9rem; color: var(--ink-2); }
.deck-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.deck-done { padding: 1.25rem; border: 2px solid var(--ink); background: var(--surface); }
.deck-done > * + * { margin-top: 0.8rem; }

/* ---------- kviz ---------- */
.q-wrap { max-width: 44rem; }
.q-wrap > * + * { margin-top: 1.25rem; }
.q-title { font-family: var(--font-head); font-weight: 700; font-size: 1.6rem; line-height: 1.15; }
.q-lead { max-width: 38rem; color: var(--ink-2); }

.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 1rem; }
.num { display: flex; flex-direction: column; gap: 0.25rem; }
.num .input { max-width: 8rem; }
.avail { font-size: 0.85rem; color: var(--ink-2); font-family: var(--font-head); }

.fieldset { border: 2px solid var(--ink); border-radius: 3px; padding: 0.9rem 1rem 1rem; margin: 0; min-width: 0; }
.fieldset > legend { padding: 0 0.4rem; font-family: var(--font-head); font-weight: 600; }
.radio-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.radio { display: flex; align-items: center; gap: 0.5rem; }
.radio input { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }

.topic-pick { margin-top: 0.75rem; }
.topic-pick summary { cursor: pointer; font-family: var(--font-head); font-weight: 600; padding: 0.4rem 0; }
.topic-pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.35rem 1rem; margin-top: 0.5rem; }
.topic-pick-btns { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.5rem; }

.setup-total { font-family: var(--font-head); font-weight: 600; }
.setup-msg { color: var(--red); font-family: var(--font-head); font-weight: 600; min-height: 1.5rem; }

.q-head { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; align-items: baseline; justify-content: space-between; font-family: var(--font-head); }
.q-count { font-weight: 700; font-size: 1.15rem; outline: none; }
.q-type { color: var(--ink-2); font-size: 0.95rem; }
.q-tag { font-size: 0.8rem; padding: 0.1rem 0.5rem; border: 1px solid var(--ink-2); color: var(--ink-2); }
.prog { height: 6px; background: var(--line); }
.prog > span { display: block; height: 100%; background: var(--blue); transition: width 0.3s ease; }

.qtext { font-size: 1.3rem; line-height: 1.5; max-width: 38rem; }
.q-body > * + * { margin-top: 1rem; }

.tn { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; max-width: 28rem; }
.tn .btn { min-height: 3.5rem; font-size: 1.15rem; }

.opts { display: grid; gap: 0.6rem; max-width: 38rem; }
.opt { justify-content: flex-start; text-align: left; font-weight: 500; font-family: var(--font-body); font-size: 1.05rem; min-height: 3rem; }
.opt-key { font-family: var(--font-head); font-weight: 700; color: var(--ink-2); min-width: 1.2rem; }

.btn.is-ok { background: var(--green-soft); border-color: var(--green); color: var(--ink); }
.btn.is-bad { background: var(--red-soft); border-color: var(--red); color: var(--ink); }
.btn.is-ok::after { content: "✓"; margin-left: auto; font-weight: 700; color: var(--green); }
.btn.is-bad::after { content: "✗"; margin-left: auto; font-weight: 700; color: var(--red); }

.type-row { display: flex; gap: 0.6rem; flex-wrap: wrap; max-width: 38rem; }
.type-row .input { flex: 1 1 14rem; }

.fb { padding: 0.8rem 1rem; border-left: 6px solid var(--ink-2); background: var(--surface); max-width: 38rem; }
.fb > * + * { margin-top: 0.5rem; }
.fb.ok { border-left-color: var(--green); background: var(--green-soft); }
.fb.bad { border-left-color: var(--red); background: var(--red-soft); }
.fb.part { border-left-color: var(--yellow); background: var(--hl-soft); }
.fb-h { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; }
.fb-act { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

.order { counter-reset: ord; display: grid; gap: 0.5rem; max-width: 38rem; }
.order-item {
  counter-increment: ord;
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: center;
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 3px;
}
.order-item::before { content: counter(ord); font-family: var(--font-head); font-weight: 700; color: var(--blue); min-width: 1.2rem; text-align: center; }
.order-item[draggable="true"] { cursor: grab; }
.order-item.dragging { opacity: 0.45; }
.order-item.over { border-style: dashed; background: var(--blue-soft); }
.order-item.is-ok { border-color: var(--green); background: var(--green-soft); }
.order-item.is-bad { border-color: var(--red); background: var(--red-soft); }
.order-name { min-width: 0; }
.order-when { display: block; font-family: var(--font-head); font-size: 0.85rem; color: var(--ink-2); }
.order-btns { display: flex; gap: 0.3rem; }
.order-btns .btn { min-width: 2.5rem; min-height: 2.5rem; padding: 0.2rem 0.5rem; }
.order-key { max-width: 38rem; }
.order-key li { padding: 0.15rem 0; }

.words { font-family: var(--font-head); font-size: 0.85rem; color: var(--ink-2); }
.model {
  max-width: 40rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 3px;
}
.model > * + * { margin-top: 0.8rem; }
.model-h { font-family: var(--font-head); font-weight: 700; }
.keypts { display: grid; gap: 0.4rem; }
.keypts label { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.98rem; line-height: 1.45; }
.keypts input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--blue); flex: 0 0 auto; }
.suggest { font-family: var(--font-head); font-size: 0.95rem; color: var(--ink-2); }
.verdicts { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.next-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* rezultati */
.score-big { font-family: var(--font-head); font-weight: 700; font-size: clamp(2.6rem, 9vw, 4.2rem); line-height: 1; color: var(--blue); font-variant-numeric: tabular-nums; }
.score-sub { font-family: var(--font-head); font-size: 1.1rem; color: var(--ink-2); margin-top: 0.4rem; }
.bars { display: grid; gap: 0.7rem; max-width: 38rem; }
.bar-row { display: grid; grid-template-columns: 11rem 1fr 4.5rem; gap: 0.6rem; align-items: center; font-family: var(--font-head); font-size: 0.95rem; }
.bar-track { height: 10px; background: var(--line); }
.bar-track > span { display: block; height: 100%; background: var(--blue); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
.redo { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.wrong-list { display: grid; gap: 0.9rem; max-width: 40rem; }
.wrong-item { border-left: 5px solid var(--red); padding: 0.4rem 0 0.4rem 0.9rem; }
.wrong-item > * + * { margin-top: 0.35rem; }
.wrong-item .k { font-family: var(--font-head); font-weight: 600; font-size: 0.9rem; color: var(--ink-2); }

.foot {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center;
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--line);
}

/* ---------- uski zasloni ---------- */
@media (max-width: 40rem) {
  body { font-size: 1rem; }
  .topic-sum { grid-template-columns: minmax(0, 1fr) auto; }
  .topic-yrs { grid-column: 1 / -1; font-size: 1.15rem; }
  .topic-state { min-width: 0; }
  .topic-body { padding-left: 0.25rem; }
  .tl-group { grid-template-columns: 1fr; gap: 0.3rem; }
  .bar-row { grid-template-columns: 1fr 4.5rem; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .seg { align-self: stretch; }
  .seg-btn { flex: 1 1 auto; padding-inline: 0.5rem; }
  .card-text.is-term { font-size: 1.6rem; }
  .qtext { font-size: 1.15rem; }
  .yr { height: 2.2rem; }
}

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

@media print {
  .tabbar, .ruler, .toolbar, .foot, #theme, .topic-actions { display: none !important; }
  .topic-body { display: block; }
  body { background: #fff; color: #000; }
}
