/* Cristal owns this stage; the other three proposals keep the original scene. */
html:has([data-cristal-story]) { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.device-story[data-cristal-story] {
  --cristal-top: calc(96px + env(safe-area-inset-top, 0px));
  --cristal-line: #cbd2ce;
  --cristal-soft-ink: #676f69;
  height: 620svh;
  min-height: 0;
  margin-top: 20px;
}

.device-story[data-cristal-story] .device-pin {
  position: sticky;
  top: var(--cristal-top);
  height: calc(100svh - var(--cristal-top));
  min-height: 0;
  padding: 10px 0 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  row-gap: 8px;
  align-content: stretch;
}

/* Override the shared navigation offset without changing the other proposals. */
body:has(.na-header) .device-story[data-cristal-story] .device-pin {
  top: var(--cristal-top);
}

.device-story[data-cristal-story] .device-heading {
  width: 100%;
  min-height: 0;
  padding: 0 24px;
}

/* Reserve the final heading's footprint throughout the desktop-to-phone turn. */
.cristal-heading-content {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 200ms ease-in-out, transform 200ms ease-in-out, visibility 0s linear 200ms;
}
.is-phone-ready .cristal-heading-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}

.device-story[data-cristal-story] .device-heading h2 {
  font-size: clamp(40px, 4.3vw, 64px);
  line-height: 1.04;
  letter-spacing: -.035em;
  font-weight: 650;
}

.device-story[data-cristal-story] .device-heading p {
  margin-top: 6px;
  color: #69716b;
  font-size: 15px;
  line-height: 1.45;
}

.cristal-stage {
  position: relative;
  width: min(100%, 1220px);
  min-width: 0;
  min-height: 0;
  margin-inline: auto;
}

.device-story[data-cristal-story] .device-viewport {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}

.device-story[data-cristal-story] .device-viewport::after {
  display: none;
}

.cristal-shadow {
  display: none;
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: 500px;
  height: 20px;
  background: radial-gradient(ellipse, rgb(34 40 49 / .2), transparent 70%);
  filter: blur(7px);
  pointer-events: none;
  visibility: hidden;
}
.device-story[data-cristal-story].is-rendered .cristal-shadow { display: block; visibility: visible; }
.device-story[data-cristal-story] .device-canvas { z-index: 1; width: 100%; height: 100%; }
.device-story[data-cristal-story] .device-fallback { border-radius: 20px; }

.cristal-feature-copy,
.cristal-feature-note {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: clamp(175px, 20vw, 260px);
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 320ms ease-in-out, visibility 0s linear 420ms;
}

.cristal-feature-copy { left: clamp(24px, 4.5vw, 65px); }
.cristal-feature-note { right: clamp(24px, 4.5vw, 65px); width: clamp(165px, 18vw, 235px); }
.is-phone-ready .cristal-feature-copy,
.is-phone-ready .cristal-feature-note { opacity: 1; visibility: visible; transition-delay: 0s; }

