/**
 * HealthN.E.S.S. — Scroll chapter system
 * Reusable chapter wrappers, one primary transition per chapter,
 * selective sticky storytelling, desktop progress rail.
 */

/* --------------------------------------------------------------------------
 * Chapter architecture
 * ------------------------------------------------------------------------ */
.chapter {
  --chapter-seam: transparent;
}

.chapter[data-chapter] {
  position: relative;
}

.chapter[data-rhythm="immersive"] {
  /* Hero owns its own height via .hero */
}

.chapter[data-rhythm="focused"] {
  --chapter-pad-y: clamp(4.5rem, 10vw, 8.5rem);
}

.chapter[data-rhythm="proof"] {
  --chapter-pad-y: clamp(5rem, 11vw, 9.5rem);
}

.chapter[data-rhythm="calm"] {
  --chapter-pad-y: clamp(4rem, 8vw, 6.5rem);
}

.chapter[data-rhythm="action"] {
  --chapter-pad-y: clamp(5rem, 12vw, 9rem);
}

/* Nested story scenes inside a parent chapter (film / Ascend within proof) */
.chapter-scene {
  position: relative;
  scroll-margin-top: 5.5rem;
  padding-block: clamp(2rem, 4vw, 3rem);
}

@media (min-width: 768px) {
  .chapter-scene {
    scroll-margin-top: 6rem;
  }
}

.chapter-media-slot {
  position: relative;
  overflow: hidden;
}

.chapter-align-left {
  text-align: left;
}

.chapter-align-center {
  text-align: center;
}

/* Soft gold seam — marks chapter entry without slideshow chrome */
.chapter[data-chapter]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: min(12rem, 40%);
  height: 1px;
  transform: translateX(-50%) scaleX(0.4);
  transform-origin: center;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(242, 202, 80, 0.45),
    transparent
  );
  opacity: 0;
  transition:
    opacity 0.8s var(--ease-out-expo),
    transform 0.9s var(--ease-out-expo);
  pointer-events: none;
  z-index: 1;
}

.chapter[data-chapter].is-active::before,
.chapter-scene.is-active::before {
  opacity: 1;
  transform: translateX(-50%) scaleX(1);
}

.chapter--flush-top[data-chapter]::before,
.hero[data-chapter]::before {
  display: none;
}

.chapter-scene::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(242, 202, 80, 0.22),
    transparent
  );
  opacity: 0;
  transition: opacity 0.7s var(--ease-out-expo);
  pointer-events: none;
}

.chapter-scene.is-active::before {
  opacity: 1;
}

/* --------------------------------------------------------------------------
 * Primary transition ideas (one per chapter)
 * ------------------------------------------------------------------------ */

/* tone — problem: soft lift, ambient already shifts */
[data-transition="tone"].is-active {
  box-shadow: inset 0 4rem 6rem -4rem rgba(0, 0, 0, 0.35);
}

/* gold-edge — growth system: restrained side light */
[data-transition="gold-edge"]::after {
  content: "";
  position: absolute;
  top: 15%;
  left: 0;
  width: 2px;
  height: 0;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(242, 202, 80, 0.55),
    transparent
  );
  opacity: 0;
  transition:
    height 1s var(--ease-out-expo),
    opacity 0.8s var(--ease-out-expo);
  pointer-events: none;
}

[data-transition="gold-edge"].is-active::after {
  height: 55%;
  opacity: 1;
}

/* mask — featured work: media clip reveal (pairs with .reveal-media) */
[data-transition="mask"] .reveal-media {
  clip-path: inset(8% 6% 8% 6%);
  transition: clip-path 1.15s var(--ease-out-expo);
}

[data-transition="mask"].is-active .reveal-media.is-in,
[data-transition="mask"] [data-reveal-block].is-in .reveal-media {
  clip-path: inset(0);
}

.js-ready [data-transition="mask"] .reveal-media img,
.js-ready [data-transition="mask"] .reveal-media .cinematic-img {
  transform: scale(1.05);
}

