/* The unenhanced document is eight complete, readable pairs. Wide and narrow
   screens use the same content; only the surfaces that stick to the viewport change. */
[data-product-story] {
  --story-mode: wide;
  --scene: 100svh;
  --hold: 95svh;
  --edge: clamp(1rem, 3.3vw, 4rem);
  --marble: #F1F5F9 url("ivory-silk.webp") center / cover no-repeat;
  --folio-width: 60rem;
  --folio-foot: clamp(1.25rem, 3.5svh, 3rem);
  --static-height: clamp(25rem, 46vw, 43rem);
  position: relative;
  isolation: isolate;
  background: var(--snow);
  color: var(--ink);
}
section[data-product-story] { scroll-margin: 0; }
.story-location {
  position: absolute;
  top: calc(var(--step) * var(--scene));
  left: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
html:has(.story-location:target, .story-entry:target) { scroll-behavior: auto; }
.story-frame {
  width: 100%;
}
.story-skip {
  position: absolute;
  z-index: 5;
  top: var(--masthead);
  left: var(--edge);
  padding: .75rem 1rem;
  background: var(--snow);
  clip-path: inset(50%);
}
.story-skip:focus { clip-path: none; }
.story-lane { display: none; }
.story-mask, .story-track, .story-entry { min-width: 0; }
.story-entry {
  display: grid;
  align-items: center;
  grid-template: "visual copy" auto / minmax(0, 1fr) minmax(0, 1fr);
}
.story-caption {
  grid-area: copy;
  width: min(100%, 36rem);
  justify-self: center;
  padding: clamp(1.5rem, 4vw, 4rem) clamp(1.25rem, 4.4vw, 4rem);
}
.story-index {
  display: inline-block;
  margin-bottom: clamp(.8rem, 2vh, 1.3rem);
  color: var(--gold-deep);
  font-size: .76rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
}
.story-caption h3 {
  margin: 0;
  font-size: clamp(2.15rem, 3.45vw, 3.5rem);
  font-weight: 520;
  line-height: 1.04;
  letter-spacing: -.046em;
  text-wrap: balance;
}
.story-caption p {
  max-width: 46ch;
  margin: clamp(.85rem, 1.4vw, 1.35rem) 0 0;
  color: var(--graphite);
  font-size: clamp(1rem, 1.18vw, 1.125rem);
  line-height: 1.6;
  text-wrap: pretty;
}
[data-product-story] .product-story-screen {
  grid-area: visual;
  container-type: size;
  position: relative;
  inset: auto;
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 100%;
  height: auto;
  min-height: var(--static-height);
  padding: 0;
  border-radius: 0;
  background: var(--marble);
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: none;
  pointer-events: auto;
}
[data-product-story]:not([data-story-mode]) :is(.demo-gpt-message,.demo-gpt-tool,.demo-gpt-composer) {
  opacity: 1; transform: none;
}
[data-story-mode] .story-lane { display: block; min-width: 0; }
.story-plate {
  height: 100%;
  width: 100%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--marble);
}
[data-story-mode] .story-plate > [data-story-screen] {
  position: absolute;
  inset: 0;
  min-height: 0;
  height: 100%;
  /* The plate, not the slides, carries the image. It never crossfades. */
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .48s ease, visibility 0s linear .48s;
}
[data-story-mode] .story-plate > .active {
  z-index: 2;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}
[data-story-mode] .story-entry { display: block; padding: 0; }
[data-story-mode] .story-caption {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  margin-inline: auto;
}

/* Separate the bleed from the typesetting. The marble owns the whole left
   leaf; only the interface and the copy need space under the floating nav. */
