/* =====================================================
   Buzz Stack Cards — Reusable Deck Component
   =====================================================
   A stacked card deck that fans out on hover.
   Supports 2 – 6 cards. Cards stay within the
   container — nothing escapes to the viewport edges.

   Usage:
     <div class="buzz-stack-wrap">
       <div class="buzz-stack buzz-stack--2">
         <a class="buzz-stack-card" href="#">
           <img class="buzz-stack-card__img" src="..." alt="">
           <div class="buzz-stack-card__overlay">
             <div class="buzz-stack-card__tags">
               <span class="bsc-tag">Tag</span>
               <span class="bsc-tag bsc-tag--accent">Tag</span>
             </div>
             <div class="buzz-stack-card__body">
               <h3>Card Title</h3>
               <p>Short description text.</p>
               <span class="buzz-stack-card__cta">Go there →</span>
             </div>
           </div>
           <span class="buzz-stack-card__label">Label</span>
         </a>
         ...more .buzz-stack-card elements...
       </div>
     </div>

   Variants (add to .buzz-stack):
     .buzz-stack--2   2 cards  horizontal fan
     .buzz-stack--3   3 cards  horizontal fan
     .buzz-stack--4   4 cards  horizontal fan
     .buzz-stack--5   5 cards  horizontal fan (smaller)
     .buzz-stack--6   6 cards  horizontal fan (smaller)
     .buzz-stack--cascade  vertical peek/expand (any count)

   Override sizing via CSS custom properties on .buzz-stack:
     --bsc-card-w   card width   (default 240px)
     --bsc-card-h   card height  (default 360px)
     --bsc-gap      gap between fanned cards (default 16px)
   ===================================================== */

/* ---------- Custom Properties ---------- */
.buzz-stack {
  --bsc-card-w: 300px;
  --bsc-card-h: 360px;
  --bsc-gap:     30px;
  --bsc-radius:  1.25rem;
  --bsc-trans:   1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  --bsc-peek:    36px;   /* cascade: how much of lower card shows */
}

/* 5 & 6 card decks: use smaller defaults so they fit on screen */
.buzz-stack--5,
.buzz-stack--6 {
  --bsc-card-w: 180px;
  --bsc-card-h: 290px;
  --bsc-gap:    12px;
}

/* ---------- Overflow wrapper ---------- */
.buzz-stack-wrap {
  overflow: hidden;
  padding: 1.5rem 0.5rem;
  isolation: isolate;  /* contain z-index within this stacking context */
}

/* ---------- Deck container ----------
   Sized exactly to hold all fanned cards.
   Container width = N × card-w + (N-1) × gap
   This guarantees no horizontal overflow.       */
.buzz-stack {
  position: relative;
  height: var(--bsc-card-h);
  margin: 0 auto;
}

.buzz-stack--2 { width: calc(2 * var(--bsc-card-w) + 1 * var(--bsc-gap)); }
.buzz-stack--3 { width: calc(3 * var(--bsc-card-w) + 2 * var(--bsc-gap)); }
.buzz-stack--4 { width: calc(4 * var(--bsc-card-w) + 3 * var(--bsc-gap)); }
.buzz-stack--5 { width: calc(5 * var(--bsc-card-w) + 4 * var(--bsc-gap)); }
.buzz-stack--6 { width: calc(6 * var(--bsc-card-w) + 5 * var(--bsc-gap)); }

/* ---------- Card Base ---------- */
.buzz-stack-card {
  position: absolute;
  top: 0;
  width: var(--bsc-card-w);
  height: var(--bsc-card-h);
  border-radius: var(--bsc-radius);
  overflow: hidden;
  display: block;
  text-decoration: none;
  will-change: transform;
  transition: transform var(--bsc-trans), box-shadow var(--bsc-trans);
  cursor: pointer;
}

/* ---------- Natural (fanned) positions ----------
   Each card's left edge = i × (card-w + gap).
   On hover the deck returns to these positions.  */
.buzz-stack--2 .buzz-stack-card:nth-child(1) { left: 0; }
.buzz-stack--2 .buzz-stack-card:nth-child(2) { left: calc(var(--bsc-card-w) + var(--bsc-gap)); }

