.kapitel:has( > .hg-buehne) {
  --hg-vorlauf: 70svh;
  isolation: isolate;
  overflow: clip;
}

.kapitel:has( > .hg-buehne) > :not(.hg-buehne, .hg-vorlauf) {
  position: relative;
}

.hg-buehne[data-astro-cid-psk2vizi] {
  position: sticky;
  top: 0;
  z-index: -1;
  block-size: 100svh;
  margin-block-end: -100svh;
  overflow: hidden;
}

.hg-buehne__bild[data-astro-cid-psk2vizi], .hg-buehne__schleier[data-astro-cid-psk2vizi], .hg-buehne__ausklang[data-astro-cid-psk2vizi] {
  position: absolute;
  inset: 0;
}

.hg-buehne__bild[data-astro-cid-psk2vizi] img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: var(--hg-fokus);
  filter: brightness(var(--hg-helligkeit, 1));
  transform-origin: var(--hg-fokus);
}

[data-astro-cid-psk2vizi][data-grund="dunkel"]:not([data-effekt="blende"]) .hg-buehne__bild[data-astro-cid-psk2vizi] {
  background: var(--c-ink);
}

.hg-buehne__ausklang[data-astro-cid-psk2vizi] {
  background: var(--c-paper);
  opacity: 0;
}

[data-astro-cid-psk2vizi][data-grund="dunkel"] .hg-buehne__ausklang[data-astro-cid-psk2vizi] {
  background: var(--c-ink);
}

[data-astro-cid-psk2vizi][data-effekt="blende"][data-grund="dunkel"] {
  background: var(--c-ink);
}

[data-astro-cid-psk2vizi][data-effekt="blende"][data-grund="hell"] {
  background: var(--c-paper);
}

[data-astro-cid-psk2vizi][data-effekt="blende"] .hg-buehne__bild[data-astro-cid-psk2vizi] {
  opacity: 0;
}

[data-astro-cid-psk2vizi][data-flaeche][data-grund="dunkel"] .hg-buehne__bild[data-astro-cid-psk2vizi] {
  background: var(--c-ink);
}

[data-astro-cid-psk2vizi][data-flaeche][data-grund="hell"] .hg-buehne__bild[data-astro-cid-psk2vizi] {
  background: var(--c-paper);
}

.hg-buehne__schleier[data-astro-cid-psk2vizi] {
  background: var(--c-paper);
  opacity: var(--hg-schleier);
}

[data-astro-cid-psk2vizi][data-grund="dunkel"] .hg-buehne__schleier[data-astro-cid-psk2vizi] {
  background: var(--c-ink);
}

