/* ============================================================
   Header — Utility bar + Main bar + Mobile nav
   ============================================================ */

/* --- Sticky wrapper --- */
.apoh-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
}

/* ── Admin bar: always fixed + header offset ──
   WordPress makes the admin bar position:absolute on mobile (<600px),
   causing it to scroll away. Override so both admin bar and header
   stay sticky at all times. Header sits right below the admin bar. */
.admin-bar #wpadminbar { position: fixed !important; }
.admin-bar .apoh-header { top: 32px; }
@media screen and (max-width: 782px) {
  .admin-bar .apoh-header { top: 46px; }
}

/* --- Utility bar --- */
.apoh-utility-bar {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
}

.apoh-utility-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  font-size: var(--fs-caption);
  color: var(--fg-2);
  max-width: 1280px;
}

.apoh-utility-bar__left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.apoh-utility-bar__location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.apoh-utility-bar__location svg {
  flex-shrink: 0;
}

.apoh-utility-bar__sep {
  color: var(--apoh-gray-4);
}

.apoh-utility-bar__right {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.apoh-utility-bar__menu {
  display: flex;
  align-items: center;
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.apoh-utility-bar__right a {
  color: var(--fg-2);
  text-decoration: none;
  font-size: var(--fs-caption);
}

.apoh-utility-bar__right a:hover {
  color: var(--fg-link);
  text-decoration: none;
}

.apoh-utility-bar__divider {
  color: var(--border-strong);
}

/* Override for wp_nav_menu output in utility bar */
.apoh-utility-bar__right .menu-item {
  display: inline;
  list-style: none;
  margin-top: 0; /* Reset base.css li + li margin */
}
.apoh-utility-bar__right .menu-item + .menu-item::before {
  content: '|';
  margin: 0 10px;
  color: var(--border-strong);
}
.apoh-utility-bar__right .menu-item a {
  color: var(--fg-2);
  text-decoration: none;
  font-size: var(--fs-caption);
}
.apoh-utility-bar__right .menu-item a:hover {
  color: var(--fg-link);
}

/* --- Main bar --- */
.apoh-main-bar { position: relative; z-index: 50; background: var(--bg-surface); }

.apoh-main-bar__inner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-top: 14px;
  padding-bottom: 14px;
  max-width: 1280px;
}

.apoh-main-bar__logo {
  flex: 0 0 auto;
  display: block;
  line-height: 0;
}

.apoh-main-bar__logo img {
  height: 44px;
  width: auto;
}

/* --- Primary nav --- */
.apoh-nav__close { display: none; }
.apoh-nav__expand { display: none; }

.apoh-nav {
  flex: 1;
  display: flex;
  justify-content: center;
  /* Prevent overflow clipping dropdowns */
  overflow: visible;
}

.apoh-nav__list {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.apoh-nav__item {
  position: relative;
  margin-top: 0; /* Reset base.css li + li margin */
}

.apoh-nav__link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  color: #3D3F47;
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

/* Remove default focus ring on nav items (Safari shows a blue box on tap).
   Keyboard focus gets a subtle ring via :focus-visible. */
.apoh-nav__link:focus,
.apoh-nav__expand:focus {
  outline: none;
}
.apoh-nav__link:focus-visible,
.apoh-nav__expand:focus-visible {
  outline: 2px solid var(--apoh-blue);
  outline-offset: 2px;
}

.apoh-nav__link:hover,
.apoh-nav__item--has-dropdown:hover > .apoh-nav__link {
  background: #F0F5FB;
  color: var(--apoh-blue);
  text-decoration: none;
}

.apoh-nav__item--current > .apoh-nav__link {
  font-weight: 800;
  color: var(--apoh-blue);
  box-shadow: inset 0 -2px 0 var(--apoh-green);
}

.apoh-nav__chevron {
  opacity: 0.55;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: middle;
  transition: transform var(--dur-fast);
}

/* Rotate chevron when dropdown is open */
.apoh-nav__item--has-dropdown:hover > .apoh-nav__link > .apoh-nav__chevron {
  transform: rotate(180deg);
  opacity: 0.8;
}

/* --- Dropdown panel --- */
.apoh-nav__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 6px;
  min-width: 260px;
  z-index: 50;
  display: none;
}

/* No-JS: show on hover/focus-within */
.apoh-nav__item--has-dropdown:hover > .apoh-nav__dropdown,
.apoh-nav__item--has-dropdown:focus-within > .apoh-nav__dropdown {
  display: block;
}

.apoh-nav__dropdown-list {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(31, 42, 61, 0.14);
  padding: 8px;
  list-style: none;
  margin: 0;
}

.apoh-nav__dropdown-item {
  list-style: none;
  margin-top: 0; /* Reset base.css li + li margin */
}

.apoh-nav__dropdown-link {
  display: block;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #3D3F47;
  text-decoration: none;
  border-radius: 8px;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.apoh-nav__dropdown-link:hover {
  background: #F0F5FB;
  color: var(--apoh-blue);
  text-decoration: none;
}

/* --- Right actions --- */
.apoh-main-bar__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.apoh-main-bar__cta {
  box-shadow: 0 4px 14px rgba(137, 190, 64, 0.3);
}

/* --- Mobile hamburger toggle --- */
.apoh-mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 4px;
  cursor: pointer;
  text-decoration: none;
}

.apoh-mobile-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--fg-1);
  border-radius: 1px;
  transition: transform var(--dur-base) var(--ease-out);
}

