:root {
  --bg: #f4f5fa; --card: #ffffff; --text: #14161f; --muted: #3f4456; --line: #cfd3e3;
  --accent: #2b3bd0; --accent-text: #ffffff; --ring: #e8380d; --bezel: #14161f;
  --focus: #b35900; --note-bg: #fff4d6; --note-text: #4a3500;
  --top: 52px; --nav: 76px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --card: #1a1d28; --text: #f3f4f8; --muted: #c4c8d8; --line: #3a3f55;
    --accent: #8b9bff; --accent-text: #0f1117; --ring: #e8380d; --bezel: #000;
    --focus: #ffc266; --note-bg: #3a2f10; --note-text: #ffe9b0;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body { font: 20px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Knapper */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; min-width: 48px; padding: 8px 18px; font-family: inherit; font-weight: 700; font-size: 20px; line-height: 1.1; color: var(--text); background: var(--card); border: 3px solid var(--line); border-radius: 14px; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn-main { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-big { min-height: 64px; font-size: 24px; padding: 12px 28px; }
.btn:disabled { opacity: .35; cursor: default; }
.btn[hidden] { display: none; }

/* Øverste linje */
.topbar { position: fixed; z-index: 5; top: 0; left: 0; right: 0; height: var(--top); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--card); border-bottom: 2px solid var(--line); }
.topbar .btn { min-height: 44px; padding: 4px 14px; font-size: 18px; }
.count { margin: 0; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.bar { position: absolute; left: 0; right: 0; bottom: -2px; height: 5px; background: var(--line); }
.bar-fill { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform .3s; }

/* Nederste linje */
.nav { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; height: var(--nav); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; padding: 0 12px; background: var(--card); border-top: 2px solid var(--line); }
.nav .btn { min-height: 56px; font-size: 22px; width: 100%; max-width: 320px; }
.nav #prev { justify-self: start; }
.nav #next { justify-self: end; }

/* Lysbilde-rekka: sveip sidelengs, ett bilde om gangen */
.deck { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100dvh; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; outline: none; }
.deck::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; padding: calc(var(--top) + 8px) 16px calc(var(--nav) + 8px); overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; display: flex; align-items: center; justify-content: center; }

/* Forklaringsbilder: kort tekst, stor skrift */
.slide-in { width: 100%; max-width: 640px; margin: auto; }
.eyebrow { margin: 0 0 8px; font-weight: 800; font-size: 18px; letter-spacing: .02em; color: var(--accent); text-transform: uppercase; }
h1, h2 { margin: 0 0 14px; line-height: 1.12; }
h1 { font-size: clamp(36px, 10vw, 60px); }
.slide-text h2 { font-size: clamp(36px, 10vw, 60px); }
.big { margin: 0 0 14px; font-size: clamp(27px, 7.4vw, 38px); line-height: 1.3; }
.note { display: inline-block; margin: 0 0 14px; padding: 6px 14px; background: var(--note-bg); color: var(--note-text); border-radius: 12px; font-weight: 700; font-size: 19px; }
.small { margin: 16px 0 0; font-size: 18px; color: var(--muted); }
.logo { display: block; margin-bottom: 14px; border-radius: 16px; }
.hint { margin: 18px 0 0; font-size: clamp(26px, 7vw, 36px); font-weight: 800; color: var(--accent); }
.arrow { display: inline-block; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(10px); } }
pre { margin: 12px 0 0; padding: 12px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; font-size: 16px; white-space: pre-wrap; word-break: break-word; }
.slide-end p { margin: 0 0 14px; }