.js-ready [data-transition="mask"] .reveal-media.is-in img,
.js-ready [data-transition="mask"] [data-reveal-block].is-in .reveal-media img,
.js-ready [data-transition="mask"] .reveal-media.is-in .cinematic-img,
.js-ready [data-transition="mask"] [data-reveal-block].is-in .reveal-media .cinematic-img {
  transform: scale(1);
}

/* scale-soft — film */
[data-transition="scale-soft"] .proof-media--video {
  transform: scale(0.985);
  opacity: 0.88;
  transition:
    transform 1.1s var(--ease-out-expo),
    opacity 0.9s var(--ease-out-expo);
}

[data-transition="scale-soft"].is-active .proof-media--video,
[data-transition="scale-soft"].is-in .proof-media--video {
  transform: scale(1);
  opacity: 1;
}

/* split — Ascend: copy and mock enter from opposite sides */
.js-ready .chapter-scene[data-transition="split"] > .chapter-sticky-copy {
  opacity: 0;
  transform: translate3d(-1.25rem, 0, 0);
  transition:
    opacity 0.95s var(--ease-out-expo),
    transform 0.95s var(--ease-out-expo);
}

.js-ready .chapter-scene[data-transition="split"] > .proof-mock {
  opacity: 0;
  transform: translate3d(1.25rem, 0, 0);
  transition:
    opacity 0.95s var(--ease-out-expo),
    transform 0.95s var(--ease-out-expo);
  transition-delay: 90ms;
}

.js-ready .chapter-scene[data-transition="split"].is-active > .chapter-sticky-copy,
.js-ready .chapter-scene[data-transition="split"].is-in > .chapter-sticky-copy,
.js-ready .chapter-scene[data-transition="split"].is-active > .proof-mock,
.js-ready .chapter-scene[data-transition="split"].is-in > .proof-mock {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* rise — process: existing reveal stagger is enough; lighten pad */
[data-transition="rise"].is-active {
  background-image:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(242, 202, 80, 0.05), transparent 55%);
}

/* breath — why: calm spacing, opacity-only emphasis */
.chapter[data-transition="breath"] {
  background-color: var(--color-background);
}

.chapter[data-transition="breath"] .chapter__calm {
  max-width: 36rem;
  margin-inline: auto;
  text-align: center;
}

.why-points {
  list-style: none;
  margin: 1.75rem auto 0;
  padding: 0;
  max-width: 34rem;
  display: grid;
  gap: 0.85rem;
  text-align: left;
}

.why-points li {
  position: relative;
  padding-left: 1.15rem;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-on-surface-variant);
}

.why-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 0.35rem;
  height: 0.35rem;
  background: var(--color-primary);
}

/* wash — final CTA gold atmosphere */
[data-transition="wash"].is-active {
  background-image:
    radial-gradient(ellipse 75% 55% at 50% 45%, rgba(242, 202, 80, 0.11), transparent 62%);
}

/* --------------------------------------------------------------------------
 * Sticky storytelling — desktop only, predictable release
 * ------------------------------------------------------------------------ */
.chapter-sticky-intro {
  position: relative;
}

@media (min-width: 1024px) {
  .chapter-sticky-intro__pin {
    position: sticky;
    top: 6.5rem;
    z-index: 2;
    padding-bottom: 1.5rem;
  }

  .chapter-sticky-copy {
    position: sticky;
    top: 7rem;
    align-self: start;
  }

  /* Featured work: sticky meta column */
  .chapter-sticky-featured .chapter-sticky-copy {
    top: 7.25rem;
  }
}

@media (max-width: 1023px) {
  .chapter-sticky-intro__pin,
  .chapter-sticky-copy {
    position: static;
  }
}

/* --------------------------------------------------------------------------
 * Desktop chapter progress rail
 * ------------------------------------------------------------------------ */
.chapter-rail {
  display: none;
}

