/* ==========================================================================
   Liquid Glass Bottom Nav — FINAL PLATFORM-NEUTRAL CSS
   - Base = iOS-friendly sticky + safe-area padding
   - Android fixes are applied by JS at runtime (no UA-specific CSS)
   ========================================================================== */

/* ─── Design tokens ───────────────────────────────────────────────────────── */
:root{
  --bar-max: 860px;
  --bar-h: 64px;
  --glass-bg: rgba(255,255,255,0.55);
  --glass-stroke: rgba(255,255,255,0.35);
  --ink: #0b0b0c;
  --ink-dim: #3a3a3c;
}
@media (prefers-color-scheme: dark){
  :root{
    --glass-bg: rgba(18,18,20,0.55);
    --glass-stroke: rgba(255,255,255,0.08);
    --ink: #f5f5f7;
    --ink-dim: #c7c7cc;
  }
}

/* Reserve page space (safe for iOS; Android JS will override body padding) */
body{
  padding-bottom: calc(var(--bar-h) + max(24px, env(safe-area-inset-bottom, 0px)));
}

/* ─── Bar container (base = sticky) ───────────────────────────────────────── */
.ios-glass-tabbar{
  position: sticky;
  bottom: 2px;                         /* sticky trigger */
  /* extra visible gap handled via margin-bottom so iOS respects it */
  margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 2px);
  z-index: 9999;

  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  gap: 4px;

  /* stable centering; JS will take over on Android */
  max-width: var(--bar-max);
  width: calc(100% - 16px);
  margin-left: auto; margin-right: auto;

  height: var(--bar-h);

  /* anti-flicker prep; avoid transforms on sticky */
  isolation: isolate;
  backface-visibility: hidden;
  will-change: auto;

  /* visuals moved to ::before */
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Frosted glass on its own layer (lighter blur looks sharper on product pages) */
.ios-glass-tabbar::before{
  content:"";
  position:absolute;
  inset:-10px;                          /* bleed hides blur edge; JS may clamp to 0 on Android PDPs */
  border-radius:18px;                   /* tweak e.g. 32px if you want rounder capsule */
  z-index:-1;

  background:var(--glass-bg);
  border:1px solid var(--glass-stroke);
  box-shadow:0 8px 24px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.35);

  /* choose one of these two lines; 6px is crisper, 16px is frosted
     backdrop-filter: saturate(180%) blur(16px); */
  backdrop-filter: saturate(180%) blur(6px);
  -webkit-backdrop-filter: saturate(180%) blur(6px);
}

/* Hide on tablet/desktop */
@media (min-width:768px){
  .ios-glass-tabbar{ display:none; }
}

/* Tabs */
.ios-glass-tabbar .tab{
  position:relative;
  height:var(--bar-h);
  text-decoration:none;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:4px;
  color:var(--ink-dim);
  font:500 11px/1.1 ui-sans-serif, system-ui, -apple-system, "SF Pro", Inter, Roboto, "Segoe UI", sans-serif;
  transition: color .25s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.ios-glass-tabbar .tab:active{ transform: translateY(1px) scale(.98); }
.ios-glass-tabbar .tab.is-active{ color:var(--ink); }

.ios-glass-tabbar .tab svg{
  width:22px; height:22px; display:block; fill:currentColor;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.35));
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.ios-glass-tabbar .tab.is-active svg{ transform: translateY(-2px) scale(1.05); }

/* Badge */
.ios-glass-tabbar .tab .badge,
.ios-glass-tabbar .tab [data-cart-count]{
  position:absolute; top:6px; right:22%;
  min-width:16px; height:16px; padding:0 4px;
  border-radius:999px; background:#ff3b30; color:#fff;
  font-size:10px; line-height:16px; text-align:center;
  box-shadow:0 1px 2px rgba(0,0,0,.3);
}

/* Blob highlight off */
.ios-glass-tabbar .blob{ display:none !important; }

/* Ripple */
.tap-ripple{ position:absolute; inset:0; overflow:hidden; border-radius:14px; pointer-events:none; }
.tap-ripple > span{
  position:absolute; width:12px; height:12px; border-radius:999px;
  background:rgba(255,255,255,.65);
  transform: translate(-50%,-50%) scale(0);
  animation: ripple .5s ease-out forwards;
  mix-blend-mode: soft-light;
}
@keyframes ripple{ to{ transform: translate(-50%,-50%) scale(9); opacity:0; } }

/* No backdrop-filter support */
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))){
  .ios-glass-tabbar::before{
    backdrop-filter:none !important;
    -webkit-backdrop-filter:none !important;
    background:rgba(240,240,245,.96);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .ios-glass-tabbar, .ios-glass-tabbar .tab{ transition:none !important; animation:none !important; }
}
