/* ==========================================================================
   The Flip Shop — motion layer
   Flowing waves, the arrival animation, scroll reveals and the horizontal
   product rails.

   Three rules this file keeps to:

   1. Content is readable at first paint. Every reveal animates FROM a visible
      state, so if the JS never runs, or the observer never fires, nothing is
      hidden. There is no opacity:0 that depends on JavaScript to undo.
   2. Only transform and opacity are animated — both composited, so the work
      stays off the main thread and layout is never invalidated.
   3. prefers-reduced-motion removes all of it, including the waves.
   ========================================================================== */

:root{
  /* The band carries the eye from the hero's cream down into the bone of the
     section beneath it. The back layer is the deepest, and the FRONT layer is
     exactly the next section's colour, so the two meet with no visible seam —
     that is what makes the transition read as seamless rather than as a
     decorative stripe. A blush cast on the middle layer supplies the warmth. */
  --fs-wave-1:#E7DAC2;
  --fs-wave-2:#F2E2D6;
  --fs-wave-3:#FBF9F6;
  --fs-wave-h:clamp(110px,13vw,200px);
}

/* ==========================================================================
   1. Waves
   A seamless band: each layer is a 200%-wide SVG holding the same wave twice,
   translated by -50% over its cycle, so the loop has no visible seam. Three
   layers at different speeds and opacities read as depth rather than as one
   sliding shape.
   ========================================================================== */

.fs-waves{
  position:absolute;left:0;right:0;bottom:-1px;height:var(--fs-wave-h);
  pointer-events:none;overflow:hidden;z-index:1;line-height:0;
}
.fs-waves--top{top:-1px;bottom:auto;transform:scaleY(-1);}

.fs-wave{
  position:absolute;left:0;bottom:0;width:200%;height:100%;
  will-change:transform;
}
.fs-wave svg{display:block;width:100%;height:100%;}

.fs-wave--1{animation:fs-drift 26s linear infinite;opacity:.78;}
.fs-wave--2{animation:fs-drift 19s linear infinite reverse;opacity:.92;}
.fs-wave--3{animation:fs-drift 33s linear infinite;opacity:1;}

@keyframes fs-drift{
  from{transform:translate3d(0,0,0);}
  to{transform:translate3d(-50%,0,0);}
}

/* A gentle vertical breathing on the middle layer, so the band is not a flat
   horizontal slide. Deliberately small — 6px. */
.fs-wave--2 svg{animation:fs-swell 9s ease-in-out infinite;}
@keyframes fs-swell{
  0%,100%{transform:translateY(0);}
  50%{transform:translateY(6px);}
}

/* The hero sits above its wave band. */
.fs-hero{position:relative;}
.fs-hero__inner{position:relative;z-index:2;}

/* Section that receives the wave needs room for it so nothing is covered. */
.fs-has-wave{position:relative;padding-bottom:calc(var(--fs-wave-h) + clamp(20px,3vw,44px));}

/* ==========================================================================
   2. Arrival
   One short, staged reveal on first paint. Elements start visible and are
   nudged — translateY only — so a failed script leaves a correct page.
   ========================================================================== */

/*
 * The arrival only ever hides content once JS has confirmed it will play it
 * back. Previously these rules used `animation: ... both` on a keyframe that
 * starts at opacity:0, which meant that if the animation never ran — a
 * throttled tab, a background iframe, a device that defers animations — the
 * hero headline stayed invisible permanently. Gating on .fs-arrive-ready
 * means no-JS and animation-never-runs both leave a correct, readable page.
 */
