/* ==========================================================================
   Northlightframe V9 · SOTY-WOW-Engine
   - 1. Nahtlose Kino-Seitenübergänge (Cross-Document View Transitions +
        farbabgestimmte 260-ms-Licht-Blende mit 1-px-Gold-/Smaragd-Linie)
   - 2. Scroll-Choreografie (No-JS-sichere Headline-Reveals, 1-px-Laser-
        Haarlinien & gedämpfte Scroll-Velocity-Trägheit --v9-vel)
   - 3. Magnetischer Studio-Cursor (nur Desktop hover:hover & pointer:fine,
        echter OS-Cursor bleibt 100 % sichtbar)
   - 4. Rahmenloser Studio-Ton-Schalter (.v9-sound-btn, 14 px Wellen-SVG)
   - 0 Fremdhosts · 0 px Überlauf · 60 fps · No-JS & Reduced-Motion sicher
   ========================================================================== */

:root {
  --v9-vel: 0;
  --v9-vel-abs: 0;
  --v9-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --v9-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --v9-gold: #D59B42;
  --v9-emerald: #34D399;
}

/* ==========================================================================
   1. NAHTLOSE KINO-SEITENÜBERGÄNGE (VIEW TRANSITIONS + LICHT-BLENDE)
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root) {
    animation: v9-vt-out 280ms cubic-bezier(0.65, 0, 0.35, 1) both;
  }

  ::view-transition-new(root) {
    animation: v9-vt-in 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

@keyframes v9-vt-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.992);
  }
}

@keyframes v9-vt-in {
  from {
    opacity: 0;
    transform: scale(1.008);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

html.is-still::view-transition-old(root),
html.is-still::view-transition-new(root) {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}

/* Wenn V9-Blende navigiert, alten Portal-Vorhang ruhig ausblenden */
html.v9-is-navigating .sw-portal-curtain {
  display: none !important;
}

