/**
 * Site header: utility bar + primary nav + mobile off-canvas menu.
 */

/* Just a wrapper — .header-utility and .header-main each handle their
   own position/background independently below, so the top utility
   bar can scroll away normally while only the logo/nav row stays
   pinned. */
.site-header {
  position: relative;
}

.header-utility {
  background: var(--color-bg-muted);
  color: var(--color-primary-600);
  font-size: var(--fs-eyebrow);
}

/* Homepage (and any page with its own hero/header photo): taken out
   of flow, at the true top of the page, so it doesn't push the hero
   photo down — but absolute, not fixed/sticky, so it scrolls away
   normally with the rest of the page instead of staying pinned like
   .header-main below. On pages that were never transparent, this
   never applies and the utility bar just sits in normal flow above
   the (sticky) main row, same effect via ordinary layout. */
.site-header--transparent .header-utility {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 51;
}

/* Solid white + dark logo/text is the default look everywhere — this
   is also what a transparent-over-hero header (below) falls back to
   the moment it's scrolled, or was never transparent to begin with
   (no hero photo on this page). Only background/box-shadow transition
   — top tracks the scroll position 1:1 below (see .site-header--
   transparent .header-main) and must never lag behind it. */
.header-main {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-white);
  box-shadow: var(--shadow-sm);
  transition: background var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

/* Homepage (and any page with its own hero/header photo): floats over
   that photo instead of sitting in normal document flow above it.
   Fixed — not sticky, and unconditionally, whether currently
   transparent or (once scrolled) solid below — so toggling between
   those two never changes whether this reserves document-flow space
   (it never does), avoiding a layout jump right at the scroll
   threshold. --header-utility-height (see assets/js/header-scroll.js)
   isn't just the bar's height — it's continuously recomputed on every
   scroll frame as however much of that height hasn't scrolled off yet
   (down to 0), so this stays pixel-flush against the bar's bottom
   edge as it scrolls away, rather than snapping into place late and
   leaving a gap between them for part of the scroll. */
.site-header--transparent .header-main {
  position: fixed;
  top: var(--header-utility-height, 0px);
  left: 0;
  right: 0;
}

/* Everything below only holds while transparent AND not yet fully
   scrolled (offset above has reached 0) — see header-scroll.js, which
   adds .site-header--scrolled at exactly that point. Past that point
   (or on a page that was never transparent), all of this stops
   applying and the solid/dark defaults above take over. */
.site-header--transparent:not(.site-header--scrolled) .header-main {
  background: transparent;
  box-shadow: none;
}

.site-header--transparent:not(.site-header--scrolled) .primary-nav__list a {
  color: var(--color-white);
}

.site-header--transparent:not(.site-header--scrolled) .primary-nav__list a::after {
  background: var(--color-white);
}

/* The submenu dropdown is always a solid white card regardless of the
   transparent header, so its links need to stay dark — otherwise
   they'd inherit the white nav-link color above and vanish. Not
   scroll-guarded like the rest here: this needs to hold in both
   transparent sub-states, and is a no-op once .primary-nav__list a
   itself is no longer white. */
.site-header--transparent .primary-nav__list .sub-menu a {
  color: var(--color-heading);
}

.site-header--transparent:not(.site-header--scrolled) .menu-toggle__bar,
.site-header--transparent:not(.site-header--scrolled) .menu-toggle__bar::before,
.site-header--transparent:not(.site-header--scrolled) .menu-toggle__bar::after {
  background: var(--color-white);
}

.header-utility__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2xs) var(--space-md);
  padding-block: var(--space-2xs);
}

.header-utility__location {
  margin: 0;
  font-weight: 700;
}

.header-utility__right {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  flex-wrap: wrap;
}

.header-utility__phone {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-weight: 700;
  transition: color var(--duration-fast) var(--ease-standard);
}

.header-utility__phone:hover,
.header-utility__phone:focus-visible {
  color: var(--color-primary-700);
}

.header-utility__divider {
  color: var(--color-primary-600);
  opacity: 0.5;
}

.header-utility__badge {
  font-weight: 400;
}

