/* smartbilbytte.no – se DESIGN.md for reglene bak verdiene. */

@font-face { font-family: 'Barlow'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/barlow-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/barlow-700.woff2') format('woff2'); }
/* Reservefont med Barlows mål (bredde 92,7 % av Arial, typo-mål 1000/200), så byttet ikke flytter teksten. */
@font-face {
  font-family: 'Barlow reserve';
  src: local('Arial'), local('Helvetica Neue'), local('Helvetica');
  size-adjust: 92.7%; ascent-override: 107.9%; descent-override: 21.6%; line-gap-override: 0%;
}

/* Fargene er skrevet i OKLCH, så tonetrinnene er jevne. Tilstander avledes i stedet for å plukkes for hånd. */
:root {
  color-scheme: light;
  --canvas: oklch(0.962 0.005 118);
  --surface: oklch(0.988 0.003 106);
  --surface-2: oklch(0.928 0.008 122);
  --ink: oklch(0.207 0.012 254);
  --muted: oklch(0.436 0.017 255);
  --line: oklch(0.841 0.011 124);
  --accent: oklch(0.854 0.171 87);
  --on-accent: oklch(0.207 0.012 254);
  --focus: oklch(0.44 0.183 265);
  --plate: #ffffff;
  --plate-ink: oklch(0.18 0 0);
  --plate-strip: oklch(0.396 0.163 265);
  --series-beholde: #2a78d6;
  --series-bytte: #eb6834;
  --grid: oklch(0.906 0.009 100);
  --axis: oklch(0.812 0.015 103);
  --axis-text: oklch(0.537 0.008 133);
  --warn-bg: oklch(0.964 0.049 92);
  --warn-ink: oklch(0.392 0.081 84);
  --error: oklch(0.501 0.178 29);
  --asfalt: oklch(0.213 0.007 258);
  --asfalt-2: oklch(0.272 0.01 261);
  --asfalt-3: oklch(0.327 0.012 258);
  --asfalt-ink: oklch(0.965 0.005 118);
  --asfalt-muted: oklch(0.774 0.01 253);
  --asfalt-feil: oklch(0.788 0.123 26);
  --midtlinje: var(--accent);
  --konklusjon-under: oklch(0.315 0.064 92);

  /* Avledede tilstander */
  --accent-hover: oklch(from var(--accent) calc(l + 0.035) calc(c - 0.02) h);
  --accent-press: oklch(from var(--accent) calc(l - 0.05) c h);
  --ink-hover: oklch(from var(--ink) calc(l + 0.08) c h);

  --font: 'Barlow', 'Barlow reserve', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --t-display: clamp(2.75rem, 1.5rem + 5.2vw, 6rem);
  --t-heading: clamp(1.6rem, 1.2rem + 1.6vw, 2.5rem);
  --t-body: 1.0625rem;
  --t-small: 0.9375rem;

  --margin: clamp(16px, 4vw, 40px);
  --gap-section: clamp(72px, 10vw, 140px);
  --radius: 999px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-press: 140ms;
  --dur-ui: 220ms;
  --dur-page: 260ms;
}
@supports not (color: oklch(from red l c h)) {
  :root {
    --accent-hover: color-mix(in oklch, var(--accent) 80%, white);
    --accent-press: color-mix(in oklch, var(--accent) 90%, black);
    --ink-hover: color-mix(in oklch, var(--ink) 85%, white);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: oklch(0.194 0.009 256);
    --surface: oklch(0.233 0.011 254);
    --surface-2: oklch(0.279 0.015 257);
    --ink: oklch(0.952 0.006 129);
    --muted: oklch(0.787 0.013 256);
    --line: oklch(0.369 0.016 256);
    --focus: oklch(0.764 0.12 266);
    --series-beholde: #3987e5;
    --series-bytte: #d95926;
    --grid: oklch(0.304 0.008 256);
    --axis: oklch(0.396 0.014 257);
    --axis-text: oklch(0.703 0.012 252);
    --warn-bg: oklch(0.31 0.049 90);
    --warn-ink: oklch(0.924 0.089 88);
    --error: oklch(0.759 0.144 26);
    --asfalt: oklch(0.158 0.007 258);
    --asfalt-2: oklch(0.234 0.013 258);
    --asfalt-3: oklch(0.287 0.015 257);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: oklch(0.194 0.009 256);
  --surface: oklch(0.233 0.011 254);
  --surface-2: oklch(0.279 0.015 257);
  --ink: oklch(0.952 0.006 129);
  --muted: oklch(0.787 0.013 256);
  --line: oklch(0.369 0.016 256);
  --focus: oklch(0.764 0.12 266);
  --series-beholde: #3987e5;
  --series-bytte: #d95926;
  --grid: oklch(0.304 0.008 256);
  --axis: oklch(0.396 0.014 257);
  --axis-text: oklch(0.703 0.012 252);
  --warn-bg: oklch(0.31 0.049 90);
  --warn-ink: oklch(0.924 0.089 88);
  --error: oklch(0.759 0.144 26);
  --asfalt: oklch(0.158 0.007 258);
  --asfalt-2: oklch(0.234 0.013 258);
  --asfalt-3: oklch(0.287 0.015 257);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-block-start: 16px;
  scrollbar-gutter: stable;
  interpolate-size: allow-keywords;
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.5;
  caret-color: var(--focus);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--on-accent); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p, li, dd, figcaption { text-wrap: pretty; }
@supports (text-box: trim-both cap alphabetic) {
  h1 { text-box: trim-both cap alphabetic; }
}
a {
  color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px;
  transition: text-decoration-color var(--dur-ui) var(--ease-out), color var(--dur-ui) var(--ease-out);
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
button, input, select { font: inherit; color: inherit; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.hopp { position: absolute; inset-inline-start: 16px; top: -48px; background: var(--ink); color: var(--canvas); padding: 10px 16px; z-index: 10; border-radius: 6px; }
.hopp:focus { top: 12px; }

/* Asfalt: toppmeny, intro og bilvalg ligger på samme mørke flate */
.vei { background: var(--asfalt); color: var(--asfalt-ink); }
.vei ::selection { background: var(--accent); color: var(--on-accent); }
.ramme { max-width: 1320px; margin: 0 auto; padding: 0 var(--margin); }

/* Toppmeny */
.topp { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 20px; padding-bottom: 20px; }
.ordmerke { display: inline-flex; align-items: center; font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; text-decoration: none; }
.ordmerke span { color: var(--asfalt-muted); font-weight: 500; }
.ordmerke-skilt { width: 34px; height: 21px; flex: none; margin-right: 10px; }
.topp nav { display: flex; gap: 28px; font-size: var(--t-small); }
.topp nav a { text-decoration: none; color: var(--asfalt-muted); padding: 10px 0; transition: color 160ms ease; }
.topp nav a:hover { color: var(--asfalt-ink); }

/* Intro */
.vei-hero { padding-bottom: clamp(48px, 7vw, 104px); }
.intro { padding: clamp(32px, 7vw, 96px) 0 clamp(36px, 5vw, 64px); max-width: 1040px; }
h1 {
  font-size: var(--t-display);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 700;
  text-wrap: balance;
}
.ingress { margin-top: 24px; font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); line-height: 1.45; max-width: 36em; color: var(--asfalt-ink); }

/* Bilene: to kolonner med gul midtlinje mellom, som på en norsk landevei */
.bilene { display: grid; grid-template-columns: 1fr 96px 1fr; align-items: start; }
.midtlinje { align-self: stretch; position: relative; display: flex; justify-content: center; overflow: clip; }
.midtlinje::before {
  content: ''; position: absolute; top: -312px; bottom: 8px; left: 50%; width: 6px; margin-left: -3px;
  background: repeating-linear-gradient(to bottom, var(--midtlinje) 0 28px, transparent 28px 52px);
  border-radius: 3px;
}
.midtlinje span {
  position: relative; margin-top: 108px; align-self: flex-start;
  background: var(--asfalt); color: var(--asfalt-muted); padding: 10px 0; font-size: var(--t-small); font-weight: 500;
}
.bilkolonne { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.kolonnetittel { font-size: 1.25rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.serie-merke { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.serie-beholde { background: var(--series-beholde); }
.serie-bytte { background: var(--series-bytte); }

.skiltform { display: flex; gap: 10px; align-items: stretch; }
.skilt {
  flex: 1; min-width: 0;
  display: flex; align-items: stretch;
  background: var(--plate); color: var(--plate-ink);
  border: 3px solid var(--plate-ink);
  box-shadow: 0 0 0 2px var(--plate);
  border-radius: 10px;
  overflow: hidden;
  height: 76px;
  cursor: text;
}
.skilt:focus-within { outline: 3px solid var(--accent); outline-offset: 4px; }
.skilt-landkode {
  flex: none; width: 42px;
  background: var(--plate-strip); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
  padding: 0 0 9px; font-weight: 700; font-size: 1rem; line-height: 1;
}
.flagg { width: 22px; height: 16px; margin-bottom: auto; margin-top: 10px; }
.skilt-input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-weight: 700; font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.75rem);
  letter-spacing: 0.06em; text-transform: uppercase; padding: 0 14px;
  font-variant-numeric: tabular-nums;
  color: var(--plate-ink); caret-color: var(--plate-strip);
}
.skilt-input::placeholder { color: #b4b7b2; }

.knapp {
  border: 0; cursor: pointer; border-radius: var(--radius);
  padding: 0 26px; min-height: 48px; font-weight: 600;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.knapp:active { transform: scale(0.97); }
.knapp-primar { background: var(--accent); color: var(--on-accent); font-size: 1.0625rem; }
@media (hover: hover) and (pointer: fine) { .knapp-primar:hover { background: var(--accent-hover); } }
.knapp-primar:active { background: var(--accent-press); }
.knapp-primar[aria-busy="true"] { cursor: progress; opacity: 0.75; }
.knapp-stille { background: var(--surface); color: var(--ink); margin-top: 20px; }
@media (hover: hover) and (pointer: fine) { .knapp-stille:hover { background: var(--canvas); } }

.skiltstatus { min-height: 1.5em; font-size: var(--t-small); color: var(--asfalt-muted); }
.skiltstatus.feil { color: var(--asfalt-feil); font-weight: 500; }

.bilkort {
  background: var(--asfalt-2); border-radius: 20px; padding: 20px 22px;
  display: grid; gap: 8px;
}
.bilkort-navn { font-size: 1.375rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.bilkort-fakta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--asfalt-muted); font-size: var(--t-small); margin: 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
.bilkort-varsel { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: var(--t-small); margin-top: 6px; }
.vei .bilkort-varsel { background: #3a2f10; color: #ffe3a1; }
.ikon { width: 18px; height: 18px; flex: none; margin-top: 2px; }

.maler { border: 0; margin: 4px 0 0; padding: 0; min-width: 0; }
.maler legend { font-size: var(--t-small); color: var(--asfalt-muted); padding: 0; margin-bottom: 10px; }
.malvalg { display: flex; flex-wrap: wrap; gap: 8px; }
.malvalg label { position: relative; }
.malvalg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.malvalg span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius); background: var(--asfalt-2); color: var(--asfalt-ink); font-size: var(--t-small); font-weight: 500;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out);
}
.malvalg label:active span { transform: scale(0.97); }
.malvalg input:checked + span { background: var(--asfalt-ink); color: var(--asfalt); }
.malvalg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .malvalg input:not(:checked):hover + span { background: var(--asfalt-3); } }

/* Regnestykket */
.regnestykket {
  display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: clamp(24px, 4vw, 64px);
  padding-top: clamp(48px, 6vw, 80px); align-items: start;
}
.seksjonstittel { font-size: 1.25rem; font-weight: 600; margin-bottom: 20px; }
.kontroller { display: flex; flex-direction: column; gap: 26px; }
@media (min-width: 961px) and (min-height: 860px) {
  .kontroller:not(:has(details[open])) { position: sticky; top: 16px; }
}

.glider-topp { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.glider-topp label { font-weight: 500; }
.verdifelt { display: inline-flex; align-items: baseline; gap: 6px; }
.verdifelt input {
  width: 7.5ch; text-align: right; border: 0; border-bottom: 2px solid var(--line);
  background: transparent; padding: 2px 0; font-weight: 600; font-size: 1.125rem;
  font-variant-numeric: tabular-nums; border-radius: 0;
  -moz-appearance: textfield; appearance: textfield;
}
.verdifelt input::-webkit-outer-spin-button, .verdifelt input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.verdifelt input:focus { border-bottom-color: var(--focus); outline: none; }
.verdifelt input::placeholder { color: var(--muted); font-weight: 400; }
.enhet { color: var(--muted); font-size: var(--t-small); }
.hjelp { font-size: var(--t-small); color: var(--muted); margin-top: 6px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; cursor: pointer; margin: 0;
  --fyll: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--ink) var(--fyll), var(--surface-2) var(--fyll));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; margin-top: -10px;
  background: var(--surface); border: 3px solid var(--ink);
  transition: transform 160ms var(--ease-out);
}
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--focus); }