.v9-transition-veil {
  position: fixed;
  inset: 0;
  z-index: 9995;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  background: var(--v9-veil-bg, var(--sw-bg, var(--bg, #0C0F13)));
  transition:
    opacity 260ms var(--v9-ease),
    visibility 0s linear 260ms;
  will-change: opacity;
}

.v9-transition-veil::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 64% 46% at 50% 50%,
    color-mix(in srgb, var(--v9-veil-accent, var(--sw-a1, #D59B42)) 12%, transparent) 0%,
    transparent 72%
  );
}

.v9-transition-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--v9-veil-accent, var(--sw-a1, #D59B42)) 88%, transparent) 22%,
    var(--v9-veil-accent-2, #34D399) 52%,
    color-mix(in srgb, var(--v9-veil-accent, var(--sw-a1, #D59B42)) 88%, transparent) 80%,
    transparent 100%
  );
  box-shadow: 0 0 18px color-mix(in srgb, var(--v9-veil-accent, var(--sw-a1, #D59B42)) 52%, transparent);
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  transition:
    transform 260ms var(--v9-ease),
    opacity 220ms ease;
  will-change: transform, opacity;
}

/* Ausblenden zur Zielseite */
.v9-transition-veil.is-leaving {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 260ms var(--v9-ease),
    visibility 0s linear 0s;
}

.v9-transition-veil.is-leaving .v9-transition-line {
  transform-origin: left center;
  transform: scaleX(1);
  opacity: 1;
}

/* Weiches Auflösen beim Ankommen auf der Zielseite */
.v9-transition-veil.is-entering {
  opacity: 1;
  visibility: visible;
  transition: none;
}

.v9-transition-veil.is-entering .v9-transition-line {
  transform-origin: right center;
  transform: scaleX(1);
  opacity: 0.92;
  transition: none;
}

.v9-transition-veil.is-entering.is-clearing {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 320ms var(--v9-ease),
    visibility 0s linear 320ms;
}

.v9-transition-veil.is-entering.is-clearing .v9-transition-line {
  transform-origin: right center;
  transform: scaleX(0);
  opacity: 0;
  transition:
    transform 280ms var(--v9-ease),
    opacity 240ms ease;
}

html.is-still .v9-transition-veil {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .v9-transition-veil {
    display: none !important;
  }
}

/* ==========================================================================
   2. SCROLL-CHOREOGRAFIE (HEADLINE-REVEALS, 1-PX-LASERLINIEN & --v9-vel)
   SICHERHEITSGARANTIE: Standardmäßig opacity: 1 (100 % No-JS-sicher!).
   Nur Elemente unterhalb des Viewports erhalten per JS .v9-arm.
   ========================================================================== */
.v9-reveal {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  html:not(.is-still) .v9-reveal.v9-arm:not(.is-in) {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
  }

  html:not(.is-still) .v9-reveal.v9-arm {
    transition:
      opacity 620ms var(--v9-ease),
      transform 620ms var(--v9-ease);
    will-change: opacity, transform;
  }

  html:not(.is-still) .v9-reveal.v9-arm.is-in {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    will-change: auto;
  }
}

html.is-still .v9-reveal,
html.is-still .v9-reveal.v9-arm {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .v9-reveal,
  .v9-reveal.v9-arm {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Feine 1-px-Laser-Trennlinien (.v9-line-draw) */
.v9-line-draw {
  position: relative;
}

.v9-line-draw::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 58%, transparent) 0%,
    color-mix(in srgb, currentColor 22%, transparent) 58%,
    transparent 100%
  );
  transform-origin: left center;
  transform: scaleX(1);
  opacity: 0.48;
}

@media (prefers-reduced-motion: no-preference) {
  html:not(.is-still) .v9-line-draw.v9-arm:not(.is-in)::after {
    transform: scaleX(0);
    opacity: 0;
  }

  html:not(.is-still) .v9-line-draw.v9-arm::after {
    transition:
      transform 760ms var(--v9-ease),
      opacity 540ms ease;
    will-change: transform, opacity;
  }

  html:not(.is-still) .v9-line-draw.v9-arm.is-in::after {
    transform: scaleX(1);
    opacity: 0.56;
    will-change: auto;
  }
}

html.is-still .v9-line-draw::after,
html.is-still .v9-line-draw.v9-arm::after {
  transform: scaleX(1) !important;
  opacity: 0.42 !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .v9-line-draw::after,
  .v9-line-draw.v9-arm::after {
    transform: scaleX(1) !important;
    opacity: 0.42 !important;
    transition: none !important;
  }
}

/* Scroll-Velocity-Spannung (--v9-vel im Stand exakt 0) auf Film & Linse
   Nutzt CSS Individual Transform Properties (translate / scale), damit
   bestehende transform-Regeln in edgeless-magic.css unberührt bleiben. */
@media (prefers-reduced-motion: no-preference) {
  html:not(.is-still) [data-v6-video-scrub] > video,
  html:not(.is-still) [data-v6-video-scrub] > img,
  html:not(.is-still) [data-v6-video-scrub] .v7-w01-film-layer {
    translate: 0 calc(var(--v9-vel, 0) * -4px);
    scale: calc(1 + var(--v9-vel-abs, 0) * 0.012);
  }

  html:not(.is-still) [data-v6-lens] > img {
    translate: 0 calc(var(--v9-vel, 0) * -5px);
  }
}

html.is-still [data-v6-video-scrub] > video,
html.is-still [data-v6-video-scrub] > img,
html.is-still [data-v6-video-scrub] .v7-w01-film-layer,
html.is-still [data-v6-lens] > img {
  translate: none !important;
  scale: none !important;
}

/* ==========================================================================
   3. MAGNETISCHER STUDIO-CURSOR (.v9-cursor)
   NUR Desktop (hover: hover) and (pointer: fine).
   Der echte OS-Cursor bleibt 100 % sichtbar (nirgends cursor: none!).
   ========================================================================== */
.v9-cursor {
  display: none;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  /* Legacy-Punkt aus nlf.js sauber unterdrücken, damit nie zwei Ringe laufen */
  html.v9-cursor-ready:not(.is-still) .cursor {
    display: none !important;
  }

  html.v9-cursor-ready:not(.is-still) .v9-cursor {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    z-index: 9990;
    pointer-events: none;
    opacity: 0;
    transition: opacity 220ms ease;
    will-change: transform, opacity;
  }

  html.v9-cursor-ready:not(.is-still) .v9-cursor.is-visible {
    opacity: 1;
  }

  .v9-cursor-ring {
    position: absolute;
    left: 0;
    top: 0;
    width: 24px;
    height: 24px;
    transform: translate3d(-50%, -50%, 0);
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--sw-fg, var(--ink, #EAEFF6)) 52%, transparent);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
      width 240ms var(--v9-ease),
      height 240ms var(--v9-ease),
      border-radius 240ms var(--v9-ease),
      border-color 220ms ease,
      background-color 240ms ease,
      box-shadow 260ms ease,
      transform 220ms var(--v9-ease);
  }

  .v9-cursor.is-on-light .v9-cursor-ring {
    border-color: rgba(16, 19, 24, 0.44);
  }

  .v9-cursor-label {
    font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.14em;
    line-height: 1;
    color: var(--sw-a1, var(--gold, #D59B42));
    opacity: 0;
    transform: scale(0.82);
    transition: opacity 180ms ease, transform 200ms var(--v9-ease);
    user-select: none;
    white-space: nowrap;
  }

  .v9-cursor.is-on-light .v9-cursor-label {
    color: #8A5A0F;
  }

  /* Zustand: Standard-Link / Button */
  .v9-cursor.is-link .v9-cursor-ring {
    width: 30px;
    height: 30px;
    border-color: color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 78%, transparent);
    background: color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 6%, transparent);
  }

  /* Zustand: Primärer CTA / Magnet (.sw-btn-primary, [data-v3-magnet]) */
  .v9-cursor.is-magnet .v9-cursor-ring {
    width: 34px;
    height: 34px;
    border-color: var(--sw-a1, var(--gold, #D59B42));
    background: color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 10%, transparent);
    box-shadow: 0 0 18px color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 24%, transparent);
  }

  /* Zustand: 3D-Bühne ([data-v3-embedded-stage]) → Ring + 3D */
  .v9-cursor.is-3d .v9-cursor-ring {
    width: 46px;
    height: 46px;
    border-color: var(--sw-a1, var(--gold, #D59B42));
    background: color-mix(in srgb, var(--sw-bg, #0C0F13) 42%, transparent);
    box-shadow: 0 0 20px color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 22%, transparent);
  }

  .v9-cursor.is-3d.is-on-light .v9-cursor-ring {
    background: rgba(244, 241, 234, 0.54);
    border-color: #8A5A0F;
  }

  .v9-cursor.is-3d .v9-cursor-label {
    opacity: 1;
    transform: scale(1);
  }

  /* Zustand: Video-Scrub ([data-v6-video-scrub]) → Film-Klammer ↔ */
  .v9-cursor.is-scrub .v9-cursor-ring {
    width: 52px;
    height: 28px;
    border-radius: 999px;
    border-color: color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 86%, transparent);
    background: color-mix(in srgb, var(--sw-bg, #0C0F13) 46%, transparent);
  }

  .v9-cursor.is-scrub.is-on-light .v9-cursor-ring {
    background: rgba(244, 241, 234, 0.62);
    border-color: #8A5A0F;
  }

  .v9-cursor.is-scrub .v9-cursor-label {
    opacity: 1;
    transform: scale(1);
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  /* Zustand: Optische Linse ([data-v6-lens]) → Weicher Licht-Ring */
  .v9-cursor.is-lens .v9-cursor-ring {
    width: 44px;
    height: 44px;
    border-color: color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 64%, rgba(255, 255, 255, 0.4));
    background: radial-gradient(
      circle,
      color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 16%, transparent) 0%,
      transparent 72%
    );
    box-shadow: 0 0 24px color-mix(in srgb, var(--sw-a1, var(--gold, #D59B42)) 26%, transparent);
  }

  /* Zustand: Klick-Impuls */
  .v9-cursor.is-down .v9-cursor-ring {
    transform: translate3d(-50%, -50%, 0) scale(0.88);
  }

  /* Sanfter magnetischer Zug (max 5 px via CSS Individual Property translate) */
  [data-v9-magnet-bound="1"] {
    translate: var(--v9-mag-x, 0px) var(--v9-mag-y, 0px);
  }
}

html.is-still .v9-cursor {
  display: none !important;
}

html.is-still [data-v9-magnet-bound="1"] {
  translate: none !important;
}

/* ==========================================================================
   4. FLÜSTERLEISER, KOMPLETT RAHMENLOSER STUDIO-TON-SCHALTER (.v9-sound-btn)
   Direkt links neben #modusSchalter in <header class="nav"> — kein Pill-Kasten!
   ========================================================================== */
.v9-sound-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0 2px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink, var(--sw-fg, currentColor));
  opacity: 0.44;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    opacity 220ms ease,
    color 220ms ease,
    transform 200ms var(--v9-ease);
}

.v9-sound-btn:hover {
  opacity: 0.88;
}

.v9-sound-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--mint, var(--sw-a2, #9BC4D8));
  outline-offset: 3px;
}

.v9-sound-btn[aria-pressed="true"] {
  opacity: 0.96;
  color: var(--gold, var(--sw-a1, #D59B42));
}

.v9-sound-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  overflow: visible;
  pointer-events: none;
}

.v9-sound-btn .v9-wave-bar {
  transform-box: fill-box;
  transform-origin: center center;
  transition: transform 240ms var(--v9-ease), opacity 220ms ease;
}

.v9-sound-btn[aria-pressed="false"] .v9-wave-bar--2 {
  transform: scaleY(0.45);
  opacity: 0.72;
}

.v9-sound-btn[aria-pressed="false"] .v9-wave-bar--3 {
  transform: scaleY(0.35);
  opacity: 0.56;
}

.v9-sound-btn .v9-wave-mute {
  opacity: 0.85;
  transition: opacity 200ms ease;
}

.v9-sound-btn[aria-pressed="true"] .v9-wave-mute {
  opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html:not(.is-still) .v9-sound-btn[aria-pressed="true"] .v9-wave-bar--1 {
    animation: v9-wave-breathe 2.2s ease-in-out infinite;
  }
  html:not(.is-still) .v9-sound-btn[aria-pressed="true"] .v9-wave-bar--2 {
    animation: v9-wave-breathe 2.2s ease-in-out 0.25s infinite;
  }
  html:not(.is-still) .v9-sound-btn[aria-pressed="true"] .v9-wave-bar--3 {
    animation: v9-wave-breathe 2.2s ease-in-out 0.5s infinite;
  }
}

@keyframes v9-wave-breathe {
  0%, 100% {
    transform: scaleY(0.84);
  }
  50% {
    transform: scaleY(1.12);
  }
}

html.is-still .v9-sound-btn .v9-wave-bar {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .v9-sound-btn,
  .v9-sound-btn .v9-wave-bar {
    transition: none !important;
    animation: none !important;
  }
}
