/* =====================================================================
   Kaaalshelf — Storefront v2: motion, polish & mobile-first layout
   Loaded after style.css + animations.css on every customer page.
   ===================================================================== */

/* ---------- Scroll progress bar ---------- */
.ks-scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 120;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--ks-accent), var(--ks-gold));
  box-shadow: 0 0 12px rgba(251, 191, 36, .6);
  pointer-events: none;
}

/* ---------- Promo marquee ---------- */
.ks-promo-bar { overflow: hidden; white-space: nowrap; padding: 7px 0; }
.ks-promo-track { display: inline-flex; gap: 80px; padding-left: 100%; animation: ksMarquee 26s linear infinite; }
.ks-promo-bar:hover .ks-promo-track { animation-play-state: paused; }
@keyframes ksMarquee { to { transform: translateX(-100%); } }
@media (min-width: 1100px) {
  .ks-promo-track { padding-left: 0; animation: none; justify-content: center; width: 100%; }
  .ks-promo-track span[aria-hidden] { display: none; }
}

/* ---------- Header shrink on scroll ---------- */
.ks-header { transition: background .3s ease, box-shadow .3s ease; }
.ks-header .ks-nav-inner { transition: min-height .3s ease; }
.ks-header.is-scrolled { background: rgba(15, 8, 11, .9); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.ks-header.is-scrolled .ks-nav-inner { min-height: 60px; }
.ks-header.is-scrolled .ks-logo-ring { width: 40px; height: 40px; }
.ks-nav-links a::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 4px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--ks-accent), var(--ks-gold));
  transform: scaleX(0); transition: transform .3s ease;
}
.ks-nav-links a:hover::after, .ks-nav-links a.active::after { transform: scaleX(1); }
.ks-cart-badge.ks-bump { animation: ksBump .6s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes ksBump { 0% { transform: scale(1); } 40% { transform: scale(1.55); } 100% { transform: scale(1); } }

/* Drawer links slide in one after another */
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a { animation: ksSlideIn .45s cubic-bezier(.22, 1, .36, 1) both; }
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a:nth-child(2) { animation-delay: .04s; }
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a:nth-child(3) { animation-delay: .08s; }
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a:nth-child(4) { animation-delay: .12s; }
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a:nth-child(5) { animation-delay: .16s; }
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a:nth-child(6) { animation-delay: .2s; }
.ks-mobile-drawer.is-open .ks-mobile-drawer-inner a:nth-child(7) { animation-delay: .24s; }
@keyframes ksSlideIn { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
.ks-drawer-call { background: linear-gradient(135deg, rgba(16,185,129,.22), rgba(16,185,129,.08)) !important; border-color: rgba(16,185,129,.45) !important; }

/* ---------- Hero ---------- */
.ks-hero-title .ks-word { display: inline-block; opacity: 0; transform: translateY(.55em) rotate(3deg); filter: blur(6px);
  animation: ksWordIn .8s cubic-bezier(.22, 1, .36, 1) forwards; animation-delay: calc(var(--w, 0) * 70ms + 120ms); }
@keyframes ksWordIn { to { opacity: 1; transform: none; filter: none; } }
.ks-gradient-text { background-size: 200% auto; animation: ksShimmerText 7s ease-in-out infinite alternate; }
.ks-hero-title .ks-word { background: inherit; -webkit-background-clip: text; background-clip: text; }
@keyframes ksShimmerText { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
.ks-hero-sub { animation: ksFadeUp .8s .45s ease both; }
.ks-hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; animation: ksFadeUp .8s .6s ease both; }
@keyframes ksFadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.ks-hero-stats > * { animation: ksFadeUp .7s ease both; }
.ks-hero-stats > *:nth-child(1) { animation-delay: .75s; }
.ks-hero-stats > *:nth-child(2) { animation-delay: .85s; }
.ks-hero-stats > *:nth-child(3) { animation-delay: .95s; }

/* Shine sweep on primary CTA */
.ks-btn-shine { position: relative; overflow: hidden; }
.ks-btn-shine::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent);
  transform: skewX(-20deg); animation: ksShine 3.6s ease-in-out 1.4s infinite;
}
@keyframes ksShine { 0% { left: -60%; } 30%, 100% { left: 130%; } }

/* Ripple on tap */
.ks-btn { position: relative; overflow: hidden; }
.ks-ripple { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255,255,255,.35); pointer-events: none; animation: ksRipple .6s ease-out forwards; }
@keyframes ksRipple { to { transform: scale(2.6); opacity: 0; } }

/* Fly-to-basket dot */
.ks-fly-dot { position: fixed; z-index: 130; width: 18px; height: 18px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--ks-gold), var(--ks-accent)); box-shadow: 0 0 16px var(--ks-gold);
  transition: transform .75s cubic-bezier(.5, -0.35, .4, 1), opacity .75s ease; }

