/*
 * Global site header / primary navigation.
 *
 * Independent clean-room implementation, written directly from a
 * dictated written specification (selectors, computed declarations,
 * cascade facts, and load-order notes only). No prior version of this
 * file -- on any branch, in any diff, or in any capture -- was read,
 * viewed, or referenced while authoring the rules below.
 *
 * Covers the fixed top bar (#main-nav.nav-bar), the desktop link row
 * with its Services / Service Areas hover-and-focus dropdowns, and the
 * off-canvas mobile menu with its accordion sections. Color, radius,
 * spacing and timing values all come from custom properties defined
 * upstream; nothing in this file declares a custom property of its
 * own.
 */

.nav-bar {
  position: fixed;
  top: calc(var(--wp-admin-bar-offset, 0px) + var(--wp-admin-bar-gap, 0px));
  right: 0;
  bottom: auto;
  left: 0;
  z-index: 100;
  border-bottom-color: var(--ocf-border-light);
  border-bottom-style: solid;
  border-bottom-width: 1px;
  background-color: color-mix(in srgb, var(--ocf-bg) 96%, transparent);
}

.nav-inner {
  justify-content: space-between;
  align-items: center;
  display: flex;
  min-height: 4.5rem;
  row-gap: 1.25rem;
  column-gap: 1.25rem;
}

/* Shared layout for every inline cluster in the header: a horizontal
   flex row, centered on the cross axis. */
.nav-logo,
.nav-right,
.nav-links,
.nav-phone,
.nav-dropdown-trigger,
.dropdown-item,
.mobile-link,
.mobile-accordion-trigger {
  align-items: center;
  display: flex;
}

.nav-logo {
  min-width: 0;
  color: var(--ocf-heading);
  font-weight: var(--font-weight-bold);
}

.nav-logo-img { max-height: 2.75rem; width: auto; }

.nav-logo-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  font-size: var(--font-label-size);
  color: var(--ocf-heading);
  row-gap: clamp(1.25rem, 2.2vw, 2rem);
  column-gap: clamp(1.25rem, 2.2vw, 2rem);
}

.nav-link {
  padding-bottom: 0.75rem;
  padding-top: 0.75rem;
}

.nav-link,
.nav-dropdown-trigger {
  font-weight: var(--font-weight-semibold);
}

.nav-right {
  column-gap: 0.75rem;
  row-gap: 0.75rem;
}

.nav-phone {
  font-size: var(--font-label-size);
  color: var(--ocf-heading);
  column-gap: 0.4rem;
  row-gap: 0.4rem;
}

/* Small glyphs across the header share a fixed box and never flex, so
   they hold their size under a tight flex row. */
.nav-phone svg,
.nav-dropdown-chevron,
.dropdown-item svg,
.dropdown-item-icon svg,
.mobile-accordion-chevron,
.mobile-phone svg {
  flex-basis: auto;
  flex-grow: 0;
  flex-shrink: 0;
  height: 1rem;
  width: 1rem;
}

/* The Services/Areas trigger chevron is smaller than the shared icon
   box above. Kept AFTER that shared rule on purpose: same
   specificity, so source order decides and this wins for
   .nav-dropdown-chevron only. */
.nav-dropdown-chevron {
  height: 0.75rem;
  width: 0.75rem;
}

.nav-divider {
  height: 1.5rem;
  width: 1px;
  background-color: var(--ocf-border-light);
}

.nav-mobile-btn {
  color: var(--ocf-heading);
  display: none;
  border-width: 0;
  background-color: transparent;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  column-gap: 0.25rem;
  row-gap: 0.25rem;
}

/* Hidden by default: no pointer events, transparent, nudged down a
   touch; fades and slides into place on reveal. */
