:root {
  color-scheme: dark;
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, 0.58);
  --hair: rgba(255, 255, 255, 0.28);
  --bg: #000000;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

.experience {
  position: relative;
  min-height: 1014.0vh; /* 6 Szenen-Panels à 130vh (homogene 6-Beat-Scroll-Länge) */
  overflow: clip;
}

#network {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: transparent;
}

.fps-indicator {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 6;
  min-width: 54px;
  padding: 5px 7px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  line-height: 1;
  text-align: right;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.scroll-indicator {
  position: fixed;
  top: 44px;
  right: 18px;
  z-index: 6;
  display: flex;
  gap: 8px;
  min-width: 118px;
  padding: 5px 7px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  line-height: 1;
  justify-content: flex-end;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.controls {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 5;
  width: min(280px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  transition: transform 420ms ease;
}

.controls.is-collapsed {
  width: min(280px, calc(100vw - 32px));
}

.controls-toggle {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  color: var(--ink);
  border-radius: 999px;
  background: rgba(5, 5, 5, 0.48);
  backdrop-filter: blur(18px);
  cursor: pointer;
}

.controls-toggle span,
.controls-toggle::before,
.controls-toggle::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 1px;
  content: "";
  background: currentColor;
  transform: translate(-50%, -50%);
  transition: transform 220ms ease, opacity 220ms ease;
}

.controls-toggle::before {
  transform: translate(-50%, calc(-50% - 5px));
}

.controls-toggle::after {
  transform: translate(-50%, calc(-50% + 5px));
}

.controls:not(.is-collapsed) .controls-toggle::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.controls:not(.is-collapsed) .controls-toggle::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.controls:not(.is-collapsed) .controls-toggle span {
  opacity: 0;
}

.controls-panel {
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 14px;
  padding-bottom: 58px;
  border: 0;
  background: rgba(5, 5, 5, 0.62);
  backdrop-filter: blur(18px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 260ms ease, transform 420ms ease;
}

.controls.is-collapsed .controls-panel {
  pointer-events: none;
  opacity: 0;
  transform: translateY(calc(100% + 18px));
}

.controls label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
}

.controls label + label {
  margin-top: 14px;
}

.control-section {
  position: relative;
  display: block;
  width: 100%;
  margin: 20px 0 14px;
  padding-top: 14px;
  padding-right: 22px;
  border-top: 1px solid rgba(246, 242, 234, 0.12);
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  line-height: 1;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.control-section::after {
  position: absolute;
  right: 0;
  top: 13px;
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.control-group.is-collapsed .control-section::after {
  transform: rotate(-45deg);
}

.control-group:first-child .control-section {
  margin-top: 0;
  border-top: 0;
}

.control-content {
  display: block;
}

.control-group.is-collapsed .control-content {
  display: none;
}

.controls [hidden] {
  display: none !important;
}

.control-subhead {
  position: relative;
  display: block;
  width: calc(100% - 12px);
  margin: 22px 0 18px 12px;
  padding-top: 14px;
  padding-right: 18px;
  padding-left: 10px;
  border-top: 1px solid rgba(246, 242, 234, 0.1);
  border-left: 1px solid rgba(246, 242, 234, 0.14);
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  color: var(--ink);
  background: transparent;
  font-size: 11px;
  line-height: 1;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.control-content .control-subhead:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.control-subhead::after {
  position: absolute;
  right: 1px;
  top: 13px;
  width: 6px;
  height: 6px;
  content: "";
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.control-subhead.is-collapsed::after {
  transform: rotate(-45deg);
}

.control-subhead + label,
.control-subhead + .toggle-control {
  margin-top: 0;
}

.control-subhead ~ label,
.control-subhead ~ .toggle-control {
  margin-left: 12px;
  width: calc(100% - 12px);
}

.controls span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.controls output {
  color: var(--ink);
}

.controls input {
  width: 100%;
  accent-color: var(--ink);
}

.controls input[type="color"] {
  width: 48px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.controls input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.controls input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 999px;
}

.color-control {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.color-control span {
  display: block;
}

.toggle-control {
  grid-template-columns: 1fr auto;
  align-items: center;
}

/* Nur im Mobile-/Portrait-Modus sichtbar (JS togglet body.is-mobile in resize()). */
.mobile-only {
  display: none;
}
body.is-mobile .mobile-only {
  display: grid;
}

.toggle-control span {
  display: block;
}

.controls input[type="checkbox"] {
  appearance: none;
  width: 42px;
  height: 24px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

.controls input[type="checkbox"]::before {
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  content: "";
  border-radius: 999px;
  background: var(--ink);
  transition: transform 180ms ease;
}

.controls input[type="checkbox"]:checked {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--ink) 42%, transparent);
}

.controls input[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

.utility-button {
  width: calc(100% - 12px);
  margin: 12px 0 0 12px;
  padding: 9px 10px;
  border: 1px solid rgba(246, 242, 234, 0.22);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  font: inherit;
  font-size: 10px;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
}

.utility-button:hover {
  background: rgba(255, 255, 255, 0.11);
}

.keyframe-list {
  display: grid;
  gap: 6px;
  width: calc(100% - 12px);
  margin: 10px 0 0 12px;
  padding: 0;
  list-style: none;
}

.keyframe-item {
  display: grid;
  grid-template-columns: 1fr 28px;
  gap: 6px;
}

.keyframe-item button,
.keyframe-empty {
  min-height: 26px;
  border: 1px solid rgba(246, 242, 234, 0.16);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font: inherit;
  font-size: 10px;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.keyframe-empty {
  display: grid;
  place-items: center;
  padding: 0 8px;
}

.save-preset {
  width: 100%;
  margin-top: 22px;
  padding: 11px 12px;
  border: 1px solid rgba(246, 242, 234, 0.22);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  font: inherit;
  font-size: 11px;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
}

.save-preset:hover {
  background: rgba(255, 255, 255, 0.11);
}

.save-status {
  min-height: 12px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.experience::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle at 50% 46%, transparent 0 42%, rgba(0, 0, 0, 0.28) 78%);
  opacity: 0.7;
}

.panel {
  position: relative;
  z-index: 2;
  min-height: 130vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: clamp(28px, 5vw, 72px);
  max-width: 760px;
}

.panel--intro {
  justify-content: center;
  padding-top: 14vh;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: clamp(12px, 1.5vw, 14px);
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: balance;
}

h1,
h2 {
  margin: 0;
  max-width: 11ch;
  font-weight: 520;
  line-height: 0.95;
}

h1 {
  font-size: clamp(58px, 13vw, 156px);
}

h2 {
  font-size: clamp(38px, 8vw, 104px);
}

.panel p:last-child {
  max-width: 34rem;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 23px);
  line-height: 1.38;
}

/* Story: zentrierte Copy (Szene 01 Hero + zentrierte Beats) — übernimmt die
   Figma-Tokens für „Title Hero": Semibold, line-height 100%, weiß, mittig. */
.panel--center {
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: none;
}

.panel--center .eyebrow {
  color: var(--fg, #fff);
  text-transform: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel--center h1,
.panel--center h2 {
  max-width: 20ch;
  font-weight: 600;
  line-height: 1;
}

.panel--center h1 {
  font-size: clamp(44px, 7vw, 104px);
}

.panel--center p:last-child {
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
  color: rgba(255, 255, 255, 0.82);
}

/* Scroll-%-gesteuertes Typo-Overlay: feste, zentrierte Blöcke, deren Opacity per
   JS aus state.scroll kommt (data-a..d = Fade-in-Start/Ende, Fade-out-Start/Ende). */
.story-text {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.story-block {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(28px, 5vw, 72px);
  opacity: 0; /* JS-getrieben (Opacity + Transform pro Frame aus state.scroll) */
  transform-origin: 50% 50%; /* = Screen-Mitte (Block ist full-screen) → Scale zur Mitte */
  will-change: opacity, transform;
}

.story-block .eyebrow {
  color: var(--fg, #fff);
  text-transform: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}
/* Opener-Headline „Das Mittwald Öko-System" — größer (ist durch den Scroll-Schnitt schon etwas geschrumpft). */
.story-block .eyebrow--lead {
  font-size: clamp(18px, 2.2vw, 26px);
}

.story-block h1,
.story-block h2 {
  max-width: 20ch;
  font-weight: 600;
  line-height: 1;
}

.story-block h1 {
  font-size: clamp(44px, 7vw, 104px);
}

/* Opener (WIP-Hinweis): deutlich kleiner als die Story-Headlines. */
.story-block--opener h2 {
  max-width: none;
  font-size: clamp(22px, 3vw, 40px);
  line-height: 1.12;
}

.story-block p {
  max-width: 46ch;
  margin: 22px auto 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(17px, 2vw, 23px);
  line-height: 1.38;
}

/* Variante: links ausgerichtet, vertikal zentriert (kommt im „arrive"-Modus mittig an). */
.story-block--left {
  align-items: flex-start;
  justify-content: center;
  text-align: left;
}
.story-block--left h1,
.story-block--left h2 {
  max-width: 16ch;
}
.story-block--left p {
  margin-left: 0;
  margin-right: 0;
  max-width: 34rem;
}

/* Variante: rechts ausgerichtet, vertikal zentriert (Spiegelung von --left). */
.story-block--right {
  align-items: flex-end;
  justify-content: center;
  text-align: right;
}
.story-block--right h1,
.story-block--right h2 {
  max-width: 16ch;
}
.story-block--right p {
  margin-left: 0;
  margin-right: 0;
  max-width: 34rem;
}

/* Weiche, dunkle Fläche hinter dem Block (Lesbarkeit). Liegt im Block → faded mit. */
.story-block.has-scrim::before {
  content: "";
  position: absolute;
  inset: -12vh -10vw;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 58% 46% at 50% 50%,
    rgba(0, 0, 0, 0.32) 0%,
    rgba(0, 0, 0, 0.2) 45%,
    rgba(0, 0, 0, 0) 75%);
}
/* Scrim folgt der links / vertikal-mittig ausgerichteten Copy. */
.story-block--left.has-scrim::before {
  background: radial-gradient(ellipse 60% 50% at 28% 50%,
    rgba(0, 0, 0, 0.36) 0%,
    rgba(0, 0, 0, 0.2) 46%,
    rgba(0, 0, 0, 0) 78%);
}

@media (max-width: 680px) {
  .panel {
    min-height: 120vh;
    justify-content: flex-end;
    padding: 24px;
  }

  .panel--intro {
    justify-content: center;
  }

  /* Mobile/Hochformat: alle Story-Textblöcke mittig — kein links-/rechtsbündig. */
  .story-block,
  .story-block--left,
  .story-block--right {
    align-items: center;
    text-align: center;
  }
  .story-block--left h1,
  .story-block--left h2,
  .story-block--left p,
  .story-block--right h1,
  .story-block--right h2,
  .story-block--right p {
    text-align: center;
  }

  /* „Deine Basis": Text auf Mobile ein Stück nach unten (Inhalt per Padding verschoben — JS setzt
     nur transform/translateY am Block, das bleibt unberührt). */
  .story-block--basis {
    justify-content: flex-end;
    padding-bottom: 22vh;
  }

  /* Lesbarkeit auf Mobile: weiche, flach abdunkelnde Fläche hinter JEDEM Textblock (mittig,
     weich auslaufend). Liegt im Block (z-index -1) → faded mit der JS-Opacity mit. Überschreibt
     auch die off-center Scrims der --left/--right-Varianten auf mittig. */
  .story-block::before,
  .story-block.has-scrim::before,
  .story-block--left.has-scrim::before,
  .story-block--right.has-scrim::before {
    content: "";
    position: absolute;
    inset: -8vh -8vw;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse 74% 54% at 50% 50%,
      rgba(0, 0, 0, 0.46) 0%,
      rgba(0, 0, 0, 0.3) 44%,
      rgba(0, 0, 0, 0) 78%);
  }
}
