/* Global header — 3 tiers. Only Tier 2 is sticky; Tier 1 and Tier 3 scroll
   away normally. Also holds the drawer-dialog system (mobile menu, mobile
   categories, RFQ quote list) and the shared quantity stepper, because those
   ship on every page. */

.site-header {
  position: relative;
  z-index: 40;
  background: var(--color-bg);
}

.header-tier1__inner,
.header-tier2__inner,
.header-tier3__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: var(--space-5);
}

/* ---------- Tier 1 — utility bar ---------- */
.header-tier1 {
  background: var(--color-navy-deep);
  color: var(--color-on-navy-muted);
  font-size: 0.8125rem;
}
.header-tier1__inner {
  height: var(--header-tier1-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.header-tier1__contact,
.header-tier1__meta {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-width: 0;
}
.header-tier1__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  white-space: nowrap;
  transition: color 0.15s var(--ease-standard);
}
.header-tier1__link:hover { color: #fff; }
.header-tier1__link svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--color-electric-light); }
.header-tier1__gst { font-size: 0.75rem; opacity: 0.85; white-space: nowrap; }

/* ---------- Tier 2 — main header (sticky) ---------- */
.header-tier2 {
  position: sticky;
  top: 0;
  z-index: 45;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow 0.2s var(--ease-standard);
}
.header-tier2.is-scrolled { box-shadow: var(--shadow-md); }

.header-tier2__inner {
  height: var(--header-tier2-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-6);
}

.header-logo { display: flex; align-items: center; flex-shrink: 0; }
.header-logo__img { height: 54px; width: auto; }

.header-search {
  display: flex;
  width: 100%;
  max-width: 680px;
  justify-self: center;
}
.header-search__field { position: relative; flex: 1; min-width: 0; }
.header-search__input {
  width: 100%;
  height: 46px;
  border: 1.5px solid var(--color-border-input);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  padding-inline: var(--space-4);
  background: var(--color-bg);
  font-size: 0.9375rem;
  transition: border-color 0.15s var(--ease-standard), box-shadow 0.15s var(--ease-standard);
}
.header-search__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}
/* Rotating example-query hint, layered over the input (a native `placeholder`
   attribute can't be animated). Hidden once the input has a value or focus,
   so it never fights with what the visitor is typing. */
.header-search__hint {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - var(--space-4) * 2);
}
.header-search__input:focus + .header-search__hint,
.header-search__input:not(:placeholder-shown) + .header-search__hint { display: none; }
/* No-JS fallback shows the static placeholder attribute; once JS runs, the
   animated hint span takes over and the native placeholder is hidden so the
   two never overlap. */