@media (prefers-reduced-motion:no-preference){
  .fs-arrive-ready .fs-arrive>*{
    animation:fs-rise 760ms cubic-bezier(.22,.61,.36,1) both;
  }
  .fs-arrive-ready .fs-arrive>*:nth-child(1){animation-delay:40ms;}
  .fs-arrive-ready .fs-arrive>*:nth-child(2){animation-delay:120ms;}
  .fs-arrive-ready .fs-arrive>*:nth-child(3){animation-delay:200ms;}
  .fs-arrive-ready .fs-arrive>*:nth-child(4){animation-delay:280ms;}
  .fs-arrive-ready .fs-arrive>*:nth-child(5){animation-delay:360ms;}

  @keyframes fs-rise{
    from{opacity:0;transform:translate3d(0,14px,0);}
    to{opacity:1;transform:none;}
  }

  .fs-arrive-ready .fs-frames .fs-frame{animation:fs-settle 900ms cubic-bezier(.22,.61,.36,1) both;}
  .fs-arrive-ready .fs-frames .fs-frame--1{animation-delay:150ms;}
  .fs-arrive-ready .fs-frames .fs-frame--2{animation-delay:260ms;}
  .fs-arrive-ready .fs-frames .fs-frame--3{animation-delay:370ms;}
  @keyframes fs-settle{
    from{opacity:0;transform:translate3d(0,22px,0) scale(.97);}
    to{opacity:1;transform:none;}
  }

  .fs-arrive-ready .fs-frames .fs-chip{animation:fs-pop 620ms cubic-bezier(.34,1.3,.64,1) both;animation-delay:620ms;}
  @keyframes fs-pop{
    from{opacity:0;transform:scale(.86);}
    to{opacity:1;transform:none;}
  }
}

/* ==========================================================================
   3. Scroll reveal
   Applied by IntersectionObserver. The base state is fully visible; the
   observer adds .is-in which plays the rise. Without JS nothing is hidden.
   ========================================================================== */

@media (prefers-reduced-motion:no-preference){
  .fs-reveal[data-fs-reveal="pending"]{opacity:0;transform:translate3d(0,20px,0);}
  .fs-reveal.is-in{
    opacity:1;transform:none;
    transition:opacity 700ms cubic-bezier(.22,.61,.36,1),transform 700ms cubic-bezier(.22,.61,.36,1);
  }
  /* Stagger children of a revealed grid. */
  .fs-reveal.is-in .fs-card{animation:fs-rise 620ms cubic-bezier(.22,.61,.36,1) both;}
  .fs-reveal.is-in .fs-card:nth-child(1){animation-delay:0ms;}
  .fs-grid>*:nth-child(2) .fs-card{animation-delay:60ms;}
  .fs-grid>*:nth-child(3) .fs-card{animation-delay:120ms;}
  .fs-grid>*:nth-child(4) .fs-card{animation-delay:180ms;}
}

/* ==========================================================================
   4. Horizontal product rails
   CSS scroll-snap. Touch momentum, trackpad gestures and keyboard scrolling
   are the browser's own, which is both lighter and more reliable than a
   transform carousel.
   ========================================================================== */

.fs-rail{position:relative;}
.fs-rail + .fs-rail{margin-top:clamp(44px,5.5vw,80px);}

.fs-rail__head{
  display:flex;align-items:flex-end;justify-content:space-between;gap:24px;
  flex-wrap:wrap;margin-bottom:clamp(20px,2.6vw,34px);
}
.fs-rail__head .fs-lede{margin-bottom:0;}
.fs-rail__controls{display:flex;align-items:center;gap:18px;}

