/* ==========================================================================
   Flash Sale carousel — medium cards, smooth staggered slide (home page only).
   Loaded after buyer-theme / buyer-motion; overrides their flash track rules.
   Cards are positioned by --fs-rel (0 = centre) set in /js/pages/home.js.
   ========================================================================== */
#flashList.flash-stage {
  --fs-w: 222px;               /* 5 cards visible comfortably on desktop */
  --fs-gap: 18px;
  --fs-step: calc(var(--fs-w) + var(--fs-gap));
  overflow: hidden; padding: 1rem 0 1.4rem; margin: -.4rem 0 -.6rem;
}
.flash-track.fs-ring {
  position: relative; display: block; perspective: 1200px;
  height: var(--fs-h, 470px);
}
/* every slot sits in the middle and is moved sideways by its position */
.fs-ring .flash-slot {
  position: absolute; top: 0; left: 50%; width: var(--fs-w); margin-left: calc(var(--fs-w) / -2);
  flex: none; display: block;
  translate: none;
  transform: translateX(calc((var(--fs-rel, 0) + var(--fs-shift, 0)) * var(--fs-step))) scale(var(--fs-scale, .93));
  opacity: var(--fs-op, .82);
  transition: transform .6s cubic-bezier(.22, 1, .36, 1), opacity .45s ease;
  transition-delay: var(--fs-delay, 0ms);
  will-change: transform, opacity;
}
.fs-ring .flash-slot[data-pos="center"] { --fs-scale: 1.04; --fs-op: 1; z-index: 4; }
.fs-ring .flash-slot[data-pos="side"]   { --fs-scale: .94;  --fs-op: .9; z-index: 3; cursor: pointer; }
.fs-ring .flash-slot[data-pos="side"]:hover { --fs-op: 1; }
.fs-ring .flash-slot[data-pos="far"]    { --fs-scale: .85;  --fs-op: .68; z-index: 2; cursor: pointer; }
.fs-ring .flash-slot[data-pos="far"]:hover { --fs-op: .95; }
.fs-ring .flash-slot[data-pos="off"]    { --fs-scale: .78;  --fs-op: 0; z-index: 1; pointer-events: none; }
.fs-ring .flash-slot.fs-jump { transition: none !important; }
/* override the older one-shot slide classes */
.fs-ring .flash-slot.fs-in, .fs-ring .flash-slot.fs-out { animation: none; translate: none; }

/* medium card */
.flash .fs-ring .product-card { padding: 9px; border-radius: 22px; }
.flash .fs-ring .product-card .pc-media { aspect-ratio: 1 / 1; padding: 8px 10px 6px; border-radius: 17px; }
.flash .fs-ring .product-card .pc-media::before { inset: 6px 12px 6px; }
.flash .fs-ring .pc-body { padding: .7rem .4rem .2rem; }
.flash .fs-ring .pc-title { font-size: .88rem; }
.flash .fs-ring .pc-price .price { font-size: 1rem; }
.flash .fs-ring .pc-meta { font-size: .74rem; }
.flash .fs-ring .stock-text { font-size: .7rem; }

/* turntable: the product image swings in when its card arrives at the centre */
.fs-ring .flash-slot.fs-turn .pc-media img { animation: fsTurn .62s cubic-bezier(.22, 1, .36, 1) var(--fs-delay, 0ms) backwards; }
@keyframes fsTurn {
  0%   { transform: perspective(800px) rotateY(calc(var(--fs-dir, 1) * -32deg)) scale(.88); opacity: .7; }
  60%  { transform: perspective(800px) rotateY(calc(var(--fs-dir, 1) * 6deg)) scale(1.03); opacity: 1; }
  100% { transform: none; }
}
/* the badge and price settle in after the swing */
.fs-ring .flash-slot.fs-turn :is(.pc-badges, .pc-price) { animation: fsSettle .4s cubic-bezier(.22, 1, .36, 1) calc(var(--fs-delay, 0ms) + 160ms) backwards; }
@keyframes fsSettle { from { opacity: 0; transform: translateY(6px); } }

/* first reveal: cards rise one by one (once) */
.js-bm .flash:not(.is-revealed) .fs-ring .flash-slot { opacity: 0; }
.js-bm .flash.is-revealed .fs-ring .flash-slot.fs-reveal { animation: fsRise .55s cubic-bezier(.22, 1, .36, 1) calc(var(--fs-i, 0) * 70ms) backwards; }
@keyframes fsRise { from { opacity: 0; translate: 0 22px; } }

/* sizes */
@media (max-width: 1199.98px) {
  .fs-ring .flash-slot[data-pos="far"] { --fs-op: 0; pointer-events: none; }
}
@media (max-width: 991.98px) {
  #flashList.flash-stage { --fs-w: 224px; --fs-gap: 16px; }
}
@media (max-width: 575.98px) {
  #flashList.flash-stage { --fs-w: min(58vw, 212px); --fs-gap: 12px; padding: .75rem 0 1.15rem; }
  .fs-ring .flash-slot[data-pos="side"] { display: block; --fs-op: .68; --fs-scale: .86; }
  .fs-ring .flash-slot[data-pos="far"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fs-ring .flash-slot { transition: opacity .2s ease; transition-delay: 0ms; }
  .fs-ring .flash-slot.fs-turn .pc-media img, .fs-ring .flash-slot.fs-turn :is(.pc-badges, .pc-price) { animation: none; }
}

/* idle motion: the product images bob gently on their own, each card out of step */
.fs-ring .flash-slot .pc-media { animation: fsBob 4.6s ease-in-out infinite; animation-delay: calc(var(--fs-i, 0) * -1.3s); }
@keyframes fsBob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
.fs-ring .flash-slot[data-pos="center"] .pc-media::before { animation: fsArch 3.2s ease-in-out infinite; }
@keyframes fsArch { 0%, 100% { opacity: 1; scale: 1; } 50% { opacity: .75; scale: 1.03; } }
.fs-ring .flash-slot:hover .pc-media { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .fs-ring .flash-slot .pc-media, .fs-ring .flash-slot .pc-media::before { animation: none; } }