.js .header-search__input::placeholder { color: transparent; }
.header-search__btn {
  height: 46px;
  padding-inline: var(--space-5);
  background: var(--color-primary);
  color: #fff;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: background 0.15s var(--ease-standard);
}
.header-search__btn:hover { background: var(--color-primary-hover); }
.header-search__btn svg { width: 18px; height: 18px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.header-action--basket {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  padding-inline: var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-navy);
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: border-color 0.15s var(--ease-standard), background 0.15s var(--ease-standard), color 0.15s var(--ease-standard);
}
.header-action--basket:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-tint); }
.header-action--basket svg { width: 20px; height: 20px; }
.header-action__count {
  min-width: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.header-action__count.is-bumped { animation: count-bump 0.25s var(--ease-out); }
@keyframes count-bump { 0% { transform: scale(1); } 45% { transform: scale(1.15); } 100% { transform: scale(1); } }
.header-action--cta { height: 44px; padding-inline: var(--space-5); font-size: 0.875rem; }

.header-search-toggle,
.header-tier3__mobile-triggers { display: none; }

/* ---------- Tier 3 — category + primary nav ---------- */
.header-tier3 {
  position: relative;
  background: var(--color-navy);
}
.header-tier3__inner {
  height: var(--header-tier3-h);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.mega-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding-inline: var(--space-4);
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s var(--ease-standard);
}
.mega-menu-trigger:hover { background: var(--color-primary-hover); }
.mega-menu-trigger svg { width: 16px; height: 16px; }
.mega-menu-trigger svg:last-child { transition: transform 0.15s var(--ease-standard); }
.mega-menu-trigger[aria-expanded="true"] svg:last-child { transform: rotate(180deg); }

.header-nav { flex: 1; min-width: 0; }
.header-nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.header-nav__list a {
  position: relative;
  display: block;
  padding-inline: var(--space-4);
  line-height: var(--header-tier3-h);
  font-size: 0.9375rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
  white-space: nowrap;
  transition: color 0.15s var(--ease-standard);
}
.header-nav__list a:hover,
.header-nav__list a.is-active { color: #fff; }
.header-nav__list a.is-active::after {
  content: "";
  position: absolute;
  left: var(--space-4);
  right: var(--space-4);
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--color-electric-light);
}

/* ============ Mega-menu panel ============
   Desktop: click dropdown anchored under the trigger.
   Mobile: full <dialog> drawer (see drawer rules below). */
.mega-menu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 46;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.mega-menu-panel.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
/* The panel is a WHITE surface inside the navy .on-navy nav bar, so it needs
   the primary-blue focus ring back (the light-blue one is for navy only). */
.mega-menu-panel :focus-visible { outline-color: var(--color-primary); }
.mega-menu-panel__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-6) var(--space-6);
}
.mega-menu-group__title {
  font-size: 0.9375rem;
  font-weight: 700;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-primary-tint);
}
.mega-menu-group__title a { color: var(--color-navy); transition: color 0.15s var(--ease-standard); }
.mega-menu-group__title a:hover { color: var(--color-primary); }
/* Recursive category branches (assets/partials/mega-menu-render.php) — one
   .mega-menu-branch per depth level. Depth 1 = sub-categories (sub-heads),
   depth 2 = sub-sub-categories (the leaf links). */
.mega-menu-branch { display: flex; flex-direction: column; gap: var(--space-2); }
.mega-menu-branch--depth-1 > li > a {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
}
.mega-menu-branch--depth-1 > li + li { margin-top: var(--space-2); }
.mega-menu-branch--depth-2 { margin-top: 4px; gap: 2px; }
.mega-menu-branch--depth-2 a {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--color-text-muted);
}
.mega-menu-branch a { transition: color 0.15s var(--ease-standard); }
.mega-menu-branch a:hover { color: var(--color-primary); }

/* ============ Drawers ============
   All native <dialog>, per this project's CLAUDE.md non-negotiable.
   dialog[open] renders instantly (no native transition), so the sliding
   motion is applied to the inner panel via GSAP (assets/js/header.js). */
.drawer-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
}
.drawer-dialog__panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(92vw, 400px);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
#mega-menu-dialog .drawer-dialog__panel { width: min(92vw, 420px); }
.drawer-dialog--right .drawer-dialog__panel { left: auto; right: 0; width: min(96vw, 460px); }

.drawer-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.drawer-dialog__title { font-size: 1.0625rem; font-weight: 700; color: var(--color-navy); }
.drawer-dialog__count { font-weight: 500; color: var(--color-text-muted); font-size: 0.875rem; }
.drawer-dialog__close {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--color-text-muted);
}
.drawer-dialog__close:hover { background: var(--color-section-tint); color: var(--color-text); }
.drawer-dialog__close svg { width: 20px; height: 20px; }
.drawer-dialog__body { flex: 1; overflow-y: auto; padding: var(--space-5); }

.mobile-nav__list a {
  display: block;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  color: var(--color-navy);
}
.mobile-nav__list a[aria-current="page"] { color: var(--color-primary); }
.mobile-nav__actions { display: grid; gap: var(--space-3); margin-top: var(--space-6); }
/* The mobile "All Categories" dialog reuses mega-menu.php's markup inside
   .drawer-dialog__body — override its desktop 4-column grid to a single
   stacked column at drawer width. */
.drawer-dialog__body .mega-menu-panel__inner { display: block; padding: 0; }
.drawer-dialog__body .mega-menu-group { margin-bottom: var(--space-5); }