.buzz-stack--3 .buzz-stack-card:nth-child(1) { left: 0; }
.buzz-stack--3 .buzz-stack-card:nth-child(2) { left: calc(1 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--3 .buzz-stack-card:nth-child(3) { left: calc(2 * (var(--bsc-card-w) + var(--bsc-gap))); }

.buzz-stack--4 .buzz-stack-card:nth-child(1) { left: 0; }
.buzz-stack--4 .buzz-stack-card:nth-child(2) { left: calc(1 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--4 .buzz-stack-card:nth-child(3) { left: calc(2 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--4 .buzz-stack-card:nth-child(4) { left: calc(3 * (var(--bsc-card-w) + var(--bsc-gap))); }

.buzz-stack--5 .buzz-stack-card:nth-child(1) { left: 0; }
.buzz-stack--5 .buzz-stack-card:nth-child(2) { left: calc(1 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--5 .buzz-stack-card:nth-child(3) { left: calc(2 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--5 .buzz-stack-card:nth-child(4) { left: calc(3 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--5 .buzz-stack-card:nth-child(5) { left: calc(4 * (var(--bsc-card-w) + var(--bsc-gap))); }

.buzz-stack--6 .buzz-stack-card:nth-child(1) { left: 0; }
.buzz-stack--6 .buzz-stack-card:nth-child(2) { left: calc(1 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--6 .buzz-stack-card:nth-child(3) { left: calc(2 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--6 .buzz-stack-card:nth-child(4) { left: calc(3 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--6 .buzz-stack-card:nth-child(5) { left: calc(4 * (var(--bsc-card-w) + var(--bsc-gap))); }
.buzz-stack--6 .buzz-stack-card:nth-child(6) { left: calc(5 * (var(--bsc-card-w) + var(--bsc-gap))); }

/* ---------- Stacked State (default / deck not hovered) ----------
   Cards don't translate all the way to center — each stops short
   by a peek amount so its edge stays visible, like a Rummy hand.
   Back card peeks from left, front card peeks from right.         */

/* N = 2  — 18px peek each side */
.buzz-stack--2 .buzz-stack-card:nth-child(1) {
  transform: translateX(calc( 0.5 * (var(--bsc-card-w) + var(--bsc-gap)) - 18px))
             rotate(-5deg) scale(0.90) translateY(22px);
  z-index: 1; box-shadow: -6px 14px 36px rgba(0,0,0,0.20);
}
.buzz-stack--2 .buzz-stack-card:nth-child(2) {
  transform: translateX(calc(-0.5 * (var(--bsc-card-w) + var(--bsc-gap)) + 18px))
             rotate(3deg) scale(0.95) translateY(10px);
  z-index: 2; box-shadow:  6px 14px 40px rgba(0,0,0,0.22);
}

/* N = 3  — 22px peek per step */
.buzz-stack--3 .buzz-stack-card:nth-child(1) {
  transform: translateX(calc( 1 * (var(--bsc-card-w) + var(--bsc-gap)) - 52px))
             rotate(-5deg) scale(0.87) translateY(28px);
  z-index: 1; box-shadow: -6px 14px 34px rgba(0,0,0,0.18);
}
.buzz-stack--3 .buzz-stack-card:nth-child(2) {
  transform: translateX(0) rotate(2deg) scale(0.93) translateY(14px);
  z-index: 2; box-shadow:  0   14px 38px rgba(0,0,0,0.22);
}
.buzz-stack--3 .buzz-stack-card:nth-child(3) {
  transform: translateX(calc(-1 * (var(--bsc-card-w) + var(--bsc-gap)) + 52px))
             rotate(-1deg) scale(0.97) translateY(5px);
  z-index: 3; box-shadow:  6px 14px 42px rgba(0,0,0,0.24);
}

/* N = 4  — 16px peek per step */
.buzz-stack--4 .buzz-stack-card:nth-child(1) {
  transform: translateX(calc( 1.5 * (var(--bsc-card-w) + var(--bsc-gap)) - 24px))
             rotate(-5deg) scale(0.85) translateY(30px);
  z-index: 1; box-shadow: -6px 12px 32px rgba(0,0,0,0.18);
}
.buzz-stack--4 .buzz-stack-card:nth-child(2) {
  transform: translateX(calc( 0.5 * (var(--bsc-card-w) + var(--bsc-gap)) -  8px))
             rotate(-2deg) scale(0.91) translateY(18px);
  z-index: 2; box-shadow: -3px 12px 36px rgba(0,0,0,0.20);
}
.buzz-stack--4 .buzz-stack-card:nth-child(3) {
  transform: translateX(calc(-0.5 * (var(--bsc-card-w) + var(--bsc-gap)) +  8px))
             rotate(2deg) scale(0.96) translateY(8px);
  z-index: 3; box-shadow:  3px 12px 40px rgba(0,0,0,0.22);
}
.buzz-stack--4 .buzz-stack-card:nth-child(4) {
  transform: translateX(calc(-1.5 * (var(--bsc-card-w) + var(--bsc-gap)) + 24px))
             rotate(4deg) scale(0.99) translateY(2px);
  z-index: 4; box-shadow:  6px 12px 44px rgba(0,0,0,0.24);
}

/* N = 5  — 12px peek per step */
.buzz-stack--5 .buzz-stack-card:nth-child(1) {
  transform: translateX(calc( 2 * (var(--bsc-card-w) + var(--bsc-gap)) - 24px))
             rotate(-5deg) scale(0.83) translateY(28px);
  z-index: 1; box-shadow: -5px 10px 28px rgba(0,0,0,0.18);
}
.buzz-stack--5 .buzz-stack-card:nth-child(2) {
  transform: translateX(calc( 1 * (var(--bsc-card-w) + var(--bsc-gap)) - 12px))
             rotate(-2.5deg) scale(0.89) translateY(18px);
  z-index: 2; box-shadow: -3px 10px 32px rgba(0,0,0,0.20);
}
.buzz-stack--5 .buzz-stack-card:nth-child(3) {
  transform: translateX(0) rotate(0deg) scale(0.94) translateY(10px);
  z-index: 3; box-shadow:  0   10px 36px rgba(0,0,0,0.22);
}
.buzz-stack--5 .buzz-stack-card:nth-child(4) {
  transform: translateX(calc(-1 * (var(--bsc-card-w) + var(--bsc-gap)) + 12px))
             rotate(2.5deg) scale(0.97) translateY(4px);
  z-index: 4; box-shadow:  3px 10px 38px rgba(0,0,0,0.22);
}
.buzz-stack--5 .buzz-stack-card:nth-child(5) {
  transform: translateX(calc(-2 * (var(--bsc-card-w) + var(--bsc-gap)) + 24px))
             rotate(4deg) scale(0.99) translateY(1px);
  z-index: 5; box-shadow:  5px 10px 42px rgba(0,0,0,0.24);
}

/* N = 6  — 10px peek per step */
.buzz-stack--6 .buzz-stack-card:nth-child(1) {
  transform: translateX(calc( 2.5 * (var(--bsc-card-w) + var(--bsc-gap)) - 25px))
             rotate(-5deg) scale(0.82) translateY(28px);
  z-index: 1; box-shadow: -5px 10px 26px rgba(0,0,0,0.16);
}
.buzz-stack--6 .buzz-stack-card:nth-child(2) {
  transform: translateX(calc( 1.5 * (var(--bsc-card-w) + var(--bsc-gap)) - 15px))
             rotate(-3deg) scale(0.87) translateY(18px);
  z-index: 2; box-shadow: -3px 10px 30px rgba(0,0,0,0.18);
}
.buzz-stack--6 .buzz-stack-card:nth-child(3) {
  transform: translateX(calc( 0.5 * (var(--bsc-card-w) + var(--bsc-gap)) -  5px))
             rotate(-1deg) scale(0.92) translateY(10px);
  z-index: 3; box-shadow: -1px 10px 34px rgba(0,0,0,0.20);
}
.buzz-stack--6 .buzz-stack-card:nth-child(4) {
  transform: translateX(calc(-0.5 * (var(--bsc-card-w) + var(--bsc-gap)) +  5px))
             rotate(1deg) scale(0.95) translateY(5px);
  z-index: 4; box-shadow:  1px 10px 36px rgba(0,0,0,0.22);
}
.buzz-stack--6 .buzz-stack-card:nth-child(5) {
  transform: translateX(calc(-1.5 * (var(--bsc-card-w) + var(--bsc-gap)) + 15px))
             rotate(3deg) scale(0.97) translateY(2px);
  z-index: 5; box-shadow:  3px 10px 38px rgba(0,0,0,0.22);
}
.buzz-stack--6 .buzz-stack-card:nth-child(6) {
  transform: translateX(calc(-2.5 * (var(--bsc-card-w) + var(--bsc-gap)) + 25px))
             rotate(5deg) scale(0.99) translateY(0px);
  z-index: 6; box-shadow:  5px 10px 40px rgba(0,0,0,0.24);
}

/* ---------- Fanned State (container :hover) ----------
   Return each card to its natural left position.       */
.buzz-stack--2:hover .buzz-stack-card:nth-child(1),
.buzz-stack--3:hover .buzz-stack-card:nth-child(1),
.buzz-stack--4:hover .buzz-stack-card:nth-child(1),
.buzz-stack--5:hover .buzz-stack-card:nth-child(1),
.buzz-stack--6:hover .buzz-stack-card:nth-child(1) {
  transform: translateX(0) rotate(-3deg) scale(0.96);
  z-index: 2; box-shadow: -10px 20px 50px rgba(0,0,0,0.24);
}
.buzz-stack--2:hover .buzz-stack-card:nth-child(2),
.buzz-stack--3:hover .buzz-stack-card:nth-child(2),
.buzz-stack--4:hover .buzz-stack-card:nth-child(2),
.buzz-stack--5:hover .buzz-stack-card:nth-child(2),
.buzz-stack--6:hover .buzz-stack-card:nth-child(2) {
  transform: translateX(0) rotate(-1deg) scale(0.97);
  z-index: 2; box-shadow:  -4px 20px 52px rgba(0,0,0,0.24);
}
.buzz-stack--3:hover .buzz-stack-card:nth-child(3),
.buzz-stack--4:hover .buzz-stack-card:nth-child(3),
.buzz-stack--5:hover .buzz-stack-card:nth-child(3),
.buzz-stack--6:hover .buzz-stack-card:nth-child(3) {
  transform: translateX(0) rotate(0deg) scale(0.97);
  z-index: 2; box-shadow:   0   20px 52px rgba(0,0,0,0.24);
}
.buzz-stack--4:hover .buzz-stack-card:nth-child(4),
.buzz-stack--5:hover .buzz-stack-card:nth-child(4),
.buzz-stack--6:hover .buzz-stack-card:nth-child(4) {
  transform: translateX(0) rotate(1deg) scale(0.97);
  z-index: 2; box-shadow:   4px 20px 52px rgba(0,0,0,0.24);
}
.buzz-stack--5:hover .buzz-stack-card:nth-child(5),
.buzz-stack--6:hover .buzz-stack-card:nth-child(5) {
  transform: translateX(0) rotate(2deg) scale(0.96);
  z-index: 2; box-shadow:   8px 20px 50px rgba(0,0,0,0.24);
}
.buzz-stack--6:hover .buzz-stack-card:nth-child(6) {
  transform: translateX(0) rotate(3deg) scale(0.96);
  z-index: 2; box-shadow:  10px 20px 50px rgba(0,0,0,0.24);
}

/* ---------- Individual card :hover (while fanned) ---------- */
.buzz-stack:hover .buzz-stack-card:hover {
  transform: translateX(0) rotate(0deg) scale(1.05) !important;
  z-index: 10 !important;
  box-shadow: 0 28px 64px rgba(0,0,0,0.36) !important;
}

/* ---------- Card image ---------- */
.buzz-stack-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}
.buzz-stack-card:hover .buzz-stack-card__img {
  transform: scale(1.06);
}

/* ---------- Overlay gradient ---------- */
.buzz-stack-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.90) 0%,
    rgba(0,0,0,0.50) 42%,
    rgba(0,0,0,0.06) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.4rem 1.5rem;
  color: #fff;
}

/* ---------- Tags ---------- */
.buzz-stack-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.32s ease, transform 0.32s ease;
}
.bsc-tag {
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(255,255,255,0.17);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.26);
  color: #fff;
  white-space: nowrap;
}
.bsc-tag--accent {
  background: rgba(245,130,15,0.28);
  border-color: rgba(245,130,15,0.52);
}

/* ---------- Body text ---------- */
.buzz-stack-card__body {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.38s ease 0.06s, transform 0.38s ease 0.06s;
}
.buzz-stack-card__body h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 0.35rem;
  line-height: 1.25;
}
.buzz-stack-card__body p {
  font-size: 0.82rem;
  line-height: 1.55;
  color: rgba(255,255,255,0.80);
  margin: 0 0 0.8rem;
}
.buzz-stack-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  border-bottom: 2px solid rgba(255,255,255,0.32);
  padding-bottom: 1px;
  transition: border-color 0.2s, gap 0.25s;
}
.buzz-stack-card:hover .buzz-stack-card__cta {
  border-color: #fff;
  gap: 0.55rem;
}

/* Reveal content on deck hover or direct card hover */
.buzz-stack:hover .buzz-stack-card__tags,
.buzz-stack:hover .buzz-stack-card__body,
.buzz-stack-card:hover .buzz-stack-card__tags,
.buzz-stack-card:hover .buzz-stack-card__body {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Corner label (hides when fanned) ---------- */
.buzz-stack-card__label {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  padding: 0.22rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.13);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.20);
  color: #fff;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.buzz-stack:hover .buzz-stack-card__label {
  opacity: 0;
}

/* ---------- "Hover to explore" hint ---------- */
.buzz-stack-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: #9ca3af;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1.75rem;
  animation: bscHintPulse 2.4s ease-in-out infinite;
}
@media (min-width: 768px) {
  .buzz-stack-hint { display: flex; }
}
@keyframes bscHintPulse {
  0%, 100% { opacity: 0.45; transform: translateY(0); }
  50%       { opacity: 1;    transform: translateY(-2px); }
}

/* ============================================
   Cascade Variant  (.buzz-stack--cascade)
   Vertical peek-and-expand — for 5-6 cards or
   any count where horizontal is too wide.
   ============================================ */
.buzz-stack--cascade {
  position: relative;
  height: auto;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
}
.buzz-stack--cascade .buzz-stack-card {
  position: relative;
  inset: auto;
  left: auto;
  width: 100%;
  height: 200px;
  margin-top: calc(-1 * (200px - var(--bsc-peek)));
  border-radius: var(--bsc-radius);
  transition: margin-top 0.45s ease, transform 0.45s ease,
              box-shadow 0.45s ease;
}
.buzz-stack--cascade .buzz-stack-card:first-child {
  margin-top: 0;
}
/* Z-order: first = top of visual stack */
.buzz-stack--cascade .buzz-stack-card:nth-child(1) { z-index: 6; }
.buzz-stack--cascade .buzz-stack-card:nth-child(2) { z-index: 5; }
.buzz-stack--cascade .buzz-stack-card:nth-child(3) { z-index: 4; }
.buzz-stack--cascade .buzz-stack-card:nth-child(4) { z-index: 3; }
.buzz-stack--cascade .buzz-stack-card:nth-child(5) { z-index: 2; }
.buzz-stack--cascade .buzz-stack-card:nth-child(6) { z-index: 1; }

/* Expand on hover */
.buzz-stack--cascade:hover .buzz-stack-card {
  margin-top: 0.75rem;
}
.buzz-stack--cascade:hover .buzz-stack-card:first-child {
  margin-top: 0;
}
/* Content always visible in cascade */
.buzz-stack--cascade .buzz-stack-card__tags,
.buzz-stack--cascade .buzz-stack-card__body {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* ============================================
   Mobile: flat vertical stack, no transforms
   ============================================ */
@media (max-width: 767px) {
  .buzz-stack--2,
  .buzz-stack--3,
  .buzz-stack--4,
  .buzz-stack--5,
  .buzz-stack--6 {
    height: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
  .buzz-stack--2 .buzz-stack-card,
  .buzz-stack--3 .buzz-stack-card,
  .buzz-stack--4 .buzz-stack-card,
  .buzz-stack--5 .buzz-stack-card,
  .buzz-stack--6 .buzz-stack-card {
    position: relative !important;
    inset: auto !important;
    left: auto !important;
    width: 100% !important;
    height: 280px !important;
    transform: none !important;
    box-shadow: 0 6px 28px rgba(0,0,0,0.16) !important;
  }
  .buzz-stack-card__tags,
  .buzz-stack-card__body {
    opacity: 1 !important;
    transform: translateY(0) !important;
  }
  .buzz-stack-card__label {
    display: none;
  }
}
