/*
 * Nuts Land text entrances
 *
 * This layer is deliberately limited to opacity and transform. The depth
 * treatment comes from perspective, translateZ(), and rotateX() rather than
 * layout-affecting properties. The product stage owns its own reveal contract
 * in home-hero-reveal.css and is excluded from every selector below.
 */

:root {
  --text-reveal-duration: 650ms;
  --text-reveal-ease: cubic-bezier(.22, .8, .24, 1);
  --text-reveal-distance: 22px;
  --text-reveal-step: 78ms;
  --text-reveal-perspective: 900px;
}

/* The runtime hook owns the final timing for rendered text. Tighten it a
 * little so the page feels more responsive without losing the soft landing
 * of the original entrance. The product-stage reveal never receives this
 * attribute and is therefore unaffected. */
[data-text-reveal] {
  transition-duration: 640ms !important;
  transition-delay: calc(var(--text-reveal-delay, 0ms) * .85) !important;
}

/*
 * `.reveal` is the existing site-wide hook. `.text-reveal` and
 * `[data-text-reveal]` are intentionally supported as explicit hooks for
 * sections added later. Keeping the initial state on the text nodes means the
 * surrounding layout never shifts while the entrance is running.
 */
:where(
  .reveal:not(.home-hero-products):not(.home-hero-products *),
  .text-reveal:not(.home-hero-products):not(.home-hero-products *),
  [data-text-reveal]:not(.home-hero-products):not(.home-hero-products *)
) :where(
  h1, h2, h3, h4, h5, h6, p, blockquote, li, dt, dd, figcaption,
  .eyebrow, .hero-copy, .page-hero-copy, .section-label, .footer-label,
  .button, .back-link, .discover-label, [data-reveal-text]
):not(.home-hero-products):not(.home-hero-products *) {
  --text-reveal-index: 0;
  opacity: 0;
  transform: translate3d(0, var(--text-reveal-distance), 0);
  transition:
    opacity var(--text-reveal-duration) var(--text-reveal-ease),
    transform var(--text-reveal-duration) var(--text-reveal-ease);
  transition-delay: calc(
    var(--reveal-delay, 0ms) +
    (var(--text-reveal-index) * var(--text-reveal-step))
  );
  will-change: opacity, transform;
}

/* Do not animate until the existing reveal controller has released the hook. */
:where(
  .reveal:not(.home-hero-products):not(.home-hero-products *),
  .text-reveal:not(.home-hero-products):not(.home-hero-products *),
  [data-text-reveal]:not(.home-hero-products):not(.home-hero-products *)
).is-ready :where(
  h1, h2, h3, h4, h5, h6, p, blockquote, li, dt, dd, figcaption,
  .eyebrow, .hero-copy, .page-hero-copy, .section-label, .footer-label,
  .button, .back-link, .discover-label, [data-reveal-text]
):not(.home-hero-products):not(.home-hero-products *) {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Small, predictable child rhythm for markup that does not set an index. */
:where(
  .reveal:not(.home-hero-products):not(.home-hero-products *),
  .text-reveal:not(.home-hero-products):not(.home-hero-products *),
  [data-text-reveal]:not(.home-hero-products):not(.home-hero-products *)
) :where(
  h1, h2, h3, h4, h5, h6, p, blockquote, li, dt, dd, figcaption,
  .eyebrow, .hero-copy, .page-hero-copy, .section-label, .footer-label,
  .button, .back-link, .discover-label, [data-reveal-text]
):nth-child(2):not(.home-hero-products):not(.home-hero-products *) { --text-reveal-index: 1; }

:where(
  .reveal:not(.home-hero-products):not(.home-hero-products *),
  .text-reveal:not(.home-hero-products):not(.home-hero-products *),
  [data-text-reveal]:not(.home-hero-products):not(.home-hero-products *)
) :where(
  h1, h2, h3, h4, h5, h6, p, blockquote, li, dt, dd, figcaption,
  .eyebrow, .hero-copy, .page-hero-copy, .section-label, .footer-label,
  .button, .back-link, .discover-label, [data-reveal-text]
):nth-child(3):not(.home-hero-products):not(.home-hero-products *) { --text-reveal-index: 2; }

:where(
  .reveal:not(.home-hero-products):not(.home-hero-products *),
  .text-reveal:not(.home-hero-products):not(.home-hero-products *),
  [data-text-reveal]:not(.home-hero-products):not(.home-hero-products *)
) :where(
  h1, h2, h3, h4, h5, h6, p, blockquote, li, dt, dd, figcaption,
  .eyebrow, .hero-copy, .page-hero-copy, .section-label, .footer-label,
  .button, .back-link, .discover-label, [data-reveal-text]
):nth-child(4):not(.home-hero-products):not(.home-hero-products *) { --text-reveal-index: 3; }

/* Hero copy: a restrained editorial depth pass, still transform-only. */
.home-hero-content.reveal:not(.home-hero-products):not(.home-hero-products *) {
  perspective: var(--text-reveal-perspective);
  perspective-origin: 18% 50%;
}

.home-hero-content.reveal:not(.home-hero-products):not(.home-hero-products *) :where(
  .home-hero-eyebrow, .home-hero-headline, .home-hero-support,
  .home-hero-actions, .home-hero-capabilities
):not(.home-hero-products):not(.home-hero-products *) {
  transform: translate3d(0, 30px, -34px) rotateX(7deg);
  transform-origin: 18% 100%;
  transition-duration: 800ms;
}

.home-hero-content.reveal.is-ready:not(.home-hero-products):not(.home-hero-products *) :where(
  .home-hero-eyebrow, .home-hero-headline, .home-hero-support,
  .home-hero-actions, .home-hero-capabilities
):not(.home-hero-products):not(.home-hero-products *) {
  transform: translate3d(0, 0, 0) rotateX(0deg);
}

.home-hero-content.reveal:not(.home-hero-products):not(.home-hero-products *) .home-hero-headline {
  transition-duration: 940ms;
}

/* Section-level entrances support scroll/reveal hooks without forcing them. */
:where(
  .section.reveal:not(.home-hero-products):not(.home-hero-products *),
  .content-shell.reveal:not(.home-hero-products):not(.home-hero-products *),
  .page-hero .shell.reveal:not(.home-hero-products):not(.home-hero-products *)
) {
  --text-reveal-distance: 18px;
}

@media (max-width: 560px) {
  :root {
    --text-reveal-distance: 16px;
    --text-reveal-step: 64ms;
  }

  .home-hero-content.reveal:not(.home-hero-products):not(.home-hero-products *) {
    perspective: 700px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-text-reveal] {
    transition: none !important;
    transition-delay: 0ms !important;
  }

  :where(
    .reveal:not(.home-hero-products):not(.home-hero-products *),
    .text-reveal:not(.home-hero-products):not(.home-hero-products *),
    [data-text-reveal]:not(.home-hero-products):not(.home-hero-products *)
  ) :where(
    h1, h2, h3, h4, h5, h6, p, blockquote, li, dt, dd, figcaption,
    .eyebrow, .hero-copy, .page-hero-copy, .section-label, .footer-label,
    .button, .back-link, .discover-label, [data-reveal-text]
  ):not(.home-hero-products):not(.home-hero-products *) {
    opacity: 1;
    transform: none;
    transition: none;
    will-change: auto;
  }
}
