:root {
  --bg: oklch(0.16 0.012 60);
  --ink: oklch(0.92 0.02 80);
  --muted: oklch(0.62 0.02 70);
  --accent: oklch(0.78 0.14 70);

  --bg-deep: oklch(0.12 0.01 60);
  --line: oklch(0.92 0.02 80 / 0.12);
  --halo: oklch(0.12 0.01 60 / 0.75);

  --f-display: "Fraunces", Georgia, serif;
  --f-body: "IBM Plex Sans", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;

  --gutter: clamp(16px, 4vw, 64px);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 300 17px/1.65 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

h1, h2, h3 { font-family: var(--f-display); font-weight: 300; margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
em { font-style: italic; color: var(--accent); font-weight: 300; }
.mono { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.kicker { color: var(--accent); margin: 0 0 1.4rem; }
::selection { background: var(--accent); color: var(--bg-deep); }

/* Filmkorn über allem */
.grain {
  position: fixed; inset: -50%; z-index: 50; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); } 60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-between;
  padding: 20px var(--gutter);
  color: var(--muted);
  mix-blend-mode: difference;
}
.topbar__count { color: var(--ink); }

/* ---------- HERO ---------- */
.hero { position: relative; height: 320vh; }
.hero__stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; background: var(--bg-deep); }
#hero-canvas, #hero-dust { position: absolute; inset: 0; width: 100%; height: 100%; }
#hero-dust { mix-blend-mode: screen; pointer-events: none; }
.hero__vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 40%, oklch(0.1 0.01 60 / 0.85) 100%),
    linear-gradient(to bottom, transparent 70%, var(--bg) 100%);
}
.hero__copy {
  position: absolute; left: var(--gutter); bottom: clamp(72px, 14vh, 160px);
  max-width: min(880px, calc(100% - 2 * var(--gutter)));
}
.hero__copy h1 {
  font-size: clamp(44px, 8.2vw, 128px); line-height: .98;
  text-shadow: 0 0 40px var(--halo), 0 0 90px var(--halo), 0 2px 4px oklch(0.1 0.01 60 / 0.6);
}
.hero__copy .kicker { text-shadow: 0 0 20px var(--halo); }
.hero__sub {
  margin: 1.6rem 0 0; max-width: 34ch; font-size: clamp(16px, 1.4vw, 20px); color: var(--ink);
  text-shadow: 0 0 24px var(--halo), 0 0 48px var(--halo);
}
.hero__hint {
  position: absolute; right: var(--gutter); bottom: 32px; margin: 0; color: var(--muted);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .35; } }

/* ---------- PROLOG ---------- */
.prolog { padding: 22vh var(--gutter) 18vh; display: grid; place-items: center; }
.prolog__text {
  margin: 0; max-width: 24ch; text-align: center;
  font: 300 clamp(26px, 3.4vw, 50px)/1.25 var(--f-display);
}
.prolog__text .w { opacity: .14; transition: opacity .3s; }

/* ---------- ATLAS ---------- */
.atlas { padding: 10vh var(--gutter) 16vh; max-width: 1400px; margin: 0 auto; }
.atlas__head { max-width: 640px; margin-bottom: 5vh; }
.atlas__head h2 { font-size: clamp(34px, 4.6vw, 68px); line-height: 1.05; }
.atlas__note { color: var(--muted); margin: 1.2rem 0 0; max-width: 42ch; }
.atlas__map { position: relative; }
#constellation { width: 100%; height: auto; display: block; overflow: visible; }
#constellation .edge { stroke: var(--accent); stroke-width: 1.2; fill: none; opacity: .75; }
#constellation .edge--index { stroke: var(--ink); stroke-width: .7; opacity: .22; stroke-dasharray: 2 7; }
#constellation .star { cursor: pointer; outline: none; }
#constellation .star circle.core { fill: var(--ink); transition: r .3s, fill .3s; }
#constellation .star circle.glow { fill: var(--accent); opacity: .18; transition: opacity .3s, r .3s; }
#constellation .star text { fill: var(--muted); font: 400 13px var(--f-mono); letter-spacing: .04em; transition: fill .3s; }
#constellation .star:hover circle.core, #constellation .star:focus-visible circle.core { fill: var(--accent); r: 7; }
#constellation .star:hover circle.glow, #constellation .star:focus-visible circle.glow { opacity: .45; r: 26; }
#constellation .star:hover text, #constellation .star:focus-visible text { fill: var(--ink); }
#constellation .hub circle { fill: none; stroke: var(--muted); stroke-width: 1; opacity: .5; }
#constellation .hub text { fill: var(--muted); font: 400 11px var(--f-mono); letter-spacing: .1em; }

