:root {
  --navy: #1c2b4a;
  --ink: #1a2236;
  --accent: #0a84ff;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(120% 95% at 50% 38%, #f7f7f8 0%, #e5e6e9 55%, #cdd0d6 100%);
  -webkit-font-smoothing: antialiased;
  /* Aanraken: geen dubbeltik-zoom, geen rubberband, geen tekstselectie of knoppenmenu */
  touch-action: manipulation; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; outline: none; }

/* Titel en terugknop (alleen bij het boek) */
.title {
  position: fixed; left: 24px; top: 22px; display: flex; flex-direction: column; gap: 1px;
  padding: 10px 18px; border-radius: 18px; pointer-events: none;
}
.title strong { font-size: 14px; letter-spacing: .01em; font-weight: 650; }
.title span { font-size: 12px; opacity: .65; }
/* Taalkeuze NL | EN: altijd zichtbaar, rechtsboven */
#lang {
  position: fixed; right: 24px; top: 22px; z-index: 5; display: flex; gap: 2px; padding: 4px; border-radius: 999px;
  transition: opacity .2s;
}
#lang button {
  height: 36px; min-width: 44px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 650; letter-spacing: .05em; color: rgba(255, 255, 255, .78);
  transition: background .15s, color .15s, transform .12s;
}
#lang button:hover { background: rgba(255, 255, 255, .15); }
#lang button:active { transform: scale(.95); }
#lang button[aria-pressed="true"] { background: #fff; color: #1c1c1e; cursor: default; }
#lang[data-busy] { opacity: .55; pointer-events: none; }
#backBtn {
  position: fixed; right: 138px; top: 22px; display: inline-flex; align-items: center; gap: 4px;
  height: 44px; padding: 0 18px 0 12px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .12s;
}
#backBtn:hover { background: rgba(60, 56, 52, .62); }
#backBtn:active { transform: scale(.96); }

/* Startscherm */
#intro {
  position: fixed; left: clamp(20px, 5vw, 72px); bottom: calc(9vh + var(--safe-b));
  width: min(440px, 92vw); padding: 30px 34px 32px; border-radius: 30px; text-align: left;
}
#intro h1 { margin: 0; font-size: clamp(28px, 4.2vw, 42px); font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
#intro p { margin: 8px 0 22px; font-size: 15px; opacity: .75; }
#intro .pill { height: 48px; padding: 0 22px 0 26px; font-size: 16px; }
#intro .pill em { font-style: normal; }

/* Wat zichtbaar is per stand: intro (kamer) / flying / view (boek) */
#intro, #bar, #hint, .title, #backBtn { transition: opacity .6s ease, transform .6s ease; }
body:not([data-mode="intro"]) #intro { opacity: 0; transform: translateY(18px); pointer-events: none; }
body:not([data-mode="view"]) #bar { opacity: 0; transform: translate(-50%, 24px); pointer-events: none; }
body:not([data-mode="view"]) #hint { opacity: 0; pointer-events: none; }
body:not([data-mode="view"]) .title { opacity: 0; transform: translateY(-10px); }
body:not([data-mode="view"]) #backBtn { opacity: 0; transform: translateY(-10px); pointer-events: none; }

/* ---- Glas: gedeelde stijl voor balk, hint en zoombalk -------------------- */
.glass {
  color: #fff;
  background: rgba(30, 28, 26, .64);
  -webkit-backdrop-filter: blur(26px) saturate(1.7);
  backdrop-filter: blur(26px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .09);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(34, 32, 30, .88); }
}

#hint {
  position: fixed; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; font-size: 12.5px; letter-spacing: .01em; text-align: center;
  width: max-content; max-width: 92vw; pointer-events: none; transition: opacity .8s, transform .8s;
}
#hint.gone { opacity: 0; transform: translateX(-50%) translateY(6px); }

#bar, #zoomBar {
  display: flex; align-items: center; gap: 4px; padding: 8px; border-radius: 999px;
}
#bar { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); }

