/* Hydraulica — one fixed 1920×1080 stage, scaled to the window.
   Look: dark blueprint steel, amber oil, cyan for pressure/force. Titles in Barlow Condensed, keywords in Barlow,
   numbers/formulas in JetBrains Mono. All motion is CSS (transform/opacity only), started by .live on the slide. */
:root {
  --bg: #060b12;
  --panel: #0d1622;
  --steel: #9fb3c8;
  --steel-d: #2a3b4f;
  --line: rgba(159,179,200,.32);
  --oil: #ffae2b;
  --oil-2: #ff6a13;
  --cyan: #45d0ff;
  --red: #ff4d5e;
  --green: #4ee39a;
  --text: #eaf2f9;
  --muted: #7d91a6;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Barlow", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.16,1,.3,1);
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0; background: #03060a; color: var(--text); font-family: var(--font-body);
  overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #03060a; color: var(--muted); font: 600 20px/1.4 Arial, sans-serif; z-index: 30; }

#viewport { position: fixed; inset: 0; overflow: hidden; background: #03060a; }
#stage {
  position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px; margin: -540px 0 0 -960px;
  transform-origin: 50% 50%; overflow: hidden; cursor: pointer;
  /* blueprint grid: static gradients, painted once */
  background:
    radial-gradient(ellipse 70% 60% at 72% 48%, rgba(40,90,140,.22), rgba(6,11,18,0) 70%),
    linear-gradient(rgba(120,170,220,.045) 1px, transparent 1px) 0 0 / 60px 60px,
    linear-gradient(90deg, rgba(120,170,220,.045) 1px, transparent 1px) 0 0 / 60px 60px,
    var(--bg);
}
#stage.hide-cursor { cursor: none; }

.slide { position: absolute; inset: 0; visibility: hidden; opacity: 0; overflow: hidden; }
.slide.shown { visibility: visible; opacity: 1; }
.slide.fade-in { animation: slide-in 1s var(--ease) both; }
.slide.fade-out { visibility: visible; animation: slide-out .7s ease both; z-index: 1; }
@keyframes slide-in { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
@keyframes slide-out { from { opacity: 1; } to { opacity: 0; } }

.art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }

/* ---------- copy block ---------- */
.copy { position: absolute; display: flex; flex-direction: column; gap: 30px; z-index: 2; }
.slide[data-layout="left"] .copy   { left: 128px; top: 50%; transform: translateY(-50%); width: 780px; }
.slide[data-layout="top"] .copy    { left: 128px; top: 104px; width: 1660px; }
.slide[data-layout="center"] .copy { left: 50%; top: 50%; width: 1500px; transform: translate(-50%, -50%); align-items: center; text-align: center; }

.kicker {
  margin: 0; display: flex; align-items: center; gap: 18px;
  font: 500 24px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--oil);
}
.kicker::before { content: ""; width: 56px; height: 3px; background: var(--oil); border-radius: 2px; }
.slide[data-layout="center"] .kicker::before { display: none; }

.title {
  margin: 0; font: 800 150px/.88 var(--font-display); text-transform: uppercase; letter-spacing: .005em;
  color: var(--text); text-wrap: balance; text-shadow: 0 6px 40px rgba(0,0,0,.6);
}
.title .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.title .w > span { display: inline-block; }
.title em { font-style: normal; color: var(--oil); }
.slide[data-layout="top"] .title { font-size: 128px; }
.sub { margin: 0; font: 600 44px/1.15 var(--font-body); color: var(--muted); letter-spacing: .01em; }

.keys { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.keys li {
  position: relative; display: flex; align-items: baseline; gap: 26px;
  font: 600 52px/1.08 var(--font-body); color: var(--text); text-shadow: 0 2px 22px rgba(0,0,0,.55);
}
.keys li .n { flex: none; width: 52px; font: 500 22px/1 var(--font-mono); color: var(--oil); letter-spacing: .06em; transform: translateY(-8px); }
.keys li b { font-weight: 700; color: var(--oil); }
.keys li .m { font-family: var(--font-mono); font-weight: 500; font-size: .86em; letter-spacing: -.01em; }
.keys.tight li { font-size: 42px; }
.slide[data-layout="center"] .keys { flex-direction: row; justify-content: center; gap: 20px 70px; }

/* per-slide copy tweaks */
.slide[data-id="titel"] .copy { width: 860px; }
.slide[data-id="titel"] .title { font-size: 200px; letter-spacing: .01em; }
.slide[data-id="titel"] .sub { font-size: 54px; color: var(--oil); }
.slide[data-layout="center"] .title { font-size: 240px; }
.slide[data-id="valtoren"] .title { font-size: 118px; }
.keys.row { flex-direction: row; gap: 0; margin-top: 18px; }
.keys.row li { font: 600 34px/1 var(--font-mono); color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.keys.row li + li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--oil); margin: 0 30px; transform: translateY(-6px); }

