/* ==========================================================================
   HEADER.CSS
   Top utility bar, main header, primary navigation, Products dropdown,
   and the mobile navigation drawer. This markup is identical on every
   page (see documents/component-reference.md) — only the active-link
   state changes per page.
   ========================================================================== */

/* ---------------------------------------------------------------------
   1. TOP UTILITY BAR
   Phone (left), two email addresses (right) — no social icons or
   secondary links here (social icons live only in the footer; see
   footer.css).
   --------------------------------------------------------------------- */
.utility-bar {
  background-color: var(--color-navy-900);
  color: var(--color-text-on-dark-muted);
  font-size: var(--fs-body-sm);
}

.utility-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-2);
}

/* Two approved phone numbers sit side by side where there is room and
   wrap/stack (never clip) on very narrow screens; each link keeps its
   own 24px+ line box so both stay tappable. */
.utility-bar__phones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--space-4);
  row-gap: 0;
  min-width: 0;
}
.utility-bar__phones .utility-bar__phone {
  min-height: 24px;
}

.utility-bar__phone,
.utility-bar__email {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-on-dark-muted);
  white-space: nowrap;
  transition: color var(--transition-fast);
}
.utility-bar__phone:hover,
.utility-bar__email:hover {
  color: var(--color-white);
}
.utility-bar__phone i,
.utility-bar__email i {
  font-size: 13px;
}

.utility-bar__emails {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

/* Mobile-first: only the phone shows by default to avoid crowding a
   320-375px header; responsive.css reveals the primary email from
   Tablet upward, and the secondary email from Desktop upward. */
.utility-bar__emails {
  display: none;
}

/* ---------------------------------------------------------------------
   2. MAIN HEADER
   --------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background-color: var(--color-white);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}

/* Toggled by navigation.js once the page scrolls past the utility
   bar — a slightly stronger shadow so the sticky header reads as
   "elevated" above the page content. No layout/height change, so
   this never causes layout shift. */
.site-header.is-scrolled {
  box-shadow: var(--shadow-md);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding-block: var(--space-3);
}

/* Logo
   The logo is the one flexible item in the header row, so it must be
   able to give up width (min-width: 0) while the mark itself never
   shrinks — a flex item with width: auto + max-width: 100% (from the
   global img rule) otherwise collapses to nothing before the text does,
   which is how the mark vanished at 320-414px. */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.site-logo__mark {
  flex: 0 0 auto;
}

.site-logo__mark picture {
  display: block;
}

/* Supplied icon is a wide (~2.3:1) transparent mark: fix the height, let the
   width follow the intrinsic ratio so it is never stretched. */
.site-logo__mark img {
  display: block;
  height: 36px;
  width: auto;
  max-width: none;
  aspect-ratio: 112 / 48;
}

/* Navy artwork disappears on the dark footer, so it sits on a clean white
   backing (artwork itself is not recoloured). */
.site-logo__mark--backed {
  background-color: var(--color-white);
  border-radius: var(--radius-md, 8px);
  padding: 6px 8px;
}

.mobile-nav__brand {
  gap: var(--space-2);
}

.site-logo__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.site-logo__name {
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  font-size: 1.25rem;
  color: var(--color-navy-900);
}

/* Mobile-first: hidden below 480px (responsive.css reveals it) — see
   the note there. */
.site-logo__tagline {
  display: none;
  font-size: 0.6875rem;
  font-weight: var(--fw-medium);
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------
   3. PRIMARY NAVIGATION (mobile-first)
   Hidden by default (mobile/large-mobile/tablet use the hamburger +
   drawer instead); responsive.css reveals it at the Laptop breakpoint.
   --------------------------------------------------------------------- */
.primary-nav {
  display: none;
  align-items: center;
  /* The links keep their natural width; if the row is ever too tight it
     is the logo's tagline that wraps, never the navigation. */
  flex-shrink: 0;
}

.primary-nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.primary-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--fw-medium);
  color: var(--color-text-heading);
  padding-block: var(--space-2);
  position: relative;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.primary-nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background-color: var(--color-teal-500);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-fast);
}

.primary-nav__link:hover,
.primary-nav__link[aria-current="page"] {
  color: var(--color-teal-brand);
}
.primary-nav__link:hover::after,
.primary-nav__link[aria-current="page"]::after {
  transform: scaleX(1);
}