.fs-rail__arrows{display:flex;gap:8px;}
.fs-rail__btn{
  width:44px;height:44px;border-radius:var(--fs-pill);
  border:1.5px solid var(--fs-line-2);background:var(--fs-bone);color:var(--fs-ink);
  display:grid;place-items:center;cursor:pointer;
  transition:background-color var(--fs-fast) var(--fs-ease),
             border-color var(--fs-fast) var(--fs-ease),
             color var(--fs-fast) var(--fs-ease),
             opacity var(--fs-fast) var(--fs-ease);
}
.fs-rail__btn:hover:not(:disabled){background:var(--fs-ink);border-color:var(--fs-ink);color:#fff;}
.fs-rail__btn:disabled{opacity:.34;cursor:default;}

.fs-rail__track{
  display:grid;grid-auto-flow:column;
  grid-auto-columns:minmax(210px,calc((100% - 3*clamp(16px,1.9vw,28px)) / 4));
  gap:clamp(16px,1.9vw,28px);
  overflow-x:auto;overscroll-behavior-x:contain;
  scroll-snap-type:x mandatory;
  /* No scroll-behavior:smooth here. It is unreliable on overflow containers
     in some engines (it silently does nothing), which makes the arrow buttons
     look broken. The arrows animate in JS instead; native touch and trackpad
     scrolling is the browser's own and unaffected. */
  padding:4px 0 18px;margin:0 -4px;
  scrollbar-width:thin;scrollbar-color:var(--fs-line-2) transparent;
}
.fs-rail__track:focus-visible{
  outline:2.5px solid var(--fs-coral);outline-offset:4px;border-radius:var(--fs-r-sm);
}
.fs-rail__item{scroll-snap-align:start;min-width:0;}

.fs-rail__track::-webkit-scrollbar{height:6px;}
.fs-rail__track::-webkit-scrollbar-track{background:transparent;}
.fs-rail__track::-webkit-scrollbar-thumb{background:var(--fs-line-2);border-radius:999px;}
.fs-rail__track::-webkit-scrollbar-thumb:hover{background:var(--fs-ink-25);}

/* Edge fade hints that there is more to the right, without hiding anything. */
.fs-rail__track{
  -webkit-mask-image:linear-gradient(to right,transparent 0,#000 14px,#000 calc(100% - 14px),transparent 100%);
  mask-image:linear-gradient(to right,transparent 0,#000 14px,#000 calc(100% - 14px),transparent 100%);
}

@media (max-width:1024px){
  .fs-rail__track{grid-auto-columns:minmax(200px,calc((100% - 2*18px) / 3));}
}
@media (max-width:760px){
  .fs-rail__track{
    grid-auto-columns:minmax(0,calc((100% - 16px) / 2));
    scroll-snap-type:x proximity;
  }
  .fs-rail__arrows{display:none;} /* swipe is the natural gesture here */
  .fs-rail__head{margin-bottom:18px;}
}
@media (max-width:420px){
  .fs-rail__track{grid-auto-columns:minmax(0,78%);}
}

/* ==========================================================================
   5. Hover polish
   ========================================================================== */

@media (prefers-reduced-motion:no-preference) and (hover:hover){
  .fs-rail__item .fs-card__mediawrap{
    transition:transform 420ms var(--fs-ease),box-shadow 420ms var(--fs-ease);
  }
  .fs-rail__item .fs-card:hover .fs-card__mediawrap{
    transform:translateY(-5px);box-shadow:var(--fs-shadow-m);
  }
}

/* ==========================================================================
   6. Reduced motion — the whole layer stands down
   ========================================================================== */

@media (prefers-reduced-motion:reduce){
  .fs-wave,
  .fs-wave--1,.fs-wave--2,.fs-wave--3,
  .fs-wave--2 svg{animation:none!important;}
  .fs-arrive>*,.fs-frames .fs-frame,.fs-frames .fs-chip{animation:none!important;opacity:1!important;transform:none!important;}
  .fs-reveal,.fs-reveal[data-fs-reveal="pending"]{opacity:1!important;transform:none!important;transition:none!important;}
}

/* ==========================================================================
   7. Hero product rotator
   A stack of real product cards that cross-fade in place. The composition
   stays still; only the product changes. Two offset shadows behind give the
   stack depth without needing extra images.
   ========================================================================== */

.fs-rotator{
  position:relative;z-index:2;
  width:min(100%,460px);margin-inline:auto;
  display:flex;flex-direction:column;align-items:center;gap:18px;
}

/* The two cards "behind" the stack. Pure CSS — no extra image requests. */
.fs-rotator__shadow{
  position:absolute;inset:0 0 58px 0;border-radius:var(--fs-r-lg);
  background:var(--fs-bone);border:1px solid var(--fs-line);pointer-events:none;
}
.fs-rotator__shadow--a{transform:rotate(3.2deg) translateY(6px);opacity:.75;}
.fs-rotator__shadow--b{transform:rotate(6.4deg) translateY(12px);opacity:.45;}

.fs-rotator__stage{
  position:relative;width:100%;aspect-ratio:1/1;
  transform:rotate(-1.2deg);
  border-radius:var(--fs-r-lg);
}

.fs-rotator__slide{
  position:absolute;inset:0;display:flex;flex-direction:column;
  background:var(--fs-bone);border:1px solid var(--fs-line);
  border-radius:var(--fs-r-lg);overflow:hidden;text-decoration:none;color:var(--fs-ink);
  box-shadow:var(--fs-shadow-m);
  opacity:0;visibility:hidden;
  transition:opacity 800ms var(--fs-ease), visibility 0s linear 800ms;
}
.fs-rotator__slide.is-active{
  opacity:1;visibility:visible;
  transition:opacity 800ms var(--fs-ease), visibility 0s;
  z-index:2;
}

.fs-rotator__media{display:block;flex:1;overflow:hidden;background:var(--fs-cream-2);}
.fs-rotator__media img{width:100%;height:100%;object-fit:cover;display:block;}

.fs-rotator__meta{
  display:flex;align-items:baseline;justify-content:space-between;gap:12px;
  padding:13px 17px;background:var(--fs-bone);border-top:1px solid var(--fs-line);
}
.fs-rotator__name{
  font-size:.86rem;font-weight:600;line-height:1.35;
  overflow:hidden;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;
}
.fs-rotator__price{
  font-size:.92rem;font-weight:700;white-space:nowrap;font-variant-numeric:tabular-nums;
}
.fs-rotator__price del{display:none;}            /* keep the chip to one figure */
.fs-rotator__price ins{text-decoration:none;color:var(--fs-coral-ink);}

.fs-rotator__dots{display:flex;gap:9px;align-items:center;}
.fs-rotator__dot{
  width:9px;height:9px;padding:0;border:0;border-radius:50%;cursor:pointer;
  background:var(--fs-line-2);
  transition:background-color var(--fs-fast) var(--fs-ease),transform var(--fs-fast) var(--fs-ease);
}
.fs-rotator__dot:hover{background:var(--fs-ink-45);}
.fs-rotator__dot.is-active{background:var(--fs-coral-dark);transform:scale(1.35);}
.fs-rotator__dot:focus-visible{outline:2.5px solid var(--fs-coral);outline-offset:3px;}

@media (max-width:900px){
  .fs-rotator{width:min(100%,380px);}
}
@media (max-width:560px){
  .fs-rotator{width:min(100%,300px);gap:14px;}
  .fs-rotator__shadow--b{display:none;}
}

/* Reduced motion: no cross-fade, no autoplay (the script checks too), and the
   stack sits square rather than tilted. */
@media (prefers-reduced-motion:reduce){
  .fs-rotator__slide{transition:none;}
  .fs-rotator__stage{transform:none;}
  .fs-rotator__shadow{display:none;}
}

/* Hero stage: holds the rotator and the two data chips.
   The chips sit clear of the card's name/price bar — overlapping it hid the
   product name, which is the one thing the rotator exists to show. */
.fs-hero__stage{
  position:relative;display:flex;align-items:center;justify-content:center;
  min-height:420px;padding:12px 0 8px;
}
.fs-hero__stage .fs-chip{z-index:4;}
.fs-hero__stage .fs-chip--tr{top:0;right:-4px;}
.fs-hero__stage .fs-chip--bl{bottom:-2px;left:-6px;}

@media (max-width:900px){
  .fs-hero__stage{min-height:380px;}
  .fs-hero__stage .fs-chip--tr{right:4px;}
  .fs-hero__stage .fs-chip--bl{left:4px;}
}
@media (max-width:560px){
  .fs-hero__stage{min-height:330px;}
  .fs-hero__stage .fs-chip{font-size:.68rem;padding:7px 12px;}
}
