/* ==========================================================================
   MOTION LAYER
   Additive animation on top of main.css. The page background (aurora,
   landmarks, noise, hero cosmos) is intentionally NOT touched here.
   Starting states hang off .motion-ready, which motion.js adds only once it
   has run; reduced-motion users never receive it.
   ========================================================================== */

/* Static look of the speaking wave; it only moves under .motion-ready. */
.wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 12px;
  margin-inline-start: 0.6rem;
  vertical-align: middle;
}

.wave i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transform: scaleY(0.5);
}

@media (prefers-reduced-motion: no-preference) {
  /* --- Hero title: words rise in one by one ----------------------------- */
  .motion-ready .hero__title .w {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.55em) rotate(2deg);
    filter: blur(6px);
  }

  .motion-ready .hero__title.is-visible .w {
    animation: lbm-word-in 700ms var(--ease-out) both;
    animation-delay: calc(var(--i) * 80ms);
  }

  @keyframes lbm-word-in {
    from { opacity: 0; transform: translateY(0.55em) rotate(2deg); filter: blur(6px); }
    to { opacity: 1; transform: none; filter: blur(0); }
  }

  /* Slow light sweep across the existing accent gradient. */
  .motion-ready .hero__title em {
    background-size: 200% 100%;
    animation: lbm-shimmer 7s ease-in-out infinite alternate;
  }

  @keyframes lbm-shimmer {
    from { background-position: 0% 50%; }
    to { background-position: 100% 50%; }
  }

  /* --- Scroll reveal variants. The .is-visible overrides are needed because
         .js .reveal.is-visible in main.css ties these on specificity. ------ */
  .motion-ready .reveal[data-motion="zoom"] { transform: translateY(14px) scale(0.94); }
  .motion-ready .reveal[data-motion="left"] { transform: translateX(-36px); }
  .motion-ready .reveal[data-motion="right"] { transform: translateX(36px); }

  .motion-ready .reveal[data-motion="zoom"].is-visible { transform: none; }
  .motion-ready .reveal[data-motion="left"].is-visible { transform: none; }
  .motion-ready .reveal[data-motion="right"].is-visible { transform: none; }

  /* --- Floating chips (translate, so existing transforms still apply) --- */
  .motion-ready .hero__float {
    animation: lbm-bob 6s ease-in-out infinite alternate;
  }

  .motion-ready .hero__float:nth-child(2) { animation-delay: -2s; }
  .motion-ready .hero__float-row:last-child .hero__float { animation-delay: -4s; }

  @keyframes lbm-bob {
    from { translate: 0 0; }
    to { translate: 0 -5px; }
  }

  /* --- Live indicator dots ---------------------------------------------- */
  .motion-ready .chip__dot {
    position: relative;
  }

  .motion-ready .chip__dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1.5px solid var(--accent);
    border-radius: 50%;
    animation: lbm-ping 2.4s ease-out infinite;
  }

  @keyframes lbm-ping {
    from { opacity: 0.7; transform: scale(1); }
    to { opacity: 0; transform: scale(3.2); }
  }

  /* --- Live speaking wave ------------------------------------------------ */
  .motion-ready .wave i {
    animation: lbm-wave 1.1s ease-in-out infinite alternate;
  }

  .motion-ready .wave i:nth-child(2) { animation-delay: -0.25s; }
  .motion-ready .wave i:nth-child(3) { animation-delay: -0.5s; }
  .motion-ready .wave i:nth-child(4) { animation-delay: -0.75s; }
  .motion-ready .wave i:nth-child(5) { animation-delay: -0.1s; }

  @keyframes lbm-wave {
    from { transform: scaleY(0.35); }
    to { transform: scaleY(1); }
  }

  /* --- Pointer effects: mouse devices only, so touch never gets stuck
         hover states. Vars are written by motion.js initPointerFx. ------- */
  @media (hover: hover) and (pointer: fine) {
    /* Spotlight following the cursor across hoverable cards. */
    .motion-ready .card--hover::after {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      opacity: 0;
      background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), var(--accent-glow), transparent 65%);
      transition: opacity var(--t-mid) ease;
    }

    .motion-ready .card--hover:hover::after {
      opacity: 1;
    }

    /* Gentle 3D tilt on the hero lesson card (max 6deg, set by tiltFor). */
    .motion-ready .hero__visual .lesson-card {
      transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
      transition: transform 180ms var(--ease-out), border-color var(--t-mid) ease,
        box-shadow var(--t-mid) var(--ease-out);
    }

    /* Magnetic primary CTA (translate, so the existing hover lift composes)
       plus a one-shot light sweep. */
    .motion-ready .btn--primary.btn--lg {
      position: relative;
      overflow: hidden;
      translate: var(--tx, 0px) var(--ty, 0px);
      transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-mid) var(--ease-out),
        background-color var(--t-mid) ease, color var(--t-mid) ease, border-color var(--t-mid) ease,
        translate 160ms var(--ease-out);
    }

    .motion-ready .btn--primary.btn--lg::after {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
      transform: translateX(-120%);
    }

    .motion-ready .btn--primary.btn--lg:hover::after {
      animation: lbm-sweep 700ms var(--ease-out);
    }

    @keyframes lbm-sweep {
      from { transform: translateX(-120%); }
      to { transform: translateX(120%); }
    }
  }
}
