/* ═══════════════════════════════════════════════════════════════
   PAST / PRESENT / FUTURE
   Nested in the design process column.
   Desktop: a 100vh sticky frame. Heading at the top, iPhone
   vertically centered, right column masked to one device.
   Mobile: stacked serial sections, no stickiness.
   ═══════════════════════════════════════════════════════════════ */

.pd-process-days .pd-states {
  margin-top: 0;
}

.pd-states {
  --pd-states-count: 3;
  --pd-states-index: 0;
  position: relative;
  display: block;
  width: 100%;
  max-width: none;
  /* One viewport of scroll per state, so the pin stays locked
     while Today → Tomorrow → Yesterday play through. */
  height: calc(var(--pd-states-count) * 100vh);
  background: transparent;
  box-sizing: border-box;
  padding-inline: 0;
  overflow: visible;
}


/* ── Sticky 100vh frame ───────────────────────────────────────── */

.pd-states-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: clamp(1.25rem, 2.5vw, 2.5rem);
  row-gap: 0;
  box-sizing: border-box;
  overflow: hidden;
  background: transparent;
  z-index: 2;
}

/* Marked up as an h3 because it nests inside the process section, but
   it heads a full-viewport frame — so it takes H1. */
.pd-states .pd-states-heading {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font: var(--pd-type-h1);
  padding-top: clamp(2.5rem, 7vh, 5.25rem);
  padding-right: clamp(1.25rem, 2.5vw, 2.5rem);
  max-width: 22em;
}


/* ── Stage: left copy + phone, sized to the iPhone ───────────── */

.pd-states-stage {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: clamp(1.25rem, 2.5vw, 2.5rem);
  align-content: center;
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.pd-states-left {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  min-width: 0;
  min-height: 0;
}

.pd-states-sticky {
  grid-row: 2;
  position: relative;
  top: auto;
  align-self: center;
  height: auto;
  display: flex;
  align-items: flex-start;
  padding: 0;
  box-sizing: border-box;
  z-index: 2;
  background: transparent;
}

.pd-states-hint {
  grid-row: 3;
  align-self: end;
  margin: 0;
  font: var(--pd-type-body-sm);
  color: var(--c-ink);
  opacity: 0;
  transform: translateY(0.7em);
}

.pd-states-hint.is-in {
  animation: pd-states-hint-in 0.8s var(--ease-expo) 0.12s both;
}

@keyframes pd-states-hint-in {
  from {
    opacity: 0;
    transform: translateY(0.7em);
  }
  to {
    opacity: 0.42;
    transform: translateY(0);
  }
}

.pd-states-sticky-inner {
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 1.3vw, 1.1rem);
  width: 100%;
  max-width: 28rem;
}


/* ── Day label sits under the section heading ───────────────── */

/* Reserved height is derived from the type tokens, so the slide-up
   swap can never clip a descender when the scale changes. */
.pd-states-title-wrap {
  position: relative;
  overflow: hidden;
  min-height: calc(var(--pd-line-h4) * 1.1);
}

.pd-states-title {
  margin: 0;
  max-width: none;
  font: var(--pd-type-h4);
  color: var(--c-ink);
  opacity: 1;
}

.pd-states-title-wrap .pd-states-title {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transition: none;
}

.pd-states--ready .pd-states-title-wrap .pd-states-title {
  transition:
    transform 0.55s var(--ease-expo),
    opacity 0.45s ease;
}

.pd-states-body-wrap {
  position: relative;
  overflow: hidden;
  /* Four lines of body copy — the longest of the three day states */
  min-height: calc(var(--pd-line-body-lg) * 4);
}

.pd-states-body {
  margin: 0;
  max-width: none;
}

.pd-states-body-wrap .pd-states-body {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transition: none;
}

.pd-states--ready .pd-states-body-wrap .pd-states-body {
  transition:
    transform 0.55s var(--ease-expo),
    opacity 0.45s ease;
}


/* ── Chips ────────────────────────────────────────────────────── */

.pd-states-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.pd-states-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 0 0 auto;
  min-width: 0;
}

.pd-states-chip-value-wrap {
  position: relative;
  display: grid;
  grid-template-columns: max-content;
  overflow: hidden;
  height: 2.25rem;
  width: max-content;
}

.pd-states-chip-value {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 0.3em 0.75em;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font: var(--pd-type-body-sm);
  color: var(--c-ink);
  white-space: nowrap;
  box-sizing: border-box;
}

.pd-states-chip-value-wrap .pd-states-chip-value {
  grid-area: 1 / 1;
  transition: none;
}

.pd-states--ready .pd-states-chip-value-wrap .pd-states-chip-value {
  transition:
    transform 0.5s var(--ease-expo),
    opacity 0.4s ease;
}

.pd-states-chip-value.is-static {
  position: static;
  opacity: 1;
}


/* ── Slide states ─────────────────────────────────────────────── */

.pd-states-title.is-visible,
.pd-states-body.is-visible,
.pd-states-chip-value.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.pd-states-title.is-above,
.pd-states-body.is-above,
.pd-states-chip-value.is-above {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
}

