/* ============================================================
   maketeori - teoritentamen-stil (lys grå eksamensside).
   Siktet mot skjermbildene av teoritentamen.no:
     lyst grått lerret, sentrert spørsmål, ETT hvitt svarkort
     med skillelinjer, mintgrønn riktig-markering, kremfarget
     fasitboks, segmenterte Forrige/Sjekk svar/Neste-knapper.
   Alt av farger endres HER, i :root under.
     --bg      app-bakgrunn (lys grå)
     --card    kort og svarrader
     --ink     hovedtekst
     --muted   nedtonet tekst
     --line    skillelinjer i svarkortet
     --mint    riktig-markering (rad + Neste-knapp)
     --cream   fasitboks
     --green/--red  riktig/feil-tekst
     --pill    22/45-teller
   ============================================================ */
:root {
  --bg: #e9e9e9;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #5d6b7d;
  --line: #ececec;
  --mint: #b6e3c8;
  --mint-btn: #a9dfc0;
  --mint-ink: #1d3a2c;
  --cream: #fcf0dc;
  --cream-line: #f0dcc0;
  --green: #16794c;
  --red: #b3261e;
  --red-bg: #fbe3e1;
  --pill: #d9d9d9;
  --radius: 16px;
  color-scheme: light;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* svh + clip: dvh/hidden får mobilnettleseren til å re-layoute siden
     når URL-linja viser/skjuler seg (bakgrunn + sticky hopper). */
  min-height: 100svh;
  padding-bottom: 124px; /* plass til fast QR-fot */
  overflow-x: hidden;
  overflow-x: clip;
}

/* Bakgrunnsformer som i referansen: heldekkende, skarpe figurer med
   avrundede hjørner som stikker inn fra ytterkantene. */
