/* styles.css -- FE-4 (look + feel).
   Design thesis: a Norwegian road-sign board. Cool sign-white surfaces, a
   slate ink, and accents lifted straight from signage semantics -- forbud red
   for a wrong pick, motorvei blue for action, forkjorsvei yellow for the
   signature confidence dial, permitted green for the correct answer. Review
   mode flips to asphalt. One bold element (the dial + the resurface moment);
   everything else stays quiet. */

:root {
  --paper: #EBEEF3;
  --surface: #FFFFFF;
  --ink: #14181D;
  --muted: #5B6673;
  --line: #D6DCE4;

  --road: #11151A;
  --road-2: #181D24;
  --road-line: #2A3138;
  --road-ink: #E8ECF1;
  --road-muted: #8B95A3;

  --signal: #D7232E;
  --signal-tint: #FCEAEB;
  --priority: #F3C300;
  --route: #0E63C4;
  --route-tint: #E8F0FB;
  --go: #1C8A4D;
  --go-tint: #E8F4ED;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 20, 26, 0.05), 0 14px 40px -22px rgba(16, 20, 26, 0.28);

  --ui: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Space Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(circle at 1px 1px, rgba(20, 24, 29, 0.045) 1px, transparent 0);
  background-size: 22px 22px;
}

#app { max-width: 760px; margin: 0 auto; padding: 0 18px 64px; }

/* ---- app bar ------------------------------------------------------------ */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 0 14px; margin-bottom: 8px;
  background: linear-gradient(var(--paper) 78%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 0; color: inherit; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--signal);
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px rgba(20, 24, 29, 0.12);
  transform: rotate(45deg);
}
.brand__txt { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; line-height: 1; display: flex; flex-direction: column; gap: 2px; }
.brand__sub { font: 600 0.62rem/1 var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }

.tabs { display: flex; gap: 4px; background: rgba(20, 24, 29, 0.05); padding: 4px; border-radius: 999px; }
.tab {
  position: relative; border: 0; background: none; cursor: pointer; color: var(--muted);
  font: 600 0.9rem/1 var(--ui); padding: 8px 16px; border-radius: 999px;
}
.tab.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tab__badge {
  margin-left: 7px; font: 700 0.72rem/1 var(--mono); background: var(--signal); color: #fff;
  padding: 2px 6px; border-radius: 999px; vertical-align: 1px;
}
.bar__progress { display: flex; align-items: baseline; gap: 12px; }
.bar__count { font: 700 1.15rem/1 var(--mono); }
.bar__den { color: var(--muted); font-size: 0.85rem; }
.bar__correct { font: 600 0.8rem/1 var(--ui); color: var(--go); }

/* ---- home / category picker --------------------------------------------- */
.home { padding-top: 18px; }
.eyebrow { font: 600 0.7rem/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--route); margin: 0 0 14px; }
.home__title { font-size: clamp(2rem, 6vw, 2.7rem); line-height: 1.04; letter-spacing: -0.03em; margin: 0 0 12px; font-weight: 700; }
.home__lead { color: var(--muted); max-width: 52ch; margin: 0 0 26px; }