.atlas__peek {
  position: absolute; margin: 0; width: 280px; pointer-events: none;
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s;
  box-shadow: 0 30px 60px oklch(0.08 0.01 60 / 0.7);
}
.atlas__peek.is-on { opacity: 1; transform: none; }
.atlas__peek img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.atlas__peek figcaption { background: var(--bg-deep); padding: 8px 10px; color: var(--accent); font-size: 11px; }

/* ---------- KAMMERN ---------- */
.kammer {
  position: relative; min-height: 100vh;
  display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; align-items: center;
  padding: 12vh var(--gutter);
  border-top: 1px solid var(--line);
}
.kammer__media {
  grid-column: 1 / span 8; position: relative; overflow: hidden;
  aspect-ratio: 16 / 9; background: var(--bg-deep);
  clip-path: inset(8% 8% 8% 8%);
}
.kammer__media video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.12); }
.kammer__media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, oklch(0.1 0.01 60 / 0.55));
}
.kammer__body { grid-column: 9 / span 4; position: relative; z-index: 2; }
.kammer:nth-child(even) .kammer__media { grid-column: 5 / span 8; grid-row: 1; }
.kammer:nth-child(even) .kammer__body { grid-column: 1 / span 4; grid-row: 1; }

.kammer__num {
  position: absolute; top: 9vh; font: 300 clamp(80px, 13vw, 200px)/1 var(--f-display);
  color: transparent; -webkit-text-stroke: 1px oklch(0.92 0.02 80 / 0.14);
  right: var(--gutter); pointer-events: none;
}
.kammer:nth-child(even) .kammer__num { right: auto; left: var(--gutter); }

.kammer__file { color: var(--accent); margin: 0 0 1.2rem; display: flex; gap: 12px; flex-wrap: wrap; }
.kammer__file span:last-child { color: var(--muted); }
.kammer h3 { font-size: clamp(28px, 2.9vw, 44px); line-height: 1.1; margin-bottom: 1.4rem; }
.kammer__text { margin: 0 0 2rem; color: oklch(0.85 0.02 78); }
.kammer__keep { margin: 0; padding-top: 1.1rem; border-top: 1px solid var(--accent); }
.kammer__keep .mono { display: block; color: var(--muted); font-size: 11px; margin-bottom: .5rem; }
.kammer__keep p { margin: 0; font: italic 300 clamp(19px, 1.6vw, 23px)/1.35 var(--f-display); }

/* ---------- CODA ---------- */
.coda { min-height: 90vh; display: grid; place-items: center; padding: 16vh var(--gutter); text-align: center; border-top: 1px solid var(--line); }
.coda h2 { font-size: clamp(32px, 5vw, 76px); line-height: 1.08; }
.coda__meta { color: var(--muted); margin: 3rem 0 1.4rem; }
.coda__top { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 2px; }
.coda__top:hover { color: var(--ink); }

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .kammer { grid-template-columns: 1fr; row-gap: 40px; min-height: auto; padding: 14vh var(--gutter); }
  .kammer__media, .kammer:nth-child(even) .kammer__media { grid-column: 1; grid-row: 1; }
  .kammer__body, .kammer:nth-child(even) .kammer__body { grid-column: 1; grid-row: 2; max-width: 620px; }
  .kammer__num, .kammer:nth-child(even) .kammer__num { top: 4vh; right: var(--gutter); left: auto; }
  .atlas__peek { display: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { height: 260vh; }
  .hero__copy { bottom: 88px; }
  .kammer { padding: 10vh var(--gutter); }
  .kammer__media { clip-path: none !important; }
  .kammer__num { font-size: 72px; top: 3vh; }
  #constellation .star text { font-size: 25px; }
  #constellation .hub text { font-size: 19px; }
  #constellation .star circle.core { r: 7; }
  .coda h2 br { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .hero__hint { animation: none; }
}
