/* =========================================================================
   3d.html – Seitenkopf, RS4-Bildfolge (Sticky 400vh) mit Kapiteln, Karten.
   Baut auf css/base.css auf. Bewegung nur über --p aus js/main.js:
   keine @keyframes, keine Timer. Kapitel blenden über --p ein und aus.
   ========================================================================= */

/* ---------- Seitenkopf ---------- */
.hv3d-head {
  /* unten knapp: die Bühne darunter hält selbst Abstand zur Navigation */
  padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(.75rem, 2vw, 1.5rem);
}
.hv3d-head-kicker { margin-bottom: 1rem; }
.hv3d-head .t-lead { margin-top: 1.25rem; }
.hv3d-head .link-arrow { margin-top: .75rem; }

/* Sätze, die nur beim Scroll-Spulen stimmen («Scroll weiter …»).
   Bei reduzierter Bewegung und ohne JavaScript steht ein Standbild da. */
@media (prefers-reduced-motion: reduce) {
  .hv3d-nur-scroll { display: none; }
}
html:not(.js) .hv3d-nur-scroll { display: none; }

/* ---------- Hero: Bühne ----------
   Handy und Hochformat: Bild oben, Text darunter. Wird es eng, verliert das
   Bild an Höhe, nie der Text. Die Navigation (52 px) liegt über der Bühne,
   darum beginnt der Inhalt erst darunter. */
.hv3d-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: .75rem;
  width: min(100% - var(--gutter) * 2, var(--max));
  margin-inline: auto;
  padding-top: calc(var(--nav-h) + .5rem);
  padding-bottom: calc(.875rem + env(safe-area-inset-bottom));
}

/* Freie Fläche für das Bild; darin ein Rahmen genau im Format 9:16 */
.hv3d-media {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.hv3d-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--r-tile);
  background: var(--surface);
}
@supports (width: 1cqh) {
  .hv3d-frame {
    width: min(100cqw, 100cqh * 9 / 16);
    height: auto;
    aspect-ratio: 9 / 16;
  }
}
.hv3d-frame > .sequence-canvas,
.hv3d-frame > .sequence-video,
.hv3d-frame > .hv3d-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hv3d-fallback { display: none; object-fit: contain; }

/* Text unter (Handy) bzw. neben (Desktop) dem Bild */
.hv3d-copy {
  display: grid;
  gap: .625rem;
  min-width: 0;
}

/* Bildzähler + Fortschritt, direkt an --p gebunden */
.hv3d-progress {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.hv3d-progress .t-exif { white-space: nowrap; }
.hv3d-bar {
  position: relative;
  flex: 1;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line);
}
.hv3d-bar > span {
  position: absolute;
  inset: 0;
  background: var(--text-2);
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
}

/* Kapitel liegen übereinander (gleiche Rasterzelle, Höhe = längstes Kapitel).
   Pro Kapitel: --a → --b einblenden, --c → --d ausblenden (Werte von --p). */
.hv3d-chapters { display: grid; }
.hv3d-chapter {
  grid-area: 1 / 1;
  --in: clamp(0, (var(--p, 0) - var(--a, 0)) / (var(--b, 1) - var(--a, 0)), 1);
  --out: clamp(0, (var(--d, 2) - var(--p, 0)) / (var(--d, 2) - var(--c, 1)), 1);
  opacity: min(var(--in), var(--out));
  transform: translateY(calc((1 - var(--in)) * 14px - (1 - var(--out)) * 14px));
}
.hv3d-kicker { margin-bottom: .375rem; }
.hv3d-text {
  max-width: 36ch;
  margin-top: .5rem;
  font-size: 1.0625rem;
  line-height: 1.45;
  color: var(--text-2);
  text-wrap: pretty;
}

/* Breite Querformate (Desktop, Tablet quer, Browser-Zoom): Text links, Bild rechts */
@media (min-width: 640px) and (orientation: landscape) {
  .hv3d-stage {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(2rem, 6vw, 6rem);
    padding-top: calc(var(--nav-h) + 1.5rem);
    padding-bottom: 1.5rem;
  }
  .hv3d-media {
    order: 2;
    flex: none;
    height: calc(100vh - var(--nav-h) - 3rem);
    height: calc(100svh - var(--nav-h) - 3rem);
    width: calc((100vh - var(--nav-h) - 3rem) * 9 / 16);
    width: calc((100svh - var(--nav-h) - 3rem) * 9 / 16);
    max-width: 50%;
  }
  .hv3d-copy {
    flex: 1 1 0;
    max-width: 36rem;
    gap: 1.5rem;
  }
  .hv3d-progress { order: 2; max-width: 22rem; }
  .hv3d-kicker { margin-bottom: .75rem; }
  .hv3d-chapter .t-h2 { font-size: clamp(1.75rem, .9rem + 2.6vw, 3.5rem); }   /* bis 56 px */
  .hv3d-text {
    margin-top: 1rem;
    font-size: clamp(1.1875rem, 1.095rem + .381vw, 1.4375rem);
    line-height: 1.42;
  }
}

