/* =========================================================
   Audiliver Labs — Motion
   Entrance animations & scroll reveals, driven by js/motion.js.
   Everything lives under `.motion` (added in <head> only when the
   visitor allows motion), so reduced-motion users and no-JS
   visitors get the static site exactly as before.
   ========================================================= */

:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Hold the page for the few ms before motion.js is wired */
.motion:not(.motion-live) .site-header,
.motion:not(.motion-live) main,
.motion:not(.motion-live) .footer {
  opacity: 0;
}

/* ---------- Keyframes ---------- */

@keyframes m-rise {
  from { opacity: 0; translate: 0 28px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes m-card {
  from { opacity: 0; translate: 0 44px; scale: 0.975; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes m-slide {
  from { opacity: 0; translate: -24px 0; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes m-fade {
  from { opacity: 0; }
}

@keyframes m-word {
  from { opacity: 0; translate: 0 108%; rotate: 4deg; }
  to { opacity: 1; translate: 0 0; rotate: 0deg; }
}

@keyframes m-line {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes m-chip {
  from { opacity: 0; translate: 0 10px; scale: 0.86; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes m-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes m-step {
  0% { opacity: 0; scale: 0.4; rotate: -45deg; }
  70% { opacity: 1; scale: 1.08; rotate: 4deg; }
  100% { opacity: 1; scale: 1; rotate: 0deg; }
}

@keyframes m-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes m-type {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes m-blink {
  50% { opacity: 0; }
}

@keyframes m-header {
  from { opacity: 0; translate: 0 -100%; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes m-tag-float {
  from { translate: 0 0; }
  to { translate: var(--tx, 8px) var(--ty, -10px); }
}

@keyframes m-grid-drift {
  to { background-position: 80px 80px, 80px 80px; }
}

@keyframes m-grid-drift-glow {
  to { background-position: 0 0, 80px 80px, 80px 80px; }
}

@keyframes m-offset-1 {
  from { opacity: 0; transform: translate(0, 0); }
  to { opacity: 1; transform: translate(12px, 12px); }
}

@keyframes m-offset-2 {
  from { opacity: 0; transform: translate(0, 0); }
  to { opacity: 1; transform: translate(24px, 24px); }
}

@keyframes m-frame {
  from { opacity: 0; translate: -12px -12px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes m-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}

@keyframes m-glow {
  0% { text-shadow: 0 0 0 rgba(74, 222, 128, 0); }
  40% { text-shadow: 0 0 18px rgba(74, 222, 128, 0.65); }
  100% { text-shadow: 0 0 0 rgba(74, 222, 128, 0); }
}

/* ---------- Header ---------- */

.motion-live .site-header {
  animation: m-header 0.9s var(--ease-out) both 0.05s;
}

.motion-live .site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), var(--yellow));
  transform-origin: left;
  transform: scaleX(var(--progress, 0));
  pointer-events: none;
}

/* ---------- Base reveal ---------- */

.motion-live [data-reveal]:not(.is-in) {
  opacity: 0;
}

.motion-live [data-reveal].is-in {
  animation: m-rise 0.9s var(--ease-out) both var(--d, 0s);
}

.motion-live [data-reveal="card"].is-in,
.motion-live [data-reveal="step"].is-in {
  animation-name: m-card;
  animation-duration: 1s;
}

.motion-live [data-reveal="slide"].is-in {
  animation-name: m-slide;
}

.motion-live [data-reveal="chip"].is-in {
  animation: m-chip 0.6s var(--ease-out) both var(--d, 0s);
}

/* ---------- Words (headlines) ---------- */

.motion-live [data-reveal="words"].is-in {
  animation: none;
  opacity: 1;
}

.motion-live .w,
.motion-live .wi {
  color: inherit;
}

.motion-live .w {
  display: inline-block;
  overflow: hidden;
  padding: 0.14em 0.06em 0.08em;
  margin: -0.14em -0.06em -0.08em;
}

.motion-live .wi {
  display: inline-block;
  transform-origin: 0 100%;
}

.motion-live .is-in .wi {
  animation: m-word 1.05s var(--ease-out) both;
  animation-delay: calc(var(--d, 0s) + var(--i, 0) * 55ms);
}

/* ---------- Eyebrows ---------- */

.motion-live [data-reveal="eyebrow"].is-in {
  animation: none;
  opacity: 1;
}

.motion-live [data-reveal="eyebrow"] span {
  transform-origin: left;
}

.motion-live .eyebrow.centered[data-reveal="eyebrow"] span:first-child {
  transform-origin: right;
}

.motion-live [data-reveal="eyebrow"].is-in span {
  animation: m-line 0.8s var(--ease-out) both var(--d, 0s);
}

.motion-live [data-reveal="eyebrow"].is-in p {
  animation: m-slide 0.8s var(--ease-out) both calc(var(--d, 0s) + 0.18s);
}

/* ---------- Hero ambience ---------- */

.motion-live .floating-tags span {
  animation:
    m-fade 1.6s ease both var(--td, 0.6s),
    m-tag-float var(--tf, 8s) ease-in-out infinite alternate var(--td, 0.6s);
}

.motion-live .grid-overlay {
  animation:
    m-fade 1.8s ease both,
    m-grid-drift 40s linear infinite;
}

.motion-live .grid-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(244, 217, 62, 0.07), transparent 65%),
    linear-gradient(rgba(244, 217, 62, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 217, 62, 0.22) 1px, transparent 1px);
  background-size: 100% 100%, 80px 80px, 80px 80px;
  -webkit-mask-image: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 75%);
  mask-image: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), #000 0%, transparent 75%);
  opacity: 0;
  transition: opacity 0.5s ease;
  animation: m-grid-drift-glow 40s linear infinite;
}

.motion-live .is-pointer .grid-overlay::after {
  opacity: 1;
}

/* Hero stats: divider draws, numbers rise and count */
.motion-live [data-reveal="stats"] {
  position: relative;
  border-top-color: transparent;
}

.motion-live [data-reveal="stats"].is-in {
  animation: none;
  opacity: 1;
}

.motion-live [data-reveal="stats"]::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  transform: scaleX(0);
  transform-origin: left;
}

.motion-live [data-reveal="stats"].is-in::before {
  animation: m-line 1.2s var(--ease-out) both var(--d, 0s);
}

.motion-live [data-reveal="stats"] > div {
  opacity: 0;
}

.motion-live [data-reveal="stats"].is-in > div {
  animation: m-rise 0.9s var(--ease-out) both;
}

.motion-live [data-reveal="stats"] strong {
  font-variant-numeric: tabular-nums;
}

/* Cases hero tags */
.motion-live [data-reveal="chips"].is-in {
  animation: none;
  opacity: 1;
}

.motion-live [data-reveal="chips"] > * {
  opacity: 0;
}

.motion-live [data-reveal="chips"].is-in > * {
  animation: m-chip 0.6s var(--ease-out) both;
}

.motion-live [data-reveal="stats"].is-in > :nth-child(1),
.motion-live [data-reveal="chips"].is-in > :nth-child(1) { animation-delay: calc(var(--d, 0s) + 0.1s); }
.motion-live [data-reveal="stats"].is-in > :nth-child(2),
.motion-live [data-reveal="chips"].is-in > :nth-child(2) { animation-delay: calc(var(--d, 0s) + 0.2s); }
.motion-live [data-reveal="stats"].is-in > :nth-child(3),
.motion-live [data-reveal="chips"].is-in > :nth-child(3) { animation-delay: calc(var(--d, 0s) + 0.3s); }
.motion-live [data-reveal="stats"].is-in > :nth-child(4),
.motion-live [data-reveal="chips"].is-in > :nth-child(4) { animation-delay: calc(var(--d, 0s) + 0.4s); }
.motion-live [data-reveal="chips"].is-in > :nth-child(5) { animation-delay: calc(var(--d, 0s) + 0.5s); }
.motion-live [data-reveal="chips"].is-in > :nth-child(6) { animation-delay: calc(var(--d, 0s) + 0.6s); }

/* ---------- Service icons draw themselves ---------- */

.motion-live .service-card .draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.motion-live .service-card.is-in .draw {
  animation: m-draw 1.3s var(--ease-soft) both calc(var(--d, 0s) + 0.35s);
}

.motion-live .service-card .pop {
  transform-box: fill-box;
  transform-origin: center;
}

.motion-live .service-card.is-in .pop {
  animation: m-pop 0.55s var(--ease-back) both calc(var(--d, 0s) + 1.05s);
}

.motion-live .service-card.is-in .fade {
  animation: m-fade 1s ease both calc(var(--d, 0s) + 0.45s);
}

/* ---------- Process steps ---------- */

.motion-live [data-reveal="step"].is-in .step-number {
  animation: m-step 0.8s var(--ease-out) both calc(var(--d, 0s) + 0.2s);
}

.motion-live [data-reveal="step"]::after {
  transform-origin: left;
}

.motion-live [data-reveal="step"].is-in::after {
  animation: m-line 0.9s var(--ease-out) both calc(var(--d, 0s) + 0.55s);
}

/* ---------- Debug terminal types itself ---------- */

.motion-live [data-reveal="code"].is-in {
  animation-name: m-card;
  animation-duration: 1s;
}

.motion-live [data-reveal="code"]::after {
  opacity: 0;
}

.motion-live [data-reveal="code"].is-in::after {
  animation: m-frame 0.9s var(--ease-out) both calc(var(--d, 0s) + 0.25s);
}

.motion-live [data-reveal="code"] .code-lines p {
  width: fit-content;
  clip-path: inset(0 100% 0 0);
}

.motion-live [data-reveal="code"].is-in .code-lines p {
  animation: m-type var(--dur, 0.5s) steps(var(--steps, 20), end) both calc(var(--d, 0s) + var(--ld, 0s));
}

.motion-live [data-reveal="code"].is-in .code-lines p.success {
  animation:
    m-type var(--dur, 0.5s) steps(var(--steps, 20), end) both calc(var(--d, 0s) + var(--ld, 0s)),
    m-glow 1.6s ease both calc(var(--d, 0s) + var(--ld, 0s) + var(--dur, 0.5s));
}

.motion-live [data-reveal="code"] .code-lines p:last-child::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 6px;
  vertical-align: -0.18em;
  background: currentColor;
  animation: m-blink 1s steps(1) infinite;
}

/* ---------- About logo box ---------- */

.motion-live [data-reveal="logo"].is-in {
  animation: none;
  opacity: 1;
}

.motion-live [data-reveal="logo"] > div,
.motion-live [data-reveal="logo"] .logo-box-line {
  opacity: 0;
}

.motion-live [data-reveal="logo"].is-in > div {
  animation: m-card 1.1s var(--ease-out) both var(--d, 0s);
}

.motion-live [data-reveal="logo"].is-in .logo-box-line.one {
  animation: m-offset-1 0.9s var(--ease-out) both calc(var(--d, 0s) + 0.45s);
}

.motion-live [data-reveal="logo"].is-in .logo-box-line.two {
  animation: m-offset-2 1s var(--ease-out) both calc(var(--d, 0s) + 0.6s);
}

.motion-live [data-reveal="logo"].is-in img {
  animation: m-float 6s ease-in-out infinite calc(var(--d, 0s) + 1.4s);
}