.pd-states-title.is-below,
.pd-states-body.is-below,
.pd-states-chip-value.is-below {
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none;
}

.pd-states-body-wrap .pd-states-body.is-visible {
  opacity: 1;
}


/* ── Right mask: one phone at a time, vertically centered ─────── */

.pd-states-mask {
  position: relative;
  overflow: hidden;
  overflow: clip;
  clip-path: inset(0);
  isolation: isolate;
  width: min(336px, 26vw, calc(78dvh * 434 / 887));
  aspect-ratio: 434 / 887;
  max-height: 78dvh;
  box-sizing: border-box;
  min-height: 0;
}

.pd-states-panels {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--pd-states-count) * 100%);
  transform: translateY(
    calc(var(--pd-states-index, 0) * -100% / var(--pd-states-count))
  );
  will-change: transform;
}

.pd-states--ready .pd-states-panels {
  transition: transform 0.75s var(--ease-expo);
}

.pd-states-panel {
  height: calc(100% / var(--pd-states-count));
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  background: transparent;
}

.pd-states-panel-copy {
  display: none;
}

.pd-states-panel-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: transparent;
}


/* ── Phone mockup ─────────────────────────────────────────────── */

.pd-states-phone {
  position: relative;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 19.5;
  background: #111111;
  border-radius: clamp(28px, 3.5vw, 48px);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.1),
    0 18px 40px rgba(0, 0, 0, 0.1);
}

.pd-states-phone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.06) 0%,
    transparent 52%
  );
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
}

.pd-states-phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 33%;
  height: clamp(16px, 2.2%, 22px);
  background: #000000;
  border-radius: 0 0 14px 14px;
  z-index: 3;
}

.pd-states-phone-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.pd-states-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

/*
   State videos: phone on page-colored bg.
   Crop via CSS vars on each .pd-states-phone--video:
     --v-w/--v-h source canvas, --c-x/--c-y/--c-w/--c-h phone crop
*/
.pd-states-phone--video {
  --v-w: 1920;
  --v-h: 1080;
  --c-x: 744;
  --c-y: 95;
  --c-w: 434;
  --c-h: 887;
  aspect-ratio: var(--c-w) / var(--c-h);
  background: #111111;
}

.pd-states-phone--video .pd-states-phone-notch {
  display: none;
}

.pd-states-phone--video::before {
  display: none;
}

.pd-states-media-video {
  position: absolute;
  width: calc(var(--v-w) / var(--c-w) * 100%);
  height: calc(var(--v-h) / var(--c-h) * 100%);
  left: calc(-1 * var(--c-x) / var(--c-w) * 100%);
  top: calc(-1 * var(--c-y) / var(--c-h) * 100%);
  max-width: none;
  object-fit: fill;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .pd-states--ready .pd-states-panels {
    transition: none;
  }

  .pd-states-hint,
  .pd-states-hint.is-in {
    animation: none;
    opacity: 0.42;
    transform: none;
  }
}


/* ── Responsive: stacked text + video, no sticky / no hint ───── */

@media (max-width: 768px) {
  .pd-states {
    height: auto;
  }

  .pd-states-pin {
    position: static;
    top: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: visible;
    background: transparent;
  }

  .pd-states .pd-states-heading {
    padding-top: 0;
    padding-right: 0;
    max-width: none;
  }

  .pd-states-stage {
    display: contents;
    height: auto;
  }

  .pd-states-left,
  .pd-states-sticky,
  .pd-states-hint {
    display: none;
  }

  .pd-states-mask {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    overflow: visible;
    clip-path: none;
    isolation: auto;
    padding-inline: 0;
  }

  .pd-states-panels,
  .pd-states--ready .pd-states-panels {
    position: static;
    inset: auto;
    height: auto;
    transform: none;
    will-change: auto;
    transition: none;
  }

  .pd-states-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    min-height: 0;
    gap: clamp(1.35rem, 4vw, 1.85rem);
    padding-block: clamp(2rem, 5.5vw, 2.75rem) 0;
    background: transparent;
  }

  .pd-states-panel + .pd-states-panel {
    margin-top: clamp(1.75rem, 4.5vw, 2.5rem);
    padding-top: clamp(2rem, 5vw, 2.75rem);
  }

  .pd-states-panel-copy {
    display: flex;
    flex-direction: column;
    order: 1;
    gap: clamp(0.9rem, 2.5vw, 1.25rem);
  }

  .pd-states-panel-copy .pd-states-title {
    position: static;
    transform: none;
    opacity: 1;
  }

  .pd-states-panel-copy .pd-states-body {
    position: static;
    transform: none;
    opacity: 1;
    max-width: none;
  }

  .pd-states-panel-media {
    order: 2;
    height: auto;
    width: 100%;
    justify-content: center;
  }

  .pd-states-phone {
    width: clamp(168px, 52vw, 236px);
    max-height: none;
    height: auto;
  }
}

@media (max-width: 480px) {
  .pd-states-phone {
    width: clamp(156px, 62vw, 210px);
  }
}