/* Bewegung reduziert: Standbild (Mitte) + Knopf «Video abspielen» aus
   js/sequence.js, alle Kapitel ruhig untereinander. base.css nimmt der
   Sektion schon die Leerstrecke (height: auto, Bühne relativ). */
@media (prefers-reduced-motion: reduce) {
  .hv3d-stage {
    height: auto;
    overflow: visible;
    padding-top: .5rem;
    padding-bottom: clamp(3rem, 8vw, 5rem);
  }
  .hv3d-media { height: min(72vh, 44rem); }
  .hv3d-progress { display: none; }
  .hv3d-chapters { gap: 2rem; }
  .hv3d-chapter { grid-area: auto; opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) and (min-width: 640px) and (orientation: landscape) {
  .hv3d-stage { align-items: flex-start; }
  .hv3d-media {
    height: min(calc(100svh - var(--nav-h) - 3rem), 56rem);
    width: calc(min(calc(100svh - var(--nav-h) - 3rem), 56rem) * 9 / 16);
  }
}

/* Ohne JavaScript: gleiche ruhige Ansicht, Standbild statt canvas */
html:not(.js) .hv3d-hero { height: auto; }
html:not(.js) .hv3d-stage {
  position: relative;
  height: auto;
  overflow: visible;
  padding-top: .5rem;
  padding-bottom: clamp(3rem, 8vw, 5rem);
}
html:not(.js) .hv3d-media { height: min(72vh, 44rem); }
html:not(.js) .hv3d-frame > .sequence-canvas,
html:not(.js) .hv3d-progress { display: none; }
html:not(.js) .hv3d-fallback { display: block; }
html:not(.js) .hv3d-chapters { gap: 2rem; }
html:not(.js) .hv3d-chapter { grid-area: auto; opacity: 1; transform: none; }
@media (min-width: 640px) and (orientation: landscape) {
  html:not(.js) .hv3d-stage { align-items: flex-start; }
}

/* ---------- Weitere Renders ---------- */
.hv3d-more { border-top: 1px solid var(--line); }

.hv3d-cards {
  display: grid;
  gap: clamp(2.5rem, 6vw, 4rem) var(--gap);
  align-items: start;
}
@media (min-width: 768px) {
  .hv3d-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hv3d-card-wide,
  .hv3d-still { grid-column: 1 / -1; }
}

/* Video-Karten aus base.css, nur das Seitenverhältnis weicht von 9:16 ab */
.hv3d-frame-21x9 { aspect-ratio: 1920 / 804; }
/* Im Breitbild stehen links die Motordaten: ab 768 px Knopf nach rechts unten (dunkler Boden).
   Auf dem Handy ist die Datentafel ohnehin zu klein zum Lesen, und rechts würde der
   Knopf «Video abspielen» den Motor verdecken: dort bleibt er links (Standard). */
@media (min-width: 768px) {
  .hv3d-frame-21x9 .video-play { left: auto; right: 14px; }
}
.hv3d-frame-16x9 { aspect-ratio: 16 / 9; }

/* Render→Echt-Paare: Etikett oben links im Bild, verschwindet beim Abspielen.
   Nur Hinweis fürs Auge (aria-hidden), Titel und Chips der Karte sagen es auch. */
.hv3d-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 26px;
  padding: .2rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: rgba(16, 18, 23, .82);
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}
.hv3d-tag-ki::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  background: currentColor;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.video-card.is-playing .hv3d-tag { display: none; }

/* Standbild-Karte (Profilbild-Kamera): ohne REC-Punkt, kein Klick */
.hv3d-still {
  display: grid;
  gap: 1rem;
  margin: 0;
}
.hv3d-still-media {
  overflow: hidden;
  border-radius: var(--r-tile);
  background: var(--surface);
}
.hv3d-still-media img { width: 100%; height: auto; }
.hv3d-still-body {
  display: grid;
  gap: .35rem;
  align-content: center;
}
.hv3d-still-body .link-arrow { justify-self: start; margin-top: .25rem; }
@media (min-width: 768px) {
  .hv3d-still {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(1.5rem, 4vw, 3.5rem);
    align-items: center;
  }
}