/* Animerte bilder */
.anim { --h: clamp(200px, calc(100vh - 262px), 660px); --h: clamp(200px, calc(100dvh - 262px), 660px); margin: auto; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.phone { background: var(--bezel); padding: 6px; border-radius: 26px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
/* Bildet og markøren ligger i samme boks, som har nøyaktig bildets sideforhold: da faller markøren alltid på rett sted. */
.shot { position: relative; height: var(--h); aspect-ratio: 780 / 1688; }
.shot-wide { height: auto; width: min(calc(100vw - 56px), 520px); aspect-ratio: 4 / 3; }
.frame { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; border-radius: 20px; background: #fff; opacity: 0; transition: opacity .5s ease; }
.frame.is-active { opacity: 1; }
.anim.is-drawing .phone { padding: 4px; background: var(--line); box-shadow: none; }

/* Markør: fast størrelse, bare blinking. Midten ligger på trykkpunktet. */
.marker { position: absolute; left: var(--x, 50%); top: var(--y, 50%); width: 44px; height: 44px; transform: translate(-50%, -50%); border: 4px solid var(--ring); border-radius: 50%; box-shadow: 0 0 0 2px #fff, inset 0 0 0 2px #fff, 0 2px 8px 2px rgba(0, 0, 0, .3); pointer-events: none; opacity: 0; transition: left .5s ease, top .5s ease; }
.marker.is-on { opacity: 1; animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

figcaption { width: min(100%, 460px); text-align: center; }
.phone.is-scrub { position: relative; cursor: pointer; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.phone.is-scrub img { -webkit-user-drag: none; pointer-events: none; }
.phone.is-scrub:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.paused { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 18px; border-radius: 999px; background: rgba(0, 0, 0, .72); color: #fff; font-weight: 700; font-size: 1.1rem; opacity: 0; transition: opacity .2s; pointer-events: none; }
.phone.is-paused .paused { opacity: 1; }
.hint-seen .hint { display: none; }
.hint { margin: 4px 0 0; font-size: .95rem; color: var(--muted); text-align: center; }
.dots { display: flex; justify-content: center; gap: 8px; margin: 0 0 6px; height: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dot.is-on { background: var(--accent); }
.caption { margin: 0 0 8px; min-height: 2.6em; display: flex; align-items: center; justify-content: center; font-size: clamp(18px, 4.8vw, 22px); font-weight: 700; line-height: 1.25; }

/* Meny */
.menu { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .6); }
.menu[hidden] { display: none; }
.menu-in { width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; padding: 20px; background: var(--card); border-radius: 22px; }
.menu-in h2 { font-size: 30px; margin-bottom: 12px; }
.menu-in ul { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.menu-link { width: 100%; justify-content: flex-start; text-align: left; }
.menu-in p { margin: 0; }
.menu-in .btn-main { width: 100%; }

/* Tegninger (Hjem-skjerm) */
.d-box { fill: var(--card); stroke: var(--line); stroke-width: 3; }
.d-line { fill: none; stroke: var(--text); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.d-hl { fill: var(--accent); opacity: .25; }
.frame-svg text { font: 600 30px system-ui, sans-serif; text-anchor: middle; }
.d-t { fill: var(--text); }
.frame-svg .d-s { font-size: 24px; }
.frame-svg .d-n { fill: var(--accent); font-weight: 800; font-size: 34px; }
.d-icon { fill: var(--accent); }
.frame-svg .d-w { fill: var(--accent-text); font-weight: 800; font-size: 38px; }

/* Liggende telefon: bilde til venstre, tekst til høyre */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --top: 44px; --nav: 60px; }
  .topbar .btn { min-height: 36px; font-size: 16px; }
  .nav .btn { min-height: 46px; font-size: 20px; }
  .slide { padding: calc(var(--top) + 6px) 24px calc(var(--nav) + 6px); }
  .anim { --h: clamp(150px, calc(100vh - var(--top) - var(--nav) - 28px), 660px); --h: clamp(150px, calc(100dvh - var(--top) - var(--nav) - 28px), 660px); flex-direction: row; gap: 28px; }
  .anim.is-drawing .shot-wide { width: min(46vw, calc((100vh - var(--top) - var(--nav) - 44px) * 4 / 3)); width: min(46vw, calc((100dvh - var(--top) - var(--nav) - 44px) * 4 / 3)); }
  figcaption { width: min(46%, 380px); }
  .caption { font-size: 22px; min-height: 0; }
  .slide-text h2 { font-size: clamp(28px, 6vw, 40px); }
  .big { font-size: clamp(20px, 3.6vw, 26px); margin-bottom: 8px; }
  h1 { font-size: clamp(28px, 5.5vw, 40px); }
  .logo { width: 48px; height: 48px; margin-bottom: 6px; }
  .hint { margin-top: 8px; font-size: 24px; }
  .small { margin-top: 8px; font-size: 16px; }
  .note { margin-bottom: 8px; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .frame, .marker, .bar-fill { transition: none; }
  .marker.is-on { animation: none; }
  .arrow { animation: none; }
}