/* Card glow follows the finger / cursor */
.ks-product-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(260px circle at var(--gx, 50%) var(--gy, 0%), rgba(251,191,36,.16), transparent 60%);
}
.ks-product-card:hover::before { opacity: 1; }
.ks-product-card:active { transform: scale(.985); }

/* Stagger reveal inside grids */
.ks-reveal { transition-delay: calc(var(--i, 0) * 70ms); }

/* ---------- How it works ---------- */
.ks-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; position: relative; }
.ks-steps::before {
  content: ''; position: absolute; top: 34px; left: 8%; right: 8%; height: 2px;
  background: linear-gradient(90deg, var(--ks-accent), var(--ks-gold));
  transform-origin: 0 50%; transform: scaleX(0); transition: transform 1.4s cubic-bezier(.22, 1, .36, 1) .2s;
}
.ks-steps.is-drawn::before { transform: scaleX(1); }
.ks-step {
  position: relative; padding: 18px; border-radius: 20px; text-align: center;
  background: var(--ks-glass); border: 1px solid var(--ks-border); backdrop-filter: blur(14px);
}
.ks-step-ico {
  display: grid; place-items: center; width: 54px; height: 54px; margin: -4px auto 10px; border-radius: 50%; font-size: 1.5rem;
  background: linear-gradient(135deg, var(--ks-accent), #9F1239); box-shadow: 0 0 0 6px rgba(225,29,72,.18), 0 10px 24px rgba(225,29,72,.35);
  position: relative; z-index: 1;
}
.ks-step.is-visible .ks-step-ico { animation: ksPop .7s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--i, 0) * 120ms + .2s); }
@keyframes ksPop { from { transform: scale(.3) rotate(-25deg); } to { transform: none; } }
.ks-step strong { display: block; font-family: 'Outfit', sans-serif; font-size: 1.02rem; }
.ks-step p { margin: 6px 0 0; color: var(--ks-muted); font-size: .86rem; }

/* ---------- Mobile bottom navigation ---------- */
.ks-bottom-nav { display: none; }
.ks-swipe-dots { display: none; }

/* ---------- Product sticky buy bar ---------- */
.ks-sticky-buy { display: none; }

/* =====================================================================
   PHONES & TABLETS
   ===================================================================== */
