/* Motion layer: scroll, hover and click animations. Loaded after app.css, driven by motion.js.
   Everything here is opt-out for people who ask their system for reduced motion. */
@media (prefers-reduced-motion: no-preference) {

  /* ---------------------------------------------------------- page-to-page transitions */
  @view-transition { navigation: auto; }
  .topnav { view-transition-name: topnav; }
  ::view-transition-old(root) { animation: mo-vt-out .22s ease both; }
  ::view-transition-new(root) { animation: mo-vt-in .42s var(--ease-out) both; }
  @keyframes mo-vt-out { to { opacity: 0; transform: translateY(-6px); } }
  @keyframes mo-vt-in { from { opacity: 0; transform: translateY(14px); } }

  /* ---------------------------------------------------------- scroll progress + nav */
  .mo-progress { position: fixed; left: 0; top: 0; width: 100%; height: 3px; z-index: 1400; pointer-events: none;
    transform: scaleX(0); transform-origin: 0 50%; will-change: transform;
    background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand-3)); box-shadow: 0 0 10px color-mix(in srgb, var(--brand) 60%, transparent); }
  .topnav { transition: box-shadow .35s, background-color .35s; }
  .topnav.is-scrolled { box-shadow: 0 12px 32px -20px rgba(2, 6, 23, .45); }
  .mainnav a::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px; border-radius: 2px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2)); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease-out); }
  .mainnav a.active::after { transform: scaleX(1); }
  @media (hover: hover) { .mainnav a:hover::after { transform: scaleX(1); } }

  /* ---------------------------------------------------------- scroll reveals (extra flavours) */
  @keyframes rv-pop { from { opacity: 0; transform: translateY(28px) scale(.93); } to { opacity: 1; transform: none; } }
  @keyframes rv-left { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: none; } }
  @keyframes rv-right { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: none; } }
  @keyframes rv-blur { from { opacity: 0; transform: translateY(16px); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
  @keyframes rv-zoom { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
  .feature.rv-in, .plan-card.rv-in, .exam-card.rv-in, .test-card.rv-in, .series-card.rv-in, .about-feature.rv-in, .contact-card.rv-in { animation-name: rv-pop; animation-duration: .7s; }
  .step.rv-in, .method.rv-in { animation-name: rv-pop; animation-duration: .75s; }
  .section-head.rv-in { animation-name: rv-blur; animation-duration: .8s; }
  .trust-inner.rv-in, .cta-band.rv-in, .about-stat-card.rv-in { animation-name: rv-zoom; animation-duration: .75s; }
  .faq details.rv-in:nth-child(odd) { animation-name: rv-left; }
  .faq details.rv-in:nth-child(even) { animation-name: rv-right; }
  .req-item.rv-in { animation-name: rv-left; animation-duration: .5s; }

  /* ---------------------------------------------------------- hero: parallax, glow, particles */
  .hero .hl { background-size: 220% 100%; animation: mo-hl 7s ease-in-out infinite alternate; }
  @keyframes mo-hl { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
  .hero.mo-live .hero-orb { translate: calc(var(--px, 0) * -36px) calc(var(--py, 0) * -26px + var(--sy, 0) * .16px); transition: translate .6s var(--ease-out); }
  .hero.mo-live .hero-visual .hero-shot { transform: rotateY(calc(-9deg + var(--px, 0) * 7deg)) rotateX(calc(4deg - var(--py, 0) * 6deg)); transition: transform .25s ease-out; }
  .hero.mo-live .float-card { translate: calc(var(--px, 0) * 18px) calc(var(--py, 0) * 14px); transition: translate .5s var(--ease-out); }
  .hero-dots { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
  .hero-dots i { position: absolute; bottom: -14px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%; opacity: 0;
    background: rgba(255, 255, 255, .55); box-shadow: 0 0 12px rgba(165, 180, 252, .8); animation: mo-dot var(--t) linear var(--d) infinite; }
  @keyframes mo-dot {
    0% { transform: translate3d(0, 0, 0) scale(.6); opacity: 0; }
    15% { opacity: .75; }
    100% { transform: translate3d(var(--dx), -560px, 0) scale(1.15); opacity: 0; }
  }

  /* ---------------------------------------------------------- click ripple */
  .res-tabs .btn-tab { position: relative; overflow: hidden; }
  .mo-ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .24;
    transform: translate(-50%, -50%) scale(0); animation: mo-ripple .7s var(--ease-out) forwards; }
  @keyframes mo-ripple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }
  .btn:active .ico-svg { transform: translateX(5px) scale(.92); }

  /* ---------------------------------------------------------- tilt + spotlight cards (mouse only) */
  @media (hover: hover) and (pointer: fine) {
    .mo-tilt.mo-hot { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-5px);
      transition: transform .14s linear, box-shadow .3s, border-color .3s;
      background-image: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--brand) 13%, transparent), transparent 60%); }
    .mo-tilt.mo-hot:active { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(.985); }
  }

  /* ---------------------------------------------------------- floating back-to-top */
  .mo-fab { position: fixed; left: 18px; bottom: 18px; z-index: 900; width: 46px; height: 46px; display: grid; place-items: center; padding: 0;
    border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--brand); cursor: pointer; box-shadow: var(--shadow-lift);
    opacity: 0; transform: translateY(18px) scale(.8); pointer-events: none; transition: opacity .3s, transform .45s var(--ease-spring), box-shadow .25s, background-color .2s; }
  .mo-fab.show { opacity: 1; transform: none; pointer-events: auto; }
  .mo-fab.show:hover { transform: translateY(-4px); background: var(--brand-soft); }
  .mo-fab.show:active { transform: scale(.9); }

  /* ---------------------------------------------------------- small touches */
  .faq details[open] > *:not(summary) { animation: rise-in .4s var(--ease-out) both; }
  .pill { transition: transform .2s var(--ease-spring), background-color .2s; }
  @media (hover: hover) { .pill:hover { transform: scale(1.06); } }
  .brand-mark { animation: mo-breathe 5s ease-in-out infinite; }
  @keyframes mo-breathe { 0%, 100% { box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, .3); } 50% { box-shadow: 0 0 22px color-mix(in srgb, var(--brand) 55%, transparent), inset 0 1px 0 rgba(255, 255, 255, .3); } }
  .feature-icon { transition: transform .5s var(--ease-spring); }
  .feature:hover .feature-icon { transform: translateY(-3px) rotate(-8deg) scale(1.1); }
  .tk-msg { animation: pop-in .35s var(--ease-out) both; }

  /* ---------------------------------------------------------- phones */
  @media (max-width: 680px) {
    /* keep clear of the full-width toasts at the bottom */
    .mo-fab { left: auto; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); width: 42px; height: 42px; }
    .mo-progress { height: 2px; }
    .hero-dots i:nth-child(n+9) { display: none; }
  }
}