/* SVG text styles */
.lbl   { font: 600 34px var(--font-body); fill: var(--text); }
.lbl-s { font: 600 26px var(--font-body); fill: var(--muted); }
.lbl-o { font: 700 34px var(--font-body); fill: var(--oil); }
.lbl-c { font: 700 34px var(--font-body); fill: var(--cyan); }
.mono  { font: 700 34px var(--font-mono); fill: var(--oil); }
.mono-c { font: 700 34px var(--font-mono); fill: var(--cyan); }
.mono-s { font: 500 28px var(--font-mono); fill: #9fb3c8; letter-spacing: .08em; }
.big   { font: 800 120px var(--font-display); fill: var(--text); }
.badge circle { fill: var(--oil); }
.badge text { font: 700 22px var(--font-mono); fill: #1a0d00; text-anchor: middle; dominant-baseline: central; }
.tm { text-anchor: middle; }
.te { text-anchor: end; }

/* ---------- entrance animations (run only while the slide is live) ---------- */
.live .title .w > span { animation: word-up 1s var(--ease) both; animation-delay: calc(.15s + var(--i) * .08s); }
.live .kicker { animation: fade-left .9s var(--ease) both .05s; }
.live .sub { animation: rise .9s var(--ease) both .6s; }
.live .keys li { animation: rise .85s var(--ease) both; animation-delay: calc(.7s + var(--i) * .16s); }
@keyframes word-up { from { transform: translateY(110%); } to { transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes fade-left { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: none; } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: none; } }

/* every animated SVG piece transforms around its own box */
.art [class] { transform-box: fill-box; }
.a-fade, .a-rise, .a-pop, .a-draw, .a-gx, .a-gy { --d: 0s; }
.live .a-fade { animation: fade 1s ease both; animation-delay: var(--d); }
.live .a-rise { animation: rise 1s var(--ease) both; animation-delay: var(--d); }
.live .a-pop  { animation: pop .8s var(--ease) both; animation-delay: var(--d); transform-origin: center; }
.a-draw { stroke-dasharray: 1; }
.live .a-draw { animation: draw 1.4s cubic-bezier(.65,0,.35,1) both; animation-delay: var(--d); }
.live .a-gx { animation: grow-x 1.1s var(--ease) both; animation-delay: var(--d); transform-origin: left center; }
.live .a-gy { animation: grow-y 1.1s var(--ease) both; animation-delay: var(--d); transform-origin: center bottom; }

/* ---------- loops ----------
   .mech = the mechanism being explained (cheap transforms, kept in light mode)
   .amb  = ambient decoration (flowing dashes, glows, ripples) — switched off in light mode */
.flow { stroke-dasharray: 18 26; }
.live .flow { animation: flow 1.2s linear infinite; }
.live .flow.rev { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -44; } }
.live .glow { filter: url(#f-glow); }
.live .pulse { animation: pulse 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ---------- light mode for weak devices ---------- */
html.lite .title, html.lite .keys li { text-shadow: none; }
html.lite .live .glow { filter: none; }
html.lite .live .amb, html.lite .live .flow, html.lite .live .pulse { animation: none !important; }
html.lite .slide.fade-in { animation: fade .45s ease both; }
html.lite .slide.fade-out { animation-duration: .4s; }
html.lite #stage { background: linear-gradient(rgba(120,170,220,.04) 1px, transparent 1px) 0 0 / 60px 60px, linear-gradient(90deg, rgba(120,170,220,.04) 1px, transparent 1px) 0 0 / 60px 60px, var(--bg); }

/* reduced motion: show every slide in its final state */
html.still .live *, html.still .slide { animation: none !important; transition: none !important; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; right: 0; bottom: 0; height: 64px; pointer-events: none; z-index: 5; }
.hud-count { position: absolute; right: 56px; bottom: 30px; font: 500 22px/1 var(--font-mono); letter-spacing: .16em; color: var(--muted); opacity: .7; }
.hud-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(159,179,200,.1); }
.hud-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--oil-2), var(--oil)); transition: transform .8s var(--ease); }

/* ---------- panels outside the stage ---------- */
.panel {
  position: fixed; z-index: 20; color: var(--text); background: rgba(13,22,34,.97);
  border: 1px solid rgba(159,179,200,.18); box-shadow: 0 20px 60px rgba(0,0,0,.6);
  user-select: text; -webkit-user-select: text; cursor: auto;
}
#help {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box;
  border-radius: 16px; padding: 24px 26px; font-size: 16px; line-height: 1.5;
}
#help h2 { margin: 0 0 4px; font: 800 44px/1 var(--font-display); text-transform: uppercase; color: var(--oil); }
#help p { margin: 0 0 14px; color: var(--muted); }
.keys-table { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 14px; }
.keys-table kbd {
  font: 700 13px/1 var(--font-body); padding: 5px 8px; border-radius: 6px; white-space: nowrap; justify-self: start;
  background: rgba(159,179,200,.1); border: 1px solid rgba(159,179,200,.24); color: var(--text);
}
.lite-state { font-size: 14px; }
.btn { font: 700 15px var(--font-body); color: #1a0d00; background: var(--oil); border: 0; border-radius: 999px; padding: 10px 22px; cursor: pointer; }
.btn:focus-visible, .help-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.help-btn {
  position: fixed; z-index: 15; left: 14px; bottom: max(14px, env(safe-area-inset-bottom, 0px));
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font: 800 16px var(--font-body); color: var(--text);
  background: rgba(13,22,34,.7); border: 1px solid rgba(159,179,200,.25); opacity: 0; transition: opacity .3s;
}
body.show-ui .help-btn, .help-btn:focus-visible { opacity: .85; }
