/* Motion: on-load entrances (CSS only) and scroll reveals (js/reveal.js).

   Everything here is scoped to html.kc-anim, which partials/motion-boot adds only when
   the browser supports IntersectionObserver and the visitor hasn't asked for reduced
   motion. Without JS, with "reduce motion", or if reveal.js fails to load, content is
   simply shown as normal.

   Markup:
     data-reveal                     fade up when scrolled into view
     data-reveal="left|right|zoom"   slide in from the left/right, or grow in
     data-reveal-stagger             on a container: its children reveal one after another

   Animations use fill-mode "backwards" (start frame only), so once an element has
   arrived its normal styles — e.g. card hover lifts — work untouched. */

@keyframes kc-rise      { from { opacity: 0; transform: translateY(26px); } }
@keyframes kc-from-left { from { opacity: 0; transform: translateX(-44px); } }
@keyframes kc-from-right{ from { opacity: 0; transform: translateX(44px); } }
@keyframes kc-zoom      { from { opacity: 0; transform: scale(.92); } }
@keyframes kc-pop       { from { opacity: 0; transform: scale(.7) rotate(-4deg); } 70% { transform: scale(1.04); } }
@keyframes kc-float     { 50% { transform: translateY(-10px); } }
@keyframes kc-bump      { 30% { transform: scale(1.45); } 60% { transform: scale(.9); } }
@keyframes kc-wave      { from { background-position-x: 0; } to { background-position-x: 112px; } } /* 4 × the 28px scallop, so the loop is seamless */

/* ---------------------------------------------------------------- scroll reveal */
.kc-anim [data-reveal]:not(.is-in),
.kc-anim [data-reveal-stagger] > :not(.is-in) { opacity: 0; }

.kc-anim [data-reveal].is-in,
.kc-anim [data-reveal-stagger] > .is-in {
  animation: kc-rise .8s var(--kc-ease) backwards;
  animation-delay: calc(var(--kc-i, 0) * 90ms);  /* --kc-i: order within the batch that came into view together */
}
.kc-anim [data-reveal="left"].is-in  { animation-name: kc-from-left; }
.kc-anim [data-reveal="right"].is-in { animation-name: kc-from-right; }
.kc-anim [data-reveal="zoom"].is-in  { animation-name: kc-zoom; }

/* ---------------------------------------------------------------- home hero (on load) */
.kc-anim .kc-hero__text > * { animation: kc-rise .8s var(--kc-ease) backwards; }
.kc-anim .kc-hero__text > :nth-child(2) { animation-delay: .1s; }
.kc-anim .kc-hero__text > :nth-child(3) { animation-delay: .2s; }
.kc-anim .kc-hero__text > :nth-child(4) { animation-delay: .3s; }

/* the photo crate rises, each photo pops in, then the crate gently floats */
.kc-anim .kc-crate { animation: kc-zoom .9s var(--kc-ease) .1s backwards, kc-float 7s ease-in-out 1.6s infinite; }
.kc-anim .kc-crate img { animation: kc-pop .7s var(--kc-ease) backwards; }
.kc-anim .kc-crate img:nth-child(1) { animation-delay: .35s; }
.kc-anim .kc-crate img:nth-child(2) { animation-delay: .45s; }
.kc-anim .kc-crate img:nth-child(3) { animation-delay: .55s; }
.kc-anim .kc-crate img:nth-child(4) { animation-delay: .65s; }
.kc-anim .kc-crate img:nth-child(5) { animation-delay: .75s; }

/* the scalloped edge under the hero drifts slowly */
.kc-anim .kc-hero::after, .kc-anim .kc-pagehero::after { animation: kc-wave 14s linear infinite; }

/* ---------------------------------------------------------------- inner page banner (on load) */
.kc-anim .kc-pagehero .kc-wrap > * { animation: kc-rise .7s var(--kc-ease) backwards; }
.kc-anim .kc-pagehero .kc-wrap > :nth-child(2) { animation-delay: .08s; }
.kc-anim .kc-pagehero .kc-wrap > :nth-child(3) { animation-delay: .16s; }

/* ---------------------------------------------------------------- auth pages (on load) */
.kc-anim .kc-auth-card { animation: kc-rise .8s var(--kc-ease) backwards; }
.kc-anim .kc-auth-card__aside > * { animation: kc-from-left .8s var(--kc-ease) backwards; }
.kc-anim .kc-auth-card__aside > :nth-child(2) { animation-delay: .1s; }
.kc-anim .kc-auth-card__aside > :nth-child(3) { animation-delay: .2s; }
.kc-anim .kc-auth-card__points li { animation: kc-rise .6s var(--kc-ease) backwards; }
.kc-anim .kc-auth-card__points li:nth-child(1) { animation-delay: .3s; }
.kc-anim .kc-auth-card__points li:nth-child(2) { animation-delay: .4s; }
.kc-anim .kc-auth-card__points li:nth-child(3) { animation-delay: .5s; }
.kc-anim .kc-auth-card__points li:nth-child(4) { animation-delay: .6s; }

/* ---------------------------------------------------------------- small touches (motion allowed) */
/* sticky header gets a shadow once the page scrolls (class set by reveal.js) */
.kc-header { transition: box-shadow .3s; }
.kc-header.is-scrolled { box-shadow: 0 8px 24px rgba(18, 59, 35, .1); }

/* cart count bumps when it changes (class set by cart.js) */
.kc-anim .kc-badge-count.is-bump { animation: kc-bump .5s var(--kc-ease); }

/* primary buttons: soft shine sweep on hover */
.kc-anim .kc-btn--gold, .kc-anim .kc-btn--fill { position: relative; overflow: hidden; isolation: isolate; }
.kc-anim .kc-btn--gold::after, .kc-anim .kc-btn--fill::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .7s var(--kc-ease);
}
.kc-anim .kc-btn--gold:hover::after, .kc-anim .kc-btn--fill:hover::after { transform: translateX(120%); }