.bg-decor {
  /* Eget GPU-lag med stabil lvh-høyde: males én gang, flytter seg ikke
     når mobilnettleseren endrer viewport under scrolling. */
  position: fixed; top: 0; left: 0; width: 100%; height: 100lvh;
  z-index: 0; pointer-events: none;
  overflow: hidden;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.shape { position: absolute; }
/* Blå sirkel, høyre kant */
.shape-blue {
  width: min(480px, 95vw); height: min(480px, 95vw);
  right: calc(min(480px, 95vw) / -2); top: 30%;
  background: #46709f; border-radius: 50%;
}
/* Grønn kube, venstre hjørne (rotert, avrundet) */
.shape-green {
  width: 300px; height: 430px; left: -175px; bottom: -130px;
  background: #4da187; border-radius: 38px; transform: rotate(10deg);
}
/* Gul firkant, topp midt-venstre (stikker ned fra toppkanten) */
.shape-yellow {
  width: 175px; height: 92px; left: 9%; top: -46px;
  background: #f2b84b; border-radius: 18px; transform: rotate(-12deg);
}
/* Rød trekant, nedre høyre hjørne - avrundede hjørner via rund skjøt */
.shape-red {
  width: 235px; height: auto; right: -72px; bottom: -52px;
  transform: rotate(8deg);
}
main, .exam-bar { position: relative; z-index: 1; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--ink); color: #fff; padding: .5rem .8rem; border-radius: 6px; z-index: 20; }

/* Tynn eksamens-toppbar: ✕ venstre, teller midt, brand høyre */
.exam-bar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(233, 233, 233, 0.94);
}
.exam-bar-in {
  max-width: 72rem; margin: 0 auto; padding: .9rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.icon-btn {
  font: inherit; font-size: 1.5rem; line-height: 1;
  background: none; border: 0; cursor: pointer; color: var(--ink);
  width: 2.75rem; height: 2.75rem; border-radius: 10px;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.counter-pill {
  margin: 0 auto; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--pill); border-radius: 99px; padding: .35rem 1.1rem;
  font-size: 1.05rem; letter-spacing: .02em;
}
.exam-bar-right { min-width: 2.75rem; margin-left: auto; display: flex; justify-content: flex-end; }
.brand-mini { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 0; }

/* Smale kort (start + resultat) */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card.narrow { max-width: 34rem; margin: 2rem auto 0; }

h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* --- Eksamensvisning --- */
.exam { padding-top: 2.2rem; max-width: 56rem; margin: 0 auto; }
.exam-q {
  font-size: clamp(1.35rem, 2.6vw + 0.9rem, 2rem);
  line-height: 1.3; letter-spacing: -0.015em; text-align: center;
  margin: 0 auto 2rem; max-width: 56rem; text-wrap: balance;
}
.exam-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
  overflow: hidden; max-width: 52rem; margin: 0 auto;
}
/* Bildeoppgave: skilt ved siden av svarene (som i referansen) */
.exam-body { max-width: 52rem; margin: 0 auto; }
.exam-body.has-img {
  max-width: 64rem; display: grid;
  grid-template-columns: 1.05fr 1fr; gap: 1.4rem; align-items: start;
}
.exam-body.has-img .exam-card { margin: 0; max-width: none; }
.exam-media {
  margin: 0; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.10); overflow: hidden;
}
.exam-media svg, .exam-media img { display: block; width: 100%; height: auto; }
.exam-opts { display: flex; flex-direction: column; }
.exam-opts button {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 1.05rem; color: var(--ink);
  background: var(--card); border: 0; border-bottom: 1px solid var(--line);
  padding: 1.15rem 1.5rem; cursor: pointer; line-height: 1.45;
}
.exam-opts button:last-child { border-bottom: 0; }
.exam-opts button:hover:not(:disabled) { background: #f6f6f6; }
.exam-opts button:focus-visible { outline: 3px solid #7aa7e0; outline-offset: -3px; }
.exam-opts button.is-selected { background: #e9eef5; box-shadow: inset 4px 0 0 var(--ink); }
.exam-opts button.is-right { background: var(--mint); font-weight: 500; }
.exam-opts button.is-wrong { background: var(--red-bg); }
.exam-opts button:disabled { cursor: default; color: var(--ink); }
.qid { text-align: right; max-width: 52rem; margin: .45rem auto 0; font-size: .85rem; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Segmenterte knapper: Forrige | Sjekk svar | Neste */
.seg {
  display: flex; justify-content: center; margin: 1.6rem auto 0; width: fit-content;
  background: var(--card); border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
}
.seg-btn {
  font: inherit; font-weight: 600; font-size: 1.05rem; color: var(--ink);
  background: var(--card); border: 0; border-left: 1px solid var(--line);
  padding: .95rem 2.4rem; min-height: 56px; cursor: pointer; min-width: 10rem;
}
.seg-btn:first-child { border-left: 0; }
.seg-btn:hover:not(:disabled) { background: #f6f6f6; }
.seg-btn:disabled { opacity: .55; cursor: default; }
.seg-next { background: var(--mint-btn); color: var(--mint-ink); font-weight: 700; }
.seg-next:hover { filter: brightness(0.97); }

/* Fasitboks (krem) - overflow synlig så maskoten kan titte over kanten */
.fb {
  position: relative;
  max-width: 46rem; margin: 1.6rem auto 0;
  background: var(--cream); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: visible;
}
.fb.no { background: var(--red-bg); }
.fb-title {
  margin: 0; padding: 1rem 1.5rem; font-size: 1.3rem;
  border-bottom: 1px solid rgba(0,0,0,.07);
}
.fb-title b { font-weight: 800; letter-spacing: -0.01em; }
.fb-body { padding: 1.2rem 1.5rem 1.4rem; }
.fb-body p { margin: 0 0 1rem; line-height: 1.65; }
.fb-body p:last-child { margin-bottom: 0; }

/* Knapper (start/resultat) */
button.primary {
  font: inherit; font-weight: 700; font-size: 1rem;
  color: #fff; background: var(--ink); border: 1px solid var(--ink);
  border-radius: 12px; padding: .8rem 1.4rem; min-height: 52px;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.25); }
button.primary.big { width: 100%; }
button:focus-visible, a:focus-visible {
  outline: 3px solid #7aa7e0; outline-offset: 2px;
}
.row { margin-top: 1.1rem; }
.row .primary { width: 100%; }

/* Resultatbanner */
.banner {
  margin: 0; padding: .7rem 1rem; border-radius: 12px;
  font-weight: 800; font-size: 1.05rem; letter-spacing: .04em; text-align: center;
}
.banner[data-pass="1"] { background: #e6f4ec; color: var(--green); border: 1px solid var(--green); }
.banner[data-pass="0"] { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.score { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; text-align: center; margin: .8rem 0 .3rem; }
#res-msg { text-align: center; }

/* Hjelpelenker */
.help { display: flex; flex-direction: column; gap: .5rem; margin-top: .6rem; }
.help a {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  color: var(--ink); text-decoration: none;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: .75rem 1rem; min-height: 52px;
}
.help a span { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.help a:hover { border-color: #9fb0c3; }

/* Stor QR på startskjermen */
.qr-hero {
  margin: 1.4rem auto 0; text-align: center;
}
.qr-hero canvas {
  width: min(220px, 70vw); height: auto; aspect-ratio: 1;
  image-rendering: pixelated; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
}
.qr-hero figcaption { margin-top: .5rem; }

a { color: #2f5f8a; }

/* --- Landing (dashboard i teoritentamen-stil) --- */
.dash-bar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(233, 233, 233, 0.96);
}
.dash-bar-in {
  max-width: 72rem; margin: 0 auto; padding: .8rem 1.25rem;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .9rem;
}
.dash-title { grid-column: 2; text-align: center; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.01em; }
.dash-right { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: .7rem; }
.pass-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--card); border-radius: 12px; padding: .55rem .95rem;
  font-size: .88rem; font-weight: 500; color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.08); white-space: nowrap;
}
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  display: flex; flex-direction: column; min-width: 13rem;
  background: var(--card); border-radius: 12px; overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.menu button {
  font: inherit; text-align: left; background: none; border: 0;
  padding: .85rem 1.1rem; cursor: pointer; color: var(--ink);
}
.menu button:hover { background: #f2f2f2; }

.dash { padding: 1.5rem 0 0; }
.dash-grid {
  display: grid; gap: 2rem;
  grid-template-columns: 1.05fr 1.15fr 1.2fr;
  align-items: start;
}
.dash-grid h2 { font-size: 1.12rem; margin: 0 0 .8rem; color: #2b3644; }

/* Din tilgang: kort med farget venstrestripe */
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.acc {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: .8rem;
  background: var(--card); border: 0; border-radius: 14px;
  padding: 1.1rem 1rem 1.1rem 1.3rem; min-height: 96px;
  font: inherit; font-weight: 600; color: var(--ink); text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
button.acc { cursor: pointer; }
button.acc:hover { filter: brightness(0.97); box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.acc::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 11px;
  background: var(--stripe, #999);
}
.acc svg { width: 32px; height: 32px; flex: none; color: #33302b; }
.acc span small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }

/* Anbefalt for deg */
.guy { display: block; }
.rec-list { display: flex; flex-direction: column; gap: .9rem; }
.rec {
  display: flex; align-items: center; gap: .9rem;
  background: var(--card); border-radius: 14px; padding: 1.05rem 1.2rem;
  font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.rec svg { width: 30px; height: 30px; flex: none; color: #33302b; }
.mini-pill {
  display: block; width: fit-content; margin: .9rem auto 0;
  background: #e2e2e2; border-radius: 10px; padding: .35rem 1rem;
  font-size: .85rem; color: var(--ink);
}

/* Beståttgaranti */
.garanti-card {
  position: relative; background: var(--card); border-radius: var(--radius);
  padding: 1.4rem 1.2rem 1.2rem; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  text-align: center;
}
.info-btn {
  position: absolute; top: .8rem; right: .8rem;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: #e6e8eb; border: 0; color: var(--ink);
  font: inherit; font-weight: 700; font-style: italic; cursor: pointer; line-height: 1;
}
.ring { width: 100%; height: auto; display: block; }
.ring-top { max-width: 190px; margin: 0 auto; }
.ring-num { font-size: 1.5rem; font-weight: 500; fill: var(--ink); }
.ring-den { fill: #9aa3ad; font-size: 1.1rem; }
.ring-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1.2rem; }
.ring-cell p, .ring-note {
  display: flex; gap: .45rem; align-items: flex-start; text-align: left;
  font-size: .82rem; color: #2b3644; margin: .7rem 0 0; line-height: 1.4;
  border-left: 3px solid #e2e2e2; padding-left: .55rem;
}
.ring-cell:first-child p { border-color: var(--mint-btn); }
.ring-note { margin-top: 1rem; }

/* Maskot i fasitboksen (titter over kanten, som i referansen) */
.guy-fb {
  position: absolute; top: -52px; right: 14px; width: 84px; height: auto;
  pointer-events: none;
}

/* Stor QR på landing */
.qr-hero-title { font-weight: 800; font-size: 1.05rem; margin: 0 0 .7rem; }

/* Fast QR-fot - synlig på alle skjermer */
.qr-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
}
.qr-foot-in {
  max-width: 56rem; margin: 0 auto; padding: .55rem 1rem;
  display: flex; align-items: center; gap: .8rem;
}
.qr-foot canvas {
  width: 72px; height: 72px; flex: none;
  image-rendering: pixelated; border-radius: 8px;
  border: 1px solid var(--line); background: #fff;
}

@media (max-width: 960px) {
  .dash-grid { grid-template-columns: 1fr; gap: 1.8rem; }
  .dash { padding-top: 1rem; }
  .garanti-card { max-width: 32rem; }
}
@media (max-width: 640px) {
  .exam { padding-top: 1rem; }
  .seg-btn { padding: .85rem 1.1rem; min-width: 0; flex: 1; font-size: .95rem; }
  .seg { width: 100%; max-width: 52rem; }
  .brand-mini { display: none; }
  .exam-opts button { font-size: .98rem; padding: 1rem 1.1rem; }
  /* Bildeoppgave stables på mobil: skilt over svarene */
  .exam-body.has-img { grid-template-columns: 1fr; }
  .exam-body.has-img .exam-card { max-width: 52rem; }
  .exam-media { max-width: 24rem; width: 100%; margin: 0 auto; }
  /* Landing mobil: kompakt toppbar, kort stablet */
  .dash-bar-in { padding: .6rem .8rem; gap: .5rem; }
  .dash-title { font-size: 1.05rem; }
  .pass-pill { display: none; }
  .acc { min-height: 84px; padding: .9rem .8rem .9rem 1.1rem; font-size: .92rem; }
  .acc svg { width: 28px; height: 28px; }
  .guy-fb { width: 64px; top: -40px; right: 8px; }
  .ring-top { max-width: 150px; }
  .ring-num { font-size: 1.6rem; }
  /* Fast QR-fot skjules på mobil (stor QR finnes på landingssiden) */
  .qr-foot { display: none; }
  body { padding-bottom: 2rem; }
  /* Bakgrunnsformer: mindre, fortsatt bare på gløtt fra kantene */
  .shape-blue { top: 40%; }
  .shape-green { width: 190px; height: 300px; left: -125px; bottom: -95px; border-radius: 26px; }
  .shape-yellow { width: 118px; height: 62px; top: -31px; left: 6%; border-radius: 12px; }
  .shape-red { width: 150px; right: -48px; bottom: -34px; }
}