.nav-dropdown-panel {
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 14rem;
  transform: translateY(0.5rem);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

/* Revealed on pointer hover over the wrapper, or when keyboard focus
   lands anywhere inside it (so the menu stays reachable without a
   mouse). */
.nav-dropdown:hover .nav-dropdown-panel,
.nav-dropdown:focus-within .nav-dropdown-panel {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.dropdown-menu {
  display: grid;
  row-gap: 0.25rem;
  column-gap: 0.25rem;
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
  border-bottom-right-radius: var(--card-radius);
  border-bottom-left-radius: var(--card-radius);
  border-color: var(--ocf-border-light);
  border-style: solid;
  border-width: 1px;
  background-color: var(--ocf-bg);
  padding-top: 0.5rem;
  padding-right: 0.5rem;
  padding-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.dropdown-menu--wide {
  min-width: 18rem;
}

.dropdown-item {
  color: var(--ocf-heading);
  row-gap: 0.5rem;
  column-gap: 0.5rem;
  padding-top: 0.65rem;
  padding-right: 0.75rem;
  padding-bottom: 0.65rem;
  padding-left: 0.75rem;
}

.dropdown-item:hover {
  color: var(--ocf-heading);
  background-color: var(--ocf-bg-alt);
}

.mobile-menu {
  border-top-color: var(--ocf-border-light);
  border-top-style: solid;
  border-top-width: 1px;
  display: none;
  background-color: var(--ocf-bg);
}

.mobile-menu-inner {
  display: grid;
  row-gap: 0.25rem;
  column-gap: 0.25rem;
  padding-top: 1rem;
  padding-right: var(--container-pad);
  padding-bottom: 1rem;
  padding-left: var(--container-pad);
}

.mobile-link,
.mobile-accordion-trigger {
  text-align: left;
  justify-content: space-between;
  width: 100%;
  color: var(--ocf-heading);
  border-width: 0;
  background-color: transparent;
  padding-top: 0.75rem;
  padding-right: 0;
  padding-bottom: 0.75rem;
  padding-left: 0;
}

.mobile-accordion-panel {
  padding-left: 1rem;
  display: none;
}

/* Opened by chrome.js: toggles .is-open on the accordion wrapper when
   its trigger button is clicked. */
.mobile-accordion.is-open .mobile-accordion-panel {
  display: grid;
}

.mobile-actions {
  display: grid;
  row-gap: 0.75rem;
  column-gap: 0.75rem;
  margin-top: 0.75rem;
  border-top-color: var(--ocf-border-light);
  border-top-style: solid;
  border-top-width: 1px;
  padding-top: 1rem;
}

.mobile-cta,
.mobile-phone {
  align-items: center;
  justify-content: center;
  display: flex;
  min-height: 3rem;
  font-weight: var(--font-weight-bold);
  border-top-left-radius: var(--button-radius);
  border-top-right-radius: var(--button-radius);
  border-bottom-right-radius: var(--button-radius);
  border-bottom-left-radius: var(--button-radius);
}

.mobile-cta {
  color: var(--ocf-primary-contrast);
  background-color: var(--ocf-primary);
}

.mobile-phone {
  row-gap: 0.5rem;
  column-gap: 0.5rem;
  color: var(--ocf-heading);
  border-color: var(--ocf-border-light);
  border-style: solid;
  border-width: 1px;
  background-color: var(--ocf-bg);
}

.mobile-phone-icon {
  align-items: center;
  display: inline-flex;
}

/* Below this width the desktop link row / phone / divider / CTA give
   way to the hamburger button and the off-canvas menu above. */
@media (max-width: 980px) {
  .nav-links,
  .nav-phone,
  .nav-divider,
  .nav-cta {
    display: none;
  }

  .nav-mobile-btn {
    display: inline-flex;
  }

  .mobile-menu {
    overscroll-behavior-y: contain;
    overflow-y: auto;
    max-height: calc(100vh - var(--wp-admin-bar-offset, 0px) - var(--wp-admin-bar-gap, 0px) - 4rem);
    -webkit-overflow-scrolling: touch;
  }

  /* Dynamic viewport height tracks mobile browser chrome better than
     100vh; falls back to the rule above where dvh isn't supported.
     Kept after it on purpose so it wins when the feature query
     matches. */
  @supports (height: 100dvh) {
    .mobile-menu {
      max-height: calc(100dvh - var(--wp-admin-bar-offset, 0px) - var(--wp-admin-bar-gap, 0px) - 4rem);
    }
  }

  .mobile-menu.is-open {
    display: block;
  }

  .nav-inner {
    min-height: 4rem;
  }
}