/* Below ~480px, keep only the click-to-call link — the address and
   badge are both repeated in the footer, and cramming all three onto
   one line at phone width forces awkward wrapping. */
@media (max-width: 30rem) {
  .header-utility__location,
  .header-utility__divider,
  .header-utility__badge {
    display: none;
  }
}

.header-main {
  min-height: var(--header-height);
  margin-top: 10px;
}

/* Dropped once actually pinned at the top (.site-header--scrolled —
   see header-scroll.js) — .header-main is positioned (sticky, or
   fixed while transparent) by that point, and a margin here would
   offset it that much further down from wherever `top` places it,
   leaving a gap above it. No transition on this: it needs to land
   exactly when .site-header--scrolled does, same as `top` above. */
.site-header--scrolled .header-main {
  margin-top: 0;
}

.header-main__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: var(--header-height);
}

.site-logo {
  display: flex;
  align-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: calc(var(--fs-h5) * 1.875);
  color: var(--color-heading);
  flex-shrink: 0;
}

.site-logo img {
  max-height: 83px; /* 44px base logo size, +25% twice, then +20% (44 -> 55 -> 69 -> 83) */
  width: auto;
}

/* Phones: 15% smaller (83 -> ~71px). */
@media (max-width: 36rem) {
  .site-logo img {
    max-height: 71px;
  }
}

/* Two logos are always in the markup (see nav.php); which one is
   visible follows the same transparent/scrolled state as the rest of
   the header. .site-logo__dark shows by default — it's what's correct
   everywhere except while transparent-and-unscrolled below. */
.site-logo__light {
  display: none;
}

.site-header--transparent:not(.site-header--scrolled) .site-logo__light {
  display: block;
}

.site-header--transparent:not(.site-header--scrolled) .site-logo__dark {
  display: none;
}

.primary-nav {
  display: none;
}

.primary-nav__list {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 0.4rem + 1.6vw, 2.25rem);
  flex-wrap: wrap;
}

.primary-nav__list a {
  position: relative;
  font-weight: 600;
  font-size: var(--fs-body);
  color: var(--color-heading);
  padding-block: var(--space-2xs);
  transition: color var(--duration-fast) var(--ease-standard);
}

.primary-nav__list a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-base) var(--ease-standard),
    background var(--duration-fast) var(--ease-standard);
}

.primary-nav__list a:hover::after,
.primary-nav__list a:focus-visible::after,
.primary-nav__list .current-menu-item > a::after {
  transform: scaleX(1);
}

/* ---- Desktop submenus: open on hover or keyboard focus ---- */
.primary-nav__list > .menu-item-has-children {
  position: relative;
}

.primary-nav__list > .menu-item-has-children > a {
  padding-right: 1.15em;
}

.primary-nav__list > .menu-item-has-children > a::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-75%) rotate(45deg);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.primary-nav__list > .menu-item-has-children:hover > a::before,
.primary-nav__list > .menu-item-has-children:focus-within > a::before {
  transform: translateY(-25%) rotate(-135deg);
}

.primary-nav__list .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  min-width: 15rem;
  margin-top: var(--space-xs);
  padding: var(--space-3xs);
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--duration-base) var(--ease-standard),
    transform var(--duration-base) var(--ease-standard),
    visibility var(--duration-base);
}

/* Closes the visual gap left by the margin above so moving the
   pointer from the parent link down into the dropdown doesn't cross a
   dead zone and lose :hover partway there. */
.primary-nav__list .sub-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: var(--space-xs);
}

.primary-nav__list > .menu-item-has-children:last-child .sub-menu {
  left: auto;
  right: 0;
}

.primary-nav__list > .menu-item-has-children:hover > .sub-menu,
.primary-nav__list > .menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sub-menu li {
  list-style: none;
}

.sub-menu a {
  position: relative;
  display: block;
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--fs-body);
  color: var(--color-heading);
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.sub-menu a::after {
  content: none;
}

.sub-menu a:hover,
.sub-menu a:focus-visible {
  background: var(--color-bg-muted);
  color: var(--color-primary-600);
}

