/* Beetle Life motion layer. Loaded after app.css. Everything is gated behind
   .js-anim (set by motion.js) so the site is fully visible without JavaScript,
   and behind prefers-reduced-motion so nothing moves for people who opt out. */

:root {
  --ease-out: cubic-bezier(.22, .8, .24, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

@media (prefers-reduced-motion: no-preference) {

  /* ---------- Page entrance ---------- */
  .js-anim body { animation: bl-page .5s var(--ease-out) both; }
  @keyframes bl-page { from { opacity: 0; } to { opacity: 1; } }

  /* ---------- Scroll reveal ---------- */
  .js-anim [data-reveal] {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
    transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
    transition-delay: var(--d, 0ms);
    will-change: opacity, transform;
  }
  .js-anim [data-reveal="left"]  { transform: translate3d(-36px, 0, 0); }
  .js-anim [data-reveal="right"] { transform: translate3d(36px, 0, 0); }
  .js-anim [data-reveal="zoom"]  { transform: scale(.94); }
  [dir="rtl"].js-anim [data-reveal="left"],
  .js-anim [dir="rtl"] [data-reveal="left"]  { transform: translate3d(36px, 0, 0); }
  [dir="rtl"].js-anim [data-reveal="right"],
  .js-anim [dir="rtl"] [data-reveal="right"] { transform: translate3d(-36px, 0, 0); }
  .js-anim [data-reveal].is-in { opacity: 1; transform: none; will-change: auto; }

  /* ---------- Hero entrance ---------- */
  .js-anim .bl-hero > * { animation: bl-rise .8s var(--ease-out) both; }
  .js-anim .bl-hero > *:nth-child(1) { animation-delay: .10s; }
  .js-anim .bl-hero > *:nth-child(2) { animation-delay: .22s; }
  .js-anim .bl-hero > *:nth-child(3) { animation-delay: .34s; }
  .js-anim .bl-hero > *:nth-child(4) { animation-delay: .46s; }
  @keyframes bl-rise { from { opacity: 0; transform: translate3d(0, 30px, 0); } to { opacity: 1; transform: none; } }

  /* The Beetle drives in, then idles with a gentle bob */
  .js-anim .bl-drive { animation: bl-drive 1.3s var(--ease-out) .25s both; }
  [dir="rtl"].js-anim .bl-drive, .js-anim [dir="rtl"] .bl-drive { animation-name: bl-drive-rtl; }
  .js-anim .bl-drive img { animation: bl-bob 4.5s ease-in-out 1.6s infinite; }
  @keyframes bl-drive     { from { opacity: 0; transform: translate3d(-18%, 0, 0); } to { opacity: 1; transform: none; } }
  @keyframes bl-drive-rtl { from { opacity: 0; transform: translate3d(18%, 0, 0); }  to { opacity: 1; transform: none; } }
  @keyframes bl-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

  /* ---------- Header ---------- */
  header.bl-stuck { box-shadow: 0 6px 24px -12px rgba(21, 20, 19, .35); }
  header { transition: box-shadow .3s ease; }

  /* ---------- Buttons ---------- */
  .btn { transition: background-color .2s, color .2s, border-color .2s, transform .2s var(--ease-spring), box-shadow .2s; }
  .btn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -10px rgba(21, 20, 19, .5); }
  .btn:active { transform: translateY(0) scale(.97); box-shadow: none; }
  .btn-red:hover { box-shadow: 0 10px 22px -10px rgba(198, 4, 22, .7); }

  /* ---------- Cards and tiles ---------- */
  article.group > a:first-child { transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out); }
  article.group:hover > a:first-child { transform: translateY(-4px); box-shadow: 0 16px 28px -18px rgba(21, 20, 19, .45); }
  a.group.rounded-card { transition: background-color .25s, color .25s, translate .3s var(--ease-out), opacity .7s var(--ease-out) var(--d, 0ms), transform .7s var(--ease-out) var(--d, 0ms); }
  a.group.rounded-card:hover { translate: 0 -4px; }
  a.group.rounded-card svg { transition: transform .35s var(--ease-spring); }
  a.group.rounded-card:hover svg { transform: scale(1.18) rotate(-6deg); }

  /* Links: underline slides in */
  .link { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .3s var(--ease-out); padding-bottom: 2px; }
  .link:hover { background-size: 100% 1px; }
  [dir="rtl"] .link { background-position: 100% 100%; }

  /* Chevrons nudge on hover */
  a:hover > svg.flip-rtl, a:hover > .flip-rtl { transform: translateX(4px); }
  [dir="rtl"] a:hover > svg.flip-rtl { transform: scaleX(-1) translateX(4px); }
  svg.flip-rtl { transition: transform .25s var(--ease-out); }

  /* Form focus glow */
  .field { transition: border-color .2s, box-shadow .25s; }
  .field:focus { box-shadow: 0 0 0 4px rgba(21, 20, 19, .08); }

  /* ---------- Cart bump, toast, WhatsApp pulse ---------- */
  .bl-bump { animation: bl-bump .45s var(--ease-spring); }
  @keyframes bl-bump { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

  a[href*="wa.me"] { animation: bl-pulse 2.8s ease-out 2s infinite; }
  @keyframes bl-pulse { 0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .55), 0 10px 15px -3px rgba(0,0,0,.2); } 70%, 100% { box-shadow: 0 0 0 18px rgba(37, 211, 102, 0), 0 10px 15px -3px rgba(0,0,0,.2); } }

  /* ---------- Scroll progress bar ---------- */
  .bl-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; background: #C60416; transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }
  [dir="rtl"] .bl-progress { transform-origin: 100% 50%; }

  /* ---------- Marquee-free: images fade in when loaded ---------- */
  .js-anim img[loading="lazy"] { opacity: 0; transition: opacity .6s ease, transform .5s var(--ease-out); }
  .js-anim img[loading="lazy"].is-loaded { opacity: 1; }
}
