.heading-scene {
  position: relative;
  isolation: isolate;
}

.heading-scene--intro {
  padding-top: clamp(24px, 3vw, 45px);
}

.heading-scene--panel {
  min-height: 136px;
  border-radius: 18px;
  padding: clamp(16px, 2.6vw, 32px);
}

.heading-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  background: #0c071f;
}

.heading-scene--intro > .heading-backdrop,
.home-hero.heading-scene > .heading-backdrop {
  mask-image:
    linear-gradient(90deg, transparent, #000 7% 91%, transparent),
    linear-gradient(to bottom, transparent, #000 16%);
  mask-composite: intersect;
}

.md-choice-heading.heading-scene--panel {
  margin-bottom: 18px;
}

.md-choice-heading.heading-scene--panel > p:last-child {
  margin-bottom: 0;
}

.heading-backdrop__layer {
  position: absolute;
  inset: 0;
  background: var(--heading-scene) right center / cover no-repeat;
}

.heading-backdrop__layer--second,
.heading-backdrop__layer--third {
  display: none;
  opacity: 0;
}

.heading-backdrop__layer--contrast {
  background-image: linear-gradient(90deg, #100721f5 28%, #100721da 58%, #10072199 100%), var(--heading-scene);
}

.heading-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to top, var(--bg, #080220), transparent 28%),
    linear-gradient(90deg, #08022080 0% 58%, #08022014 100%);
}

@media (prefers-reduced-motion: no-preference) {
  .heading-backdrop__layer--second {
    --heading-animation: heading-backdrop-second;
  }
  .heading-backdrop__layer--third {
    --heading-animation: heading-backdrop-third;
  }

  /* The site's motion switch pauses the same timeline instead of removing it. */
  .heading-backdrop__layer--second,
  .heading-backdrop__layer--third {
    display: block;
    animation: var(--heading-animation) 12s ease-in-out infinite var(--heading-play-state, running) !important;
  }

  .motion-paused .heading-backdrop {
    --heading-play-state: paused;
  }
}

/* Three four-second slots with 0.6-second fades over an opaque first frame. */
@keyframes heading-backdrop-second {
  0%, 28.333%, 71.667%, 100% { opacity: 0; }
  33.333%, 66.667% { opacity: 1; }
}

@keyframes heading-backdrop-third {
  0%, 61.667%, 100% { opacity: 0; }
  66.667%, 95% { opacity: 1; }
}

@media (max-width: 1024px) {
  .heading-backdrop::after {
    background:
      linear-gradient(to top, var(--bg, #080220), transparent 30%),
      linear-gradient(90deg, #080220df, #080220a6);
  }
}

@media print {
  .heading-backdrop { display: none; }
}
