/**
 * Friends of Bulgaria - Header & Navigation Styles
 * Mobile-first approach with sticky header, hamburger menu, and slide-out panel.
 * Requirements: 3.14, 4.2
 *
 * @package Friends_of_Bulgaria
 * @since   1.0.0
 */

/* =========================================
   Site Header - Sticky
   ========================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--fob-line);
  transition: box-shadow 0.3s ease;
}

.site-header--scrolled {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* =========================================
   Header Container - Flexbox Layout
   ========================================= */

.site-header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--fob-header-height);
  gap: 18px;
}

/* =========================================
   Site Branding — stacked wordmark lockup
   ========================================= */

.site-branding {
  flex-shrink: 0;
}

.site-branding__link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-branding__lockup {
  display: block;
}

.site-branding__name {
  display: block;
  font-family: var(--fob-serif);
  font-size: 1.14rem;
  font-weight: var(--fob-font-weight-semibold);
  line-height: 1.02;
  letter-spacing: var(--fob-tracking-heading);
  color: var(--fob-ink);
}

.site-branding__rule {
  display: block;
  width: 118px;
  height: 3px;
  margin: 4px 0 5px;
  background-color: var(--fob-red);
  border-radius: 1px;
}

/**
 * Second rule, closing the lockup beneath the strapline. Hairline-thin so it
 * reads as an underscore to the strapline rather than a second brand bar —
 * the 3px rule above the strapline stays the heavier of the two.
 *
 * The lockup is shrink-to-fit around its widest child — the strapline — so
 * 100% makes this rule run exactly the strapline's width.
 */
.site-branding__rule--under {
  width: 100%;
  height: 1px;
  margin: 5px 0 0;
  border-radius: 0;
}

.site-branding__tagline {
  display: block;
  font-family: var(--fob-sans);
  font-size: 0.6rem;
  font-weight: var(--fob-font-weight-semibold);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  line-height: 1.4;
  color: var(--fob-ink-soft);
}

/* Inverted lockup for the dark footer band */
.site-branding__lockup--footer .site-branding__name {
  font-size: 1.2rem;
  color: var(--fob-white);
}

.site-branding__lockup--footer .site-branding__tagline {
  color: var(--fob-grey-3);
}

/* =========================================
   Menu Toggle (Hamburger) - Visible on Mobile
   ========================================= */

.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: var(--fob-space-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  order: 2;
}

