/*
 * Motion, kept quiet on purpose:
 *   1. Hero intro: the device comes into focus, one ring of air, pills settle in; then a slow float and rising air.
 *   2. Depth: scroll pulls the camera back (--hero-p); the mouse tilts the scene, smoothed in motion.js (--mx/--my).
 *   3. Sections fade up once; cards follow one after another (--i). Banners lift on hover.
 *   4. The breeze: every few seconds a gust of air streaks across the page and the hero pills sway.
 * `transform` belongs to keyframes; scroll and pointer use `translate`/`scale`/`rotate`, so they never fight.
 * Nothing here runs for prefers-reduced-motion (base.css).
 */
:root {
  --ap-cine: cubic-bezier(.16, 1, .3, 1);
  --ap-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Static pieces ---------- */
.ap-hero__scene::before { /* soft halo behind the circular art */
  content: ''; position: absolute; z-index: -1; inset: 6%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, #5fd0ff33, #2aa8ff0f 62%, transparent 100%);
}
.ap-hero__image { position: relative; z-index: 0; }
.ap-hero__air { position: absolute; z-index: 1; inset: 0; pointer-events: none; clip-path: circle(43% at 50% 50%); }
.ap-hero__air span {
  position: absolute; top: 34%; left: var(--x); width: var(--size); height: var(--size); border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, #fff 0 35%, #c9f3ff99 60%, transparent 72%); box-shadow: 0 0 6px #bff1ff;
}
.ap-progress {
  position: absolute; inset-inline: 0; bottom: -1px; height: 2px; pointer-events: none;
  background: linear-gradient(270deg, var(--ap-brand), var(--ap-cyan));
  transform: scaleX(var(--progress, 0)); transform-origin: 100% 50%; /* RTL: fills from the right */
}
/* Breeze layer: above the content, under the top bar, never catches a tap. */
.ap-breeze { position: fixed; z-index: 15; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ap-breeze__streak { fill: none; stroke-linecap: round; opacity: 0; stroke-width: var(--w, 2px); }
.ap-breeze__streak--glow { stroke: #9fd8ff; stroke-opacity: .35; filter: blur(3px); }
.ap-breeze__streak--core { stroke: #4fb2ff; stroke-opacity: .75; }
/* A small two-tone leaf; motion.js flies it along a streak with offset-path. */
.ap-breeze__leaf {
  position: fixed; z-index: 15; top: 0; left: 0; width: 11px; height: 7px; pointer-events: none; opacity: 0;
  border-radius: 80% 0 80% 0; background: linear-gradient(135deg, var(--leaf-a, #b8f0d2), var(--leaf-b, #4fbf95));
  box-shadow: inset -1px -1px 0 #ffffff55; offset-rotate: auto;
}

@media (prefers-reduced-motion: no-preference) {
  /* ---------- 1. Hero intro ---------- */
  /* Hold the scene until the art has loaded (hero.js adds .is-ready; boot-guard.js after 10s). */
  @media (scripting: enabled) {
    .ap-hero:not(.is-ready) :is(.ap-hero__image, .ap-hero-label, .ap-hero__copy > *) { opacity: 0; }
  }
  .ap-hero.is-ready .ap-hero__image { animation: ap-focus 1300ms var(--ap-cine) both, ap-float 7s 1300ms ease-in-out infinite; }
  .ap-hero.is-ready .ap-hero__scene::before { animation: ap-halo 1500ms 100ms var(--ap-cine) both, ap-breathe 6s 1600ms ease-in-out infinite; }
  .ap-hero.is-ready .ap-hero__scene::after { /* one ring of air as the device comes into focus */
    content: ''; position: absolute; z-index: -1; inset: 8%; border-radius: 50%; pointer-events: none;
    border: 1.5px solid #5cc3ff; animation: ap-ring 1600ms 420ms var(--ap-cine) both;
  }
  .ap-hero.is-ready .ap-hero__air { animation: ap-fade 1200ms 1000ms ease-out both; }
  .ap-hero.is-ready .ap-hero__air span { animation: ap-mote var(--dur) var(--delay) linear infinite; }
  .ap-hero.is-ready .ap-hero-label { animation: ap-pill-in 900ms calc(var(--entry-delay) + 650ms) var(--ap-spring) both; }
  .ap-hero.is-ready .ap-hero-label::before { animation: ap-sheen 1000ms calc(var(--entry-delay) + 1400ms) both; }
  .ap-hero.is-ready .ap-hero-pill { animation: ap-wiggle 8s calc(var(--wiggle-delay) + 1s) ease-in-out infinite; }
  .ap-hero.is-ready .ap-hero-label:is(:hover, :focus-visible, :active) .ap-hero-pill { animation: none; }
  .ap-hero.is-ready .ap-hero__title { animation: ap-rise 900ms 750ms var(--ap-cine) both; }
  .ap-hero.is-ready .ap-hero__description { animation: ap-rise 900ms 880ms var(--ap-cine) both; }
  .ap-hero.is-ready .ap-search-entry { animation: ap-rise 900ms 1000ms var(--ap-cine) both; }

  .ap-hero.is-paused :is(.ap-hero__image, .ap-hero__air span, .ap-hero-pill, .ap-hero__scene::before),
  html.is-panel-open .ap-hero :is(.ap-hero__image, .ap-hero__air span, .ap-hero-pill, .ap-hero__scene::before) { animation-play-state: paused; }

  /* ---------- 2. Depth ---------- */
  html.ap-motion .ap-hero__scene {
    opacity: calc(1 - var(--hero-p, 0) * .85);
    transform: perspective(1100px) rotateX(calc(var(--my, 0) * -5deg)) rotateY(calc(var(--mx, 0) * 6deg));
    transform-style: preserve-3d;
  }
  html.ap-motion .ap-hero__image {
    translate: calc(var(--mx, 0) * -7px) calc(var(--hero-p, 0) * 64px + var(--my, 0) * -7px);
    scale: calc(1 - var(--hero-p, 0) * .12);
  }
  /* Pills sit "in front" of the art: they move further and the other way. */
  html.ap-motion .ap-hero-label { translate: calc(var(--mx, 0) * 12px) calc(var(--my, 0) * 10px + var(--hero-p, 0) * 22px); }
  html.ap-motion .ap-hero__copy { translate: 0 calc(var(--hero-p, 0) * 22px); }

  /* ---------- 3. Sections ---------- */
  html.ap-motion :is(.ap-section, .ap-banner-slot, .ap-banner-row).is-reveal:not(.is-inview) > * { opacity: 0; }
  html.ap-motion .ap-section.is-inview .ap-section__head { animation: ap-rise 700ms var(--ap-cine) both; }
  html.ap-motion .ap-section.is-inview .ap-section__body > :not(.ap-swiper, .ap-tile-grid, .ap-shelf) { animation: ap-rise 800ms 120ms var(--ap-cine) both; }
  html.ap-motion .ap-section.is-inview :is(.swiper-slide, .ap-tile-grid > li, .ap-tab) {
    animation: ap-card-in 800ms calc(100ms + var(--i, 0) * 70ms) var(--ap-cine) both;
  }
  /* backwards fill only: the clip-path must not stay on, or it would cut the banner's shadow. */
  html.ap-motion :is(.ap-banner-slot, .ap-banner-row).is-inview .ap-banner { animation: ap-banner-in 1000ms calc(var(--i, 0) * 120ms) var(--ap-cine) backwards; }
  html.ap-motion :is(.ap-banner-slot, .ap-banner-row).is-inview .ap-banner img { animation: ap-settle 1600ms calc(var(--i, 0) * 120ms) var(--ap-cine) both; }

  /* Pictures develop instead of popping in. */
  @media (hover: hover) and (pointer: fine) {
    .ap-banner__frame img { transition: scale 700ms var(--ap-cine); }
    .ap-banner:hover .ap-banner__frame img { scale: 1.04; }
  }
  html.ap-motion [data-media] > img { transition: opacity 600ms ease, filter 800ms var(--ap-cine), transform 500ms var(--ap-ease), scale 700ms var(--ap-cine); }
  html.ap-motion [data-media] > img:not(.is-loaded) { opacity: 0; filter: blur(8px); }

  /* ---------- 4. Breeze: the hero leans into the gust ---------- */
  html.is-gusting .ap-hero.is-ready .ap-hero-pill { animation: ap-gust 2600ms ease-in-out both; }
  .ap-hero__air { transition: translate 1400ms ease-in-out; }
  html.is-gusting .ap-hero__air { translate: -22px 0; }

  /* ---------- Panel ---------- */
  .ap-panel[open] { animation: ap-panel-in 480ms var(--ap-cine) both; }
  .ap-panel[open]::backdrop { animation: ap-fade 300ms ease-out both; }
  .ap-panel.is-closing { animation: ap-panel-out 220ms cubic-bezier(.4, 0, 1, 1) both; pointer-events: none; }
  .ap-panel.is-closing::backdrop { animation: ap-fade-out 220ms ease-in both; }
  .ap-panel__content > div > * { animation: ap-rise 600ms var(--ap-cine) both; }
  .ap-panel__content > div > :nth-child(2) { animation-delay: 60ms; }
  .ap-panel__content > div > :nth-child(n + 3) { animation-delay: 120ms; }
  .ap-panel .ap-grid > li { animation: ap-rise 650ms var(--ap-cine) both; }
  .ap-panel .ap-grid > li:nth-child(2) { animation-delay: 50ms; }
  .ap-panel .ap-grid > li:nth-child(3) { animation-delay: 100ms; }
  .ap-panel .ap-grid > li:nth-child(4) { animation-delay: 150ms; }
  .ap-panel .ap-grid > li:nth-child(n + 5) { animation-delay: 200ms; }
}
.ap-panel::backdrop { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

/* ---------- Keyframes ---------- */
@keyframes ap-focus {
  0% { opacity: 0; transform: scale(1.12) translateY(14px); filter: blur(14px) brightness(1.3) saturate(.6); }
  50% { opacity: 1; filter: blur(2px) brightness(1.08); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes ap-float { 0%, 100% { transform: none; } 50% { transform: translateY(-5px); } }
@keyframes ap-halo { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes ap-breathe { 0%, 100% { transform: none; opacity: 1; } 50% { transform: scale(1.05); opacity: .7; } }
@keyframes ap-ring { 0% { opacity: .55; transform: scale(.74); } 100% { opacity: 0; transform: scale(1.16); } }
@keyframes ap-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ap-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes ap-mote {
  0% { opacity: 0; transform: translate3d(0, 46px, 0) scale(.6); }
  18% { opacity: var(--peak, .7); }
  70% { opacity: calc(var(--peak, .7) * .6); }
  100% { opacity: 0; transform: translate3d(var(--drift, 0px), -150px, 0) scale(1.1); }
}
@keyframes ap-pill-in {
  0% { opacity: 0; transform: translateY(14px) scale(.7); filter: blur(4px); }
  60% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes ap-sheen {
  0% { opacity: 0; background-position: 150% 0; }
  20%, 80% { opacity: .8; }
  100% { opacity: 0; background-position: -50% 0; }
}
@keyframes ap-wiggle {
  0%, 12%, 100% { transform: none; }
  3% { transform: translateY(-1.5px) rotate(-.7deg); }
  6% { transform: translateY(-1px) rotate(.5deg); }
  9% { transform: rotate(-.2deg); }
}
@keyframes ap-gust {
  0%, 100% { transform: none; }
  20% { transform: translateX(-3px) rotate(-2deg); }
  40% { transform: translateX(-5px) rotate(-3deg) skewX(2deg); }
  60% { transform: translateX(-2px) rotate(1.4deg); }
  80% { transform: translateX(1px) rotate(-.6deg); }
}
@keyframes ap-rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
@keyframes ap-card-in { from { opacity: 0; transform: translate3d(-22px, 10px, 0) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ap-banner-in {
  from { opacity: 0; clip-path: inset(0 0 0 100% round var(--ap-radius-l)); transform: translateY(12px); }
  to { opacity: 1; clip-path: inset(0 0 0 0 round var(--ap-radius-l)); transform: none; }
}
@keyframes ap-settle { from { transform: scale(1.12); } to { transform: none; } }
@keyframes ap-panel-in { from { opacity: 0; transform: translate3d(0, 36px, 0); } to { opacity: 1; transform: none; } }
@keyframes ap-panel-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translate3d(0, 24px, 0); } }