.horisont { border: 0; padding: 0; margin: 0; }
.horisont legend { font-weight: 500; margin-bottom: 10px; padding: 0; }
.segment { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface-2); border-radius: var(--radius); padding: 4px; }
.segment label { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: var(--radius);
  font-weight: 500; font-size: var(--t-small); transition: background-color 160ms ease, color 160ms ease;
}
.segment input:checked + span { background: var(--ink); color: var(--canvas); }
.segment input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.flere { background: var(--surface-2); border-radius: 18px; }
.flere summary { cursor: pointer; padding: 14px 20px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
.flere summary::-webkit-details-marker { display: none; }
.flere summary::after { content: '+'; font-size: 1.5rem; line-height: 1; font-weight: 500; transition: transform 200ms var(--ease-out); }
.flere[open] summary::after { transform: rotate(45deg); }
.flere-innhold { padding: 0 20px 20px; }
.flere h3 { font-size: 1rem; font-weight: 600; margin: 18px 0 10px; }
.flere h3:first-child { margin-top: 0; }
.feltrad { display: grid; gap: 10px; }
.felt { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: var(--t-small); }
.felt .verdifelt input { font-size: 1rem; width: 7ch; }

/* Resultat */
.resultat { min-width: 0; display: flex; flex-direction: column; gap: 28px; }
/* Svaret står på vegskiltgult: det eneste stedet utenom primærknappen som får aksentfargen. */
.konklusjon {
  background: var(--accent); color: var(--on-accent);
  border-radius: 28px; padding: clamp(26px, 4vw, 52px);
}
.konklusjon ::selection { background: var(--on-accent); color: var(--accent); }
.konklusjon-tekst {
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 3.25rem); line-height: 1.04; letter-spacing: -0.03em; font-weight: 700; text-wrap: balance;
  font-variant-numeric: tabular-nums;
}
.krysning-tekst { margin-top: 18px; font-size: 1.125rem; color: var(--konklusjon-under); max-width: 40em; }

