/* ============================================================
   IDA Website v3 — Scroll-Film-Modul (scrub.css)
   Gehört zu scrub.js (initScrub). Apple-Technik: eine hohe
   Sektion, darin ein sticky 100vh-Viewport mit Canvas; der
   Scrollfortschritt scrubbt die Frame-Sequenz. Am Ende wird
   das echte HTML-Overlay (#mac-handoff) auf die Bildschirm-
   fläche des Endframes geblendet.

   Keine externen Requests, keine Libraries.
   Animationen nur über transform/opacity.
   ============================================================ */

/* ---------- Sektion + Sticky-Viewport ---------- */

.scrub-section {
  /* Scroll-Strecke des Films: ~3.5 Viewporthöhen ergeben ein
     ruhiges, kontrollierbares Scrubbing-Tempo für 120 Frames. */
  height: 350vh;
  position: relative;
  /* Untergrund passend zum dunklen Rand des Films, damit beim
     Cover-Fit nie ein heller Blitzer durchscheint. */
  background: var(--night, #0e0f12);
}

.scrub-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh; /* mobile Adressleisten */
  overflow: hidden;
  /* Positionierungs-Anker für Canvas, Overlay und Ladeanzeige */
  isolation: isolate;
}

.scrub-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Ladeanzeige (dezent) ---------- */

.scrub-loader {
  position: absolute;
  left: 50%;
  bottom: clamp(1.2rem, 4vh, 2.4rem);
  transform: translateX(-50%);
  width: min(220px, 40vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none;
  z-index: 3;
}

.scrub-loader.done { opacity: 0; }

.scrub-loader-text {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(242, 243, 245, 0.55);
}

.scrub-loader-track {
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: rgba(242, 243, 245, 0.18);
  overflow: hidden;
}

.scrub-loader-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--teal, #1fc4a8);
  /* Breite wird von scrub.js gesetzt; kleine Glättung reicht */
  transition: width 0.25s linear;
}

/* ---------- Mac-Overlay (Handoff) ----------
   Das Element #mac-handoff kommt vom Demo-Modul und wird von
   scrub.js in den Sticky-Viewport gehängt. Position/Verzerrung
   übernimmt ein per JS berechnetes matrix3d (transform-origin
   0 0 ist dafür Pflicht). */

.scrub-handoff {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;      /* scrub.js schaltet am Sequenz-Ende frei */
  will-change: transform, opacity;
  z-index: 2;
  backface-visibility: hidden;
}

.scrub-handoff.interactive { pointer-events: auto; }

/* ---------- Screenreader-Beschreibung ---------- */

.scrub-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Standbild-Modus (prefers-reduced-motion) ----------
   Statt Scrub: drei Standbilder, weich übergeblendet. Eine
   Überblendung gilt als sanft genug; alles andere steht still. */

.scrub-section.scrub-stills { height: 220vh; }

.scrub-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.scrub-still.active { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .scrub-loader-bar { transition: none; }
  .scrub-handoff { transition: opacity 0.3s ease; }
}

/* ---------- Fallback ohne Manifest/Bilder ----------
   Wenn die Sequenz nicht geladen werden kann, kollabiert die
   Sektion und das Overlay steht flach und bedienbar im Fluss. */

.scrub-section.scrub-fallback {
  height: auto;
  min-height: 60vh;
  padding: 8vh 0;
}

.scrub-section.scrub-fallback .scrub-sticky {
  position: static;
  height: auto;
  overflow: visible;
}

.scrub-section.scrub-fallback .scrub-handoff {
  position: relative;
  opacity: 1;
  pointer-events: auto;
  transform: none !important;
  margin: 0 auto;
  max-width: min(920px, 92vw);
}

/* ---------- Kleine Viewports ---------- */

@media (max-width: 899px) {
  .scrub-section { height: 300vh; }         /* etwas kürzere Strecke */
  .scrub-loader { width: min(160px, 44vw); }
}
