/* C02 and C04 share one editorial composition. Scoped to Option C so the
   original phone demos and the numbered image-to-card chapters stay intact. */
.phone-chapter {
  --chapter-phone-width: min(338px, 37.2svh, 27.5vw);
  --chapter-secondary: #485b69;
  display: grid;
  grid-template-columns: minmax(0, 46%) minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  row-gap: clamp(24px, 4svh, 44px);
  padding: 70px clamp(28px, 3vw, 64px);
}

.phone-chapter .phone-chapter-sky {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.phone-chapter .phone-chapter-copy,
.phone-chapter.panel-system.is-active .phone-chapter-copy {
  position: relative;
  inset: auto;
  grid-area: 1 / 1;
  width: 100%;
  max-width: 760px;
  margin: 0;
  transform: none;
  opacity: 1;
  z-index: 3;
}

.phone-chapter.story-scene .phone-chapter-copy :is(h1, h2) {
  max-width: 17ch;
  min-height: 2.94em;
  margin: 0;
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(2.15rem, 3.85vw, 5.3rem);
  font-weight: 520;
  letter-spacing: -.06em;
  line-height: .98;
  text-wrap: balance;
  text-shadow: none;
}

.phone-chapter .phone-chapter-copy .phone-chapter-description {
  display: block;
  max-width: 42ch;
  margin: clamp(20px, 2.8svh, 30px) 0 0;
  color: var(--chapter-secondary);
  font-size: clamp(16px, 1.12vw, 20px);
  font-weight: 400;
  line-height: 1.5;
}

.phone-chapter .reading-beats {
  position: relative;
  z-index: 3;
  grid-area: 2 / 1;
  width: 100%;
  max-width: 760px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phone-chapter .reading-beat {
  --reading-delay: 0s;
  position: relative;
  display: grid;
  grid-template-columns: minmax(125px, .8fr) minmax(0, 1.8fr);
  gap: clamp(16px, 2vw, 34px);
  align-items: baseline;
  padding: clamp(15px, 2.1svh, 24px) 0;
  border-bottom: 1px solid #24485830;
}

.phone-chapter .reading-beat h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(19px, 1.65vw, 28px);
  font-weight: 520;
  letter-spacing: -.035em;
  line-height: 1.2;
}

.phone-chapter .reading-beat p {
  min-height: 3em;
  margin: 0;
  color: var(--chapter-secondary);
  font-size: clamp(15px, 1.05vw, 18px);
  line-height: 1.5;
}

/* The original text stays readable underneath an exactly aligned bold layer.
   A soft opacity mask sweeps across that layer, never across the background. */
.phone-chapter .reading-emphasis {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: inherit;
  gap: inherit;
  align-items: inherit;
  padding: inherit;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  -webkit-mask-image: linear-gradient(to right, #000 42%, transparent 58%);
  mask-image: linear-gradient(to right, #000 42%, transparent 58%);
  -webkit-mask-size: 240% 100%;
  mask-size: 240% 100%;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.phone-chapter .reading-emphasis :is(h3, p) {
  color: var(--ink);
  -webkit-text-stroke: .03em currentColor;
}

/* Text and underline travel left to right at a constant, two-second pace. */
.phone-chapter .reading-beat::before {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 3px;
  background: #244858;
  transform-origin: left center;
  transform: scaleX(0);
  pointer-events: none;
}

.phone-chapter .reading-beat:nth-child(2) { --reading-delay: 2s; }
.phone-chapter .reading-beat:nth-child(3) { --reading-delay: 4s; }

.phone-chapter .reading-beats { --reading-play-state: paused; }
.phone-chapter .reading-beats.is-reading-running { --reading-play-state: running; }

@media (prefers-reduced-motion: no-preference) {
  .phone-chapter .reading-beats.is-reading-started .reading-beat::before {
    animation: reading-underline 2s linear var(--reading-delay) 1 both;
    animation-play-state: var(--reading-play-state) !important;
  }
  .phone-chapter .reading-beats.is-reading-started .reading-emphasis {
    animation: reading-text-sweep 2s linear var(--reading-delay) 1 both;
    /* Reading has its own visibility: the mobile phone may already be offscreen. */
    animation-play-state: var(--reading-play-state) !important;
  }
}

@keyframes reading-underline {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes reading-text-sweep {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; opacity: 0; }
  10% { opacity: 1; }
  to { -webkit-mask-position: 0 0; mask-position: 0 0; opacity: 1; }
}

.phone-chapter .reading-beats.is-reading-settled .reading-beat::before {
  animation: none;
  transform: scaleX(1);
}
.phone-chapter .reading-beats.is-reading-settled .reading-emphasis {
  animation: none;
  -webkit-mask-image: none;
  mask-image: none;
  opacity: 1;
}

.phone-chapter .phone-chapter-media {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.phone-chapter.panel-intro .intro-phone-orbit {
  top: 50%;
  left: 74.25%;
  width: var(--chapter-phone-width);
  transform: translate(-50%, -50%);
}

.phone-chapter .system-motion-story {
  /* Place the grid itself: the original phone's drift animates top and left. */
  padding-left: 48.5%;
}

.phone-chapter .system-motion-story .system-motion-phone-wrap {
  position: relative;
  top: 0;
  left: 0;
  width: var(--chapter-phone-width);
}

.phone-chapter .system-motion-glow,
.phone-chapter .system-motion-floor,
.phone-chapter .system-motion-shadow { display: none; }

/* Desktop C02 -> C04 keeps a continuous sky while each complete phone
   and its copy travel in opposite vertical directions. */
.commerce-scene.phone-match-scene { background: transparent; }
.commerce-scene.phone-match-scene .phone-chapter-sky { visibility: hidden; }

/* Warm daylight gives way to pearl blue. These light layers sit above the
   continuous cloud image and below both chapters' phones, copy and rules. */
.system-scene.phone-match-scene .phone-chapter-sky::before,
.system-scene.phone-match-scene .phone-chapter-sky::after,
.system-scene.phone-match-scene::before,
.system-scene.phone-match-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.system-scene.phone-match-scene .phone-chapter-sky::before {
  background: linear-gradient(105deg, rgba(255, 240, 220, .02), rgba(255, 224, 187, .12) 56%, rgba(255, 227, 192, .23));
  opacity: calc(1 - var(--match-sky-cool, 0));
}
.system-scene.phone-match-scene .phone-chapter-sky::after {
  /* A feathered veil lowers cloud contrast where the text sits. */
  background: linear-gradient(90deg, rgba(245, 248, 247, .28), rgba(245, 248, 247, .18) 34%, rgba(245, 248, 247, 0) 62%);
}
.system-scene.phone-match-scene::before {
  background: linear-gradient(108deg, rgba(203, 224, 244, .26), rgba(219, 226, 247, .46) 55%, rgba(218, 218, 245, .62));
  opacity: var(--match-sky-cool, 0);
}
.system-scene.phone-match-scene::after {
  background: radial-gradient(ellipse 32% 66% at 74.25% 50%, rgba(255, 255, 255, .65), rgba(222, 225, 255, .35) 28%, rgba(212, 225, 255, .08) 58%, transparent 78%);
  opacity: var(--match-sky-light, 0);
  transform: scale(var(--match-sky-scale, .78));
  transform-origin: 74.25% 50%;
}

.phone-match-scene .phone-chapter-copy,
.phone-match-scene .reading-beats {
  opacity: var(--match-copy-opacity);
  translate: 0 var(--match-copy-y);
}
.phone-match-scene.panel-system.is-active .phone-chapter-copy {
  opacity: var(--match-copy-opacity);
}
.phone-match-scene .phone-chapter-media {
  opacity: var(--match-copy-opacity);
  translate: 0 calc(-1 * var(--match-copy-y));
}
.phone-match-scene.panel-intro .intro-phone-device,
.phone-match-scene.panel-system .system-motion-phone-wrap {
  animation: none;
  transform: none;
  top: 0;
  left: 0;
}
.phone-match-scene .intro-phone-shadow { display: none; }
.phone-match-scene.panel-intro .intro-phone-discover { padding-top: 0; }
.phone-match-scene .system-motion-status > .showcase-phone-island {
  width: 22cqw;
  height: 6.1cqw;
  background: #090a09;
}
.phone-match-scene.is-phone-waiting .phone-chapter-media *,
.phone-match-scene.is-phone-waiting .phone-chapter-media *::before,
.phone-match-scene.is-phone-waiting .phone-chapter-media *::after { animation-play-state: paused !important; }
.phone-match-scene .system-motion-phone-wrap::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: calc(var(--showcase-phone-radius) + 2px);
  box-shadow: 0 0 18px rgba(114, 178, 227, .7), 0 0 38px rgba(169, 143, 231, .4);
  opacity: var(--match-glow, 0);
  pointer-events: none;
}

/* Compact landscape desktops still get full copy without a smaller phone UI. */
@media (min-width: 1024px) and (min-height: 681px) and (max-height: 760px) {
  .phone-chapter { padding-block: 58px; row-gap: 22px; }
  .phone-chapter.story-scene .phone-chapter-copy :is(h1, h2) { font-size: clamp(34px, 6.6svh, 50px); }
  .phone-chapter .phone-chapter-copy .phone-chapter-description { margin-top: 18px; font-size: 16px; }
  .phone-chapter .reading-beat { padding-block: 12px; }
  .phone-chapter .reading-beat h3 { font-size: 20px; }
  .phone-chapter .reading-beat p { font-size: 15px; }
}

@media (max-width: 1023px), (max-height: 680px), (max-aspect-ratio: 4/3), (min-aspect-ratio: 5/2) {
  .phone-chapter {
    --chapter-phone-width: min(270px, 72vw);
    --chapter-secondary: #334c5b;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    row-gap: 32px;
    padding: 82px var(--mobile-gutter) 58px;
  }
  .phone-chapter .phone-chapter-sky { display: none; }
  .phone-chapter .phone-chapter-copy,
  .phone-chapter.panel-system.is-active .phone-chapter-copy {
    grid-area: 1 / 1;
    max-width: 610px;
    margin-inline: auto;
  }
  .phone-chapter.story-scene .phone-chapter-copy :is(h1, h2) {
    max-width: 18ch;
    min-height: 0;
    font-size: clamp(2.25rem, 8.8vw, 3.8rem);
    line-height: 1.05;
    letter-spacing: -.045em;
  }
  .phone-chapter .phone-chapter-copy .phone-chapter-description {
    margin-top: 22px;
    font-size: 1.0625rem;
    line-height: 1.55;
  }
  .phone-chapter .phone-chapter-media {
    position: relative;
    inset: auto;
    grid-area: 2 / 1;
    max-width: 610px;
    height: 590px;
    min-height: 0;
    margin-inline: auto;
    overflow: visible;
  }
  .phone-chapter.panel-intro .intro-phone-orbit {
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
  }
  .phone-chapter .system-motion-story { padding-left: 0; }
  .phone-chapter .reading-beats {
    grid-area: 3 / 1;
    max-width: 610px;
    margin-inline: auto;
  }
  .phone-chapter .reading-beat {
    grid-template-columns: minmax(100px, .85fr) minmax(0, 1.4fr);
    gap: 18px;
    padding-block: 22px;
  }
  .phone-chapter .reading-beat h3 { font-size: 1.25rem; }
  .phone-chapter .reading-beat p { min-height: 0; font-size: 1rem; }
}

@media (max-width: 359px) {
  .phone-chapter.story-scene .phone-chapter-copy :is(h1, h2) { font-size: 2rem; }
  .phone-chapter .reading-beat { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

@media (min-width: 701px) {
  .mobile-ready .phone-chapter {
    --chapter-phone-width:min(300px,32vw);
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-rows:auto auto;
    align-content:center;
    gap:32px 40px;
    padding-inline:max(32px,calc((100vw - 1280px) / 2));
  }
  .mobile-ready .phone-chapter .phone-chapter-copy { grid-area:1 / 1; }
  .mobile-ready .phone-chapter .phone-chapter-copy :is(h1, h2) {
    font-size:clamp(2rem,4.6vw,3.8rem);
    overflow-wrap:normal;
  }
  .mobile-ready .phone-chapter .phone-chapter-media { grid-area:1 / 2 / 3 / 3; height:660px; align-self:center; }
  .mobile-ready .phone-chapter .reading-beats { grid-area:2 / 1; }
}
