/* ╔══════════════════════════════════════════════════════════════════════════════╗
   ║  PAPIK · Motion System v1.0                                                  ║
   ║  Foundation for premium scroll-driven motion across the site.                ║
   ║  Pairs with css/motion-system.css + Lenis (CDN) + GSAP/ScrollTrigger (CDN).  ║
   ║  Selectors no-op gracefully on pages where target elements don't exist.      ║
   ╚══════════════════════════════════════════════════════════════════════════════╝ */

/* ─── Motion tokens · easing curves + durations · shared vocabulary ─── */
:root {
  --ease-luxe:     cubic-bezier(0.16, 1, 0.3, 1);      /* Apple-style hero reveals */
  --ease-snap:     cubic-bezier(0.32, 0.72, 0, 1);     /* iOS scroll-snap feel */
  --ease-physical: cubic-bezier(0.4, 0, 0.2, 1);       /* Material Design standard */
  --ease-bounce:   cubic-bezier(0.68, -0.6, 0.32, 1.6);/* magnetic snap-back */
  --dur-fast:      240ms;
  --dur-base:      420ms;
  --dur-cinematic: 1.2s;
}

/* Lenis takes control of scroll · native scroll-behavior would fight it */
html {
  scroll-padding-top: 96px;
}

/* ============================================================================
   BEAT-HEADER · ARCH VARIANT
   Architectural blueprint numeral as backdrop · used on narrative chapter markers.
   ============================================================================ */
.beat-header--arch {
  position: relative;
  overflow: hidden;
  padding: 32px;
  min-height: calc(100vh - 96px);
  min-height: calc(100dvh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.beat-header--arch .beat-header__container {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  text-align: center;
  width: 100%;
}
.beat-header--arch .beat-header__num-large {
  grid-area: 1 / 1;
  font-family: inherit;
  font-size: clamp(180px, 26vw, 340px);
  font-weight: var(--fw-regular);
  line-height: 1;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--green);
  text-stroke: 1.5px var(--green);
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  white-space: nowrap;
  margin: 0;
}
.beat-header--arch .beat-header__content {
  grid-area: 1 / 1;
  z-index: 1;
  max-width: 1040px;
  padding: 0 16px;
}
.beat-header--arch .beat-header__title {
  font-family: inherit;
  font-size: clamp(30px, 3.6vw, 48px);
  font-weight: var(--fw-light);
  line-height: 1.18;
  letter-spacing: -0.014em;
  color: var(--text);
  margin: 0 auto;
  max-width: 1040px;
}
.beat-header--arch .beat-header__title strong {
  font-weight: var(--fw-medium);
  color: var(--green);
}
/* Optional lead + CTA row inside a beat-header (used on hero beats with commercial CTAs) */
.beat-header--arch .beat-header__lead {
  font-family: inherit;
  font-size: clamp(15px, 1.35vw, 19px);
  font-weight: var(--fw-light);
  line-height: 1.55;
  color: var(--green-light);
  margin: 22px auto 0;
  max-width: 680px;
  letter-spacing: -0.003em;
}
.beat-header--arch .beat-header__cta-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 36px;
}
.beat-header--arch .beat-header__cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: var(--fw-medium);
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: transform 0.4s var(--ease-luxe), background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.beat-header--arch .beat-header__cta--primary {
  background: var(--green);
  color: #fff;
  border: 1px solid transparent;
}
.beat-header--arch .beat-header__cta--primary:hover {
  background: transparent;
  color: var(--green);
}
.beat-header--arch .beat-header__cta--ghost {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
}
.beat-header--arch .beat-header__cta--ghost:hover {
  border-color: transparent;
}
.beat-header--arch .beat-header__cta svg { display: inline-block; }
@media (max-width: 768px) {
  .beat-header--arch .beat-header__cta { padding: 12px 22px; font-size: 13px; }
}
@media (max-width: 768px) {
  .beat-header--arch { padding: 64px 22px; }
  .beat-header--arch .beat-header__num-large {
    font-size: clamp(140px, 36vw, 220px);
    -webkit-text-stroke-width: 1.2px;
  }
}