@media (prefers-reduced-motion: reduce) {
  .primary-nav__list .sub-menu {
    transition: none;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.header-actions .btn {
  display: none;
}

/* Colors come from .btn's own defaults (branded blue fill, white
   text) — this only needs to adjust layout. */
.header-cta-btn {
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

/* Overlapping the hero, while still transparent: transparent fill
   with a solid white border instead of the solid blue pill. */
.site-header--transparent:not(.site-header--scrolled) .header-cta-btn {
  --btn-bg: transparent;
  --btn-bg-hover: var(--color-white);
  --btn-border: var(--color-white);
}

.site-header--transparent:not(.site-header--scrolled) .header-cta-btn:hover,
.site-header--transparent:not(.site-header--scrolled) .header-cta-btn:focus-visible {
  --btn-fg: var(--color-ink);
}

.header-icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-border);
  color: var(--color-heading);
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.header-icon-btn svg {
  width: 18px;
  height: 18px;
}

.header-icon-btn:hover,
.header-icon-btn:focus-visible {
  background: var(--color-primary-600);
  border-color: var(--color-primary-600);
  color: var(--color-white);
}

.site-header--transparent:not(.site-header--scrolled) .header-icon-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--color-white);
}

/* ---- Mobile menu toggle ---- */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
}

.menu-toggle__bar {
  position: relative;
  width: 22px;
  height: 2px;
  background: var(--color-heading);
  transition: background var(--duration-fast) var(--ease-standard);
}

.menu-toggle__bar::before,
.menu-toggle__bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 22px;
  height: 2px;
  background: var(--color-heading);
  transition: transform var(--duration-base) var(--ease-standard);
}

.menu-toggle__bar::before {
  top: -7px;
}

.menu-toggle__bar::after {
  top: 7px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar {
  background: transparent;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar::before {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar::after {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---- Mobile off-canvas panel ---- */
.mobile-nav {
  position: fixed;
  inset: 0;
  z-index: 60;
  visibility: hidden;
}

.mobile-nav__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 37, 36, 0.55);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
}

.mobile-nav__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 86vw);
  background: var(--color-white);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease-standard);
  overflow-y: auto;
}

.mobile-nav.is-open {
  visibility: visible;
}

.mobile-nav.is-open .mobile-nav__backdrop {
  opacity: 1;
}

.mobile-nav.is-open .mobile-nav__panel {
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav__panel,
  .mobile-nav__backdrop {
    transition: none;
  }
}

.mobile-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-nav__close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.mobile-nav__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.mobile-nav__list--more {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.mobile-nav__list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding-block: var(--space-xs);
  font-weight: 600;
  font-size: var(--fs-h6);
  color: var(--color-heading);
  border-bottom: 1px solid var(--color-border);
}

/* ---- Mobile/off-canvas submenus (nav-submenu.js) ---- */
.mobile-nav .menu-item-has-children {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
}

.mobile-nav .menu-item-has-children > a {
  flex: 1;
  min-width: 0;
  border-bottom: none;
}

.mobile-submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  color: var(--color-heading);
}

.mobile-submenu-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast) var(--ease-standard);
}

.mobile-nav .menu-item-has-children.is-submenu-open > .mobile-submenu-toggle svg {
  transform: rotate(90deg);
}

.mobile-nav .menu-item-has-children > .sub-menu {
  flex-basis: 100%;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  padding-left: var(--space-sm);
  transition: max-height var(--duration-base) var(--ease-standard);
}

.mobile-nav .menu-item-has-children.is-submenu-open > .sub-menu {
  max-height: 40rem;
}

.mobile-nav .sub-menu a {
  min-height: 40px;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom-color: var(--color-border);
}

.mobile-nav .sub-menu li:last-child a {
  border-bottom: none;
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav .menu-item-has-children > .sub-menu {
    transition: none;
  }
}

.mobile-nav__utility {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: var(--fs-body);
  color: var(--color-text-muted);
}

@media (min-width: 62rem) {
  .header-main__inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-md);
  }

  .primary-nav {
    display: block;
    justify-self: center;
    min-width: 0;
  }

  .header-actions .btn {
    display: inline-flex;
  }

  .header-icon-btn {
    display: inline-flex;
  }

  .menu-toggle {
    display: none;
  }
}