.menu-toggle__bar {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--fob-dark);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hamburger animation - open state */
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(2) {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* =========================================
   Primary Navigation - Mobile (Default)
   ========================================= */

.primary-navigation {
  position: fixed;
  top: 0;
  right: 0;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  height: 100dvh;
  background-color: var(--fob-white);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1001;
  overflow-y: auto;
  padding: var(--fob-space-xxl) var(--fob-space-lg) var(--fob-space-lg);
}

.primary-navigation--open {
  transform: translateX(0);
}

.primary-navigation__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.primary-navigation__list li {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.primary-navigation__list a {
  display: block;
  padding: var(--fob-space-md) 0;
  color: var(--fob-color-text);
  text-decoration: none;
  font-size: var(--fob-font-size-base);
  font-weight: var(--fob-font-weight-medium);
  transition: color 0.2s ease;
}

/**
 * As in the concept: soft grey at rest, red on hover.
 *
 * The current item is weighted rather than recoloured — same-page anchors are
 * stripped of their current classes in theme-setup.php, but the genuine
 * current page should not read as permanently hovered.
 */
.primary-navigation__list a:hover,
.primary-navigation__list a:focus {
  color: var(--fob-red);
}

.primary-navigation__list .current-menu-item > a,
.primary-navigation__list .current_page_item > a {
  color: var(--fob-ink-soft);
  font-weight: var(--fob-font-weight-semibold);
}

.primary-navigation__list .current-menu-item > a:hover,
.primary-navigation__list .current_page_item > a:hover {
  color: var(--fob-red);
}

/* Mobile overlay behind slide-out panel */
.nav-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 999;
}

.nav-overlay--active {
  opacity: 1;
  visibility: visible;
}

/* =========================================
   Header Donate Button
   ========================================= */

/**
 * The header CTA is desktop-only. Below the nav breakpoint the wordmark,
 * the button and the burger together exceed a phone viewport, pushing the
 * burger off-screen and making the menu unreachable — so the button is
 * hidden here and reappears inside the slide-out panel instead.
 */
.header-donate-btn {
  display: none;
  flex-shrink: 0;
  order: 1;
  font-size: 0.95rem;
  padding: 10px 20px;
  white-space: nowrap;
}

.primary-navigation__donate {
  display: inline-flex;
  width: 100%;
  margin-top: var(--fob-space-lg);
}

/* =========================================
   Desktop Styles

   The concept switches to the inline bar at 980px, but this build's wordmark
   and menu labels are wider. Measured at the current menu: the wordmark (225px)
   plus the seven items (692px) plus the Donate button (91px) and their gaps
   need 1100px before the button stops overrunning the container.

   If menu labels change, re-check this figure — it is content-dependent.
   ========================================= */

@media (min-width: 1100px) {
  /* Hide hamburger on desktop */
  .menu-toggle {
    display: none;
  }

  /* Navigation shown inline on desktop */
  .primary-navigation {
    position: static;
    width: auto;
    max-width: none;
    height: auto;
    background-color: transparent;
    box-shadow: none;
    transform: none;
    transition: none;
    overflow-y: visible;
    padding: 0;
    flex: 1;
    display: flex;
    justify-content: center;
  }

  .primary-navigation__list {
    display: flex;
    align-items: center;
    gap: 22px;
  }

  .primary-navigation__list li {
    border-bottom: none;
    position: relative;
  }

  .primary-navigation__list a {
    display: inline-flex;
    align-items: center;
    padding: var(--fob-space-xs) 0;
    font-size: 0.92rem;
    font-weight: var(--fob-font-weight-medium);
    color: var(--fob-ink-soft);
    white-space: nowrap;
  }

  .primary-navigation__list a:hover,
  .primary-navigation__list a:focus {
    color: var(--fob-red);
  }

  /* =========================================
     Dropdown submenus
     ========================================= */

  .primary-navigation__list .menu-item-has-children > a::after {
    content: "\25BE";
    font-size: 0.66em;
    margin-left: 5px;
    opacity: 0.55;
  }

  .primary-navigation__list .sub-menu {
    position: absolute;
    top: 100%;
    left: -14px;
    min-width: 212px;
    padding: 8px 0;
    margin: 0;
    background-color: var(--fob-white);
    border: 1px solid var(--fob-line);
    border-radius: var(--fob-radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.09);
    display: none;
    flex-direction: column;
    z-index: 10;
  }

  .primary-navigation__list .menu-item-has-children:hover > .sub-menu,
  .primary-navigation__list .menu-item-has-children:focus-within > .sub-menu {
    display: flex;
  }

  .primary-navigation__list .sub-menu a {
    display: block;
    width: 100%;
    padding: 9px 18px;
    font-size: 0.88rem;
  }

  .primary-navigation__list .sub-menu a:hover,
  .primary-navigation__list .sub-menu a:focus {
    background-color: var(--fob-grey-1);
    color: var(--fob-red);
  }

  /* Hide overlay on desktop */
  .nav-overlay {
    display: none;
  }

  /* Donate button ordering */
  .header-donate-btn {
    display: inline-flex;
    order: 3;
  }

  /* The panel's own CTA is redundant once the header button is back. */
  .primary-navigation__donate {
    display: none;
  }
}

/* =========================================
   Focus Styles for Accessibility
   ========================================= */

.menu-toggle:focus-visible {
  outline: 2px solid var(--fob-color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.primary-navigation__list a:focus-visible {
  outline: 2px solid var(--fob-color-primary);
  outline-offset: 4px;
  border-radius: 2px;
}
