/* ==========================================================================
   smudgechild — header / logo / primary nav + submenu
   Maps the "glass pill nav" design onto Genesis's native markup:
   .site-header > .wrap > [ .title-area (logo) | button.menu-toggle | nav.nav-primary ]
   The PILL lives on .site-header > .wrap (logo + nav share one bar).
   nav-primary itself is a transparent flex child, not its own pill.
   Submenus: ul.sub-menu ; mobile toggle: button.menu-toggle / button.sub-menu-toggle
   Depends on :root variables defined in style.css (loaded first).
   ========================================================================== */

/* ── header / pill container ───────────────────────────────────────────── */

.site-header {
  z-index: 50;
  background: transparent;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  will-change: top;
  transition: top 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* toggled by custom.js's scroll-direction watcher */
.site-header--hidden {
  top: -140px;
  pointer-events: none;
  transition: top 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header > .wrap {
  position: relative; /* anchor for .title-area below, and for true pill-wide nav centering */
  width: auto;
  max-width: none;
  display: flex;
  align-items: center;
  gap: 26px;
  margin: 22px clamp(20px, 3vw, 40px) 0;
  padding: 14px 16px 14px 26px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 36px -18px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  z-index: 0; /* own stacking context, so the ::before glass below sits behind the logo/nav, not behind the page */
}

/*
 * The pill's frosted glass lives on this layer, not on .wrap itself.
 * An element with backdrop-filter stops its descendants' backdrop-filter from
 * seeing the page: they can only blur what's inside it. The mobile menu sheet
 * and the desktop dropdowns are both inside .wrap, so the glass sits on a
 * ::before layer (a sibling of the menu, not its parent) and the menu can
 * blur the page.
 * Don't put backdrop-filter, filter, opacity < 1, mask or clip-path back on
 * .wrap or .site-header — any of them breaks the menu's blur.
 */
.site-header > .wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: rgba(18, 17, 14, 0.32);
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  pointer-events: none;
}

/* ── logo / title-area ────────────────────────────────────────────────── */

.title-area {
  /* desktop: pulled out of .wrap's flex flow so nav-primary (and therefore
     the centered menu) spans the FULL pill instead of only the space to
     the right of the logo — fixes the menu reading as skewed right.
     NOTE: absolute positioning's containing block is the padding EDGE,
     not the content edge, so padding-left on .wrap is NOT inherited as
     an inset here — left must explicitly match .wrap's padding-left (26px).
     Reset back to a normal flex item at the mobile breakpoint below.
     z-index: nav-primary's full-width <ul> (position: relative) comes later
     in the DOM, so it paints over this absolutely-positioned logo and
     swallows its clicks. Lifting the logo above it keeps the link clickable;
     the menu's links never sit over the logo, so nothing else is covered. */
  position: absolute;
  z-index: 1;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  flex: none;
}

.custom-logo-link {
  display: flex;
  align-items: center;
}

/* .custom-logo-link prefix: on WooCommerce pages (product, cart, account)
   WooCommerce's `.woocommerce-page img { height: auto }` outranked a bare
   .custom-logo and the SVG logo collapsed to 0x0 (Lumart, 21 Nov). */
.custom-logo-link .custom-logo {
  height: 26px;
  width: auto;
  display: block;
}

/* hide the redundant text title + tagline once a custom logo is set.
   :has() degrades gracefully — without support, the title text just
   stays visible next to the logo rather than breaking anything. */
.title-area:has(.custom-logo-link) .site-title {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-description {
  display: none;
}

/* fallback text-only logo styling, in case no custom logo is uploaded yet */
.title-area:not(:has(.custom-logo-link)) .site-title a {
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
}

/* ── nav-primary: transparent flex child of the pill, not its own box ──── */

/*
 * Selected as `.site-header .nav-primary`, not
 * `.nav-primary.genesis-responsive-menu`: responsive-menus.js adds that
 * class from the footer, so rules depending on it don't apply until the
 * script runs, and on phones the whole menu flashes open inside the pill.
 * This selector styles the nav the same before and after the script.
 */
.site-header .nav-primary {
  flex: 1;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.nav-primary .wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
}

/* ── desktop menu ──────────────────────────────────────────────────────── */

ul.genesis-nav-menu.menu-primary {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.genesis-nav-menu .menu-item {
    position: relative;
    padding-bottom: 0;
    margin-bottom: 0;
}

.genesis-nav-menu .menu-item > a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  padding: 6px 0;
  transition: color 0.18s ease;
}

.genesis-nav-menu .menu-item > a:hover,
.genesis-nav-menu .menu-item > a:focus {
  color: #fff;
}

/* caret on items that have children */
.genesis-nav-menu .menu-item-has-children > a::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.25s ease;
}

.genesis-nav-menu .menu-item-has-children:hover > a::after,
.genesis-nav-menu .menu-item-has-children:focus-within > a::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

/* hide Genesis's own sub-menu-toggle button on desktop — caret above replaces it */
.nav-primary .sub-menu-toggle {
  display: none;
}

/* ── header actions (login + cart + become a member) ───────────────────
   Injected as the last <li> of the primary menu via wp_nav_menu_items.
   The menu links stay centred via justify-content above; this item is
   pulled out of that flow with position:absolute and pinned to the right
   edge of the full-width <ul>. ────────────────────────────────────────── */

.genesis-nav-menu .menu-item--actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
}