@media (min-width: 1100px) {
  .chapter-rail {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    position: fixed;
    top: 50%;
    right: clamp(0.75rem, 2vw, 1.5rem);
    transform: translateY(-50%);
    z-index: 40;
    width: 7.5rem;
    pointer-events: none;
  }

  .chapter-rail__track {
    position: absolute;
    top: 0.35rem;
    bottom: 0.35rem;
    right: 0.35rem;
    width: 1px;
    background: rgba(153, 144, 124, 0.28);
  }

  .chapter-rail__progress {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 1px;
    height: 0%;
    background: linear-gradient(
      to bottom,
      var(--color-primary-container),
      var(--color-primary)
    );
    transform-origin: top center;
    transition: height 0.35s var(--ease-standard);
  }

  .chapter-rail__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
    position: relative;
    z-index: 1;
  }

  .chapter-rail__item {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.55rem;
    min-height: 1.25rem;
  }

  .chapter-rail__link {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--color-outline);
    font-family: var(--font-label);
    font-size: 0.5625rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.55;
    transition:
      opacity var(--duration-base) var(--ease-standard),
      color var(--duration-base) var(--ease-standard);
  }

  .chapter-rail__link:hover,
  .chapter-rail__link:focus-visible {
    opacity: 1;
    color: var(--color-primary);
    outline: none;
  }

  .chapter-rail__label {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transition:
      max-width 0.35s var(--ease-standard),
      opacity 0.3s var(--ease-standard);
  }

  .chapter-rail__item.is-active .chapter-rail__label,
  .chapter-rail__link:hover .chapter-rail__label,
  .chapter-rail__link:focus-visible .chapter-rail__label {
    max-width: 7rem;
    opacity: 1;
  }

  .chapter-rail__index {
    font-variant-numeric: tabular-nums;
  }

  .chapter-rail__dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    border: 1px solid rgba(153, 144, 124, 0.55);
    background: transparent;
    flex-shrink: 0;
    transition:
      background-color var(--duration-base) var(--ease-standard),
      border-color var(--duration-base) var(--ease-standard),
      box-shadow var(--duration-base) var(--ease-standard);
  }

  .chapter-rail__item.is-active .chapter-rail__dot {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(242, 202, 80, 0.15);
  }

  .chapter-rail__item.is-active .chapter-rail__link {
    opacity: 1;
    color: var(--color-primary);
  }
}

@media (max-width: 1099px) {
  .chapter-rail {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
 * Mobile adaptations
 * ------------------------------------------------------------------------ */
@media (max-width: 767px) {
  .chapter[data-rhythm="focused"],
  .chapter[data-rhythm="proof"],
  .chapter[data-rhythm="calm"],
  .chapter[data-rhythm="action"] {
    --chapter-pad-y: clamp(3.5rem, 12vw, 5.5rem);
  }

  .chapter-scene {
    padding-block: clamp(1.5rem, 5vw, 2.25rem);
  }

  [data-transition="gold-edge"]::after {
    display: none;
  }

  .js-ready [data-transition="mask"] .reveal-media {
    clip-path: inset(4% 3% 4% 3%);
  }

  .js-ready .chapter-scene[data-transition="split"] > .chapter-sticky-copy,
  .js-ready .chapter-scene[data-transition="split"] > .proof-mock {
    transform: translate3d(0, 0.85rem, 0);
  }
}

/* --------------------------------------------------------------------------
 * Reduced motion
 * ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .chapter[data-chapter]::before,
  .chapter-scene::before,
  [data-transition="gold-edge"]::after {
    transition: none;
  }

  .js-ready [data-transition="mask"] .reveal-media,
  .js-ready [data-transition="mask"] .reveal-media img,
  .js-ready [data-transition="mask"] .reveal-media .cinematic-img,
  [data-transition="scale-soft"] .proof-media--video,
  .js-ready .chapter-scene[data-transition="split"] > .chapter-sticky-copy,
  .js-ready .chapter-scene[data-transition="split"] > .proof-mock {
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }

  .chapter-sticky-intro__pin,
  .chapter-sticky-copy {
    position: static !important;
  }

  .chapter-rail__progress {
    transition: none;
  }
}
