/* ════════════════════════════════════════════════════════════════════════
   bk-floating-nav.css — translucent floating scroll-shrink bottom nav
   Shared primitive · DESIGN.md §4.15 (component spec) · pk-approved pattern.

   ONE canonical implementation, included by + driving the bottom nav of:
     · shop.html        (.bk-floating-nav, ecom storefront — trust-blue)
     · studio.html      (.bk-floating-nav, yoga bookings — clay-orange)
     · app.html         (.bk-floating-nav, clinic bookings — trust-blue)
     · admin_shop.html  (.bk-floating-nav, admin — indigo)

   WHY GLASS IS ALLOWED HERE (DESIGN.md §1, ~line 140 — glassmorphism is
   "allowed only with a deliberate, justified reason — never ambient
   decoration"): this nav FLOATS over scrolling content, so the user must
   keep spatial context of what is behind it while it stays legible. The
   frosted blur IS the justification — it lets the page read through while
   a semi-opaque fill (§2.7) keeps glyphs/labels above the contrast floor.
   This is the single sanctioned glass surface; it is not decoration.

   DESIGN CONTRACT TOUCHPOINTS
     §1   ~144  pick ONE depth cue — shadow only, no 1px-border + heavy shadow.
     §2.7       semi-opaque fill so labels ≥4.5:1 / glyphs ≥3:1 over any bg.
     §2.1/§2.6  active tab = var(--brand-primary) (themes per page/tenant).
     §6.1       soft brand-tinted float shadow (no flat black).
     §6.4       z-index from the named ladder (--z-sticky), never 999.
     §8.2       every tap target ≥44px — in full AND compact states.
     §8.3       prefers-reduced-motion: no shrink animation / no translate.

   Cross-page token strategy: this file references its OWN namespaced
   --bkfn-* tokens, each var()-chained to the page's existing token with a
   hard fallback, so a single CSS drives four different token vocabularies
   (shop uses text-mute/bg tokens; studio/admin use the bk-ink and bk-surface
   token families.) The ONE token universal across all four pages is
   --brand-primary, which is why the active tab keys off it directly.
   ════════════════════════════════════════════════════════════════════════ */