.primary-nav__chevron {
  font-size: 10px;
  transition: transform var(--transition-fast);
}

.primary-nav__item--dropdown:hover .primary-nav__chevron,
.primary-nav__item--dropdown.is-open .primary-nav__chevron {
  transform: rotate(180deg);
}

/* Same chevron-flip treatment for the mobile drawer's Products
   accordion toggle, which shares the .primary-nav__chevron icon but
   sits inside a different wrapper (.mobile-nav__item, not
   .primary-nav__item--dropdown) — without this rule the desktop
   dropdown's chevron animated on open but the mobile one never did. */
.mobile-nav__item--expanded .primary-nav__chevron {
  transform: rotate(180deg);
}

/* ---------------------------------------------------------------------
   4. PRODUCTS DROPDOWN
   --------------------------------------------------------------------- */
.primary-nav__item--dropdown {
  position: relative;
}

.products-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 260px;
  background-color: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--transition-base), transform var(--transition-base),
    visibility var(--transition-base);
  z-index: var(--z-dropdown);
}

/* Visibility is driven only by the JS-managed .is-open class, not by
   a CSS :hover rule — navigation.js already opens the dropdown on
   mouseenter for hover-capable pointers (and on click/keyboard/touch
   otherwise), so a separate :hover selector here would let the
   dropdown stay visibly open from pure CSS even after JS has closed
   it (e.g. Escape while the pointer is still resting over the menu),
   leaving computed visibility and aria-expanded out of sync. */
.primary-nav__item--dropdown.is-open .products-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.products-dropdown__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-heading);
  font-weight: var(--fw-medium);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.products-dropdown__link:hover,
.products-dropdown__link[aria-current="page"] {
  background-color: var(--color-teal-100);
  color: var(--color-teal-brand);
}

.products-dropdown__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--color-navy-900);
  color: var(--color-white);
  flex-shrink: 0;
}
.products-dropdown__icon i {
  font-size: 14px;
}

/* ---------------------------------------------------------------------
   5. HEADER ACTIONS (Request a Quote button + hamburger)
   --------------------------------------------------------------------- */
.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  /* The quote button / hamburger are essential controls: they keep
     their size and the logo is what yields space. */
  flex-shrink: 0;
}

/* Uppercase text is now part of the shared .btn base class (see
   components.css) since it's used consistently across every button
   sitewide, not just navigation — this scoped override is no longer
   needed. */

/* Mobile-first: the hamburger is visible by default; responsive.css
   hides it again once .primary-nav takes over at the Laptop tier. */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
}

.nav-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  background-color: var(--color-navy-900);
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.nav-toggle.is-active .nav-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.is-active .nav-toggle__bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle.is-active .nav-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------------------------------------------------------------------
   6. MOBILE NAVIGATION DRAWER
   --------------------------------------------------------------------- */
.mobile-nav {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(340px, 86vw);
  height: 100vh;
  /* 100vh on mobile browsers includes the area behind the collapsing
     URL bar, which pushes the drawer's last links/CTA below the visible
     screen; dvh tracks what is actually visible. Browsers without dvh
     keep the 100vh line above. */
  height: 100dvh;
  background-color: var(--color-white);
  /* The closed drawer is parked just off the right edge with
     translateX(100%). Its 60px-blur modal shadow used to stay on in that
     state, so a band of it spilled back INTO the viewport as a soft dark
     fade down the whole right edge of every page (header included), at
     every width. The shadow now exists only while the drawer is open. */
  box-shadow: none;
  z-index: var(--z-mobile-nav);
  transform: translateX(100%);
  /* Stage 7A: the closed drawer is also visibility:hidden (applied after the
     slide-out finishes), so it is not rendered, not focusable and not hit-
     testable even if `inert` were unsupported. It is position:fixed, so it
     never added scrollable width; this just makes the closed state explicit
     now that body no longer clips the page sideways. */
  visibility: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base),
    visibility 0s linear var(--transition-base);
  overflow-y: auto;
  padding: var(--space-5);
}

.mobile-nav.is-open {
  box-shadow: var(--shadow-modal);
  transform: translateX(0);
  visibility: visible;
  transition-delay: 0s;
}