/* Knoppen */
button { font: inherit; color: inherit; border: 0; background: transparent; cursor: pointer; padding: 0; }
.ib, .pill {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  height: 44px; border-radius: 999px; transition: background .15s, transform .12s, opacity .15s;
}
.ib { width: 44px; }
.ib:hover { background: rgba(255, 255, 255, .15); }
.ib:active { background: rgba(255, 255, 255, .24); transform: scale(.94); }
.pill {
  gap: 8px; padding: 0 20px 0 16px; background: #fff; color: #1c1c1e;
  font-size: 14px; font-weight: 600; letter-spacing: .005em;
}
.pill em { font-style: normal; }
.pill:hover { background: #f0f0f2; }
.pill:active { transform: scale(.96); background: #e4e4e7; }
button:disabled { opacity: .35; cursor: default; pointer-events: none; }
button:focus-visible, #slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pill svg { width: 20px; height: 20px; }
.sep { flex: none; width: 1px; height: 24px; background: rgba(255, 255, 255, .2); margin: 0 6px; }

/* Tooltip met sneltoets */
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 14px);
  transform: translate(-50%, 4px); padding: 6px 11px; border-radius: 9px; white-space: pre;
  background: rgba(28, 28, 30, .92); color: #fff; font-size: 12px; font-weight: 500; letter-spacing: .01em;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
@media (hover: hover) { [data-tip]:hover::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .35s; } }
[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* Paginalabel + scrubber */
.pager { display: flex; flex-direction: column; align-items: stretch; gap: 3px; width: 224px; padding: 0 8px; }
.pg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; white-space: nowrap; }
#label, #zLabel { font-size: 13px; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
#sub { font-size: 11.5px; opacity: .62; font-variant-numeric: tabular-nums; }
#slider {
  --p: 0%; -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0;
  background: transparent; cursor: pointer;
}
#slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(#fff, #fff) 0 / var(--p) 100% no-repeat, rgba(255, 255, 255, .28);
}
#slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .45); transition: transform .12s;
}
#slider:active::-webkit-slider-thumb { transform: scale(1.18); }
#slider::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .28); }
#slider::-moz-range-progress { height: 4px; border-radius: 2px; background: #fff; }
#slider::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .45); }

/* ---- Zoomoverlay --------------------------------------------------------- */
#zoom { position: fixed; inset: 0; z-index: 10; background: rgb(14, 20, 36); }
#zoomStage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
#zoomStage.drag { cursor: grabbing; }
/* Geen will-change: transform. Daarmee tekent de browser de afbeelding eenmalig op beginmaat en rekt hem op (waas). */
#zoomContent { position: absolute; left: 0; top: 0; display: flex; transform-origin: 0 0; }
#zoomContent img { display: block; user-select: none; -webkit-user-drag: none; }
#zoomBar { position: absolute; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: rgba(70, 72, 82, .5); }
#zLabel { min-width: 104px; text-align: center; padding: 0 6px; white-space: nowrap; }

#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #eceded; transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading div { text-align: center; font-size: 14px; font-weight: 500; letter-spacing: .01em; }
#loading i { display: block; width: 220px; height: 3px; margin: 14px auto 0; background: rgba(28, 43, 74, .15); overflow: hidden; }
#loading u { display: block; width: 0; height: 100%; background: var(--navy); transition: width .15s; }
#nogl { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: #eceded; padding: 24px; text-align: center; }

@media (max-width: 640px) {
  .title { left: 12px; top: 12px; padding: 8px 14px; }
  #lang { right: 12px; top: 12px; }
  #lang button { min-width: 40px; padding: 0 8px; }
  #backBtn { right: 108px; top: 12px; width: 44px; padding: 0; justify-content: center; }
  #backBtn span { display: none; }
  #intro { padding: 22px 24px 24px; border-radius: 26px; width: min(380px, 92vw); }
  #intro .pill { width: auto; padding: 0 22px 0 26px; }
  #intro .pill em { display: inline; }
  #bar, #zoomBar { gap: 2px; padding: 6px; }
  .pager { width: 124px; padding: 0 4px; }
  #sub { display: none; }
  .pill { width: 44px; padding: 0; }
  .pill em { display: none; }
  .sep { margin: 0 3px; }
  #hint { bottom: calc(94px + var(--safe-b)); font-size: 11.5px; }
  #zLabel { min-width: 78px; }
}
/* Staand scherm: kaart gecentreerd onderaan, boek erboven */
@media (max-width: 640px) and (orientation: portrait) {
  #intro { left: 50%; transform: translateX(-50%); text-align: center; bottom: calc(5vh + var(--safe-b)); width: min(290px, 72vw); padding: 18px 18px 20px; border-radius: 24px; }
  #intro h1 { font-size: 24px; }
  #intro p { margin: 4px 0 14px; font-size: 13px; }
  #intro .pill { height: 42px; padding: 0 18px 0 22px; font-size: 15px; }
  body:not([data-mode="intro"]) #intro { transform: translate(-50%, 18px); }
}
/* Weinig hoogte (liggende telefoon): compactere kaart */
@media (max-height: 480px) and (orientation: landscape) {
  #intro { bottom: calc(6vh + var(--safe-b)); width: min(300px, 46vw); padding: 16px 20px 18px; border-radius: 22px; }
  #intro h1 { font-size: 22px; }
  #intro p { margin: 4px 0 12px; font-size: 12.5px; }
  #intro .pill { height: 40px; font-size: 14px; padding: 0 18px 0 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