.hg-vorlauf[data-astro-cid-psk2vizi] {
  display: none;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .kapitel:has( > .hg-buehne) {
      view-timeline: --hg block;
      scroll-margin-top: calc(-1 * var(--hg-vorlauf));
    }

    .hg-vorlauf[data-astro-cid-psk2vizi] {
      display: block;
      block-size: var(--hg-vorlauf);
    }

    .kapitel:has( > .hg-buehne:is([data-effekt="kreis"], [data-effekt="spalt"])[data-von="dunkel"]) {
      background: var(--c-ink);
    }

    .kapitel:has( > .hg-buehne:is([data-effekt="kreis"], [data-effekt="spalt"])[data-von="hell"]) {
      background: var(--c-paper);
    }

    .kapitel:has( > .hg-buehne[data-effekt="spalt"]) {
      --hg-vorlauf: 30svh;
    }

    .kapitel:has( > .hg-buehne[data-effekt="spalt"][data-grund="dunkel"]) {
      animation: linear both hg-grund-dunkel;
      animation-timeline: --hg;
      animation-range: entry 64% entry 65%;
    }

    .kapitel:has( > .hg-buehne[data-effekt="spalt"][data-grund="hell"]) {
      animation: linear both hg-grund-hell;
      animation-timeline: --hg;
      animation-range: entry 64% entry 65%;
    }

    [data-astro-cid-psk2vizi][data-effekt="spalt"] .hg-buehne__bild[data-astro-cid-psk2vizi] {
      clip-path: inset(0 50%);
      animation: cubic-bezier(.65, 0, .35, 1) both hg-spalt;
      animation-timeline: --hg;
      animation-range: entry 10% entry 65%;
    }

    .kapitel:has( > .hg-buehne[data-effekt="spalt"]) {
      scroll-margin-top: 0;
    }

    [data-astro-cid-psk2vizi][data-effekt="spalt"] + .hg-vorlauf[data-astro-cid-psk2vizi] {
      animation: linear both hg-vorlauf-weg;
      animation-timeline: --hg;
      animation-range: entry 65% entry calc(100% - var(--kopf-hoehe));
    }

    [data-astro-cid-psk2vizi][data-effekt="kreis"] .hg-buehne__bild[data-astro-cid-psk2vizi] {
      clip-path: circle(0%);
      animation: linear both hg-kreis;
      animation-timeline: --hg;
      animation-range: entry 20% contain calc(var(--hg-vorlauf) * .8);
    }

    [data-astro-cid-psk2vizi][data-effekt="kreis"] .hg-buehne__bild[data-astro-cid-psk2vizi] img {
      animation: linear both hg-kreis-zoom;
      animation-timeline: --hg;
      animation-range: entry 20% contain var(--hg-vorlauf);
    }

    [data-astro-cid-psk2vizi][data-effekt="zoom"] .hg-buehne__bild[data-astro-cid-psk2vizi] img {
      animation: cubic-bezier(.55, 0, .9, .6) both hg-zoom-hinein;
      animation-timeline: --hg;
      animation-range: entry 20% contain calc(var(--hg-vorlauf) * .7);
    }

    .kapitel:has( > .hg-buehne[data-effekt="blende"]) {
      --hg-vorlauf: 130svh;
    }

    [data-astro-cid-psk2vizi][data-effekt="blende"][data-grund="dunkel"] {
      animation: linear both hg-blende-dunkel;
      animation-timeline: --hg;
      animation-range: contain contain 50svh;
    }

    [data-astro-cid-psk2vizi][data-effekt="blende"][data-grund="hell"] {
      animation: linear both hg-blende-hell;
      animation-timeline: --hg;
      animation-range: contain contain 50svh;
    }

    [data-astro-cid-psk2vizi][data-effekt="blende"] .hg-buehne__bild[data-astro-cid-psk2vizi] {
      animation: linear both hg-blende-bild;
      animation-timeline: --hg;
      animation-range: contain contain 60svh;
    }

    [data-astro-cid-psk2vizi][data-effekt="blende"] .hg-buehne__bild[data-astro-cid-psk2vizi] img {
      animation: linear both hg-blende-zoom;
      animation-timeline: --hg;
      animation-range: contain contain 60svh;
    }

    .hg-buehne__ausklang[data-astro-cid-psk2vizi] {
      animation: linear both hg-ausklang;
      animation-timeline: --hg;
      animation-range: contain calc(100% - 60svh);
    }

    .hg-buehne__schleier[data-astro-cid-psk2vizi] {
      animation: linear both hg-schleier;
      animation-timeline: --hg;
      animation-range: contain calc(var(--hg-vorlauf) * .75) contain calc(var(--hg-vorlauf) + 40svh);
    }

    [data-astro-cid-psk2vizi][data-effekt="zoom"] .hg-buehne__schleier[data-astro-cid-psk2vizi] {
      animation-range: entry 70% contain calc(var(--hg-vorlauf) * .7);
    }
  }
}

@keyframes hg-vorlauf-weg {
  from {
    block-size: var(--hg-vorlauf);
  }

  to {
    block-size: 0;
  }
}

@keyframes hg-grund-dunkel {
  from {
    background-color: var(--c-paper);
  }

  to {
    background-color: var(--c-ink);
  }
}

@keyframes hg-grund-hell {
  from {
    background-color: var(--c-ink);
  }

  to {
    background-color: var(--c-paper);
  }
}

@keyframes hg-spalt {
  from {
    clip-path: inset(0 50%);
  }

  to {
    clip-path: inset(0);
  }
}

@keyframes hg-kreis {
  from {
    clip-path: circle(0%);
  }

  to {
    clip-path: circle(75%);
  }
}

@keyframes hg-kreis-zoom {
  from {
    transform: scale(1.35) rotate(-6deg);
  }

  to {
    transform: scale(1) rotate(0);
  }
}

@keyframes hg-zoom-hinein {
  from {
    transform: scale(1) rotate(0);
  }

  to {
    transform: scale(9) rotate(35deg);
  }
}

@keyframes hg-blende-dunkel {
  from {
    background-color: var(--c-paper);
  }

  to {
    background-color: var(--c-ink);
  }
}

@keyframes hg-blende-hell {
  from {
    background-color: var(--c-ink);
  }

  to {
    background-color: var(--c-paper);
  }
}

@keyframes hg-blende-bild {
  0% {
    opacity: 0;
  }

  45% {
    opacity: .85;
  }

  100% {
    opacity: 0;
  }
}

@keyframes hg-blende-zoom {
  from {
    transform: scale(1.25);
  }

  to {
    transform: scale(1);
  }
}

@keyframes hg-ausklang {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes hg-schleier {
  from {
    opacity: 0;
  }

  to {
    opacity: var(--hg-schleier);
  }
}