.mobile-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.mobile-nav__close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--color-surface-light);
}
.mobile-nav__close i {
  font-size: 16px;
}

.mobile-nav__list > li {
  border-bottom: 1px solid var(--color-border);
}

.mobile-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
  font-weight: var(--fw-medium);
  color: var(--color-text-heading);
}

.mobile-nav__link[aria-current="page"] {
  color: var(--color-teal-brand);
}

/* Accordion submenu for Products inside the mobile drawer */
/* Collapsed state is also visibility:hidden, so the four category links
   are out of the tab order and the accessibility tree until the
   accordion is opened (max-height:0 + overflow:hidden alone left them
   keyboard-focusable while invisible). Visibility flips immediately on
   open and only after the collapse transition on close. The expanded
   cap is in rem (it scales with text size) and generous, rather than a
   fixed 320px that clipped the last item once labels wrapped to more
   lines at narrow widths or larger text sizes. */
.mobile-nav__submenu {
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height var(--transition-base), visibility 0s linear var(--transition-base);
}

.mobile-nav__item--expanded .mobile-nav__submenu {
  max-height: 40rem;
  visibility: visible;
  transition: max-height var(--transition-base), visibility 0s;
}

.mobile-nav__submenu-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
  padding-left: var(--space-4);
  font-weight: var(--fw-medium);
  color: var(--color-text-body);
}
.mobile-nav__submenu-link:hover,
.mobile-nav__submenu-link[aria-current="page"] {
  color: var(--color-teal-brand);
}

.mobile-nav__submenu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
  color: var(--color-teal-500);
  font-size: 15px;
}

.mobile-nav__cta {
  margin-top: var(--space-5);
}

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-navy-50);
  z-index: calc(var(--z-mobile-nav) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}
.mobile-nav-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* Products accordion toggle inside the mobile drawer — replaces what
   was previously an inline style="width:100%; text-align:left;" on
   the button in the generated HTML. */
.mobile-nav__submenu-toggle {
  width: 100%;
  text-align: left;
}

/* Laptop band (nav visible, logo column narrow): keep all five categories in the
   tagline by tightening its type slightly so it wraps to two lines, not three. */
@media (min-width: 960px) and (max-width: 1199px) {
  .site-header .site-logo__tagline {
    font-size: 0.625rem;
    letter-spacing: 0;
    text-wrap: balance;
  }
}

/* ---------------------------------------------------------------------
   HEADER BRAND (Batch 31b, corrected in 31c)
   ONLY the "HM UNIQUE" name moves: logo above, name centred below it.
   The category tagline stays where it was: to the right of the logo/name
   block, with its previous responsive visibility (hidden below 480px,
   shown from 480px up; see .site-logo__tagline and responsive.css). The
   text wrapper uses display:contents so the logo, name and tagline are
   cells of one small grid. Scoped to the site header and the drawer
   brand, so the footer brand keeps its own layout. Logo artwork is not
   touched: only its display height changes.
   --------------------------------------------------------------------- */
.site-header .site-logo {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  justify-content: start;
  align-items: center;
  column-gap: var(--space-3);
  row-gap: 2px;
}
.site-header .site-logo__text {
  display: contents;
}
.site-header .site-logo__mark {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
}
.site-header .site-logo__name {
  grid-column: 1;
  grid-row: 2;
  justify-self: center;
  font-size: 1.125rem;
  line-height: 1.1;
  white-space: nowrap;
  text-align: center;
}
.site-header .site-logo__tagline {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  max-width: 16rem;
  text-align: left;
  line-height: 1.25;
}
.site-header .site-logo__mark img {
  height: 32px;
}
@media (min-width: 480px) {
  .site-header .site-logo__mark img {
    height: 38px;
  }
}
@media (min-width: 960px) and (max-width: 1199px) {
  .site-header .site-logo__tagline {
    max-width: 13rem;
  }
}

/* Mobile drawer brand: logo above "HM UNIQUE", no tagline. */
.mobile-nav__brand {
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
.mobile-nav__brand .site-logo__mark img {
  height: 32px;
}
.mobile-nav__brand .site-logo__name {
  font-size: 1.125rem;
  line-height: 1.1;
}
