/* =========================================================
   RONIC — Motion layer (GSAP)
   Works together with js/ronic-motion.js
   Safe by design: if GSAP fails to load, or the visitor prefers
   reduced motion, nothing below keeps content hidden.
   ========================================================= */

/* 1) Hero entrance — pure CSS, runs from first paint.
   The hero never waits for GSAP / the network: nothing is hidden by JS, the
   copy simply fades up on its own timeline (class set by the inline <head> script).
   Animations use fill-mode "backwards" so, once finished, the element returns to
   its normal CSS and GSAP / ronic-hero.js can take over without a jump. */
/* "to" frames are omitted on purpose: each element animates towards its own
   normal CSS (rotated side label, scaled panels, 1.015 hero image ...). */
@keyframes rm-rise  { from { opacity: 0; transform: translate3d(0, 0.75rem, 0); } }
@keyframes rm-fade  { from { opacity: 0; } }
@keyframes rm-drop  { from { opacity: 0; transform: translate3d(0, -2.25rem, 0); } }
@keyframes rm-zoom  { from { transform: scale(1.12); } }
@keyframes rm-grid  { from { opacity: 0; transform: scale(1.05); } }

/* arriving through the page-transition curtain: start once it has lifted */
html.rm-hero-nav { --rm-nav: 0.05s; }

html.rm-hero :is(.service-hero, .ind-hero, .hero-section)
  :is(.breadcrumb, .eyebrow, h1, .hero-description, .ind-lead, .hero-buttons,
      .service-hero-meta, .hero-tech-panel, .ind-hero-visual, .ind-proofline,
      .hero-side-label) {
  animation: rm-rise 0.45s cubic-bezier(0.215, 0.61, 0.355, 1) backwards;
  animation-delay: calc(0s + var(--rm-nav, 0s));
}
html.rm-hero :is(.service-hero, .ind-hero, .hero-section) .breadcrumb { animation-delay: calc(0s + var(--rm-nav, 0s)); }
html.rm-hero :is(.service-hero, .ind-hero, .hero-section) h1 { animation-delay: calc(0.03s + var(--rm-nav, 0s)); animation-duration: 0.5s; }
html.rm-hero :is(.service-hero, .ind-hero, .hero-section) :is(.hero-description, .ind-lead) { animation-delay: calc(0.08s + var(--rm-nav, 0s)); }
html.rm-hero :is(.service-hero, .ind-hero, .hero-section) .hero-buttons { animation-delay: calc(0.13s + var(--rm-nav, 0s)); }
html.rm-hero :is(.service-hero, .ind-hero, .hero-section) :is(.service-hero-meta, .ind-proofline) { animation-delay: calc(0.17s + var(--rm-nav, 0s)); }
/* elements that carry their own transform: fade only, so it is never overridden */
html.rm-hero :is(.service-hero, .ind-hero, .hero-section) :is(.hero-tech-panel, .ind-hero-visual) { animation-name: rm-fade; animation-delay: calc(0.08s + var(--rm-nav, 0s)); animation-duration: 0.45s; }
html.rm-hero .hero-section .hero-side-label { animation-name: rm-fade; animation-delay: calc(0.2s + var(--rm-nav, 0s)); }
/* hero photo: shown at its final size from first paint (no zoom-in / resize jump) */
html.rm-hero .ind-hero-grid      { animation: rm-fade 0.45s ease-out backwards; }
/* header is visible from first paint (no drop-in delay) */

/* homepage hero copy: the old IntersectionObserver fade is replaced by the entrance above */
.hero-section .hero-copy.reveal-on-scroll { opacity: 1; transform: none; transition: none; }

/* Tablet and smaller (<= 1023px): hero entrance animation is disabled. */
@media (max-width: 1023px) {
  html.rm-hero :is(.service-hero, .ind-hero, .hero-section) *,
  html.rm-hero .ind-hero-grid { animation: none !important; }
}

/* 2) Page-transition curtain (arrival side, before JS runs) */
html.rm-curtain-in::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
  background: var(--color-background, #04101e);
  animation: rm-fade-out 0.28s ease-out 0.04s forwards;
}
@keyframes rm-fade-out { to { opacity: 0; visibility: hidden; } }
.rm-curtain {
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
  background: var(--color-background, #04101e);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  will-change: transform;
}
.rm-curtain::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #55d9ff, #087aff, transparent);
  box-shadow: 0 0 1.5rem 2px rgba(85, 217, 255, .55);
}

/* 3) Scroll progress bar */
.rm-progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 0.1875rem;
  z-index: 1100;
  pointer-events: none;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #087aff, #55d9ff);
  box-shadow: 0 0 0.75rem rgba(85, 217, 255, .6);
}

/* 4) Word-mask used for headline reveals */
.rm-w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding: 0 .03em .14em;
  margin: 0 -.03em -.14em;
}
.rm-wi { display: inline-block; will-change: transform; }

/* 5) While GSAP animates an element, the old CSS transition must not fight it */
.rm-anim { transition: none !important; }
.rm-tilt {
  transition-property: border-color, box-shadow, background, color, opacity !important;
  transform-style: preserve-3d;
}
.rm-mag {
  transition-property: background, border-color, color, box-shadow, opacity !important;
}

/* 6) Circuit-trace decoration (CTA panels) */
.rm-circuit-host { position: relative; }
.rm-circuit {
  position: absolute;
  top: 0; right: 0;
  width: 62%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  -webkit-mask-image: linear-gradient(to left, #000 45%, transparent);
          mask-image: linear-gradient(to left, #000 45%, transparent);
}
.rm-circuit path {
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rm-circuit .t { stroke: rgba(85, 217, 255, .42); }
.rm-circuit .p {
  stroke: #9fefff;
  stroke-width: 2.4;
  filter: drop-shadow(0 0 0.3125rem rgba(85, 217, 255, .9));
}
.rm-circuit circle.n { fill: #04101e; stroke: #55d9ff; stroke-width: 1.6; }
html[data-theme="light"] .rm-circuit .t { stroke: rgba(0, 120, 220, .34); }
html[data-theme="light"] .rm-circuit .p { stroke: #0a86ff; filter: drop-shadow(0 0 0.25rem rgba(10, 134, 255, .6)); }
html[data-theme="light"] .rm-circuit circle.n { fill: #fff; stroke: #0a86ff; }

/* 7) Reduced motion: switch every decoration off */
@media (prefers-reduced-motion: reduce) {
  .rm-curtain, .rm-progress, .rm-circuit { display: none !important; }
}
