/* Shared storefront header. Load after the legacy storefront/navigation styles.
   Only the enhanced mobile panel needs JS geometry; native details stays usable. */
.unified-header {
  position: sticky;
  top: 0;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 70;
  overflow: visible;
  background: var(--header, #24292d);
}

html:has(.unified-header) {
  scroll-padding-top: calc(var(--header-height, 94px) + 12px);
}

.unified-header .header-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: none;
  min-height: 94px;
  margin: 0;
  padding: 18px 30px;
  gap: 24px;
}

.unified-header .site-logo {
  display: flex;
  flex: 0 0 244px;
  align-items: center;
  width: 244px;
  min-width: 0;
  max-width: 244px;
  min-height: 44px;
  margin: 0;
}

.unified-header .site-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.unified-header .site-navigation,
.unified-header .site-navigation[open] {
  position: static;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 0 0 auto;
  padding: 0;
  order: 0;
}

.unified-header .site-navigation > summary {
  display: none;
}

.unified-header .header-menu-panel {
  position: static;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  width: auto;
  min-width: 0;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  gap: 16px;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.unified-header .header-menu-panel > .primary-menu {
  flex-wrap: wrap;
  gap: clamp(8px, 1.25vw, 24px);
}

.unified-header .header-menu-panel > .primary-menu > li {
  flex: 0 0 auto;
}

.unified-header .header-tool {
  position: relative;
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  max-width: none;
  margin: 0;
  padding: 0;
  gap: 0;
  order: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  font: inherit;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

.unified-header .header-tool::-webkit-details-marker {
  display: none;
}

.unified-header .header-tool::marker {
  content: '';
}

.unified-header .header-tool > svg {
  display: block;
  flex: 0 0 23px;
  width: 23px;
  height: 23px;
}

.unified-header .header-label {
  position: absolute;
  display: block;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.unified-header .header-tool:hover:not(:disabled) {
  background: #383328;
  color: var(--gold, #dfc48e);
}

.unified-header .header-tool:focus-visible {
  outline: 3px solid var(--gold, #dfc48e);
  outline-offset: 3px;
}

.unified-header .header-cart:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.unified-header .header-cart > .inquiry-count {
  position: absolute;
  top: -4px;
  right: -3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  min-height: 20px;
  margin: 0;
  padding: 1px 4px;
  border: 1px solid var(--gold, #dfc48e);
  border-radius: 999px;
  background: var(--gold, #dfc48e);
  color: #171512;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
}

.unified-header .header-tool[hidden],
.unified-header .inquiry-count[hidden] {
  display: none !important;
}

.unified-header .header-tool > svg.header-menu-close {
  display: none;
}

.unified-header .header-cart > .header-label {
  display: block;
}

body:has(.unified-header) > .skip-link:focus {
  z-index: 100;
}

@media (min-width: 1001px) {
  .unified-header .site-navigation,
  .unified-header .site-navigation[open] {
    position: static;
  }

  .unified-header .nav-branch[data-depth="1"] > .submenu-panel {
    top: 100%;
    right: 30px;
  }

  :root[data-header-enhanced="true"] .unified-header .nav-branch[data-depth="1"] > .submenu-panel {
    max-height: var(--header-panel-height, calc(100dvh - 140px - var(--warning-space, 110px) - 12px));
  }

  /* A no-JS user may close native details on mobile before resizing wider. */
  .unified-header .site-navigation:not([open]) > summary.header-tool {
    display: inline-flex;
  }
}

@media (min-width: 1001px) and (max-width: 1200px) {
  .unified-header .header-inner {
    gap: 16px;
    padding-inline: 20px;
  }

  .unified-header .nav-branch[data-depth="1"] > .submenu-panel {
    right: 20px;
  }

  .unified-header .site-logo {
    flex-basis: 185px;
    width: 185px;
    max-width: 185px;
  }

  .unified-header .header-menu-panel > .primary-menu {
    gap: 10px;
  }
}

@media (max-width: 1000px) {
  html:has(.unified-header) {
    scroll-padding-top: calc(var(--header-height, 62px) + 12px);
  }

  .unified-header .header-inner,
  .unified-header .header-inner:has(.public-inquiry-link) {
    min-height: 60px;
    padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
    gap: 6px;
  }

  .unified-header .site-logo {
    flex: 1 1 auto;
    width: auto;
    max-width: 196px;
    margin-right: auto;
  }

  .unified-header .site-navigation,
  .unified-header .site-navigation[open] {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    margin: 0;
    order: 0;
  }

  .unified-header .site-navigation > summary.header-tool {
    display: inline-flex;
    text-align: center;
    color: #fff;
  }

  .unified-header .site-navigation[open] > summary .header-menu-open {
    display: none;
  }

  .unified-header .site-navigation[open] > summary .header-menu-close {
    display: block;
  }

  .unified-header .header-menu-panel,
  .unified-header .site-navigation nav.header-menu-panel:has(.primary-menu) {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 40;
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: max(0px, calc(100dvh - 90px - var(--warning-space, 120px)));
    margin: 0;
    padding: 4px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    border: 0;
    border-bottom: 1px solid #78684b;
    background: var(--header, #24292d);
    box-shadow: 0 12px 24px #0008;
  }

  :root[data-header-enhanced="true"] .unified-header .header-menu-panel,
  :root[data-header-enhanced="true"] .unified-header .site-navigation nav.header-menu-panel:has(.primary-menu) {
    position: fixed;
    top: var(--header-panel-top, 60px);
    right: auto;
    left: var(--fixed-view-left, 0px);
    width: var(--fixed-view-width, 100vw);
    max-height: var(--header-panel-height, max(0px, calc(100dvh - 90px - var(--warning-space, 120px))));
  }

  .unified-header .site-navigation:not([open]) > .header-menu-panel {
    display: none;
  }

  .unified-header .header-menu-panel > .primary-menu {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .unified-header .header-menu-panel > a {
    display: block;
    min-height: 48px;
    padding: 12px;
    border-bottom: 1px solid var(--line, #46423b);
  }
}

@media (max-width: 767px) {
  .unified-header .header-menu-panel > a {
    min-height: 44px;
    padding: 6px 10px;
  }
}