.cristal-feature-step { display: block; margin-bottom: 14px; color: #717a72; font-size: 11px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.cristal-feature-copy h3 { margin: 0; color: #252d28; font-size: clamp(23px, 2.3vw, 31px); line-height: 1.13; letter-spacing: -.045em; font-weight: 580; }
.cristal-feature-copy p { margin: 15px 0 0; max-width: 260px; color: var(--cristal-soft-ink); font-size: 15px; line-height: 1.65; }
.cristal-feature-note strong { display: block; color: #3a443d; font-size: 17px; line-height: 1.3; letter-spacing: -.02em; font-weight: 570; }
.cristal-feature-note p { margin: 10px 0 0; color: var(--cristal-soft-ink); font-size: 14px; line-height: 1.65; }

.cristal-feature-copy::after,
.cristal-feature-note::after {
  content: "";
  position: absolute;
  top: 50%;
  width: clamp(26px, 4vw, 58px);
  height: 1px;
  background: var(--cristal-line);
  opacity: 0;
  transform: scaleX(0);
  transition: transform 420ms ease-in-out, opacity 320ms ease-in-out;
}
.cristal-feature-copy::after { left: calc(100% + 15px); transform-origin: left center; }
.cristal-feature-note::after { right: calc(100% + 15px); transform-origin: right center; }
.is-phone-ready .cristal-feature-copy::after,
.is-phone-ready .cristal-feature-note::after { transform: scaleX(1); opacity: 1; }
.cristal-feature-copy::before,
.cristal-feature-note::before {
  content: "";
  position: absolute;
  top: calc(50% - 2px);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #b8c3bb;
  opacity: 0;
  transform: scale(0);
  transition: transform 260ms ease-in-out, opacity 260ms ease-in-out;
}
.is-phone-ready .cristal-feature-copy::before,
.is-phone-ready .cristal-feature-note::before { opacity: 1; transform: scale(1); transition-delay: 160ms; }
.cristal-feature-copy::before { left: calc(100% + 14px + clamp(26px, 4vw, 58px)); }
.cristal-feature-note::before { right: calc(100% + 14px + clamp(26px, 4vw, 58px)); }

.device-story[data-cristal-story] .device-caption { margin: 0 auto; font-size: 12px; line-height: 1.4; color: #7a817a; }


@media (max-width: 1000px) and (min-width: 801px) {
  .cristal-feature-copy { left: 22px; width: 190px; }
  .cristal-feature-note { right: 22px; width: 175px; }
  .cristal-feature-copy h3 { font-size: 25px; }
  .cristal-feature-copy p { font-size: 14px; }
  .cristal-feature-copy::after, .cristal-feature-note::after { width: 25px; }
  .cristal-feature-copy::before { left: calc(100% + 39px); }
  .cristal-feature-note::before { right: calc(100% + 39px); }
}

@media (max-width: 800px) {
  .device-story[data-cristal-story] { --cristal-top: calc(78px + env(safe-area-inset-top, 0px)); height: 480svh; }
  .device-story[data-cristal-story] .device-pin { padding: 7px 0 max(14px, env(safe-area-inset-bottom, 0px)); row-gap: 6px; grid-template-rows: auto minmax(0, 1fr); }
  .device-story[data-cristal-story] .device-heading { min-height: 0; padding-inline: 18px; }
  .device-story[data-cristal-story] .device-heading h2 { font-size: clamp(36px, 7.4vw, 56px); line-height: 1.04; }
  /* One heading and one chapter caption leave the product room to breathe. */
  .device-story[data-cristal-story] .device-heading p,
  .device-story[data-cristal-story] .device-caption { display: none; }
  .cristal-stage { display: grid; grid-template-rows: minmax(0, 1fr) 80px; row-gap: 6px; }
  .device-story[data-cristal-story] .device-viewport { grid-row: 1; min-width: 0; }
  .cristal-feature-copy, .cristal-feature-note { position: static; width: min(100% - 40px, 420px); transform: none; text-align: center; margin: auto; }
  .cristal-feature-copy { grid-row: 2; grid-column: 1; }
  .cristal-feature-note { display: none; }
  .cristal-feature-step { display: none; }
  .cristal-feature-copy h3 { font-size: 23px; line-height: 1.15; }
  .cristal-feature-copy p { max-width: 420px; margin-top: 7px; font-size: 13px; line-height: 1.45; }
  .cristal-feature-note strong { display: inline; font-size: 12px; line-height: 1.4; }
  .cristal-feature-note p { display: inline; margin: 0 0 0 4px; font-size: 12px; line-height: 1.4; }
  .cristal-feature-copy::before, .cristal-feature-copy::after, .cristal-feature-note::before, .cristal-feature-note::after { display: none; }
  .device-story[data-cristal-story] .device-caption { font-size: 11px; }
}

@media (max-width: 370px) {
  .device-story[data-cristal-story] .device-heading h2 { font-size: 32px; }
  .cristal-feature-copy h3 { font-size: 21px; }
  .cristal-feature-copy p { font-size: 12px; }
}

/* On short phones, keep the chapter title and use the space for the screen. */
@media (max-height: 640px) and (max-width: 800px) {
  .cristal-stage { grid-template-rows: minmax(0, 1fr) 48px; }
  .cristal-feature-copy p { display: none; }
}

/* Short landscape screens trade some typography for a visible product. */
@media (max-height: 650px) and (min-width: 801px) {
  .device-story[data-cristal-story] .device-pin { row-gap: 3px; padding-top: 3px; padding-bottom: 6px; }
  .device-story[data-cristal-story] .device-heading { min-height: 42px; }
  .device-story[data-cristal-story] .device-heading h2 { font-size: clamp(32px, 4vw, 44px); }
  .device-story[data-cristal-story] .device-heading p { margin-top: 3px; font-size: 12px; }
  .cristal-feature-copy h3 { font-size: 23px; }
  .cristal-feature-copy p { font-size: 13px; line-height: 1.5; margin-top: 10px; }
  .cristal-feature-step { margin-bottom: 8px; }
}

@media (max-height: 500px) and (min-width: 801px) {
  .cristal-feature-step { display: none; }
  .cristal-feature-copy p { font-size: 12px; line-height: 1.35; margin-top: 8px; }
  .cristal-feature-note strong { font-size: 15px; }
  .cristal-feature-note p { font-size: 12px; line-height: 1.4; margin-top: 6px; }
}

/* Landscape uses the full height beside the copy instead of below it. */
@media (orientation: landscape) and (max-height: 550px) and (max-width: 1000px) {
  .device-story[data-cristal-story] { height: 480svh; }
  .device-story[data-cristal-story] .device-pin {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    padding: 6px max(20px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
    gap: 12px;
  }
  .device-story[data-cristal-story] .device-heading { grid-column: 1; grid-row: 1; align-self: end; padding: 0; }
  .device-story[data-cristal-story] .device-heading h2 { font-size: clamp(26px, 4vw, 36px); }
  .device-story[data-cristal-story] .device-heading p,
  .device-story[data-cristal-story] .device-caption { display: none; }
  .cristal-stage { display: contents; }
  .device-story[data-cristal-story] .device-viewport { grid-column: 2; grid-row: 1 / 3; }
  .cristal-feature-copy { display: block; position: static; grid-column: 1; grid-row: 2; align-self: start; width: 100%; margin: 0; transform: none; text-align: center; }
  .cristal-feature-copy h3 { font-size: 20px; line-height: 1.2; }
  .cristal-feature-copy p, .cristal-feature-step, .cristal-feature-note,
  .cristal-feature-copy::before, .cristal-feature-copy::after { display: none; }
}

/* Reduced motion and GPU fallback keep all five screens reachable by scroll. */
.device-story[data-cristal-story].is-chapter-scroll { height: 300svh; min-height: 0; }
.device-story[data-cristal-story].is-chapter-scroll .device-pin { position: sticky; top: var(--cristal-top); }
.device-story[data-cristal-story].is-fallback-phone .device-fallback {
  top: 18px; bottom: auto; height: min(88%, 660px); width: auto; max-width: 90%;
}
@media (max-width: 800px), (max-height: 550px) and (max-width: 1000px) {
  .device-story[data-cristal-story].is-fallback-phone .device-fallback {
    top: 14px; height: min(calc(100% - 32px), 660px); max-width: 78%;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Keep native scroll and instant chapter changes without rotating the phone. */
  .cristal-heading-content, .cristal-feature-copy, .cristal-feature-note { transition: none; }
  .cristal-feature-copy::before, .cristal-feature-copy::after,
  .cristal-feature-note::before, .cristal-feature-note::after { transition: none; }
}
@media (prefers-contrast: more) {
  .device-story[data-cristal-story] { --cristal-soft-ink: #3b443d; --cristal-line: #667569; }
  .device-story[data-cristal-story] .device-caption { color: #4e5b51; }
}
