/* ==========================================================
   Motion layer
   - Hover / press micro-interactions (pure CSS, spring easing)
   - Ambient loops
   - Initial states for elements that js/motion.js animates in.
     These only apply under html.has-motion, which is set when
     reduced motion is off and removed if Motion fails to load.
   Hover lifts use the independent `translate` / `scale` properties
   so they compose with Motion's inline `transform`.
   ========================================================== */

:root {
  /* Spring, bounce 0.2 — generated for a 0.55s duration */
  --spring: linear(0, 0.0649, 0.2088, 0.3773, 0.539, 0.6782, 0.7891, 0.8723, 0.931, 0.97,
    0.994, 1.0073, 1.0135, 1.0152, 1.0143, 1.0121, 1.0096, 1.0071, 1.005, 1.0033, 1);
  --spring-dur: 0.55s;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  height: 3px;
  background: linear-gradient(90deg, #7aa6ff, var(--accent) 60%, #2440c9);
  box-shadow: 0 0 12px rgba(91, 140, 255, 0.8);
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* ---------- Nav: hide on scroll down, sliding indicator ---------- */
.nav { transition: background-color .35s, box-shadow .35s, transform .45s var(--ease-out); }
.nav.is-hidden { transform: translateY(-100%); }
/* Desktop only: on mobile the list is an absolutely positioned dropdown */
@media (min-width: 901px) { .nav__links { position: relative; } }
.nav__indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: 0 50%;
  opacity: 0;
  pointer-events: none;
}
.nav__links.has-indicator a.active::after { display: none; }
.nav.is-scrolled .nav__indicator { color: var(--accent); }
@media (max-width: 900px) { .nav__indicator { display: none; } }

/* ---------- Back to top with reading-progress ring ---------- */
.to-top {
  position: fixed;
  right: max(16px, calc(var(--edge) - 64px));
  bottom: 24px;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 14px 30px -12px rgba(22, 56, 140, 0.45);
  cursor: pointer;
  opacity: 0;
  translate: 0 16px;
  pointer-events: none;
  transition: opacity .3s, translate var(--spring-dur) var(--spring), scale var(--spring-dur) var(--spring);
}
.to-top.is-visible { opacity: 1; translate: 0 0; pointer-events: auto; }
.to-top:hover { scale: 1.06; }
.to-top:active { scale: 0.94; }
.to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.to-top svg { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; }
.to-top .ring-track { stroke: rgba(46, 82, 242, 0.12); }
.to-top .ring { stroke: var(--accent); stroke-linecap: round; }
.to-top .arrow { position: relative; width: 18px; height: 18px; rotate: 0deg; }
@media (max-width: 1100px) {
  /* The builder's sticky total bar takes this corner on smaller screens */
  .builder-in-view .to-top { opacity: 0; pointer-events: none; translate: 0 16px; }
}

/* ---------- Buttons: spring press ---------- */
.btn, .role__add, .stepper button, .nav__toggle {
  transition-property: background-color, border-color, color, box-shadow, translate, scale;
  transition-duration: .25s, .25s, .25s, .25s, var(--spring-dur), var(--spring-dur);
  transition-timing-function: ease, ease, ease, ease, var(--spring), var(--spring);
}
.btn:active, .role__add:active, .stepper button:active, .nav__toggle:active { scale: 0.96; }
.btn--primary:hover { transform: none; translate: 0 -1px; }

/* ---------- Organisation ---------- */
.org__halo { animation: halo-breathe 7s ease-in-out infinite; }
@keyframes halo-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.05); opacity: .8; }
}
.float-chip { animation: chip-float 5s ease-in-out infinite; }
@keyframes chip-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -6px; }
}
.float-chip .dot { position: relative; }
.float-chip .dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22c55e;
  animation: dot-ping 2.2s ease-out infinite;
}
@keyframes dot-ping {
  0%   { transform: scale(1); opacity: .6; }
  80%, 100% { transform: scale(2.8); opacity: 0; }
}
.orgchart__dept li {
  transition: translate var(--spring-dur) var(--spring), box-shadow .25s, border-color .25s;
}
.orgchart__dept li:hover {
  translate: 0 -2px;
  border-color: rgba(46, 82, 242, 0.35);
  box-shadow: 0 10px 22px -12px rgba(46, 82, 242, 0.55);
}

/* ---------- Paths ---------- */
.path {
  transition: translate var(--spring-dur) var(--spring), box-shadow .3s, border-color .3s, background-color .3s;
}
.path:hover { transform: none; translate: 0 -3px; }
.path__num { transition: color .35s, -webkit-text-stroke-color .35s; }
.path:hover .path__num, .path.is-active .path__num {
  color: rgba(46, 82, 242, 0.14);
  -webkit-text-stroke-color: var(--accent);
}
.path:hover .link-arrow svg { transform: translateX(4px); }

