/* Public home scroll motion (direction A). Paired with home-motion.js.
   Every hidden or moving state requires html[data-home-motion="on"], which the script sets only
   when motion is allowed; otherwise this file changes nothing. Only opacity, the independent
   translate / scale / rotate properties and a one-time clip-path are animated, so the Hero's own
   transform keyframes, the WebGL scenes and every layout box stay exactly as they are.
   data-motion: "armed" (waiting below the viewport) -> "in" (entering) -> "shown" (settled:
   the element's own styles and transitions apply again). */
html[data-public-home] {
  --home-motion-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --home-motion-ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --home-motion-k: 1;
}
@media (max-width: 640px) {
  html[data-public-home] { --home-motion-k: 0.7; }
}

/* ---------------------------------------------------------------- Hero depth on the way out */
/* --home-hero-exit: 0 at the top of the page -> 1 once the Hero has scrolled away (eased).
   Near layers (butterflies) travel further than far ones (title and dial). */
html[data-home-motion="on"] .home-page .hero > .butterfly-field {
  translate: 0 calc(var(--home-hero-exit, 0) * -120px * var(--home-motion-k));
}
/* The hearts wrapper becomes a full-size box (same inset 0 as the Hero) so it can move as one
   layer without changing where its absolutely positioned hearts sit. */
html[data-home-motion="on"] .home-page .hero > .floating-hearts {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  translate: 0 calc(var(--home-hero-exit, 0) * -70px * var(--home-motion-k));
}
html[data-home-motion="on"] .home-page .hero > .hero-content {
  translate: 0 calc(var(--home-hero-exit, 0) * -36px * var(--home-motion-k));
  opacity: calc(1 - var(--home-hero-exit, 0) * 0.45);
  will-change: translate, opacity;
}
html[data-home-motion="on"] .home-page .hero .hero-content > .hero-catalog-link {
  translate: 0 calc(var(--home-hero-exit, 0) * -18px * var(--home-motion-k));
  opacity: max(0, calc(1 - var(--home-hero-exit, 0) * 1.5));
}
html[data-home-motion="on"] .home-page .hero > .down-button {
  opacity: max(0, calc(1 - var(--home-hero-exit, 0) * 1.7));
}
html[data-home-motion="on"] .home-page .hero > .scroll-hint {
  translate: 0 calc(var(--home-hero-exit, 0) * -26px * var(--home-motion-k));
}
/* Once the faded controls are essentially invisible they stop taking clicks. */
html[data-home-motion="on"] .home-page .hero[data-hero-depth="far"] :is(.hero-catalog-link, .down-button) {
  pointer-events: none;
}

/* ---------------------------------------------------------------- Memories */
/* The petals and sparkle dots drift at different depths while Memories is on screen. */
html[data-home-motion="on"] .home-page #catalog-gateway > .petals {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
html[data-home-motion="on"] .home-page #catalog-gateway .petals span:nth-child(1) { translate: 0 calc(var(--home-memories-depth, 0) * -90px * var(--home-motion-k)); rotate: calc(var(--home-memories-depth, 0) * 18deg); }
html[data-home-motion="on"] .home-page #catalog-gateway .petals span:nth-child(2) { translate: 0 calc(var(--home-memories-depth, 0) * 60px * var(--home-motion-k)); rotate: calc(var(--home-memories-depth, 0) * -14deg); }
html[data-home-motion="on"] .home-page #catalog-gateway .petals span:nth-child(3) { translate: 0 calc(var(--home-memories-depth, 0) * -140px * var(--home-motion-k)); rotate: calc(var(--home-memories-depth, 0) * 24deg); }
html[data-home-motion="on"] .home-page #catalog-gateway > .section-glow { translate: 0 calc(var(--home-memories-depth, 0) * -40px * var(--home-motion-k)); }

/* Layered entrance: the script word is written left to right, then the title rises, then the
   text, then the button settles. */
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="armed"] > .chapter-script {
  opacity: 0; clip-path: inset(-20% 100% -20% -6%); translate: 0 6px;
}
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="armed"] > h2 { opacity: 0; translate: 0 26px; }
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="armed"] > p:not(.chapter-script) { opacity: 0; translate: 0 18px; }
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="armed"] > .primary-action { opacity: 0; translate: 0 14px; scale: 0.97; }

