/* A scroll-driven reveal: shadow, depth, then light. Original colors return at rest. */
:root {
  --light-entry-distance: 76px;
  --light-object-distance: 38px;
  --light-entry-depth: .045;
}

@media (prefers-reduced-motion: no-preference) {
  .light-scroll-active .light-scene {
    position: relative;
    isolation: isolate;
    --scene-shade: 0;
    --scene-beam: 0;
    --scene-rise: 0;
    --scene-depth: 0;
    --scene-tilt: 0deg;
    --scene-light: 1;
    --scene-beam-x: 0%;
  }

  .light-scroll-active .light-scene::before,
  .light-scroll-active .light-scene::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    border-radius: inherit;
  }

  .light-scroll-active .light-scene::before {
    background: linear-gradient(155deg, #02030c 8%, #070b20 58%, #010208);
    opacity: var(--scene-shade);
  }

  .light-scroll-active .light-scene::after {
    background:
      linear-gradient(118deg, transparent 20%, #688cff12 30%, #9dbdff70 39%, #edf6ffcc 44%, #ffffffed 46%, #b4d2ff80 49%, #648aff24 56%, transparent 65%),
      radial-gradient(ellipse at 54% 2%, #c5d7ff60, transparent 64%);
    opacity: var(--scene-beam);
    clip-path: inset(0);
    background-size: 200% 100%, 100% 100%;
    background-position: var(--scene-beam-x) 0, 0 0;
  }

  .light-scroll-active .light-scene-content {
    position: relative;
    z-index: 1;
    translate: 0 calc(var(--scene-rise) * var(--light-entry-distance));
    scale: calc(1 - var(--scene-depth) * var(--light-entry-depth));
    transform: perspective(1400px) rotateX(var(--scene-tilt));
    transform-origin: center 18%;
    filter: brightness(var(--scene-light));
  }

  .light-scroll-active .light-scene[data-light-state="lit"] > .light-scene-content {
    translate: none;
    scale: none;
    transform: none;
    filter: none;
  }

  .light-scroll-active .light-scene .light-object {
    translate: 0 calc(var(--object-rise, 0) * var(--light-object-distance));
    scale: calc(1 - var(--object-rise, 0) * .055);
    opacity: var(--object-opacity, 1);
    filter: brightness(var(--object-light, 1));
    transform-origin: center top;
  }

  .light-scroll-active .light-scene .light-object[data-light-object="lit"] {
    translate: none;
    scale: none;
    opacity: 1;
    filter: none;
  }

  .light-scroll-active .light-scene .phone-preview:nth-child(2) {
    translate: 0 calc(var(--object-rise, 0) * 22px);
  }

  .light-scroll-active .light-scene .phone-preview:nth-child(3) {
    translate: 0 calc(var(--object-rise, 0) * 44px);
  }

  /* The new scroll timeline owns section entry, replacing one-shot reveals. */
  .light-scroll-active .light-scene .reveal,
  .light-scroll-active .light-scene .reveal > * {
    opacity: 1 !important;
    animation: none !important;
  }

  .light-scroll-active .showcase-frame {
    translate: 0 calc(var(--hero-depart, 0) * -44px);
    opacity: calc(1 - var(--hero-depart, 0) * .44);
  }

  .light-scroll-active .showcase-shade {
    opacity: calc(1 - var(--hero-depart, 0) * .34);
  }

  .light-scroll-active .showcase::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 38%;
    background: linear-gradient(0deg, #040518, transparent);
    opacity: var(--hero-depart, 0);
    pointer-events: none;
  }

  @media (max-width: 900px), (pointer: coarse) {
    :root {
      --light-entry-distance: 34px;
      --light-object-distance: 14px;
      --light-entry-depth: .018;
    }
    .light-scroll-active .light-scene-content {
      transform: none;
      filter: none;
    }
    .light-scroll-active .light-scene .phone-preview:nth-child(n) {
      translate: none;
    }
    .light-scroll-active .showcase-frame {
      translate: 0 calc(var(--hero-depart, 0) * -16px);
      opacity: 1;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .light-scene::before, .light-scene::after { display: none; }
  .light-scene .reveal, .light-scene .reveal > * {
    opacity: 1 !important;
    animation: none !important;
  }
}