.bk-floating-nav {
  /* ── local token resolution (page token → fallback) ─────────────────── */
  /* surface fill: ~80% opaque so content blurs through but labels stay legible (§2.7) */
  --bkfn-surface:        var(--bk-surface-2, var(--bg, #ffffff));
  --bkfn-fill-translucent: color-mix(in oklch, var(--bkfn-surface) 60%, transparent);
  --bkfn-fill-solid:       color-mix(in oklch, var(--bkfn-surface) 94%, white);
  --bkfn-ink-rest:       var(--text-mute, var(--bk-ink-muted, #5B6A80));
  --bkfn-ink-active:     var(--brand-primary, #2563EB);
  --bkfn-ring:           var(--brand-primary-ring, color-mix(in oklch, var(--brand-primary, #2563EB) 45%, transparent));
  --bkfn-radius:         var(--bk-radius-pill, 999px);
  --bkfn-z:              var(--z-sticky, 1100);
  /* float shadow — soft, brand-tinted; the SINGLE depth cue (no border). §6.1 */
  --bkfn-shadow:
      0 1px 2px   0 color-mix(in oklch, var(--brand-primary, #2563EB) 10%, transparent),
      0 8px 24px  0 color-mix(in oklch, var(--brand-primary, #2563EB) 14%, transparent),
      0 16px 40px 0 color-mix(in oklch, var(--brand-primary, #2563EB) 10%, transparent);
  --bkfn-inset:          clamp(12px, 4vw, 16px);
  --bkfn-ease:           var(--bk-ease-standard, cubic-bezier(0.2, 0, 0, 1));

  position: fixed;
  left:  var(--bkfn-inset);
  right: var(--bkfn-inset);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: var(--bkfn-z);

  /* NOTE: `display` is intentionally NOT set here. Each page owns the
     show/hide breakpoint (shop/admin hide ≥768px, studio hides ≥901px), so the
     page's own `.bk-floating-nav { display:none|flex }` rules (same specificity,
     but page-specific media queries) must win. The flex LAYOUT is supplied via
     the zero-specificity :where() rule below, which never beats a page rule. */
  align-items: stretch;
  gap: 2px;
  margin: 0 auto;
  max-width: 520px;          /* keep the pill from stretching edge-to-edge on tablets */
  padding: 6px;

  border-radius: var(--bkfn-radius);
  /* glass: frosted translucent fill — content scrolling behind shows through */
  background: var(--bkfn-fill-translucent);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  backdrop-filter:         blur(10px) saturate(180%);
  box-shadow: var(--bkfn-shadow);          /* §1 ~144: shadow ONLY, no border pairing */

  /* shrink-on-scroll: animate transform/opacity-adjacent props only.
     padding + a tiny translateY are the only animated geometry; height is
     driven by the tab min-height token below so layout stays cheap. */
  transition:
      padding 180ms var(--bkfn-ease),
      transform 180ms var(--bkfn-ease);
  will-change: transform;
}

/* Flex layout at ZERO specificity so a page's own `display:none|flex` (the
   per-page desktop/mobile breakpoint rules) always wins. When the nav IS shown
   (page sets display:flex, or a page that has no media query relies on this),
   it lays out as a flex row. `:where()` contributes 0 specificity. */
:where(.bk-floating-nav) { display: flex; }

/* fallback: no backdrop-filter support → near-solid fill so labels never wash out (§2.7) */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bk-floating-nav { background: var(--bkfn-fill-solid); }
}

/* ── tab ──────────────────────────────────────────────────────────────── */
.bk-floating-nav__tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;

  /* §8.2 — tap target ≥44px in BOTH full and compact states */
  min-height: 52px;
  padding: 6px 4px;

  border: 0;
  background: transparent;
  border-radius: calc(var(--bk-radius-md, 10px) + 2px);
  cursor: pointer;
  text-decoration: none;
  color: var(--bkfn-ink-rest);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  -webkit-tap-highlight-color: transparent;
  transition: color 160ms var(--bkfn-ease), background-color 160ms var(--bkfn-ease);
}

.bk-floating-nav__tab:hover {
  color: color-mix(in oklch, var(--bkfn-ink-active) 60%, var(--bkfn-ink-rest));
}
.bk-floating-nav__tab:active {
  background: color-mix(in oklch, var(--brand-primary, #2563EB) 8%, transparent);
}
.bk-floating-nav__tab:focus-visible {
  outline: 2px solid var(--bkfn-ring);
  outline-offset: -2px;
  border-radius: var(--bk-radius-pill, 999px);
}

/* icon — size stays constant across full/compact so the pill never reflows icons */
.bk-floating-nav__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: inherit;
  display: block;
}
.bk-floating-nav__icon svg { width: 100%; height: 100%; display: block; }

/* label */
.bk-floating-nav__label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  /* animate opacity/max-height only (no layout thrash) for the compact fade */
  opacity: 1;
  max-height: 1.4em;
  transition: opacity 140ms var(--bkfn-ease), max-height 180ms var(--bkfn-ease);
}

/* active tab = brand-primary (themes per page: ecom blue / yoga clay / admin indigo) */
.bk-floating-nav__tab.is-active,
.bk-floating-nav__tab[aria-current="page"] {
  color: var(--bkfn-ink-active);
}
.bk-floating-nav__tab.is-active .bk-floating-nav__label,
.bk-floating-nav__tab[aria-current="page"] .bk-floating-nav__label {
  font-weight: 700;
}

/* ── compact state (scroll-down) — labels hide, pill shortens, icons stay ── */
/* §8.2: min-height stays ≥44px so the tap target survives the shrink. */
.bk-floating-nav.is-compact {
  padding: 4px;
  transform: translateY(2px);     /* tiny settle, reads as "tucking down" */
}
.bk-floating-nav.is-compact .bk-floating-nav__tab {
  min-height: 44px;
  padding: 4px;
}
.bk-floating-nav.is-compact .bk-floating-nav__label {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
}

/* ── reduced motion (§8.3) — no shrink animation, no translate ──────────── */
@media (prefers-reduced-motion: reduce) {
  .bk-floating-nav,
  .bk-floating-nav__tab,
  .bk-floating-nav__label {
    transition: none;
  }
  .bk-floating-nav.is-compact {
    transform: none;     /* instant, no glide */
  }
}