/* Scroll-hint · drip line indicator at the bottom of each arch header */
.beat-header__scroll-hint {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--green);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}
.beat-header__scroll-hint-track {
  position: relative;
  width: 2px;
  height: 56px;
  background: rgba(0, 40, 25, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
.beat-header__scroll-hint-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 18px;
  background: var(--green);
  border-radius: 2px;
  animation: scroll-hint-drip 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes scroll-hint-drip {
  0%   { transform: translateY(-20px); opacity: 0; }
  18%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { transform: translateY(56px);  opacity: 0; }
}
body.is-snapping .beat-header__scroll-hint {
  opacity: 0;
  transform: translate(-50%, 14px);
}
@media (max-height: 600px) {
  .beat-header__scroll-hint { display: none; }
}

/* ============================================================================
   PHASE 01 · HERO REVEAL
   First beat-header (the page hero) animates in on load · CSS-driven.
   ============================================================================ */
.beat-header--arch:first-of-type .beat-header__num-large,
.beat-header--arch:first-of-type .beat-header__title,
.beat-header--arch:first-of-type .beat-header__scroll-hint {
  opacity: 0;
  will-change: opacity, transform;
}
.beat-header--arch:first-of-type .beat-header__num-large {
  transform: scale(0.94);
}
.beat-header--arch:first-of-type .beat-header__title {
  transform: translateY(28px);
}
.beat-header--arch:first-of-type .beat-header__scroll-hint {
  transform: translate(-50%, 16px);
}
.hero-ready .beat-header--arch:first-of-type .beat-header__num-large {
  opacity: 0.14;
  transform: scale(1);
  transition: opacity 1.4s var(--ease-luxe) 0.05s, transform 1.6s var(--ease-luxe) 0.05s;
}
.hero-ready .beat-header--arch:first-of-type .beat-header__title {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 1.2s var(--ease-luxe) 0.25s, transform 1.4s var(--ease-luxe) 0.25s;
}
.hero-ready .beat-header--arch:first-of-type .beat-header__scroll-hint {
  opacity: 1;
  transform: translate(-50%, 0);
  transition: opacity 0.9s ease 1.1s, transform 0.9s var(--ease-luxe) 1.1s;
}

/* ============================================================================
   PHASE 02 · SCROLL-TRIGGERED REVEAL INITIAL STATES
   GSAP ScrollTrigger animates these in as user scrolls.
   ============================================================================ */
.beat-header--arch:not(:first-of-type) .beat-header__num-large {
  opacity: 0;
  transform: scale(0.94);
  will-change: opacity, transform;
}
.beat-header--arch:not(:first-of-type) .beat-header__title {
  opacity: 0;
  transform: translateY(28px);
  will-change: opacity, transform;
}
.beat-header--arch:not(:first-of-type) .beat-header__scroll-hint {
  opacity: 0;
  transform: translate(-50%, 16px);
  will-change: opacity, transform;
}
body > section[data-reveal-section] {
  opacity: 0;
  transform: translateY(36px);
  will-change: opacity, transform;
}
body > section[data-reveal-section] [data-reveal-stagger] > * {
  opacity: 0;
  transform: translateY(22px);
  will-change: opacity, transform;
}

/* Class-driven reveal target states. ScrollTrigger only ADDS .is-on; the
   transition itself is CSS so an interrupted frame can never strand a
   section half-hidden (the JS tweens this replaces were killable). */
body > section[data-reveal-section].is-on {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.9s var(--ease-luxe), transform 0.9s var(--ease-luxe);
}
body > section[data-reveal-section].is-on [data-reveal-stagger] > * {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.7s var(--ease-luxe), transform 0.7s var(--ease-luxe);
  transition-delay: 0.85s;
}
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(1) { transition-delay: 0.22s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(2) { transition-delay: 0.29s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(3) { transition-delay: 0.36s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(4) { transition-delay: 0.43s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(5) { transition-delay: 0.50s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(6) { transition-delay: 0.57s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(7) { transition-delay: 0.64s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(8) { transition-delay: 0.71s; }
body > section[data-reveal-section].is-on [data-reveal-stagger] > *:nth-child(9) { transition-delay: 0.78s; }
body > section[data-reveal-section].is-on .rl-combo__title-large .line {
  transform: translateY(0);
  transition: transform 1.0s var(--ease-luxe) 0.35s;
}
body > section[data-reveal-section].is-on .wall-section__layer[data-fx-build] {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.85s var(--ease-luxe), transform 0.85s var(--ease-luxe);
}
body > section[data-reveal-section].is-on .wall-section__layer[data-fx-build]:nth-child(2) { transition-delay: 0.1s; }
body > section[data-reveal-section].is-on .wall-section__layer[data-fx-build]:nth-child(3) { transition-delay: 0.2s; }
body > section[data-reveal-section].is-on .wall-section__layer[data-fx-build]:nth-child(4) { transition-delay: 0.3s; }
body > section[data-reveal-section].is-on .faq-item[data-fx-faq] {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s var(--ease-luxe);
}
body > section[data-reveal-section].is-on .faq-item[data-fx-faq]:nth-child(2) { transition-delay: 0.06s; }
body > section[data-reveal-section].is-on .faq-item[data-fx-faq]:nth-child(3) { transition-delay: 0.12s; }
body > section[data-reveal-section].is-on .faq-item[data-fx-faq]:nth-child(4) { transition-delay: 0.18s; }
body > section[data-reveal-section].is-on .faq-item[data-fx-faq]:nth-child(5) { transition-delay: 0.24s; }
body > section[data-reveal-section].is-on .faq-item[data-fx-faq]:nth-child(n+6) { transition-delay: 0.3s; }

/* ============================================================================
   PHASE 03 · MICROINTERACTIONS (desktop only)
   ============================================================================ */
@media (hover: hover) and (pointer: fine) {
  .rl-featured__card,
  .rl-posts__card,
  .phase-card {
    transition: transform 0.55s var(--ease-luxe), box-shadow 0.55s var(--ease-luxe), border-color 0.4s ease;
    will-change: transform;
  }
  .rl-featured__card:hover {
    transform: translateY(-8px) scale(1.012);
    box-shadow: 0 28px 64px -20px rgba(0, 40, 25, 0.22);
  }
  .phase-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 44px -16px rgba(0, 40, 25, 0.14);
  }
  /* rl-posts cards are "photo + caption" not floating blocks · only the inner image reacts (JS) */
  .rl-posts__card-img {
    overflow: hidden;
    border-radius: 14px;
    will-change: transform;
    transition: transform 0.6s var(--ease-luxe);
  }
  /* Nav menu underline · canonical rule lives in rl-system.css
     (centered, width 0→100%). Do NOT redefine here — the scaleX-from-left
     variant caused a visible distortion that diverged from the index. */
  /* Magnetic CTAs · cursor-reactive translation (JS sets transform) */
  [data-magnetic] { will-change: transform; }
}

/* ============================================================================
   PHASE 04 · SECTION-SPECIFIC CHOREOGRAPHY
   ============================================================================ */
.rl-combo__title-large .line-mask {
  display: block;
  overflow: hidden;
  line-height: inherit;
}
.rl-combo__title-large .line {
  display: inline-block;
  transform: translateY(110%);
  will-change: transform;
}
.wall-section__layer[data-fx-build] {
  opacity: 0;
  transform: translateX(-28px);
  will-change: opacity, transform;
}
.faq-item[data-fx-faq] {
  opacity: 0;
  transform: translateY(18px);
  will-change: opacity, transform;
}
.faq-item__chevron {
  transition: transform 0.45s var(--ease-luxe);
}
.faq-item[open] .faq-item__chevron {
  transform: rotate(180deg);
}

/* ============================================================================
   PHASE 06 · PERFORMANCE POLISH
   Clear will-change after intro animations have settled · reduces GPU pressure.
   ============================================================================ */
.motion-stable .beat-header--arch .beat-header__num-large,
.motion-stable .beat-header--arch .beat-header__title,
.motion-stable .beat-header--arch .beat-header__scroll-hint,
.motion-stable body > section[data-reveal-section],
.motion-stable body > section[data-reveal-section] [data-reveal-stagger] > *,
.motion-stable .rl-combo__title-large .line,
.motion-stable .wall-section__layer,
.motion-stable .faq-item {
  will-change: auto;
}

/* ============================================================================
   REDUCED MOTION · respect OS preference · everything appears instantly
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  .beat-header--arch:first-of-type .beat-header__num-large,
  .beat-header--arch:first-of-type .beat-header__title,
  .beat-header--arch:first-of-type .beat-header__scroll-hint,
  .beat-header--arch:not(:first-of-type) .beat-header__num-large,
  .beat-header--arch:not(:first-of-type) .beat-header__title,
  .beat-header--arch:not(:first-of-type) .beat-header__scroll-hint,
  body > section[data-reveal-section],
  body > section[data-reveal-section] [data-reveal-stagger] > *,
  .rl-combo__title-large .line,
  .wall-section__layer,
  .faq-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .faq-item__chevron { transition: none !important; }
  .beat-header__scroll-hint-dot { animation: none !important; }
}

/* ════════════════════════════════════════════════════════════════════════════
   INTER-SECTION SCROLL MOTION DISABLED · requested (the effects were defective)
   The scroll JS no longer adds .is-on or the data-reveal-* attributes, so any
   reveal target gated on a STATIC selector (non-first beat-headers) or an
   AUTHORED attribute (data-reveal-section, present on some pages) must render
   in its final, visible state with no transition — otherwise it would stay
   hidden. On-load hero reveal (first beat-header) is intentionally untouched.
   ════════════════════════════════════════════════════════════════════════════ */
/* v2 note: elements adopted by Motion v2 ([data-mo]) are excluded from this
   force-visible block, otherwise its !important would neutralize their reveal
   (84 pages carry authored data-reveal-* attributes in the HTML). */
body > section[data-reveal-section]:not([data-mo]),
body > section[data-reveal-section] [data-reveal-stagger] > *:not([data-mo]),
.beat-header--arch:not(:first-of-type) .beat-header__title:not([data-mo]),
.rl-combo__title-large .line,
.wall-section__layer[data-fx-build],
.faq-item[data-fx-faq]:not([data-mo]) {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}
.beat-header--arch:not(:first-of-type) .beat-header__num-large {
  opacity: 0.14 !important;            /* faint architectural backdrop · true final state */
  transform: none !important;
  transition: none !important;
}
.beat-header--arch:not(:first-of-type) .beat-header__scroll-hint {
  opacity: 1 !important;
  transform: translateX(-50%) !important;  /* preserve horizontal centering */
  transition: none !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   MOTION SYSTEM v2 · fast, failure-proof scroll-life + instant microresponse
   Engine: js/motion-system.js tags elements with [data-mo] and reveals them
   by adding .mo-in. The hidden initial state ONLY exists under html.mo-live,
   so with JS off (or dead) every element renders visible. No GSAP.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Reveal states · quick rise (cards, titles, CTA boxes) ── */
html.mo-live [data-mo="up"]:not(.mo-in) {
  opacity: 0;
  transform: translateY(16px);
}
html.mo-live [data-mo="fade"]:not(.mo-in) {
  opacity: 0;
}
html.mo-live [data-mo="img"]:not(.mo-in) {
  opacity: 0;
  transform: scale(1.015);
}
html.mo-live [data-mo] {
  transition:
    opacity 0.46s var(--ease-luxe),
    transform 0.46s var(--ease-luxe);
}
html.mo-live [data-mo="img"] {
  transition:
    opacity 0.6s var(--ease-luxe),
    transform 0.9s var(--ease-luxe);
}
html.mo-live [data-mo].mo-in {
  opacity: 1;
  transform: none;
}
/* Once settled, release compositing hints */
html.motion-stable [data-mo].mo-in { will-change: auto; transition-delay: 0ms !important; }

/* ── Header · scroll-aware depth ── */
html .rl-header {
  transition: box-shadow 0.32s var(--ease-physical);
}
html .rl-header.is-scrolled {
  box-shadow: 0 16px 40px -12px rgba(0, 40, 25, 0.28);
}

/* ── Cards · snappier lift + press feedback + inner photo zoom ── */
html .rl-featured__card {
  transition:
    transform 0.26s var(--ease-snap),
    border-color 0.26s ease,
    box-shadow 0.26s var(--ease-snap);
}
html .rl-featured__card:hover {
  transform: translateY(-6px);
}
html .rl-featured__card:active {
  transform: translateY(-2px) scale(0.988);
  transition-duration: 90ms;
}
html .rl-featured__card .rl-featured__card-visual { overflow: hidden; }
html .rl-featured__card .rl-featured__card-visual img {
  transition: transform 0.7s var(--ease-luxe);
}
html .rl-featured__card:hover .rl-featured__card-visual img {
  transform: scale(1.05);
}

/* ── Buttons & CTAs · instant press response ── */
html :is(.rl-header__cta, .rl-hero__btn, .rl-combo__btn, .blog-landing__btn,
        .article-foot__pdf, .article-foot__back, .papik-cc-btn, .hp-login__submit,
        .btn, .beat-header__cta, .rl-cta__btn) {
  transition-duration: 0.22s;
}
html :is(.rl-header__cta, .rl-hero__btn, .rl-combo__btn, .blog-landing__btn,
        .article-foot__pdf, .papik-cc-btn, .hp-login__submit,
        .btn, .beat-header__cta, .rl-cta__btn):active {
  transform: scale(0.965);
  transition-duration: 90ms;
}

/* ── Links, chips, language switcher · immediate color response ── */
html :is(.rl-footer__menu a, .rl-footer__contact-link, .rl-mnav a, .article-prose a,
        .rl-lang-switch__opt, .pill, .rl-mega__col ul a, .article-related-section__link) {
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

/* ── Form fields · live focus feedback ── */
html :is(.hp-login__field input, .papik-form input, .papik-form textarea,
        .newsletter-form input) {
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

/* ── Icon tiles inside cards · gentle response on card hover ── */
html .rl-featured__card:hover .rl-featured__card-visual :is(svg, i) {
  transform: scale(1.08);
}
html .rl-featured__card .rl-featured__card-visual :is(svg, i) {
  transition: transform 0.4s var(--ease-luxe);
}

/* ── Back-to-top pill · floating, appears after deep scroll ── */
.papik-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #002819;
  border: 1px solid rgba(0,40,25,0.10);
  border-radius: 50%;
  box-shadow: 0 14px 34px -14px rgba(0,40,25,0.30);
  cursor: pointer;
  z-index: 40;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.28s var(--ease-physical), transform 0.28s var(--ease-physical),
              background 0.2s ease, color 0.2s ease;
}
.papik-top.is-on {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.papik-top:hover { background: #002819; color: #fff; }
.papik-top:active { transform: scale(0.94); }
@media (max-width: 600px) {
  .papik-top { right: 14px; bottom: 14px; width: 40px; height: 40px; }
}

/* ── Reduced motion · the engine never engages, but belt and braces ── */
@media (prefers-reduced-motion: reduce) {
  html.mo-live [data-mo]:not(.mo-in) { opacity: 1 !important; transform: none !important; }
  html.mo-live [data-mo] { transition: none !important; }
  html .rl-featured__card:hover .rl-featured__card-visual :is(svg, i, img) { transform: none !important; }
  .papik-top { transition: none; }
}
