/* Park27 header — split nav: 4 items | logo | 4 items */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--brand, #69151A);
  color: var(--cream, #F2EDE5);
}

.site-header__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 40px;
  padding: 40px var(--gutter);
  height: max-content;
  max-width: 1920px;
  margin: 0 auto;
}

/* Logo (center column) */
.site-header__logo {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  color: var(--cream, #F2EDE5);
  text-decoration: none;
}

.site-header__logo img {
  height: 44px;
  width: auto;
  display: block;
}

/* Left and right nav share styles; left aligns to start, right aligns to end */
.site-header__nav {
  display: flex;
  align-items: center;
}

.site-header__nav:first-of-type {
  justify-content: flex-start;
}

.site-header__nav:last-of-type {
  justify-content: flex-end;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 36px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav > li {
  position: relative;
  margin: 0;
}

.site-nav > li > a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans, "Inter", sans-serif);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1.21;
  letter-spacing: 0.01em;
  color: var(--cream, #F2EDE5);
  text-decoration: none;
  padding: 8px 0;
  transition: opacity 0.2s ease;
}

.site-nav > li > a:hover,
.site-nav > li > a:focus-visible {
  opacity: 0.8;
}

.site-nav__caret {
  display: inline-block;
  flex-shrink: 0;
  margin-top: 1px;
  transition: transform 0.2s ease;
}

/* caret rotation on open/hover removed per design */

/* Desktop dropdown (sub-menu) */
.site-nav .sub-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav > li.menu-item-has-children > .sub-menu {
  position: absolute;
  top: 100%;
  left: -24px;
  min-width: 280px;
  padding: 10px;
  background: var(--bg, #F2EDE5);
  box-shadow: 0 18px 36px rgba(var(--ink-rgb), 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 10;
}

/* Invisible bridge to keep hover state when moving from parent link to dropdown */
.site-nav > li.menu-item-has-children > .sub-menu::before {
  content: '';
  position: absolute;
  top: -16px;
  left: 0;
  right: 0;
  height: 16px;
}

.site-nav > li.menu-item-has-children:hover > .sub-menu,
.site-nav > li.menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.site-nav .sub-menu li { margin: 0; }

.site-nav .sub-menu a {
  display: block;
  padding: 10px 0;
  font-family: var(--sans, "Inter", sans-serif);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1.21;
  color: var(--brand, #69151A);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.site-nav .sub-menu a:hover,
.site-nav .sub-menu a:focus-visible {
  opacity: 0.65;
}

/* Third level (desktop): nested sub-menu flies out to the LEFT of its parent
   (the first-level dropdown sits near the right edge, so there is no room on
   the right — but there is open space on the left). */
.site-nav .sub-menu > li {
  position: relative;
}

.site-nav .sub-menu .sub-menu {
  position: absolute;
  top: -10px;
  right: 102%;
  left: auto;
  min-width: 260px;
  padding: 10px;
  background: var(--bg, #F2EDE5);
  box-shadow: 0 18px 36px rgba(var(--ink-rgb), 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 11;
}

/* Invisible bridge so the flyout keeps hover while crossing the horizontal gap
   (gap is now on the RIGHT side of the flyout, between it and the parent). */
.site-nav .sub-menu li.menu-item-has-children > .sub-menu::before {
  content: '';
  position: absolute;
  top: 0;
  right: -16px;
  left: auto;
  bottom: 0;
  width: 16px;
}

.site-nav .sub-menu li.menu-item-has-children:hover > .sub-menu,
.site-nav .sub-menu li.menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}

/* Nested (2nd-level) parents: space the caret off the label and point it to
   the right to signal the flyout. */
.site-nav .sub-menu .site-nav__caret {
  margin-left: 6px;
}

.site-nav .sub-menu li.menu-item-has-children > a .site-nav__caret {
  transform: rotate(-90deg);
}

/* Hamburger toggle */
.site-header__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--cream, #F2EDE5);
  position: relative;
  z-index: 110; /* above the mobile drawer so the X stays clickable */
}

.site-header__toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: transform 0.2s, opacity 0.2s;
}

.site-header__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.site-header__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
.site-header__mobile-nav {
  display: none;
}

/* Offset content below fixed header */
body { padding-top: 124px; }

/* WP admin bar present: shift the fixed header below it and grow --header-h
   so sticky-parallax sections (which use top: var(--header-h)) stay in sync.
   Admin bar is 32px on viewports > 782px, 46px below that — same breakpoint
   WP uses internally. */
body.admin-bar .site-header { top: 32px; }
body.admin-bar { --header-h: 156px; padding-top: 124px; }

/* Tablet */
@media (max-width: 1200px) {
  .site-header__inner {/* padding: 0 32px; */gap: 24px;}
  .site-nav { gap: 24px; }
  .site-nav > li > a { font-size: 0.9375rem; }
}

/* Mobile */
@media (max-width: 991px) {
  .site-header__inner {
    grid-template-columns: 1fr auto auto;
    padding: 0 20px;
    height: 90px;
  }

  body { padding-top: 90px; }
  body.admin-bar { --header-h: 122px; padding-top: 90px; }

  .site-header__nav { display: none; }

  .site-header__logo { justify-self: start; grid-column: 1; }
  .site-header__toggle { display: flex; grid-column: 3; }

  .site-header__logo img { height: 36px; }

  /* Side drawer from the right (gregory-forman pattern) */
  .site-header__mobile-nav {
    display: block;
    position: fixed;
    top: 0;
    right: -100%;
    width: 90%;
    max-width: 400px;
    height: 100vh;
    background: var(--brand, #69151A);
    /* side padding trimmed 30→24px so the longest submenu label clears its
       caret on one line down to ~360px-wide phones. */
    padding: 96px 24px 30px;
    overflow-y: auto;
    transition: right 0.35s ease;
    z-index: 105;
  }

  body.admin-bar .site-header__mobile-nav {
    top: 32px;
    height: calc(100vh - 32px);
  }

  .site-header__mobile-nav.is-open {
    right: 0;
  }

  body.nav-open {
    overflow: hidden;
  }

  .site-nav--mobile {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
  }

  .site-nav--mobile > li {
    width: 100%;
    border-bottom: 1px solid rgba(var(--bg-rgb), 0.12);
  }

  .site-nav--mobile > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    font-size: 1.125rem;
    color: var(--cream, #F2EDE5);
    text-decoration: none;
  }

  /* Mobile sub-menu accordion — selectors must match the desktop sub-menu
     specificity (3 classes) to override its position/background/visibility. */
  .site-nav.site-nav--mobile > li.menu-item-has-children > .sub-menu {
    position: static;
    list-style: none;
    margin: 0;
    padding: 0 0 12px 16px;
    min-width: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: none;
    display: none;
  }

  .site-nav.site-nav--mobile > li.menu-item-has-children > .sub-menu::before {
    display: none; /* kill the desktop hover bridge inside the drawer */
  }

  .site-nav.site-nav--mobile > li.menu-item-has-children.is-open > .sub-menu {
    display: block;
  }

  .site-nav.site-nav--mobile > li.menu-item-has-children > .sub-menu li {
    border-bottom: 0;
  }

  .site-nav.site-nav--mobile > li.menu-item-has-children > .sub-menu a {
    display: block;
    padding: 10px 0;
    font-size: 0.9375rem;
    font-weight: 300;
    color: var(--cream, #F2EDE5);
    text-decoration: none;
    opacity: 0.85;
    background: transparent;
  }

  .site-nav.site-nav--mobile > li.menu-item-has-children > .sub-menu a:hover,
  .site-nav.site-nav--mobile > li.menu-item-has-children > .sub-menu a:focus-visible {
    opacity: 1;
    background: transparent;
  }

  /* Mobile third-level accordion — override the desktop side-flyout back to a
     static, collapsed list nested one indent deeper than the second level.
     4 classes beat the 3-class desktop nested-flyout rule. */
  .site-nav.site-nav--mobile .sub-menu .sub-menu {
    position: static;
    margin: 0;
    padding: 0 0 8px 16px;
    min-width: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: none;
    display: none;
  }

  .site-nav.site-nav--mobile .sub-menu li.menu-item-has-children > .sub-menu::before {
    display: none; /* no hover bridge inside the drawer */
  }

  .site-nav.site-nav--mobile .sub-menu li.menu-item-has-children.is-open > .sub-menu {
    display: block;
  }

  .site-nav.site-nav--mobile .sub-menu .sub-menu a {
    font-size: 0.875rem;
    opacity: 0.7;
  }

  /* In the drawer the accordion expands downward, so keep the caret pointing
     down (override the desktop right-rotation). The 6px label gap still applies. */
  .site-nav.site-nav--mobile .sub-menu li.menu-item-has-children > a .site-nav__caret {
    transform: none;
  }
}

/* WP admin bar grows to 46px on viewports <= 782px (WP's own breakpoint).
   Bump header offset + drawer top so they sit below the bar. */
@media screen and (max-width: 782px) {
  body.admin-bar .site-header { top: 46px; }
  body.admin-bar { --header-h: 136px; padding-top: 90px; }
  body.admin-bar .site-header__mobile-nav { top: 46px; height: calc(100vh - 46px); }
}

/* WordPress switches the admin bar to absolute below 600px. Keep it fixed so
   the fixed theme header does not leave a 46px gap after scrolling. */
@media screen and (max-width: 600px) {
  #wpadminbar {
    position: fixed;
  }
}
