/* =========================================================
   NextShop.bg — Scroll-driven effects
   Mobile-first, GPU-accelerated, reduced-motion aware.
   Strategy: structural sticky by default; JS upgrades to pinned
   where supported; CSS scroll-timeline used where native.
   ========================================================= */

/* ============ 1. HERO SCROLL FADE + BG PARALLAX ============ */
/* JS sets these vars as a fallback; native timeline overrides when supported */
.hero-inner {
  opacity: var(--hero-o, 1);
  transform: translateY(var(--hero-y, 0px));
  will-change: opacity, transform;
}
.hero-bg {
  transform: translateY(var(--hero-bg-y, 0px));
  will-change: transform;
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .hero-inner {
      animation: ns-hero-fade linear both;
      animation-timeline: scroll(root);
      animation-range: 0 65vh;
    }
    .hero-bg {
      animation: ns-hero-bg linear both;
      animation-timeline: scroll(root);
      animation-range: 0 95vh;
    }
  }
}
@keyframes ns-hero-fade {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-52px); }
}
@keyframes ns-hero-bg {
  from { transform: translateY(0); }
  to   { transform: translateY(140px); }
}

/* ============ 2. STACKING CARDS ============ */
.stack-section { padding: 72px 24px 32px; max-width: 1080px; margin: 0 auto; }
.stack-section .section-head { margin-bottom: 32px; }
.stack { position: relative; display: flex; flex-direction: column; gap: 18px; }

.stack-card {
  position: sticky;
  top: calc(var(--nav-h) + 14px);
  z-index: 1;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r4);
  padding: 34px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 30px;
  align-items: center;
  box-shadow: var(--shadow-lg);
  opacity: var(--o, 1);
  transform: scale(var(--s, 1));
  filter: brightness(var(--b, 1));
  transition: opacity .35s ease, transform .35s ease, filter .35s ease;
  overflow: hidden;
}
.stack-card:nth-child(2) { z-index: 2; }
.stack-card:nth-child(3) { z-index: 3; }
.stack-card:nth-child(4) { z-index: 4; }
.stack-card:nth-child(5) { z-index: 5; }

.stack-card.dark { background: linear-gradient(135deg, var(--ink2), var(--ink3)); color: #fff; border-color: transparent; }
.stack-card.dark .stack-text p { color: rgba(255,255,255,.7); }
.stack-card.dark .stack-num { background: rgba(167,139,250,.18); color: var(--violet-glow); }

.stack-num {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; color: var(--violet-mid);
  letter-spacing: 1.5px; text-transform: uppercase;
  background: var(--violet-pale); padding: 5px 12px; border-radius: 100px; margin-bottom: 14px;
}
.stack-text h3 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; letter-spacing: -.02em; line-height: 1.12; margin-bottom: 10px; }
.stack-text p { font-size: 15px; color: var(--muted); line-height: 1.65; }
.stack-text .stack-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.stack-tag { font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 100px; background: var(--soft); color: var(--muted); border: 1px solid var(--border); }
.stack-card.dark .stack-tag { background: rgba(255,255,255,.07); color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.1); }

.stack-visual {
  background: var(--off); border: 1px solid var(--border); border-radius: var(--r3);
  padding: 22px; min-height: 200px; display: flex; flex-direction: column; justify-content: center; gap: 10px;
  position: relative; overflow: hidden;
}
.stack-card.dark .stack-visual { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); }

/* tiny visuals inside cards */
.sv-row { display: flex; align-items: center; gap: 10px; }
.sv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--violet-light); flex-shrink: 0; }
.sv-bar { height: 8px; border-radius: 100px; background: var(--soft); overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet-light), var(--pink)); border-radius: inherit; }
.sv-line { height: 10px; border-radius: 6px; background: var(--soft); }
.sv-line.w70 { width: 70%; } .sv-line.w50 { width: 50%; } .sv-line.w90 { width: 90%; }
.sv-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 8px; background: var(--white); border: 1px solid var(--border); color: var(--ink); }
.sv-chip i { color: var(--violet-mid); }
.sv-gauge { display: flex; align-items: flex-end; gap: 8px; height: 90px; }
.sv-gauge span { flex: 1; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--violet-light), var(--violet-mid)); }

/* ============ 3. HORIZONTAL PINNED SHOWCASE ============ */
/* Default = native swipeable gallery (works without JS, reduced-motion safe) */
.h-section {
  position: relative;
  background: var(--off);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.h-sticky {
  position: relative;
  display: flex; flex-direction: column;
  padding: 64px 0;
}
.h-head { text-align: center; padding: 0 24px; margin-bottom: 28px; }
.h-head h2 { font-size: clamp(26px, 3.4vw, 40px); }
.h-head p { color: var(--muted); font-size: 15px; margin-top: 6px; }
.h-viewport {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.h-viewport::-webkit-scrollbar { display: none; }
.h-track {
  display: flex; gap: 22px; padding: 8px 8vw 24px;
  will-change: transform;
}
.h-panel {
  flex: 0 0 auto;
  width: min(520px, 82vw);
  scroll-snap-align: center;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r3); padding: 26px;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .3s, box-shadow .3s;
}
.h-panel:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.h-panel-num { font-size: 12px; font-weight: 700; color: var(--violet-mid); letter-spacing: 1px; text-transform: uppercase; }
.h-panel h3 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.h-panel p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.h-panel-visual {
  height: 170px; border-radius: 12px; background: var(--soft);
  border: 1px solid var(--border); padding: 16px;
  display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden;
}
.h-progress { display: none; }

/* JS upgrade → pinned horizontal scroll */
.h-section.js-active .h-sticky {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  justify-content: center;
  padding: 24px 0;
}
.h-section.js-active .h-viewport { overflow: hidden; }
.h-section.js-active .h-track { padding: 8px 6vw 24px; }
.h-section.js-active .h-panel:hover { transform: none; }
.h-section.js-active .h-progress {
  display: block; margin: 20px auto 0; width: 180px; height: 5px;
  background: var(--border); border-radius: 100px; overflow: hidden;
}
.h-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--violet-light), var(--pink));
  transition: width .12s linear;
}

/* ============ 4. STEP PROGRESS LINE (override) ============ */
.step-line {
  background: var(--border);
  opacity: 1;
  animation: none;
  overflow: hidden;
}
.step-line-fill {
  position: absolute; top: 0; left: 0; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--violet-light), var(--pink));
  box-shadow: 0 0 12px rgba(124,58,237,.6);
  transition: width .12s linear;
}

/* ============ Responsive ============ */
@media (max-width: 860px) {
  .stack-card { grid-template-columns: 1fr; padding: 26px; gap: 20px; }
  .stack-visual { min-height: 160px; padding: 18px; }
  .stack-section { padding: 56px 18px 24px; }
}
@media (max-width: 560px) {
  .stack-card { padding: 22px; }
  .stack-text h3 { font-size: 21px; }
  .h-head h2 { font-size: 26px; }
  .h-panel { width: 86vw; padding: 22px; }
  .h-panel-visual { height: 150px; }
}