/* --- Responsive --- */
@media (max-width: 1320px) {
  .apoh-utility-bar {
    display: none;
  }

  .apoh-nav {
    display: none;
  }

  .apoh-mobile-toggle {
    display: flex;
  }

  /* No-JS fallback: show nav when targeted */
  .apoh-nav:target,
  .apoh-nav.is-open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface);
    z-index: 100;
    padding: var(--space-8);
    padding-top: 16px;
    padding-bottom: 80px;
    overflow-y: auto;
  }

  /* Close button inside nav panel */
  .apoh-nav__close {
    display: block;
    margin-left: auto;
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #1F2A3D;
    cursor: pointer;
    padding: 8px 12px;
    margin-bottom: 8px;
  }

  .apoh-nav:target .apoh-nav__list,
  .apoh-nav.is-open .apoh-nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .apoh-nav:target .apoh-nav__link,
  .apoh-nav.is-open .apoh-nav__link {
    padding: 14px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--border-hairline);
  }

  /* Dropdowns: collapsed by default on mobile, toggled via .is-expanded */
  .apoh-nav:target .apoh-nav__dropdown,
  .apoh-nav.is-open .apoh-nav__dropdown {
    display: none;
    position: static;
    padding-top: 0;
    min-width: auto;
  }

  .apoh-nav:target .apoh-nav__item--has-dropdown.is-expanded > .apoh-nav__dropdown,
  .apoh-nav.is-open .apoh-nav__item--has-dropdown.is-expanded > .apoh-nav__dropdown {
    display: block;
  }

  .apoh-nav:target .apoh-nav__dropdown-list,
  .apoh-nav.is-open .apoh-nav__dropdown-list {
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0 0 8px 16px;
  }

  /* Mobile expand toggle button */
  .apoh-nav__expand {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-hairline);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    color: #1F2A3D;
    position: absolute;
    right: 0;
    top: 8px;
  }

  /* Make nav items position relative for the expand button */
  .apoh-nav.is-open .apoh-nav__item--has-dropdown,
  .apoh-nav:target .apoh-nav__item--has-dropdown {
    position: relative;
    padding-right: 48px;
  }

  /* Hide the inline desktop chevron on mobile */
  .apoh-nav__chevron--desktop { display: none; }

  /* Rotate chevron when expanded */
  .apoh-nav__item--has-dropdown.is-expanded > .apoh-nav__expand .apoh-nav__chevron {
    transform: rotate(180deg);
  }

  .apoh-main-bar__actions .apoh-phone-cta {
    display: none;
  }

  /* Push mobile nav panel below admin bar */
  .admin-bar .apoh-nav:target,
  .admin-bar .apoh-nav.is-open {
    top: 46px;
  }
}

@media (max-width: 480px) {
  .apoh-main-bar__logo img {
    height: 36px;
  }

  .apoh-main-bar__actions .apoh-main-bar__cta {
    font-size: 12px;
    padding: 8px 14px;
  }
}