.genesis-nav-menu .menu-item--actions::after {
  display: none; /* never gets the dropdown caret */
}

.genesis-nav-menu .menu-item--actions a.nav__login {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  padding: 10px 6px;
  transition: color 0.18s ease;
}

.genesis-nav-menu .menu-item--actions a.nav__login:hover {
  color: #fff;
}

.genesis-nav-menu .menu-item--actions a.nav__cta {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.18s ease, background 0.18s ease;
}

.genesis-nav-menu .menu-item--actions a.nav__cta:hover {
  transform: translateY(-1px);
  background: var(--accent-hover);
}

/* ── desktop submenu (hover dropdown) ────────────────────────────────────── */

.genesis-nav-menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 230px;
  list-style: none;
  margin: 0;
  padding: 8px;
  border-radius: 16px;
  background: rgba(20, 19, 15, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 50px -22px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(20px) saturate(125%);
  -webkit-backdrop-filter: blur(20px) saturate(125%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.genesis-nav-menu .menu-item-has-children:hover > .sub-menu,
.genesis-nav-menu .menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.genesis-nav-menu .sub-menu .menu-item > a {
  display: block;
  padding: 11px 14px;
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease;
}

.genesis-nav-menu .sub-menu .menu-item > a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* sub-menu items never get their own caret/children styling here */
.genesis-nav-menu .sub-menu .menu-item > a::after {
  display: none;
}

/* ── mobile burger (button.menu-toggle) ──────────────────────────────────── */

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* pure-CSS hamburger — no icon font dependency.
   JS (_mainmenuToggle) toggles an "activated" class on click, so we use
   that — not any dashicons glyph swap — to morph the icon into an X. */
.menu-toggle {
  position: relative;
}

.menu-toggle.dashicons-before::before,
.menu-toggle.dashicons-before::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: currentColor;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

/* closed state: three bars, drawn via box-shadow on the ::before line */
.menu-toggle.dashicons-before::before {
  transform: translate(-50%, -50%);
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.menu-toggle.dashicons-before::after {
  display: none;
}

/* open state ("activated"): morph into an X */
.menu-toggle.dashicons-before.activated::before {
  transform: translate(-50%, -50%) rotate(45deg);
  box-shadow: none;
}

.menu-toggle.dashicons-before.activated::after {
  display: block;
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ── mobile breakpoint ────────────────────────────────────────────────────
   IMPORTANT: responsive-menus.js (StudioPress/genesis-sample) drives show/hide
   via jQuery .slideToggle() on the elements directly — it sets inline
   display/height itself. It does NOT use aria-expanded or a class for
   visibility, only for state (icon styling). So nav-primary and .sub-menu
   MUST default to display:none here so slideToggle's "closed" detection
   and first-open animation behave correctly. Do not switch this to
   max-height/opacity — it will fight the inline styles jQuery sets.
   ────────────────────────────────────────────────────────────────────── */

@media (max-width: 1199px) {
  .site-header > .wrap {
    justify-content: space-between;
  }

  /* undo the desktop-only absolute positioning above — mobile needs the
     logo back as a normal flex item so it sits correctly next to the
     burger button under the space-between rule. */
  .title-area {
    position: static;
    transform: none;
  }

  .menu-toggle {
    display: flex; /* script detects mobile mode by checking this button's computed display */
  }

  /* stand-in burger, shown only until responsive-menus.js inserts the real
     .menu-toggle (same size, colour and three bars), so the header doesn't
     change shape when the script runs. :has() is already relied on above. */
  .site-header > .wrap:not(:has(.menu-toggle))::after {
    content: "";
    order: 99;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background:
      linear-gradient(#fff, #fff) center calc(50% - 6px) / 18px 2px no-repeat,
      linear-gradient(#fff, #fff) center / 18px 2px no-repeat,
      linear-gradient(#fff, #fff) center calc(50% + 6px) / 18px 2px no-repeat,
      rgba(255, 255, 255, 0.12);
  }

  /* closed by default — JS slideToggle()s this element open/closed.
     Matches before the script has run too (see the note on the desktop
     rule above); slideToggle's inline display still wins when it opens. */
  .site-header .nav-primary {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    left: 12px;
    right: 12px;
    padding: 10px;
    border-radius: 22px;
    /* 0.62 leaned on the blur to hide the page: wherever backdrop-filter
       isn't drawn, the breadcrumb and product photo read through the open
       menu (21 Nov). 0.96 covers the page on its own; the blur still frosts it. */
    /* Lumart 29 Nov: dark frosted glass like the header bar, not solid black.
       A heavier blur than the bar keeps page text behind it unreadable. */
    background: rgba(18, 17, 14, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 26px 54px -22px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(32px) saturate(140%);
    -webkit-backdrop-filter: blur(32px) saturate(140%);
  }

  .nav-primary .wrap {
    display: block;
  }

  ul.genesis-nav-menu.menu-primary {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
  }

  .genesis-nav-menu .menu-item > a {
    width: 100%;
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 16px;
    justify-content: space-between;
  }

  .genesis-nav-menu .menu-item > a:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .genesis-nav-menu .menu-item--actions {
    position: static;
    transform: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-left: 0;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
  }

  .genesis-nav-menu .menu-item--actions a.nav__login {
    padding: 13px 16px;
    border-radius: 14px;
  }

  .genesis-nav-menu .menu-item--actions a.nav__login:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .genesis-nav-menu .menu-item--actions a.nav__cta {
    width: 100%;
    text-align: center;
    border-radius: 14px;
    padding: 14px;
  }

  /* show Genesis's own toggle button on mobile, hide the desktop ::after caret */
  .nav-primary .sub-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 4px;
    top: 4px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: transform 0.25s ease;
  }

  /* rotate the toggle icon when open — aria-expanded is safe to use for this,
     it's set alongside the slideToggle() call, just not driving visibility */
  .nav-primary .sub-menu-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
    color: #fff;
  }

  .genesis-nav-menu .menu-item-has-children > a::after {
    display: none;
  }

  .genesis-nav-menu .menu-item-has-children {
    padding-bottom: 0;
    margin-bottom: 0;
  }

  /* mobile submenu: accordion, closed by default — JS slideToggle()s it */
  .genesis-nav-menu .sub-menu {
    display: none;
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    min-width: 0;
    margin: 2px 0 6px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
  }

  .genesis-nav-menu .sub-menu .menu-item > a {
    font-size: 15px;
    padding: 11px 14px;
  }

  /* tapping the sub-menu-toggle focuses it, which triggers :focus-within on
     desktop and re-applies its translateX(-50%) dropdown-centering transform —
     same specificity as the desktop rule, so this override (later in the
     cascade) is required to keep the accordion panel in normal flow. */
  .genesis-nav-menu .menu-item-has-children:hover > .sub-menu,
  .genesis-nav-menu .menu-item-has-children:focus-within > .sub-menu {
    position: static;
    transform: none;
  }
}

@media (max-width: 480px) {
  .site-header > .wrap {
    margin: 14px 12px 0;
    padding: 10px 10px 10px 16px;
    gap: 12px;
  }

  .custom-logo-link .custom-logo {
    height: 21px;
  }
}
/* Lumart, 12 Nov: on phones the header is a full-width dark frosted bar that
   stays put (custom.js no longer hides it on scroll below 861px), the way
   Superpower's does. Same logo, cart, menu button and menu sheet as before.
   The glass is still on .wrap::before, so the menu sheet keeps its own blur. */
@media (max-width: 860px) {
  .site-header,
  .site-header--hidden { top: 0; pointer-events: auto; transition: none; }
  .site-header > .wrap {
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px 18px;
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.55);
  }
  .site-header > .wrap::before {
    background:
      radial-gradient(120% 140% at 70% 0%, rgba(92, 70, 48, 0.28), transparent 60%),
      rgba(16, 16, 18, 0.72);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
  }
  .site-header .nav-primary { top: calc(100% + 8px); left: 10px; right: 10px; }
}

/* Shehwar's audit (12 Nov): over light pages (blog, checkout, account, 404) the
   32% pill turned muddy grey and its white links dropped to ~2:1. A darker
   glass keeps them readable on any background; over dark heroes it looks the same. */
@media (min-width: 861px) {
  .site-header > .wrap::before { background: rgba(18, 17, 14, 0.7); }
}

/* viewport-fit=cover (12 Nov): keep the header clear of the notch and status
   bar wherever iOS draws the page under them (0 everywhere else). */
.site-header { padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }

/* Lumart, 13 Nov (desktop): the dropdown opens below the menu bar instead of
   over it. The bar's bottom edge sits ~15px below the menu item; the panel
   starts 10px under that. An invisible bridge keeps hover alive across the gap. */
@media (min-width: 861px) {
  .genesis-nav-menu .sub-menu { top: calc(100% + 25px); }
  .genesis-nav-menu .sub-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -26px; height: 26px; }
}

/* Back-to-top button (js/site-scroll.js), glass like the menu pill. Shows on scroll up. */
.to-top {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px) + 16px);
  bottom: max(20px, env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 95;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(18, 17, 14, 0.32);
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}
.to-top.is-on { opacity: 1; transform: none; pointer-events: auto; }
@media (hover: hover) { .to-top:hover { background: rgba(18, 17, 14, 0.5); } }
.to-top { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.to-top:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .to-top { transition: none; } }

/* Laptop widths (1 Dec): with seven links, the menu centred on the whole pill
   ran under Login (72px at 1280). Here the logo, links and actions share one
   row, so they can't overlap; the links centre in the space between. Wider
   screens keep the pill-centred menu; below 1200 the links don't fit and the
   burger menu takes over (css/cart-drawer.css uses the same breakpoint). */
@media (min-width: 1200px) and (max-width: 1560px) {
  .site-header > .wrap { gap: 20px; }
  .title-area { position: static; transform: none; }
  ul.genesis-nav-menu.menu-primary { justify-content: flex-start; }
  ul.genesis-nav-menu.menu-primary > .menu-item { flex: none; }
  ul.genesis-nav-menu.menu-primary > .menu-item:first-child { margin-left: auto; }
  ul.genesis-nav-menu.menu-primary > .menu-item > a { white-space: nowrap; }
  ul.genesis-nav-menu.menu-primary > .menu-item--actions { position: static; transform: none; margin: -10px 0 -10px auto; } /* negative margins: the button must not make the bar taller */
}
@media (min-width: 1200px) and (max-width: 1359px) {
  ul.genesis-nav-menu.menu-primary { gap: 16px; }
  ul.genesis-nav-menu.menu-primary > .menu-item:not(.menu-item--actions) > a { font-size: 14px; }
}