[data-story-mode="wide"] .story-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}
[data-story-mode="wide"] .story-caption {
  height: var(--scene);
  padding-block: var(--masthead) var(--folio-foot);
}
[data-story-mode="wide"] .story-lane {
  position: sticky;
  top: 0;
  height: var(--scene);
}
[data-story-mode="wide"] .story-plate > [data-story-screen] {
  inset: var(--masthead) 0 var(--folio-foot) auto;
  width: min(100%, var(--folio-width));
  height: auto;
}
@media (min-width: 120rem) {
  /* Limit the distance between the demo and the copy on ultrawide glass,
     without limiting the photograph or adding an outer margin. */
  [data-story-mode="wide"] .story-caption {
    justify-self: start;
    margin-inline: calc((var(--folio-width) - 36rem) / 2) 0;
  }
}
[data-story-mode="wide"] .story-entry:last-child { height: calc(var(--scene) + var(--hold)); }
[data-story-mode="wide"] .story-entry:last-child .story-caption { position: sticky; top: 0; }

/* Phone/portrait tablet: one sticky scene. Top pane changes by step;
   text travels continuously in the lower window while the page scrolls. */
@media (max-width: 55rem) and (orientation: portrait), (max-width: 47.99rem) {
  [data-product-story] { --story-mode: narrow; --static-height: clamp(25rem, 105vw, 36rem); --edge: max(1.25rem, 6vw, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .story-entry { grid-template: "visual" auto "copy" auto / 1fr; }
  .story-caption { width: min(100%, 36rem); padding: 2rem var(--edge) 2.5rem; }
  .story-caption h3 { max-width: 23ch; font-size: clamp(1.65rem, 6.6vw, 2.55rem); }
  .story-caption p { font-size: clamp(.9375rem, 3.8vw, 1.04rem); line-height: 1.53; }
  .story-index { margin-bottom: .72rem; font-size: .7rem; }
}
[data-story-mode="narrow"] { height: calc(var(--steps) * var(--scene) + var(--hold)); }
[data-story-mode="narrow"] .story-frame {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: minmax(0, 56fr) minmax(0, 44fr);
  height: var(--scene);
}
[data-story-mode="narrow"] .story-plate { background-position: 46% center; }
[data-story-mode="narrow"] .story-mask {
  /* Only the page scrolls. A fragment must not scroll this viewport a
     second time on top of the translation already applied to the captions. */
  overflow: clip;
  mask-image: linear-gradient(to bottom, transparent, black 8%, black 93%, transparent);
}
[data-story-mode="narrow"] :is(.story-track,.story-entry,.story-caption) { height: 100%; }
[data-story-mode="narrow"] .story-caption { padding-block: .4rem 1.15rem; }
[data-story-mode="narrow"] .story-track { will-change: transform; }
@media (max-height: 42rem) {
  /* On a small phone a full caption can use nearly the entire lower pane.
     Do not fade its step number or the final line while it is at rest. */
  [data-story-mode="narrow"] .story-mask { mask-image: none; }
  [data-story-mode="narrow"] .story-caption { padding-block: .35rem; }
}

/* Very short windows, large text/zoom and reduced motion have normal-flow pairs:
   no pinned pane can obscure a caption. This is also the no-JS reading order. */
@media (max-height: 31.99rem), (prefers-reduced-motion: reduce), print {
  [data-product-story] { --story-mode: static; }
}
@media (max-height: 31.99rem) and (orientation: landscape) {
  /* In a short window the normal-flow pair may be taller than the viewport.
     Reserve a usable canvas below the nav instead of squeezing the transcript. */
  [data-product-story] {
    --edge: clamp(.75rem, 3vw, 1.75rem);
    --static-height: max(100svh, calc(var(--masthead) + 17.5rem + .5rem));
  }
  .story-entry {
    grid-template: "visual copy" auto / minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
  }
  .story-entry > [data-story-screen], .story-entry > .story-caption { padding-block: var(--masthead) .5rem; }
  .story-entry > .story-caption { padding-inline: clamp(.75rem, 2.7vw, 2.2rem); }
  .story-index { margin-bottom: .45rem; font-size: .68rem; }
  .story-caption h3 { font-size: clamp(1.3rem, 3.65vw, 1.85rem); }
  .story-caption p { margin-top: .65rem; font-size: clamp(.84rem, 2.25vw, 1rem); line-height: 1.42; }
}