/* ---------- How it works ---------- */
.steps__fill {
  position: absolute;
  top: 34px;
  left: 34px;
  right: calc((100% - 60px) / 4 - 34px);
  height: 2px;
  margin-top: -0.25px;
  border-radius: 2px;
  background: linear-gradient(90deg, #5b8cff, var(--accent));
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 1;
}
.step__icon {
  position: relative;
  z-index: 2;
  transition: translate var(--spring-dur) var(--spring), rotate var(--spring-dur) var(--spring), box-shadow .3s;
}
.step:hover .step__icon {
  translate: 0 -3px;
  rotate: -6deg;
  box-shadow: 0 22px 36px -14px rgba(46, 82, 242, 0.85);
}

/* ---------- Builder ---------- */
.builder-bar {
  translate: 0 24px;
  opacity: 0;
  pointer-events: none;
  transition: translate var(--spring-dur) var(--spring), opacity .25s;
}
.builder-bar.is-visible { translate: 0 0; opacity: 1; pointer-events: auto; }
.stepper span { display: inline-block; }

/* ---------- Pricing ---------- */
.plan {
  transition: translate var(--spring-dur) var(--spring), border-color .3s, box-shadow .3s;
}
.plan:hover {
  transform: none;
  translate: 0 -4px;
  border-color: rgba(46, 82, 242, 0.35);
  box-shadow: 0 0 0 1px rgba(46, 82, 242, 0.2), 0 30px 50px -28px rgba(22, 56, 140, 0.5);
}
.plan--dark {
  background-size: 180% 180%;
  background-position: 0% 0%;
  transition: translate var(--spring-dur) var(--spring), box-shadow .3s, background-position 1.2s var(--ease-out);
}
.plan--dark:hover { background-position: 100% 100%; }
.tier { transition: translate var(--spring-dur) var(--spring), border-color .25s; }
.tier:hover { translate: 0 -2px; border-color: var(--line-strong); }

/* ---------- Experts ---------- */
.experts__spotlight {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(140, 180, 255, 0.22), transparent 60%);
  transition: opacity .4s;
}
.experts__panel:hover .experts__spotlight { opacity: 1; }
.service { transition: translate var(--spring-dur) var(--spring), background-color .25s, border-color .25s; }
.service:hover { translate: 0 -2px; background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.28); }

/* ---------- FAQ ---------- */
.qa summary::after { transition: transform var(--spring-dur) var(--spring), background-color .25s; }
.qa summary:hover::after { background-color: #d8e2ff; }
.qa.is-closing summary::after { transform: none; }
.qa p { overflow: hidden; }

/* ---------- Closing ---------- */
.closing__glow {
  position: absolute;
  left: 50%;
  top: -40%;
  width: 70%;
  aspect-ratio: 1;
  margin-left: -35%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.28), transparent 65%);
  pointer-events: none;
}
.closing__panel > *:not(.closing__glow) { position: relative; }
.closing .h2 .w { display: inline-block; }
.closing__ctas .btn { transition-property: background-color, border-color, color, box-shadow, translate, scale; }

/* ==========================================================
   Initial states for Motion-driven entrances
   ========================================================== */
.has-motion .org__visual img,
.has-motion .orgchart,
.has-motion .orgchart__root,
.has-motion .orgchart__dept,
.has-motion .orgchart__dept li,
.has-motion .paths__visual img,
.has-motion .paths__halo,
.has-motion .path,
.has-motion .step,
.has-motion .plan,
.has-motion .service,
.has-motion .experts__figure,
.has-motion .qa,
.has-motion .closing .h2 .w { opacity: 0; }
.has-motion .orgchart__stem { transform: scaleY(0); }
.has-motion .orgchart__bar { transform: scaleX(0); }

/* ==========================================================
   Reduced motion: no loops, no springs, no hidden states
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  .org__halo, .float-chip, .float-chip .dot::after { animation: none; }
  .scroll-progress, .nav__indicator, .steps__fill, .closing__glow { display: none; }
  .to-top { transition: opacity .2s; translate: none; }
  .nav.is-hidden { transform: none; }
  .builder-bar { transition: none; }
  .path:hover, .plan:hover, .tier:hover, .service:hover, .orgchart__dept li:hover,
  .step:hover .step__icon { translate: none; rotate: none; }
  .btn:active, .role__add:active, .stepper button:active, .nav__toggle:active { scale: none; }
}