.nokkeltall { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0; }
.nokkel { background: var(--surface); border-radius: 20px; padding: 18px 22px; }
.nokkel dt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; }
.nokkel dd { margin: 4px 0 0; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.nokkel dd .enhet { font-size: 1rem; font-weight: 500; letter-spacing: 0; }
.nokkel-under { display: block; font-size: var(--t-small); color: var(--muted); font-weight: 400; margin-top: 2px; letter-spacing: 0; }

.varsler { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.varsler:empty { display: none; }
.varsler li { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-bg); color: var(--warn-ink); border-radius: 14px; padding: 12px 16px; }
.varsler li.info { background: var(--surface); color: var(--ink); }

.graf { margin: 0; background: var(--surface); border-radius: 28px; padding: clamp(18px, 3vw, 32px); }
.graf figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; margin-bottom: 12px; }
.graf-tittel { font-weight: 600; font-size: 1.125rem; }
.tegnforklaring { display: flex; gap: 20px; font-size: var(--t-small); color: var(--muted); }
.tegnforklaring > span { display: inline-flex; align-items: center; gap: 8px; }
.strek { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.graf-flate { position: relative; height: clamp(260px, 32vw, 360px); touch-action: pan-y; }
.graf-flate svg { display: block; width: 100%; height: 100%; overflow: visible; }
.graf-flate svg:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 8px; }
.graf-flate text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.akse-tekst { fill: var(--axis-text); font-size: 13px; }
.rutenett { stroke: var(--grid); stroke-width: 1; }
.grunnlinje { stroke: var(--axis); stroke-width: 1; }
.linje { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.linje-beholde { stroke: var(--series-beholde); }
.linje-bytte { stroke: var(--series-bytte); }
.punkt-beholde { fill: var(--series-beholde); stroke: var(--surface); stroke-width: 2; }
.punkt-bytte { fill: var(--series-bytte); stroke: var(--surface); stroke-width: 2; }
.serie-etikett { font-size: 14px; font-weight: 600; fill: var(--ink); }
.horisont-linje { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.horisont-tekst { fill: var(--muted); font-size: 13px; font-weight: 500; }
.krysning-punkt { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.krysning-etikett { fill: var(--ink); font-size: 13px; font-weight: 600; }
.sikte { stroke: var(--muted); stroke-width: 1; }
.verktoytips {
  position: absolute; top: 0; left: 0; pointer-events: none;
  background: var(--ink); color: var(--canvas); border-radius: 12px; padding: 10px 14px;
  font-size: var(--t-small); line-height: 1.4; white-space: nowrap; font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  opacity: 0; transform: translateY(4px); transition: opacity 120ms ease, transform 160ms var(--ease-out);
}
.verktoytips.synlig { opacity: 1; transform: none; }
.verktoytips b { font-weight: 600; }
.verktoytips .rad { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.verktoytips .rad span:first-child { display: inline-flex; align-items: center; gap: 6px; }

.tabellboks { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 600; font-size: 1.125rem; padding: 0 0 12px; }
th, td { padding: 11px 12px; text-align: right; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
thead th { font-weight: 500; color: var(--muted); font-size: var(--t-small); }
tbody tr:nth-child(odd) td, tbody tr:nth-child(odd) th { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
tbody th { font-weight: 400; }
tfoot th, tfoot td { font-weight: 700; padding-top: 14px; }
.kostnadstabell td.lavest { font-weight: 600; }

.aarstabell summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.aarstabell[open] summary { margin-bottom: 8px; }

/* Metode */
.metode { padding: var(--gap-section) 0 0; }
.metode h2 { font-size: var(--t-heading); letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 24px; }
.metode-formel {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem); font-weight: 600; line-height: 1.3; max-width: 34em;
  background: var(--surface-2); border-radius: 20px; padding: 22px 26px; margin-bottom: 40px;
}
.metode-kolonner { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px 48px; }
.metode h3 { font-size: 1.125rem; font-weight: 600; margin: 0 0 6px; }
.metode p + h3 { margin-top: 24px; }
.metode-kolonner p { max-width: 36em; }
.forbehold { margin-top: 40px; color: var(--muted); max-width: 46em; }

/* Bunn: veien kommer tilbake, med midtlinjen på tvers */
.bunn {
  background: var(--asfalt); color: var(--asfalt-muted); font-size: var(--t-small);
  margin-top: var(--gap-section);
  padding: 0 max(var(--margin), calc((100% - 1320px) / 2 + var(--margin))) 120px;
  overflow-x: clip;
}
.bunn::before {
  content: ''; display: block; height: 6px; margin-bottom: clamp(48px, 7vw, 96px);
  background: repeating-linear-gradient(to right, var(--midtlinje) 0 44px, transparent 44px 80px);
}
.bunn-ordmerke { font-size: clamp(2.75rem, 1.5rem + 7vw, 8rem); font-weight: 700; letter-spacing: -0.045em; line-height: 0.92; color: var(--asfalt-ink); margin-bottom: 20px; }

.mobilsvar { display: none; }
.noscript { position: fixed; inset: auto 16px 16px; background: var(--ink); color: var(--canvas); padding: 16px; border-radius: 16px; }

/* Nettbrett og mobil */
@media (max-width: 960px) {
  .regnestykket { grid-template-columns: 1fr; }
  .kontroller { position: static; }
  .metode-kolonner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .topp { flex-wrap: wrap; row-gap: 4px; padding-bottom: 8px; }
  .topp nav { order: 2; width: 100%; gap: 20px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
  .topp nav::-webkit-scrollbar { display: none; }
  .bilene { grid-template-columns: 1fr; }
  .midtlinje { height: 72px; align-items: center; }
  .midtlinje::before {
    top: 50%; bottom: auto; left: -312px; right: 0; width: auto; height: 6px; margin: -3px 0 0;
    background: repeating-linear-gradient(to right, var(--midtlinje) 0 28px, transparent 28px 52px);
  }
  .midtlinje span { margin-top: 0; align-self: center; padding: 0 14px; }
  .metode-kolonner { grid-template-columns: 1fr; }
  .skilt { height: 64px; }
  .nokkeltall { gap: 10px; }
  .nokkel { padding: 14px 16px; }
  .konklusjon, .graf { border-radius: 22px; }
  .mobilsvar {
    display: block; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 5;
    transform: translateY(140%); transition: transform 240ms var(--ease-out);
  }
  .mobilsvar.synlig { transform: none; }
  .mobilsvar a {
    display: block; background: var(--ink); color: var(--canvas); text-decoration: none;
    border-radius: 18px; padding: 14px 18px; font-weight: 600; font-variant-numeric: tabular-nums;
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
  }
}

/* Bevegelse. Innhold er synlig uten JavaScript; klassen .js settes av app.js. */
@media (prefers-reduced-motion: no-preference) {
  .js .intro h1, .js .intro .ingress, .js .bilkolonne, .js .midtlinje {
    animation: opp 700ms var(--ease-out) both;
  }
  .js .intro .ingress { animation-delay: 70ms; }
  .js .bilkolonne[data-rolle="naa"] { animation-delay: 140ms; }
  .js .midtlinje { animation-delay: 200ms; }
  .js .bilkolonne[data-rolle="ny"] { animation-delay: 260ms; }
  .js .midtlinje::before { animation: kjor 1600ms var(--ease-out) 200ms both; }
  @media (max-width: 720px) { .js .midtlinje::before { animation-name: kjor-tvers; } }

  .js [data-inn] { opacity: 0; transform: translateY(24px); transition: opacity 600ms var(--ease-out), transform 700ms var(--ease-out); transition-delay: var(--forsinkelse, 0ms); }
  .js [data-inn].inne { opacity: 1; transform: none; }
}
@keyframes opp { from { opacity: 0; transform: translateY(20px); } }
@keyframes kjor { from { translate: 0 -312px; } }
@keyframes kjor-tvers { from { translate: -312px 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
.belop { white-space: nowrap; }
@media (max-width: 480px) {
  th, td { padding: 10px 6px; font-size: var(--t-small); }
  caption { font-size: 1.0625rem; }
}

/* Gjeldende side i menyen */
.topp nav a[aria-current="page"] { color: var(--asfalt-ink); text-decoration: underline; text-decoration-color: var(--midtlinje); text-decoration-thickness: 3px; text-underline-offset: 8px; }

/* ---------- Artikler ---------- */
.artikkel-topp { padding-top: clamp(28px, 5vw, 72px); padding-bottom: clamp(40px, 6vw, 88px); }
.artikkel-topp h1 { font-size: clamp(2rem, 1.4rem + 3.5vw, 5rem); max-width: 16ch; hyphens: auto; overflow-wrap: break-word; }
.artikkel-topp .ingress { max-width: 38em; }
.smuler { font-size: var(--t-small); color: var(--asfalt-muted); margin-bottom: 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.smuler a { color: var(--asfalt-muted); }
.smuler a:hover { color: var(--asfalt-ink); }
.artikkel-meta { margin-top: 20px; font-size: var(--t-small); color: var(--asfalt-muted); }

.artikkel-ramme {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(32px, 6vw, 96px);
  padding-top: clamp(40px, 6vw, 80px); align-items: start;
}
.artikkel { max-width: 44rem; font-size: 1.125rem; line-height: 1.6; }
.artikkel > * + * { margin-top: 1.1em; }
.artikkel h2 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); line-height: 1.12; letter-spacing: -0.02em; margin-top: 2.2em; text-wrap: balance; }
.artikkel h2:first-child { margin-top: 0; }
.artikkel h3 { font-size: 1.25rem; line-height: 1.25; margin-top: 1.8em; }
.artikkel h2 + *, .artikkel h3 + * { margin-top: 0.6em; }
.artikkel ul, .artikkel ol { padding-left: 1.3em; margin-bottom: 0; }
.artikkel li + li { margin-top: 0.45em; }
.artikkel li::marker { color: var(--muted); }
.artikkel a { text-decoration-thickness: 2px; text-decoration-color: var(--midtlinje); }
.artikkel a:hover { text-decoration-color: var(--ink); }
.artikkel strong { font-weight: 600; }
.artikkel .tabellboks { margin-top: 1.4em; }
.artikkel table { font-size: 1rem; }
.artikkel caption { font-size: 1rem; }
.kilde { font-size: var(--t-small); color: var(--muted); }

.faktaboks { background: var(--surface); border-radius: 22px; padding: clamp(20px, 3vw, 32px); }
.faktaboks h2, .faktaboks h3 { margin-top: 0; }
.faktaboks > * + * { margin-top: 0.8em; }
.sjekkliste { list-style: none; padding: 0 !important; counter-reset: punkt; }
.sjekkliste li { position: relative; padding-left: 44px; counter-increment: punkt; }
.sjekkliste li + li { margin-top: 1em; }
.sjekkliste li::before {
  content: counter(punkt); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--canvas);
  display: grid; place-items: center; font-size: 0.9375rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

.artikkel-side { display: grid; gap: 20px; position: sticky; top: 24px; }
.cta-kort { background: var(--accent); color: var(--on-accent); border-radius: 24px; padding: 26px; }
.cta-kort h2 { font-size: 1.5rem; line-height: 1.15; letter-spacing: -0.02em; }
.cta-kort p { margin-top: 10px; color: var(--konklusjon-under); }
.knapp-blekk {
  display: inline-flex; align-items: center; justify-content: center; margin-top: 18px; text-decoration: none;
  background: var(--on-accent); color: var(--accent); border-radius: var(--radius); min-height: 48px; padding: 0 24px; font-weight: 600;
  transition: transform 160ms var(--ease-out);
}
.knapp-blekk:active { transform: scale(0.97); }
.les-ogsa { background: var(--surface); border-radius: 24px; padding: 22px 26px; }
.les-ogsa h2 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 8px; }
.les-ogsa ul { list-style: none; margin: 0; padding: 0; }
.les-ogsa a { display: block; padding: 10px 0; text-decoration: none; font-weight: 500; }
.les-ogsa a:hover { text-decoration: underline; text-decoration-color: var(--midtlinje); text-decoration-thickness: 2px; }

/* Omregistreringskalkulator i artikkelen */
.minikalk { background: var(--surface-2); border-radius: 24px; padding: clamp(20px, 3vw, 32px); display: grid; gap: 18px; }
.minikalk h2 { margin-top: 0 !important; }
.minikalk-felter { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.minikalk label { display: grid; gap: 6px; font-size: var(--t-small); font-weight: 500; }
.minikalk input, .minikalk select {
  min-height: 48px; border-radius: 14px; border: 2px solid transparent; background: var(--surface); padding: 0 14px;
  font-size: 1.0625rem; font-variant-numeric: tabular-nums; width: 100%;
}
.minikalk input:focus, .minikalk select:focus { outline: none; border-color: var(--focus); }
.minikalk-svar { background: var(--accent); color: var(--on-accent); border-radius: 18px; padding: 18px 22px; }
.minikalk-svar strong { display: block; font-size: clamp(2rem, 1.4rem + 2vw, 3rem); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.minikalk-svar span { display: block; margin-top: 8px; color: var(--konklusjon-under); font-size: var(--t-small); }
.minikalk-skilt { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.minikalk-skilt label { flex: 1 1 200px; }
.minikalk-skilt .knapp { background: var(--ink); color: var(--canvas); }
.minikalk-status { font-size: var(--t-small); color: var(--muted); min-height: 1.4em; }
.minikalk-status.feil { color: var(--error); }

/* Spørsmål og svar på forsiden */
.sporsmal { padding-top: var(--gap-section); }
.sporsmal > h2 { font-size: var(--t-heading); letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 28px; }
.sporsmal-liste { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sporsmal-liste > div { background: var(--surface); border-radius: 22px; padding: 24px 26px; }
.sporsmal-liste h3 { font-size: 1.1875rem; line-height: 1.3; margin-bottom: 8px; }
.sporsmal-liste a { text-decoration-color: var(--midtlinje); text-decoration-thickness: 2px; }

/* Guider i bunnen */
.bunn-lenker { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 24px; padding: 0; list-style: none; font-size: 1rem; }
.bunn-lenker a { color: var(--asfalt-ink); text-decoration: none; }
.bunn-lenker a:hover { text-decoration: underline; text-decoration-color: var(--midtlinje); text-decoration-thickness: 2px; }

@media (max-width: 960px) {
  .artikkel-ramme { grid-template-columns: 1fr; }
  .artikkel-side { position: static; }
  .sporsmal-liste { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .minikalk-felter { grid-template-columns: 1fr; }
  .artikkel { font-size: 1.0625rem; }
}

/* ---------- Moderne plattform: kontinuitet, scrolling og finish ---------- */

/* Bunnens midtlinje er litt lengre enn flaten, så den kan «kjøre» når du scroller. */
.bunn::before { width: calc(100% + 80px); margin-inline-start: -80px; }

/* Bilkolonnen er en gjenbrukt komponent: smal kolonne legger Hent-knappen under skiltet. */
.bilkolonne { container-type: inline-size; }
@container (width < 340px) {
  .skiltform { flex-direction: column; }
  .skiltform .knapp { inline-size: 100%; }
}

/* Nytt bilkort toner inn når bilen byttes (sjelden handling, ingen JS). */
.bilkort > * { transition: opacity var(--dur-ui) var(--ease-out), translate var(--dur-ui) var(--ease-out); }
@starting-style { .bilkort > * { opacity: 0; translate: 0 6px; } }

/* Utfoldbare paneler åpnes til auto-høyde; uten støtte åpner de bare. */
@supports selector(::details-content) {
  .flere::details-content, .aarstabell::details-content {
    block-size: 0; overflow: clip;
    transition: block-size 280ms var(--ease-out), content-visibility 280ms allow-discrete;
  }
  .flere[open]::details-content, .aarstabell[open]::details-content { block-size: auto; }
}

/* Lange seksjoner under bretten tegnes først når de nærmer seg. */
.metode, .sporsmal { content-visibility: auto; contain-intrinsic-size: auto 900px; }

[id] { scroll-margin-block-start: 16px; }

/* Scrollstyrt bevegelse: bare der den skal følge scrollingen begge veier. */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    /* Midtlinjen i toppen kjører nedover mens du scroller forbi bilene. */
    @media (min-width: 721px) {
      .js .midtlinje::before {
        animation: kjor 1600ms var(--ease-out) 200ms both, kjor-scroll linear both;
        animation-timeline: auto, scroll(root);
        animation-range: normal, 0 100vh;
      }
    }
    /* Bunnens midtlinje glir sidelengs når bunnen kommer til syne. */
    .bunn::before { animation: kjor-bunn linear both; animation-timeline: view(); animation-range: entry 0% cover 60%; }
    /* Lesefremdrift på guidene, i midtlinjegult. */
    body:has(.artikkel)::after {
      content: ''; position: fixed; inset-block-start: 0; inset-inline: 0; block-size: 4px; z-index: 20;
      background: var(--midtlinje); transform-origin: left; pointer-events: none;
      animation: fremdrift linear both; animation-timeline: scroll(root);
    }
  }
}
@keyframes kjor-scroll { to { transform: translateY(156px); } }
@keyframes kjor-bunn { from { transform: translateX(0); } to { transform: translateX(80px); } }
@keyframes fremdrift { from { transform: scaleX(0); } }

/* Sideoverganger mellom kalkulatoren og guidene. Toppmenyen står stille, innholdet bytter. */
@view-transition { navigation: auto; }
.topp { view-transition-name: topp; }
.artikkel-topp h1 { view-transition-name: tittel; }
::view-transition-group(topp) { animation: none; }
::view-transition-old(root) { animation: 140ms var(--ease-out) both side-ut; }
::view-transition-new(root) { animation: var(--dur-page) var(--ease-out) 40ms both side-inn; }
/* Lenken du trykker på blir overskriften på siden du kommer til. */
::view-transition-group(tittel) { animation-duration: 380ms; animation-timing-function: var(--ease-in-out); }
@keyframes side-ut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes side-inn { from { opacity: 0; transform: translateY(12px); } }
/* Når siden kommer via en overgang, spilles ikke lasteanimasjonen i toppen i tillegg. */
.via-overgang .intro h1, .via-overgang .intro .ingress, .via-overgang .bilkolonne, .via-overgang .midtlinje { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Krysningssvaret rett under grafen, merket med en bit midtlinje */
.krysningsboks {
  display: flex; align-items: baseline; gap: 12px; margin-top: 18px;
  background: var(--canvas); border-radius: 16px; padding: 14px 18px;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); font-weight: 700; letter-spacing: -0.01em; line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.krysningsboks::before { content: ''; flex: none; inline-size: 22px; block-size: 6px; border-radius: 3px; background: var(--midtlinje); translate: 0 -0.2em; }
.krysningsboks:empty { display: none; }

/* Neste steg etter svaret */
.neste { background: var(--asfalt); color: var(--asfalt-ink); border-radius: 28px; padding: clamp(24px, 3.5vw, 40px); }
.neste h2 { font-size: var(--t-heading); letter-spacing: -0.02em; line-height: 1.1; }
.neste-ingress { margin-top: 10px; color: var(--asfalt-muted); }
.neste-liste { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 4px; }
.neste-liste li { padding: 14px 0; }
.neste-liste a {
  font-weight: 600; font-size: 1.125rem; color: var(--asfalt-ink);
  text-decoration-color: var(--midtlinje); text-decoration-thickness: 2px; text-underline-offset: 0.25em;
}
.neste-liste a:hover { text-decoration-thickness: 3px; }
.neste-liste p { margin-top: 4px; color: var(--asfalt-muted); max-width: 46em; }

/* Verdikurve på /verditap-bil/ */
.verdigraf { margin: 1.6em 0 0; background: var(--surface); border-radius: 24px; padding: clamp(16px, 3vw, 28px); }
.verdigraf svg { display: block; inline-size: 100%; block-size: auto; }
.verdigraf figcaption { margin-top: 10px; font-size: var(--t-small); color: var(--muted); }
.verdigraf-grunn { stroke: var(--axis); stroke-width: 1; }
.verdigraf-sone { fill: var(--canvas); }
.verdigraf-sonetekst { fill: var(--ink); font-size: 15px; font-weight: 600; }
.verdigraf-stolpe { fill: var(--series-beholde); }
.verdigraf-verdi { fill: var(--ink); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.verdigraf-akse { fill: var(--axis-text); font-size: 13px; }
.verdigraf text { font-family: var(--font); }

/* Avsender, kontakt og rettigheter i bunnen */
.bunn p + p { margin-top: 8px; }
.bunn p a { color: var(--asfalt-ink); text-decoration-color: var(--midtlinje); text-decoration-thickness: 2px; }
.bunn-avsender { color: var(--asfalt-ink); font-size: 1rem; }
.bunn-rettigheter { margin-top: 24px !important; }