@media (max-width: 920px) {
  .ks-brand-sub { display: none; }
  .ks-header .ks-cart-pill { display: none; } /* basket lives in the bottom bar */

  .ks-bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 85;
    padding: 6px; border-radius: 22px;
    background: rgba(19, 10, 14, .9); backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid var(--ks-border); box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
    transition: transform .35s cubic-bezier(.22, 1, .36, 1);
  }
  .ks-bottom-nav.is-hidden { transform: translateY(140%); }
  .ks-bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; border-radius: 16px;
    font-size: .68rem; font-weight: 700; color: var(--ks-muted); transition: color .2s, background .2s, transform .2s;
  }
  .ks-bottom-nav a i { position: relative; font-style: normal; font-size: 1.25rem; line-height: 1; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
  .ks-bottom-nav a.active { color: var(--ks-text); background: rgba(255, 255, 255, .07); }
  .ks-bottom-nav a.active i { transform: translateY(-2px) scale(1.12); }
  .ks-bottom-nav a:active { transform: scale(.92); }
  .ks-bottom-nav-cta i {
    display: grid; place-items: center; width: 50px; height: 50px; margin-top: -26px; border-radius: 50%;
    background: linear-gradient(135deg, var(--ks-accent), #9F1239); box-shadow: 0 8px 22px rgba(225,29,72,.55), 0 0 0 4px rgba(19,10,14,.9);
    animation: ksCtaPulse 2.6s ease-in-out infinite;
  }
  .ks-bottom-nav-cta { color: var(--ks-gold-soft) !important; background: transparent !important; }
  @keyframes ksCtaPulse { 0%, 100% { box-shadow: 0 8px 22px rgba(225,29,72,.55), 0 0 0 4px rgba(19,10,14,.9); } 50% { box-shadow: 0 8px 30px rgba(225,29,72,.85), 0 0 0 4px rgba(19,10,14,.9); } }
  .ks-bn-badge { position: absolute; top: -8px; right: -12px; min-width: 18px; height: 18px; font-size: .62rem; padding: 0 5px; }

  body.ks-body { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .ks-toast-wrap { left: 14px; right: 14px; max-width: none; bottom: calc(96px + env(safe-area-inset-bottom)); }
  .ks-footer { margin-top: 40px; }

  .ks-steps { grid-template-columns: 1fr 1fr; }
  .ks-steps::before { display: none; }

  /* Sticky buy bar on product page */
  .ks-sticky-buy {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; left: 10px; right: 10px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 84;
    padding: 10px 10px 10px 16px; border-radius: 18px;
    background: rgba(31, 18, 24, .95); border: 1px solid var(--ks-gold); backdrop-filter: blur(18px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
    transform: translateY(160%); transition: transform .4s cubic-bezier(.22, 1, .36, 1);
  }
  .ks-sticky-buy.show { transform: none; }
  .ks-sticky-buy small { display: block; font-size: .7rem; color: var(--ks-muted); }
  .ks-sticky-buy strong { color: var(--ks-gold); font-size: 1.15rem; font-family: 'Outfit', sans-serif; }
  .ks-sticky-buy .ks-btn { padding: 12px 18px; white-space: nowrap; }
}

@media (max-width: 640px) {
  .ks-container { width: calc(100% - 28px); }
  .ks-promo-bar { font-size: .74rem; padding: 6px 0; }
  .ks-nav-inner { min-height: 60px; gap: 10px; }
  .ks-brand-name { font-size: 1.08rem; }

  /* Hero */
  .ks-hero-stage { padding: 26px 0 18px !important; }
  .ks-hero-title { font-size: clamp(2rem, 9.4vw, 2.6rem) !important; margin: 12px 0 12px !important; }
  .ks-hero-sub { font-size: .96rem !important; margin-bottom: 20px !important; }
  .ks-hero-ctas { flex-direction: column; }
  .ks-hero-ctas .ks-btn { width: 100%; padding: 15px 20px; font-size: 1rem; }
  .ks-hero-stats { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; margin-top: 22px !important; }
  .ks-hero-stats > div { padding: 10px !important; text-align: center; }
  .ks-hero-stats > div > div:first-child { font-size: 1.2rem !important; }
  .ks-hero-stats > div > div:last-child { font-size: .66rem !important; line-height: 1.25; }
  .ks-hero-3d-frame .ks-glass-card { padding: 14px !important; }
  #ksFinishSwatches { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #ksFinishSwatches::-webkit-scrollbar { display: none; }
  #ksFinishSwatches .ks-btn { white-space: nowrap; }

  /* Sections */
  .ks-section { padding: 34px 0; }
  .ks-section-head { margin-bottom: 18px; align-items: flex-start; }
  .ks-section-head h2 { font-size: 1.55rem; }
  .ks-section-head > .ks-btn { padding: 8px 12px; }

  /* Swipeable horizontal rows (categories + featured products) */
  .ks-swipe-row {
    display: grid !important; grid-auto-flow: column; grid-template-columns: none !important;
    grid-auto-columns: 78%; gap: 14px !important;
    overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    margin: 0 -14px; padding: 4px 14px 14px; scroll-padding: 0 14px; scrollbar-width: none;
  }
  .ks-swipe-row::-webkit-scrollbar { display: none; }
  .ks-swipe-row > * { scroll-snap-align: start; }
  .ks-grid-4.ks-swipe-row { grid-auto-columns: 46%; }
  .ks-grid-4.ks-swipe-row .ks-glass-card { padding: 12px !important; }
  .ks-grid-4.ks-swipe-row strong { font-size: .9rem !important; }
  .ks-swipe-dots { display: flex; justify-content: center; gap: 6px; margin-top: 2px; }
  .ks-swipe-dots i { width: 6px; height: 6px; border-radius: 99px; background: rgba(255,255,255,.22); transition: all .3s ease; }
  .ks-swipe-dots i.on { width: 20px; background: var(--ks-gold); }

  /* Product cards */
  .ks-product-card { padding: 12px; }
  .ks-product-card h3 { font-size: 1rem !important; }
  .ks-price { font-size: 1.22rem; }
  .ks-product-card .ks-btn-sm { padding: 11px 12px; }

  .ks-steps { grid-template-columns: 1fr; gap: 12px; }
  .ks-step { display: grid; grid-template-columns: 54px 1fr; gap: 4px 14px; text-align: left; align-items: center; padding: 14px; }
  .ks-step-ico { grid-row: span 2; margin: 0; }
  .ks-step p { margin: 0; }

  /* Forms: 16px stops iOS auto-zoom, bigger tap targets */
  .ks-field input, .ks-field select, .ks-field textarea { font-size: 16px; padding: 13px 14px; }
  .ks-btn { min-height: 44px; }

  /* Footer */
  .ks-footer { padding: 36px 0 18px; }
  .ks-footer-grid { gap: 20px; }
  .ks-footer-bottom { flex-direction: column; gap: 6px; font-size: .76rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ks-promo-track { padding-left: 0; }
  .ks-hero-title .ks-word { opacity: 1; transform: none; filter: none; }
}

/* Extra-small phones: ensure nothing overflows */
@media (max-width: 400px) {
  .ks-container { width: calc(100% - 20px); }
  .ks-btn { font-size: .88rem; padding: 11px 14px; }
  .ks-btn-sm { font-size: .78rem; padding: 8px 10px; }
  .ks-glass-card { border-radius: 16px; }
  .ks-price { font-size: 1.2rem; }
  .ks-product-card h3 { font-size: .92rem !important; }
  .ks-bottom-nav { left: 6px; right: 6px; }
  .ks-bottom-nav a { font-size: .62rem; padding: 6px 1px; }
}