.pick {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 18px; cursor: pointer; text-align: left; color: inherit;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.pick:hover { border-color: var(--route); transform: translateY(-1px); box-shadow: var(--shadow); }
.pick:active { transform: translateY(0); }
.pick__name { font-weight: 600; }
.pick__count { font: 700 0.85rem/1 var(--mono); color: var(--muted); background: var(--paper); padding: 5px 9px; border-radius: 7px; }
.pick--mix { margin-bottom: 14px; border-color: var(--ink); border-width: 1.5px; }
.pick--mix .pick__name { font-size: 1.05rem; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- card --------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card--quiet { display: flex; align-items: center; justify-content: center; min-height: 180px; }
.card__foot { margin-top: 22px; }
.muted { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { font: 600 0.72rem/1 var(--ui); color: var(--muted); background: var(--paper); padding: 6px 10px; border-radius: 7px; white-space: nowrap; }
.chip--id { font-family: var(--mono); color: var(--ink); }
.chip--soft { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.chip--accent { background: var(--priority); color: #2a2300; }

.diagram {
  margin: 4px 0 20px; padding: 18px; background: #fcfdff;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(20, 24, 29, 0.02);
}
.diagram__img { max-width: 100%; max-height: 248px; height: auto; display: block; }

.q { font-size: clamp(1.25rem, 3.6vw, 1.5rem); line-height: 1.32; letter-spacing: -0.015em; margin: 0 0 20px; font-weight: 600; }

/* ---- options ------------------------------------------------------------ */
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  position: relative; display: flex; align-items: flex-start; gap: 13px; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 15px 14px 14px; cursor: pointer; text-align: left; color: inherit; font: inherit;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.opt:hover:not(:disabled) { border-color: var(--route); }
.opt:disabled { cursor: default; }
.opt__key { font: 700 0.82rem/1.5 var(--mono); color: var(--muted); width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 6px; background: var(--paper); }
.opt__text { flex: 1; }
.opt__tag { font: 700 0.66rem/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; align-self: center; padding: 4px 7px; border-radius: 6px; background: var(--go); color: #fff; }
.opt__tag--wrong { background: var(--signal); }

.opt.is-picked { background: var(--route-tint); border-color: var(--route); box-shadow: inset 3px 0 0 var(--route); }
.opt.is-picked .opt__key { background: var(--route); color: #fff; }
.opt.is-correct { background: var(--go-tint); border-color: var(--go); box-shadow: inset 4px 0 0 var(--priority); }
.opt.is-correct .opt__key { background: var(--go); color: #fff; }
.opt.is-wrong { background: var(--signal-tint); border-color: var(--signal); box-shadow: inset 3px 0 0 var(--signal); }
.opt.is-wrong .opt__key { background: var(--signal); color: #fff; }

/* ---- the signature: confidence dial ------------------------------------- */
.dial { margin-top: 20px; }
.dial__label { display: block; font: 600 0.78rem/1 var(--ui); color: var(--muted); margin-bottom: 8px; }
.dial__track { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 5px; background: var(--paper); border-radius: 12px; }
.dial__stop {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font: 600 0.86rem/1 var(--ui); padding: 11px 8px; border-radius: 9px;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.dial__stop:hover:not(:disabled):not(.is-on) { color: var(--ink); }
.dial__stop:disabled { cursor: default; }
.dial__stop.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
/* the "Sikker" stop carries the stakes: getting it wrong resurfaces the item */
.dial__stop:last-child.is-on { box-shadow: var(--shadow), inset 0 -3px 0 var(--priority); }

/* ---- feedback ----------------------------------------------------------- */
.feedback__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.verdict { font: 700 0.78rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 7px 12px; border-radius: 8px; }
.verdict--go { background: var(--go-tint); color: var(--go); }
.verdict--no { background: var(--signal-tint); color: var(--signal); }
.badge--resurface {
  font: 700 0.72rem/1 var(--ui); padding: 7px 11px; border-radius: 8px;
  background: var(--priority); color: #2a2300;
  animation: pop 0.32s ease;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.why { border-left: 3px solid var(--line); padding: 2px 0 2px 14px; margin: 12px 0; }
.why p { margin: 3px 0 0; }
.why__label { font: 600 0.7rem/1 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.why--go { border-color: var(--go); }
.why--go .why__label { color: var(--go); }
.why--signal { border-color: var(--signal); }
.why--signal .why__label { color: var(--signal); }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.src { font: 400 0.74rem/1.3 var(--mono); color: var(--muted); background: var(--paper); padding: 6px 9px; border-radius: 7px; }

.feedback__actions { display: flex; gap: 10px; margin-top: 20px; }

.hazard-note { background: var(--paper); border-radius: var(--radius-sm); padding: 16px 18px; }
.hazard-note p { margin: 0; color: var(--muted); }

/* ---- done --------------------------------------------------------------- */
.card--done { text-align: center; }
.card--done .eyebrow { color: var(--muted); }
.score { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 10px 0 2px; }
.score__num { font: 700 clamp(3rem, 14vw, 4.4rem)/1 var(--mono); letter-spacing: -0.02em; }
.score__den { font: 400 1.3rem/1 var(--mono); color: var(--muted); }
.score__pct { color: var(--muted); margin: 0 0 8px; }
.done__foot { display: flex; gap: 10px; justify-content: center; }

/* ---- buttons ------------------------------------------------------------ */
.btn { font: 600 0.95rem/1 var(--ui); padding: 13px 22px; border-radius: 10px; cursor: pointer; border: 1.5px solid transparent; transition: transform 0.1s, box-shadow 0.12s, background 0.12s, border-color 0.12s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--route); color: #fff; }
.btn--primary:hover { box-shadow: 0 8px 22px -10px var(--route); }
.btn--primary:disabled { background: #aebfd6; cursor: not-allowed; box-shadow: none; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--block { width: 100%; margin-top: 16px; }

/* ---- review board (asphalt) --------------------------------------------- */
.board { background: var(--road); color: var(--road-ink); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.board.card--quiet { background: var(--road); }
.board.card--quiet .muted { color: var(--road-muted); }
.board__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--road-2); border: 1px solid var(--road-line); border-radius: var(--radius-sm); padding: 16px; }
.stat__num { display: block; font: 700 2rem/1 var(--mono); letter-spacing: -0.02em; }
.stat__lab { font: 600 0.74rem/1.3 var(--ui); color: var(--road-muted); }

.boxes { display: flex; align-items: flex-end; gap: 8px; height: 96px; margin: 20px 0 4px; padding: 0 2px; }
.box { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.box__bar { width: 100%; min-height: 2px; border-radius: 5px 5px 2px 2px; background: linear-gradient(var(--priority), #b88f00); }
.box__n { font: 700 0.82rem/1 var(--mono); }
.box__k { font: 400 0.66rem/1 var(--mono); color: var(--road-muted); }

.board__panel { margin-top: 18px; border-top: 1px solid var(--road-line); padding-top: 18px; }
.board__sub { font: 600 0.82rem/1 var(--ui); color: var(--road-muted); margin-bottom: 12px; }
.board__sub em { color: var(--road-ink); font-style: normal; }
.due-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.due { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "id q" "id meta"; gap: 0 12px; padding: 11px 13px; background: var(--road-2); border: 1px solid var(--road-line); border-radius: var(--radius-sm); }
.due--lead { border-color: var(--priority); }
.due__id { grid-area: id; align-self: center; font: 700 0.78rem/1 var(--mono); color: var(--priority); }
.due__q { grid-area: q; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.due__meta { grid-area: meta; font: 400 0.72rem/1.3 var(--ui); color: var(--road-muted); }

.empty { text-align: center; padding: 22px 0 6px; }
.empty__head { font-weight: 600; margin: 0 0 6px; }
.empty .muted { color: var(--road-muted); max-width: 44ch; margin: 0 auto 18px; }

.card--error code { font: 0.85rem var(--mono); background: var(--paper); padding: 2px 6px; border-radius: 5px; }

/* ---- quality floor ------------------------------------------------------ */
:focus-visible { outline: 3px solid var(--route); outline-offset: 2px; border-radius: 6px; }
.board :focus-visible { outline-color: var(--priority); }

/* a11y: focus-visible + sr-only + contrast --------------------------------- */
/* Explicit motorvei-blue (--route, #0E63C4) focus ring on every interactive
   element. :focus-visible only, so a mouse click never paints the ring. The
   white box-shadow halo keeps the blue outline legible where it sits flush
   against the dark asphalt board / dark .opt states, and the board override
   above swaps the outline to priority-yellow for the same reason. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.opt:focus-visible,
.btn:focus-visible,
.tab:focus-visible,
.pick:focus-visible,
.brand:focus-visible,
.dial__stop:focus-visible,
.due:focus-visible {
  outline: 3px solid var(--route);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--surface);
}
.board a:focus-visible,
.board button:focus-visible,
.board [tabindex]:focus-visible,
.board .due:focus-visible,
.board .dial__stop:focus-visible {
  outline-color: var(--priority);
  box-shadow: 0 0 0 1px var(--road);
}

/* screen-reader-only: removed from the visual layout, kept in the a11y tree */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* confidence dial "Sikker" / selected stop contrast — verified, not changed.
   The selected stop (.dial__stop.is-on) renders --ink (#14181D) on --surface
   (#FFFFFF) = 17.8:1, and the priority-yellow "Sikker" accent is only an inset
   underline (decorative, not text), so no yellow-on-light text exists. The
   yellow that does carry text — chip--accent / badge--resurface (#2a2300 on
   #F3C300 = 9.4:1) and .due__id (#F3C300 on --road-2 #181D24 = 10.2:1) — all
   already clear 4.5:1. Colors left as-is. */

@media (max-width: 480px) {
  #app { padding: 0 13px 48px; }
  .card, .board { padding: 18px; }
  .pick-grid { grid-template-columns: 1fr; }
  .tab { padding: 8px 13px; }
  .feedback__actions, .done__foot { flex-direction: column; }
  .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