html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="in"] > .chapter-script {
  clip-path: inset(-20% -6% -20% -6%);
  transition: clip-path 1.3s var(--home-motion-ease-io), opacity 0.5s linear, translate 1.3s var(--home-motion-ease);
}
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="in"] > h2 {
  transition: opacity 0.9s var(--home-motion-ease) 0.22s, translate 1s var(--home-motion-ease) 0.22s;
}
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="in"] > p:not(.chapter-script) {
  transition: opacity 0.9s var(--home-motion-ease) 0.4s, translate 1s var(--home-motion-ease) 0.4s;
}
html[data-home-motion="on"] .home-page .catalog-gateway-inner[data-motion="in"] > .primary-action {
  transition: opacity 0.8s var(--home-motion-ease) 0.6s, translate 0.9s var(--home-motion-ease) 0.6s, scale 0.9s var(--home-motion-ease) 0.6s;
}

/* ---------------------------------------------------------------- Love, in Motion / In Full Bloom */
/* Title first, then the stage (outside the WebGL scene: opacity and a small rise only), then
   the hint. The hint returns to its own 0.7 opacity. */
html[data-home-motion="on"] .home-page :is(.ph3d__title, .bg3d__title)[data-motion="armed"] { opacity: 0; translate: 0 calc(20px * var(--home-motion-k)); }
html[data-home-motion="on"] .home-page :is(.ph3d__title, .bg3d__title)[data-motion="in"] {
  transition: opacity 1.1s var(--home-motion-ease), translate 1.2s var(--home-motion-ease);
}
html[data-home-motion="on"] .home-page :is(.ph3d__stage, .bg3d__stage)[data-motion="armed"] { opacity: 0; translate: 0 calc(24px * var(--home-motion-k)); }
html[data-home-motion="on"] .home-page :is(.ph3d__stage, .bg3d__stage)[data-motion="in"] {
  transition: opacity 1.4s var(--home-motion-ease) 0.15s, translate 1.4s var(--home-motion-ease) 0.15s;
}
html[data-home-motion="on"] .home-page :is(.ph3d__hint, .bg3d__hint)[data-motion="armed"] { opacity: 0; translate: 0 8px; }
html[data-home-motion="on"] .home-page :is(.ph3d__hint, .bg3d__hint)[data-motion="in"] {
  transition: opacity 1s var(--home-motion-ease) 0.3s, translate 1s var(--home-motion-ease) 0.3s;
}

/* ---------------------------------------------------------------- Footer */
html[data-home-motion="on"] .home-page .home-footer[data-motion="armed"] :is(.home-footer__name, .home-footer__line, .home-footer__nav a, .home-footer__since, .home-footer__top) {
  opacity: 0; translate: 0 16px;
}
html[data-home-motion="on"] .home-page .home-footer[data-motion="armed"] .home-footer__heart { opacity: 0; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="armed"] .home-footer__base::before { scale: 0 1; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] :is(.home-footer__name, .home-footer__line, .home-footer__nav a, .home-footer__since, .home-footer__top) {
  transition: opacity 0.9s var(--home-motion-ease) var(--home-motion-delay, 0s), translate 1s var(--home-motion-ease) var(--home-motion-delay, 0s);
}
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__line { --home-motion-delay: 0.12s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__nav a:nth-child(1) { --home-motion-delay: 0.2s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__nav a:nth-child(2) { --home-motion-delay: 0.26s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__nav a:nth-child(3) { --home-motion-delay: 0.32s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__nav a:nth-child(4) { --home-motion-delay: 0.38s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] :is(.home-footer__since, .home-footer__top) { --home-motion-delay: 0.7s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__base::before { transition: scale 1.2s var(--home-motion-ease-io) 0.35s; }
html[data-home-motion="on"] .home-page .home-footer[data-motion="in"] .home-footer__heart { transition: opacity 0.8s var(--home-motion-ease) 1.1s; }

/* The script never arms anything under reduced motion; this guards a preference change. */
@media (prefers-reduced-motion: reduce) {
  html[data-home-motion="on"] .home-page [data-motion] *,
  html[data-home-motion="on"] .home-page [data-motion] { transition: none !important; }
}
