.dl-story-scene {
  display: block;
  inline-size: 100%;
}

.dl-story-scene__stage {
  position: relative;
  aspect-ratio: 16 / 7;
  min-block-size: 15rem;
  border-radius: var(--dl-radius-float);
  overflow: hidden;
  perspective: 900px;
  background: var(--dl-accent-strong);
  isolation: isolate;
}

/* The picture, recolored in the kit's two colors: a grayscale photo under a multiply of the accent gives a duotone
   from the accent's deepest shade to the page's light, so any photo reads as part of the palette. */
.dl-story-scene__picture {
  position: absolute;
  inset: 0;
  transform-origin: 60% 50%;
  will-change: transform;
}

.dl-story-scene__media {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.1) brightness(1.08);
}

.dl-story-scene__tone {
  position: absolute;
  inset: 0;
  background: var(--dl-accent);
  mix-blend-mode: multiply;
}

/* A soft shade on the caption's side keeps its text readable over any picture. */
.dl-story-scene__picture::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, color-mix(in oklab, var(--dl-accent-strong) 88%, transparent) 0%, color-mix(in oklab, var(--dl-accent-strong) 55%, transparent) 38%, transparent 70%);
}

.dl-story-scene__tiles {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.dl-story-scene__tile {
  position: absolute;
  inset-inline-start: var(--x);
  inset-block-start: var(--y);
  /* --fly: the entry's arc and the pointer's lean, set by the script; the base keeps the tile centred on its place. */
  transform: translate(-50%, -50%) var(--fly, translateZ(0));
  transform-style: preserve-3d;
  display: flex;
  align-items: center;
  gap: var(--dl-space-2);
  padding: var(--dl-space-2) var(--dl-space-3) var(--dl-space-2) var(--dl-space-2);
  border-radius: var(--dl-radius-control);
  background: var(--dl-surface-raised);
  color: var(--dl-ink);
  box-shadow: 0 1px 1px color-mix(in oklab, var(--dl-accent-strong) 30%, transparent), 0 14px 30px -10px color-mix(in oklab, var(--dl-accent-strong) 70%, transparent);
  transition: transform var(--dl-duration-2) var(--dl-ease-out);
  will-change: transform;
}

.dl-story-scene__icon {
  display: grid;
  place-items: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: calc(var(--dl-radius-control) - 2px);
  background: var(--dl-accent);
  color: var(--dl-on-accent);
}

.dl-story-scene__icon svg {
  inline-size: 1.25rem;
  block-size: 1.25rem;
}

.dl-story-scene__words {
  display: grid;
  line-height: 1.15;
}

.dl-story-scene__label {
  color: var(--dl-ink-muted);
  font-size: var(--dl-text-xs);
}

/* The figure and its unit stay on one line: "38.6 %", "1 of 4". */
.dl-story-scene__figure {
  display: flex;
  align-items: baseline;
  gap: 0.3em;
}

.dl-story-scene__value {
  font: var(--dl-weight-strong) var(--dl-text-lg) / 1.1 var(--dl-font-head);
  font-variant-numeric: tabular-nums;
}

.dl-story-scene__unit {
  color: var(--dl-ink-muted);
  font-size: var(--dl-text-xs);
}

.dl-story-scene__caption {
  position: absolute;
  inset-inline-start: var(--dl-space-6);
  inset-block-end: var(--dl-space-6);
  max-inline-size: min(22rem, 42%);
  color: var(--dl-on-accent);
}

.dl-story-scene__kicker {
  margin: 0 0 var(--dl-space-1);
  font-size: var(--dl-text-sm);
  opacity: 0.85;
}

.dl-story-scene__text {
  margin: 0;
  font: var(--dl-weight-strong) var(--dl-text-lg) / 1.3 var(--dl-font-head);
}

.dl-story-scene__sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.dl-story-scene__credit {
  position: absolute;
  inset-inline-end: var(--dl-space-2);
  inset-block-end: var(--dl-space-1);
  color: var(--dl-on-accent);
  font-size: 0.6875rem;
  opacity: 0.8;
  text-decoration: none;
}

.dl-story-scene__credit:hover,
.dl-story-scene__credit:focus-visible {
  opacity: 1;
  text-decoration: underline;
}

/* Before the entry runs, the tiles and the caption wait. Reduced motion never waits. */
.dl-story-scene--waiting .dl-story-scene__tile,
.dl-story-scene--waiting .dl-story-scene__kicker,
.dl-story-scene--waiting .dl-story-scene__text {
  opacity: 0;
}

/* On a phone the stage is taller and the tiles gather into a row under the caption. */
@media (max-width: 40rem) {
  .dl-story-scene__stage {
    aspect-ratio: 4 / 5;
  }
  .dl-story-scene__caption {
    inset-block-start: var(--dl-space-5);
    inset-block-end: auto;
    inset-inline: var(--dl-space-4);
    max-inline-size: none;
  }
  .dl-story-scene__picture::after {
    background: linear-gradient(180deg, color-mix(in oklab, var(--dl-accent-strong) 88%, transparent) 0%, transparent 55%);
  }
  .dl-story-scene__tiles {
    display: grid;
    align-content: end;
    justify-items: start;
    gap: var(--dl-space-2);
    padding: var(--dl-space-4);
  }
  .dl-story-scene__tiles .dl-story-scene__tile {
    position: static;
    transform: var(--fly, none);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dl-story-scene__tile { transition: none; }
}

/* The demo page. */
.dl-demo > .dl-story-scene {
  inline-size: 100%;
  box-sizing: border-box;
  max-width: var(--dl-content-max);
  margin: 0 auto;
  padding: var(--dl-space-7) var(--dl-space-5);
}