/* ---------- RFQ quote-list drawer ---------- */
.rfq-drawer__body { padding-block: var(--space-2); }
.rfq-item {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: var(--space-3);
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.rfq-item__thumb {
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}
.rfq-item__thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.rfq-item__thumb svg { width: 26px; height: 26px; color: var(--color-border-strong); }
.rfq-item__title { display: block; font-size: 0.875rem; font-weight: 600; line-height: 1.35; color: var(--color-navy); }
a.rfq-item__title:hover { color: var(--color-primary); }
.rfq-item__meta { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; }
.rfq-item__controls { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.rfq-item__remove {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rfq-item__remove:hover { color: var(--color-error); }

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: #fff;
}
.qty button {
  width: 32px; height: 34px;
  font-size: 1.125rem;
  line-height: 1;
  color: var(--color-navy);
}
.qty button:hover { background: var(--color-primary-tint); color: var(--color-primary); }
.qty input {
  width: 58px; height: 34px;
  border: none;
  border-inline: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}
.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { outline: 2px solid var(--color-primary); outline-offset: -2px; }

.rfq-drawer__footer {
  padding: var(--space-4) var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: grid;
  gap: var(--space-3);
  background: var(--color-bg);
}
.rfq-drawer__footer .btn { width: 100%; }
.rfq-drawer__clear {
  justify-self: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rfq-drawer__clear:hover { color: var(--color-error); }

/* Empty-cart upsell: PRODUCT.md's deliberate improvement over the reference
   site — an empty list points somewhere useful instead of dead-ending. */
.rfq-empty { text-align: center; padding: var(--space-8) var(--space-4); color: var(--color-text-muted); }
.rfq-empty__title { font-size: 1.0625rem; font-weight: 700; color: var(--color-navy); margin-bottom: var(--space-2); }
.rfq-empty__links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin-top: var(--space-5); }

/* ============================= Tablet & mobile (≤1023px) =============================
   The 8-item primary nav + "All Categories" no longer fits, so the mobile
   pattern applies: two separate triggers ("All Categories" + "Menu"),
   never merged into one hamburger. */
@media (max-width: 1100px) {
  .header-action__label { display: none; }
  .header-action--basket { padding-inline: var(--space-3); }
  .header-tier1__gst { display: none; }
}

@media (max-width: 1023px) {
  .header-tier3__inner { gap: var(--space-2); }
  .mega-menu-trigger:not(.mega-menu-trigger--mobile),
  .header-nav { display: none; }
  .header-tier3__mobile-triggers {
    display: flex;
    width: 100%;
    gap: var(--space-2);
  }
  .mega-menu-trigger--mobile,
  .mobile-nav-trigger { flex: 1; justify-content: center; }
  .mobile-nav-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 36px;
    padding-inline: var(--space-4);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
  }
  .mobile-nav-trigger svg { width: 16px; height: 16px; }
  .mega-menu-panel { display: none; } /* mobile uses the dialog version instead */
}

@media (max-width: 900px) {
  .header-action--cta { width: 44px; padding: 0; }
  .header-action--cta span { display: none; }
}

/* ============================= Mobile (<768px) ============================= */
@media (max-width: 767px) {
  .header-tier1__inner { padding-inline: var(--space-4); }
  .header-tier1__email { display: none; }

  .header-tier2__inner {
    padding-inline: var(--space-4);
    grid-template-columns: 1fr auto auto;
    gap: var(--space-2);
    height: auto;
    min-height: var(--header-tier2-h);
  }
  .header-logo__img { height: 40px; }
  /* Expanding search grows Tier 2 by a second explicit grid row instead of
     an absolutely-positioned overlay — an overlay's stacking context painted
     over Tier 3 (build-log, earlier pass). Explicit grid-row placement avoids
     the stacking issue entirely. */
  .header-logo, .header-search-toggle, .header-actions { grid-row: 1; }
  .header-search { display: none; grid-row: 2; grid-column: 1 / -1; }
  .header-search.is-expanded {
    display: flex;
    max-width: none;
    padding-bottom: var(--space-3);
  }
  .header-search-toggle {
    display: inline-flex;
    width: 44px; height: 44px;
    align-items: center; justify-content: center;
    border-radius: 50%;
  }
  .header-search-toggle:hover { background: var(--color-section-tint); }
  .header-search-toggle svg { width: 22px; height: 22px; }
  .header-action--cta { display: none; }
  .header-tier3__inner { padding-inline: var(--space-4); }
}
