/* Global BestBuds — Shared Navigation Styles (single source of truth) */

/* ─── Top-of-page: promo bar + desktop nav (scrolls away) ─── */
.top-promo-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 0;
  text-align: center;
  background: linear-gradient(90deg, rgba(34,197,94,.92), rgba(14,165,233,.86));
  box-shadow: 0 10px 24px rgba(2, 8, 23, .18);
}

.top-promo-bar a {
  color: #fff;
  text-decoration: none;
  text-shadow: 0 2px 10px rgba(0,0,0,.25);
}

/* Desktop nav at top: normal flow, scrolls away (NOT sticky) */
nav.desktop-nav {
  position: static;
}

@media (min-width: 921px) {
  nav.desktop-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  nav.desktop-nav .nav-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    padding: 10px 18px;
    gap: 0;
  }

  nav.desktop-nav .nav-links {
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: center;
  }

  nav.desktop-nav .cart-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
  }
}

/* ─── Sticky header: appears only after desktop nav scrolls out ─── */
body {
  padding-top: 0 !important;
}

.sticky-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  opacity: 1;
  pointer-events: none;
  transform: translateY(-100%);
  transition: transform 220ms ease;
  background: linear-gradient(90deg, #22c55e, #0ea5e9);
  box-shadow: 0 10px 24px rgba(2, 8, 23, .18);
}

.sticky-header.show {
  pointer-events: auto;
  transform: translateY(0);
}

.sticky-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  height: 56px;
}

.sticky-brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.sticky-brand img {
  height: auto;
  max-height: 46px;
  width: auto;
  max-width: 60vw;
  display: block;
}

.sticky-brand,
.sticky-nav a {
  color: #fff;
  text-decoration: none;
  text-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.sticky-hamburger,
.sticky-cart-btn {
  position: relative;
  z-index: 2;
  min-width: 52px;
  background: transparent !important;
  border: 0 !important;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}

.sticky-cart-btn .cart-badge {
  margin-left: 6px;
}

/* Sticky header: white hamburger + cart icons via color inheritance */
.sticky-header .sticky-hamburger,
.sticky-header .sticky-cart-btn {
  color: #ffffff;
}

.sticky-header .sticky-hamburger .ham-lines,
.sticky-header .sticky-hamburger .ham-lines::before,
.sticky-header .sticky-hamburger .ham-lines::after {
  background-color: #ffffff;
}

.sticky-header .sticky-cart-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
}

/* Menu dropdown (inside sticky-header) */

.sticky-header .menu {
  display: none;
  position: absolute;
  left: 12px;
  top: calc(100% + 10px);
  padding: 10px 20px 10px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border, rgba(15, 23, 42, .10));
  box-shadow: var(--shadow-sm, 0 10px 24px rgba(2, 8, 23, .10));
  z-index: 3000;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: min(360px, 92vw);
  max-height: 45vh;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity .18s ease, transform .18s ease;
}

.sticky-header .menu.open {
  display: grid;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sticky-header .menu a {
  color: var(--text, #0b1220);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.sticky-header .menu a:hover {
  background: rgba(255,255,255,.70);
  border-color: var(--border);
}

.sticky-header .menu a.active {
  background: rgba(34,197,94,.16);
  border: 1px solid rgba(34,197,94,.40);
}

/* ─── Legacy nav (when sticky-header not used) ─── */
nav {
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(247,248,251,.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border, rgba(15, 23, 42, .10));
}

.nav-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 16px;
  gap: 12px;
  box-sizing: border-box;
}

/* Desktop: single row, links centered, cart right */
@media (min-width: 921px) {
  .nav-inner .nav-left {
    display: none;
  }

  .nav-inner .nav-links .menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0;
    padding: 0;
  }
}

.nav-left,
.nav-right {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
}

.nav-right {
  margin-left: auto;
}

.nav-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 1;
}

/* Collapse logo wrapper when empty (logo removed from desktop nav) */
.nav-logo-link:empty {
  margin: 0;
  padding: 0;
  height: 0;
  min-height: 0;
  overflow: hidden;
  position: absolute;
  width: 0;
  clip: rect(0, 0, 0, 0);
}

.nav-logo-link:hover {
  opacity: 0.9;
}

.nav-logo {
  height: 40px;
  width: auto;
  display: block;
}

/* Desktop menu */
.menu {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.menu a {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: max-content;
  max-width: 100%;
  white-space: nowrap;
  color: var(--text, #0b1220);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.menu a:hover {
  background: rgba(255,255,255,.70);
  border-color: var(--border, rgba(15, 23, 42, .10));
  box-shadow: 0 10px 22px rgba(2,8,23,.10);
  transform: translateY(-1px);
}

/* Active pill style (no clipping) */
.menu a.active {
  color: var(--text, #0b1220);
  background: rgba(34,197,94,.16);
  border-color: rgba(34,197,94,.40);
  box-shadow: 0 10px 24px rgba(34,197,94,.18), 0 0 0 3px rgba(34,197,94,.20);
}

/* Hamburger button */
.hamburger {
  display: none;
  position: relative;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  background: rgba(255,255,255,.65);
  border: 1px solid var(--border, rgba(15, 23, 42, .10));
  color: var(--text, #0b1220);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm, 0 10px 24px rgba(2, 8, 23, .10));
}

.ham-lines,
.ham-lines::before,
.ham-lines::after {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform .18s ease, opacity .18s ease, top .18s ease;
  position: relative;
}

.ham-lines::before { position: absolute; top: -6px; left: 0; }
.ham-lines::after { position: absolute; top: 6px; left: 0; }

.hamburger.is-open .ham-lines { transform: rotate(45deg); }
.hamburger.is-open .ham-lines::before { top: 0; transform: rotate(90deg); }
.hamburger.is-open .ham-lines::after { top: 0; opacity: 0; }

.ham-text { transition: opacity .18s ease, transform .18s ease; }

/* Mobile breakpoint: hamburger menu + cart pinned right */
@media (max-width: 920px) {
  .top-promo-bar,
  nav.desktop-nav {
    overflow: visible;
  }

  /* Keep first header/nav above page content */
  #desktopNav {
    position: relative;
    z-index: 5000;
  }

  /* Force FIRST dropdown panel to overlay everything */
  #desktopMenu.open {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: 112px !important;
    z-index: 6000 !important;
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(10px);
  }

  .nav-inner {
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
  }

  .nav-inner::after {
    display: none; /* remove spacer that pushes cart left */
  }

  .nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
  }

  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    order: 0;
  }

  .menu {
    order: 2;
    display: none;
    position: absolute;
    left: 12px;
    right: auto;
    top: calc(100% + 10px);
    padding: 10px 20px 10px 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border, rgba(15, 23, 42, 0.10));
    box-shadow: var(--shadow-sm, 0 10px 24px rgba(2, 8, 23, 0.10));
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: min(360px, 92vw);
    max-height: 45vh;
    overflow-y: auto;
    overflow-x: visible;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .menu.open {
    display: grid;
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  .menu a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
    padding: 10px 12px;
    border-radius: 999px;
  }

  .cart-btn {
    margin-left: 0;
    margin-right: 0;
  }

  .nav-logo-link {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  .nav-logo {
    height: 32px;
  }
}

@media (max-width: 420px) {
  .nav-inner {
    padding: 10px 10px;
  }

  .sticky-brand img {
    max-height: 40px;
  }
}
