/* ===========================
   Bead Bliss — Custom Header (v3)
   Save as assets/bb-header.css
   The cart drawer styles now live in assets/cart.css
   =========================== */

:root{
  --bb-bg: #FBF7F4;
  --bb-beige: #F2E3E4;
  --bb-accent: #B76E79;
  --bb-accent-hover: #8E4B57;
  --bb-text: #241C1D;
  --bb-muted: #7C7173;
  --bb-line: rgba(142, 75, 87, .16);
  --bb-ease: cubic-bezier(.22, .61, .36, 1);
  --bb-serif: 'Playfair Display', Georgia, serif;
  --bb-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Bar heights. The spacer always uses --bb-h, so shrinking never moves the page. */
  --bb-h: 76px;
  --bb-h-s: 60px;
  --bb-overhang: 0px; /* how far the desktop logo hangs below the bar */
}

/* A fixed scrollbar gutter stops the page (and the fixed bar) from shifting sideways
   when a drawer locks scrolling */
html{ scrollbar-gutter: stable; scroll-padding-top: calc(var(--bb-h-s) + 16px); }
body.bb-lock{ overflow:hidden; }

/* Custom scrollbar, shared by search results, menu and cart */
.bb-search-results, .bb-nav{
  scrollbar-width:thin;
  scrollbar-color:#D3A9B0 transparent;
}
.bb-search-results::-webkit-scrollbar, .bb-nav::-webkit-scrollbar{ width:6px; }
.bb-search-results::-webkit-scrollbar-track, .bb-nav::-webkit-scrollbar-track{ background:transparent; margin:8px 0; }
.bb-search-results::-webkit-scrollbar-thumb, .bb-nav::-webkit-scrollbar-thumb{
  background:linear-gradient(180deg, #D8B4BA, #B76E79);
  border-radius:999px; border:2px solid transparent; background-clip:padding-box;
}
.bb-search-results::-webkit-scrollbar-thumb:hover, .bb-nav::-webkit-scrollbar-thumb:hover{ background:var(--bb-accent-hover); background-clip:padding-box; }

/* ---------- BAR ----------
   position:fixed + spacer = no layout shift. No backdrop-filter/transform here,
   or the fixed mobile drawer inside would be clipped to the bar. */
.bb-header-spacer{ height: var(--bb-h); }

.bb-header{
  --logo: 56px;
  position:fixed; top:0; left:0; right:0; z-index:999;
  height:var(--bb-h);
  background:var(--bb-bg);
  border-bottom:1px solid var(--bb-line);
  font-family:var(--bb-sans);
  transition:height .35s var(--bb-ease), box-shadow .35s var(--bb-ease);
}
.bb-header.is-scrolled{ --logo: 40px; height:var(--bb-h-s); box-shadow:0 10px 28px -18px rgba(36, 28, 29, .4); }
body.admin-bar .bb-header{ top:32px; }
@media (max-width:782px){ body.admin-bar .bb-header{ top:46px; } }

.bb-header-inner{
  height:100%; max-width:1360px; margin:0 auto; padding:0 32px;
  display:grid; grid-template-columns:1fr auto 1fr; align-items:center; column-gap:24px;
}

/* ---------- LOGO (center). Size is reserved, so it can never cause a jump ---------- */
.bb-logo{ grid-column:2; justify-self:center; width:var(--logo); height:var(--logo); transition:width .35s var(--bb-ease), height .35s var(--bb-ease); }
.bb-logo a{ display:block; width:100%; height:100%; }
.bb-logo img{ display:block; width:100%; height:100%; object-fit:contain; }

/* ---------- LOGO: desktop badge that hangs below the bar ----------
   Big at the top; on scroll the bar squeezes and the badge squeezes in place, still hanging below the bar.
   Phones keep the simple centered logo above. */
@media (min-width:901px){
  :root{ --bb-overhang: 30px; }

  .bb-header{ --badge: 104px; --badge-top: 10px; }
  /* On scroll the badge squeezes in place (same top, still centered) and still hangs 25px below the slimmer 60px bar */
  .bb-header.is-scrolled{ --badge: 75px; }

  .bb-header-inner{ position:relative; }

  .bb-logo{
    grid-column:auto; grid-row:auto; /* otherwise the grid column becomes its reference box and it drifts off-center */
    position:absolute; left:50%; top:var(--badge-top); z-index:2;
    width:var(--badge); height:var(--badge); margin-left:calc(var(--badge) / -2);
    border-radius:50%; background:#fff; border:1px solid var(--bb-line);
    box-shadow:0 16px 32px -16px rgba(36, 28, 29, .4);
    transition:width .4s var(--bb-ease), height .4s var(--bb-ease), top .4s var(--bb-ease), margin-left .4s var(--bb-ease), box-shadow .4s var(--bb-ease);
  }
  .bb-logo a{ display:flex; align-items:center; justify-content:center; border-radius:50%; }
  .bb-logo img{ box-sizing:border-box; padding:calc(var(--badge) * .15); }
}

/* Slightly smaller badge on narrower desktops so it never touches the menu */
@media (min-width:901px) and (max-width:1200px){
  :root{ --bb-overhang: 20px; }
  .bb-header{ --badge: 90px; --badge-top: 8px; }
  .bb-header.is-scrolled{ --badge: 76px; }
}

/* ---------- NAV (left, desktop) ---------- */
.bb-nav{ grid-column:1; justify-self:start; display:flex; }
.bb-drawer-head, .bb-drawer-foot{ display:none; }

.bb-menu{ display:flex; gap:30px; list-style:none; margin:0; padding:0; }
.bb-menu li{ position:relative; }
.bb-menu a{
  position:relative; display:inline-block; padding:8px 0;
  color:var(--bb-text); text-decoration:none;
  font-size:14.5px; font-weight:400; letter-spacing:.03em;
  transition:color .3s;
}
.bb-menu > li > a::after{
  content:''; position:absolute; left:0; right:0; bottom:2px; height:1px;
  background:var(--bb-accent-hover); transform:scaleX(0); transform-origin:left;
  transition:transform .45s var(--bb-ease);
}
.bb-menu > li > a:hover, .bb-menu > li.current-menu-item > a, .bb-menu > li.current-menu-ancestor > a{ color:var(--bb-accent-hover); }
.bb-menu > li > a:hover::after, .bb-menu > li.current-menu-item > a::after,
.bb-menu > li.current-menu-ancestor > a::after, .bb-menu > li:focus-within > a::after{ transform:scaleX(1); }

.bb-menu .sub-menu{
  position:absolute; top:100%; left:-18px; z-index:10;
  min-width:210px; margin:10px 0 0; padding:10px 0; list-style:none;
  background:#fff; border:1px solid var(--bb-line); border-radius:6px;
  box-shadow:0 22px 40px -20px rgba(36, 28, 29, .25);
  opacity:0; visibility:hidden; transform:translateY(6px);
  transition:opacity .3s var(--bb-ease), transform .3s var(--bb-ease), visibility .3s;
}
.bb-menu li:hover > .sub-menu, .bb-menu li:focus-within > .sub-menu{ opacity:1; visibility:visible; transform:none; }
.bb-menu .sub-menu a{ display:block; padding:9px 22px; font-size:14px; color:var(--bb-muted); }
.bb-menu .sub-menu a:hover{ color:var(--bb-accent-hover); background:var(--bb-bg); }

/* ---------- RIGHT: search + actions ---------- */
.bb-right{ grid-column:3; justify-self:end; display:flex; align-items:center; gap:18px; }
.bb-actions{ display:flex; align-items:center; gap:6px; }

/* Search (fixed width: it never changes size, so nothing around it moves) */
.bb-search{ position:relative; width:210px; transition:opacity .3s var(--bb-ease), transform .3s var(--bb-ease), visibility .3s; }
.bb-search form{
  display:flex; align-items:center; gap:6px; height:42px; margin:0;
  padding:0 14px 0 18px; background:#fff; border:1px solid var(--bb-line); border-radius:999px;
  transition:border-color .3s, box-shadow .3s;
}
.bb-search form:focus-within{ border-color:var(--bb-accent); box-shadow:0 0 0 4px rgba(183, 110, 121, .1); }
.bb-search input[type="search"]{
  flex:1; width:100%; min-width:0; height:auto; min-height:0; margin:0; padding:0;
  border:0 !important; outline:none !important; box-shadow:none !important; background:transparent;
  color:var(--bb-text); font:400 14px var(--bb-sans);
}
.bb-search input::placeholder{ color:var(--bb-muted); }
.bb-search button{
  display:flex; align-items:center; padding:0; border:0; background:transparent;
  color:var(--bb-accent); cursor:pointer; transition:color .2s;
}
.bb-search button:hover{ color:var(--bb-accent-hover); }

.bb-search-results{
  position:absolute; top:100%; right:0; z-index:100;
  width:360px; max-height:420px; margin-top:12px;
  overflow-y:auto; overscroll-behavior:contain;
  background:#fff; border:1px solid var(--bb-line); border-radius:8px;
  box-shadow:0 28px 50px -24px rgba(36, 28, 29, .3);
  display:none;
}
.bb-search-results.is-active{ display:block; animation:bb-pop .3s var(--bb-ease); }
@keyframes bb-pop{ from{ opacity:0; transform:translateY(-6px); } to{ opacity:1; transform:none; } }

.bb-search-item{
  display:flex; align-items:center; gap:16px; padding:14px 18px;
  text-decoration:none; border-bottom:1px solid var(--bb-line); transition:background .25s;
}
.bb-search-item:hover{ background:var(--bb-bg); }
.bb-search-item:last-child{ border-bottom:0; }
.bb-search-item img{ width:56px; height:56px; object-fit:cover; border-radius:4px; flex-shrink:0; }
.bb-search-info{ flex:1; min-width:0; }
.bb-search-title{ display:block; margin:0 0 4px; font:500 1rem/1.3 var(--bb-serif); color:var(--bb-text); }
.bb-search-price{ font-size:.85rem; font-weight:500; color:var(--bb-accent-hover); }
.bb-search-no-results{ padding:28px 20px; text-align:center; color:var(--bb-muted); font-size:.9rem; }

/* Search toggle (phones only, shown after the bar shrinks) */
.bb-search-toggle{
  display:none; align-items:center; justify-content:center; width:42px; height:42px; padding:0;
  border:0; background:transparent; color:var(--bb-text); cursor:pointer;
}

/* Cart */
.bb-cart a{
  position:relative; display:flex; align-items:center; justify-content:center;
  width:42px; height:42px; color:var(--bb-text); transition:color .3s;
}
.bb-cart a:hover{ color:var(--bb-accent-hover); }
.bb-cart-count{
  position:absolute; top:3px; right:0;
  min-width:17px; padding:1px 5px; border-radius:999px;
  background:var(--bb-accent-hover); color:#fff;
  font-size:10.5px; font-weight:500; line-height:1.5; text-align:center;
  transition:transform .3s var(--bb-ease);
}
.bb-cart-count[data-count="0"]{ display:none; }

/* Socials */
.bb-socials{ display:flex; gap:2px; margin-left:8px; padding-left:14px; border-left:1px solid var(--bb-line); }
.bb-socials a, .bb-drawer-foot a{
  display:flex; align-items:center; justify-content:center; width:36px; height:36px; border-radius:50%;
  color:var(--bb-text); opacity:.75; transition:opacity .3s, background .3s, color .3s;
}
.bb-socials a:hover, .bb-drawer-foot a:hover{ opacity:1; background:var(--bb-beige); color:var(--bb-accent-hover); }

.bb-header a:focus-visible, .bb-header button:focus-visible{ outline:2px solid var(--bb-accent-hover); outline-offset:3px; }

/* ---------- HAMBURGER ---------- */
.bb-toggle{
  display:none; flex-direction:column; justify-content:center; gap:6px;
  width:44px; height:44px; padding:0 10px; margin:0 0 0 -10px;
  background:transparent; border:0; cursor:pointer;
}
.bb-toggle span{ display:block; height:1.5px; background:var(--bb-text); transition:width .3s var(--bb-ease); }
.bb-toggle span:nth-child(1){ width:24px; }
.bb-toggle span:nth-child(2){ width:16px; }
.bb-toggle span:nth-child(3){ width:20px; }
.bb-toggle:hover span{ width:24px; }

/* ---------- OVERLAY (menu drawer) ---------- */
.bb-nav-overlay{
  position:fixed; inset:0; z-index:1000; background:rgba(36, 28, 29, .5);
  opacity:0; visibility:hidden; transition:opacity .45s var(--bb-ease), visibility .45s;
}
.bb-nav-overlay.bb-open{ opacity:1; visibility:visible; }

/* ---------- MEDIUM SCREENS ---------- */
@media (max-width:1200px){
  .bb-menu{ gap:22px; }
  .bb-search{ width:170px; }
  .bb-socials{ display:none; }
}

/* ---------- PHONES + SMALL TABLETS ---------- */
@media (max-width:900px){
  :root{ --bb-h: 118px; --bb-h-s: 62px; }

  .bb-header{ --logo: 46px; }
  .bb-header.is-scrolled{ --logo: 38px; }
  /* Reopen the search row on demand, even when the bar is small */
  .bb-header.is-search-open{ height:var(--bb-h); }

  .bb-header-inner{
    padding:6px 16px 8px; column-gap:0; row-gap:8px;
    grid-template-columns:88px 1fr 88px; grid-template-rows:52px 44px;
  }
  .bb-toggle{ display:flex; grid-column:1; grid-row:1; }
  .bb-logo{ grid-column:2; grid-row:1; }
  .bb-right{ display:contents; }
  .bb-actions{ grid-column:3; grid-row:1; justify-self:end; gap:0; }
  .bb-cart a{ margin-right:-6px; }
  .bb-socials{ display:none; }

  .bb-search{ grid-column:1 / -1; grid-row:2; width:100%; }
  .bb-search form{ height:44px; padding:0 16px 0 20px; }
  .bb-search input[type="search"]{ font-size:16px; } /* 16px stops iOS zoom */
  .bb-search-results{ left:0; right:0; width:auto; max-height:60vh; }

  /* Once the bar shrinks, hide the search row and show the search icon instead */
  .bb-header.is-scrolled:not(.is-search-open) .bb-search{ opacity:0; visibility:hidden; transform:translateY(-6px); pointer-events:none; }
  .bb-header.is-scrolled:not(.is-search-open) .bb-search-toggle{ display:flex; }

  /* Menu becomes a left drawer */
  .bb-nav{
    position:fixed; top:0; left:0; bottom:0; z-index:1001;
    flex-direction:column; justify-content:flex-start;
    width:min(86vw, 380px); background:var(--bb-bg);
    overflow-y:auto; overscroll-behavior:contain;
    box-shadow:30px 0 60px -30px rgba(36, 28, 29, .35);
    transform:translateX(-100%); visibility:hidden;
    transition:transform .5s var(--bb-ease), visibility .5s;
  }
  .bb-nav.bb-open{ transform:none; visibility:visible; }

  .bb-drawer-head{ display:flex; align-items:center; justify-content:space-between; padding:24px 24px 20px; border-bottom:1px solid var(--bb-line); }
  .bb-drawer-title{ font:400 1.5rem/1 var(--bb-serif); color:var(--bb-text); }
  .bb-nav-close{
    display:flex; align-items:center; justify-content:center; width:38px; height:38px; padding:0;
    border:1px solid var(--bb-line); border-radius:50%; background:transparent; color:var(--bb-text); cursor:pointer;
    transition:color .3s, border-color .3s, background .3s;
  }
  .bb-nav-close:hover{ color:var(--bb-accent-hover); border-color:var(--bb-accent-hover); background:#fff; }

  .bb-menu{ flex-direction:column; gap:0; padding:8px 24px; }
  .bb-menu > li{ border-bottom:1px solid var(--bb-line); }
  .bb-menu a{ display:block; padding:18px 0; font:400 1.3rem/1.2 var(--bb-serif); letter-spacing:0; }
  .bb-menu > li > a::after{ display:none; }
  .bb-menu .sub-menu{
    position:static; min-width:0; margin:0; padding:0 0 12px 16px;
    background:transparent; border:0; box-shadow:none; opacity:1; visibility:visible; transform:none;
  }
  .bb-menu .sub-menu a{ padding:9px 0; font:400 .95rem var(--bb-sans); color:var(--bb-muted); background:transparent !important; }

  .bb-drawer-foot{
    display:flex; gap:10px; margin-top:auto;
    padding:22px 24px calc(22px + env(safe-area-inset-bottom, 0px)); border-top:1px solid var(--bb-line);
  }
}

@media (prefers-reduced-motion:reduce){
  .bb-header, .bb-header *, .bb-nav, .bb-nav-overlay{ transition-duration:.01s !important; animation:none !important; }
}