/* ==========================================================================
   Light Generation Ministry — Site Header
   Location: assets/css/header.css
   Depends on: assets/css/variables.css only. The mobile menu (previously
   Bootstrap's Offcanvas) is now a self-contained panel — see the
   "Offcanvas mobile menu" section below and lgmInitMobileMenu() in
   assets/js/main.js.

   Kept in its own file (per project spec) rather than folded into
   main.css, since the header is pixel-matched against a specific
   reference and evolves independently of the rest of the design system.
   ========================================================================== */

:root {
  /* The reference header uses a slate-blue background that doesn't match
     the rest of the site's brand palette (--lgm-dark-blue in
     variables.css), so it's scoped to a header-only token rather than
     overwriting the global brand variable — every other component
     (buttons, footer, cards) stays on the official brand colors.
     The accent, on the other hand, reuses the site's existing
     "Ministry Red" brand token (--lgm-red) rather than introducing a
     new color, per the brand guide's "never introduce additional
     colors" rule. */
  --lgm-header-bg: #263746;
  --lgm-header-bg-rgb: 38, 55, 70; /* same color as --lgm-header-bg, split out for rgba() alpha compositing below */
  --lgm-header-accent: var(--lgm-red);
  /* Cream/tan tone used for the logo wordmark and for nav-link
     hover/active text, matching the reference header's text color. */
  --lgm-header-text-accent: #D8CFB9;
  --lgm-header-height: 60px;
  --lgm-header-max-width: 1400px;
}

body {
  /* Compensates for the header being taken out of normal flow by
     position: fixed, so page content never starts underneath it. */
  padding-top: var(--lgm-header-height);
}

/* ==========================================================================
   Header shell
   ========================================================================== */

.lgm-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  height: var(--lgm-header-height);
  display: flex;
  align-items: center;
  /* Glassmorphism: translucent brand navy (not a foreign white/glass —
     keeps the header's established dark identity) + backdrop blur +
     a faint top-edge shine + a soft glow layered under the normal
     drop shadow. */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 40%),
    rgba(var(--lgm-header-bg-rgb), 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.18),
    0 0 24px rgba(216, 207, 185, 0.06);
  transition: box-shadow var(--lgm-transition-med), background-color var(--lgm-transition-med);
}

/* Backdrop-filter isn't supported everywhere (older browsers) — fall
   back to a fully solid header rather than a half-transparent one
   sitting over unblurred content, which would look broken/muddy. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lgm-header {
    background: var(--lgm-header-bg);
  }
}

.lgm-header-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  width: 100%;
  max-width: var(--lgm-header-max-width);
  margin-inline: auto;
  padding-inline: var(--lgm-space-md);
}

.lgm-header-left {
  display: flex;
  align-items: center;
  gap: var(--lgm-space-md);
  justify-self: start;
}

.lgm-header-center {
  justify-self: center;
}

.lgm-header-right {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-self: end;
}

/* ==========================================================================
   Left — primary navigation
   ========================================================================== */

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

.lgm-nav-list a {
  position: relative;
  display: inline-block;
  padding-bottom: 4px;
  color: var(--lgm-white);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.2px;
  text-decoration: none;
  transition: color var(--lgm-transition-med);
}

/* Underline animation grows outward from the center on hover/focus. */
.lgm-nav-list a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--lgm-header-text-accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--lgm-transition-med);
}

.lgm-nav-list a:hover,
.lgm-nav-list a:focus-visible,
.lgm-nav-list a[aria-current="page"] {
  color: var(--lgm-header-text-accent);
}

.lgm-nav-list a:hover::after,
.lgm-nav-list a:focus-visible::after,
.lgm-nav-list a[aria-current="page"]::after {
  transform: scaleX(1);
}

/* Top-level items with a submenu are the positioning anchor for the
   dropdown panel below them. */
.lgm-nav-list li {
  position: relative;
}

/* Small chevron button next to "About" / "Media" — toggles the
   dropdown independently of the link itself, so the link still
   navigates normally on click/tap (a standard accessible disclosure
   pattern). Injected next to the link by lgmInitDropdownMenus() in
   main.js for both this fallback menu and a real WordPress menu. */
.lgm-submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.lgm-submenu-toggle .lgm-icon {
  width: 12px;
  height: 12px;
  transition: transform 250ms ease-out;
}

.lgm-submenu-toggle[aria-expanded="true"] .lgm-icon {
  transform: rotate(180deg);
}

/* ==========================================================================
   Dropdown submenu panel — DESKTOP ONLY. Every selector here is scoped
   under .lgm-nav-list on purpose: the mobile offcanvas has its own,
   completely separate accordion styling further down (search
   ".lgm-offcanvas-nav .sub-menu"), and previously some of these rules
   were unscoped, so a 3-class desktop selector like
   ".menu-item-has-children.is-open > .sub-menu" was specific enough to
   beat the mobile override and slide the mobile accordion off-screen
   with a leftover transform: translateX(-50%). Scoping under
   .lgm-nav-list makes that class of bug structurally impossible —
   these rules simply don't match anything inside the offcanvas.
   ========================================================================== */

.lgm-nav-list .sub-menu {
  position: absolute;
  top: calc(100% + 20px);
  left: 50%;
  z-index: 200;
  width: 380px;
  max-width: 400px;
  margin: 0;
  padding: 28px;
  list-style: none;
  background: var(--lgm-white);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 14px;
  row-gap: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 10px) scale(0.98);
  transform-origin: top center;
  transition: opacity 250ms ease-out, transform 250ms ease-out, visibility 0s linear 250ms;
}

/* Open state — toggled entirely by main.js (hover-with-close-delay on
   desktop, tap-accordion on mobile, plus keyboard), not a mix of CSS
   :hover and JS state, so there's one source of truth for "is this
   open" and no risk of the two disagreeing. */
.lgm-nav-list .menu-item-has-children.is-open > .sub-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
  transition: opacity 250ms ease-out, transform 250ms ease-out, visibility 0s linear 0s;
}

/* Diamond pointer — small rotated square connecting the panel to the
   parent menu item, centered above the panel. */
.lgm-nav-list .sub-menu::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 14px;
  height: 14px;
  background: var(--lgm-white);
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 3px 0 0 0;
  transform: translateX(-50%) rotate(45deg);
}

.lgm-nav-list .sub-menu li {
  position: static;
}

.lgm-nav-list .sub-menu a {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--lgm-heading-color);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: normal;
  text-decoration: none;
  transition: color 250ms ease, transform 250ms ease;
}

.lgm-nav-list .sub-menu a:hover,
.lgm-nav-list .sub-menu a:focus-visible {
  color: var(--lgm-royal-blue);
  transform: translateX(4px);
}

/* Mobile menu trigger — opens the mobile nav panel (see main.js). Hidden on
   desktop/tablet, where the nav list is shown inline instead. */
.lgm-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--lgm-white);
  cursor: pointer;
  transition: color var(--lgm-transition-fast);
}

.lgm-nav-toggle .lgm-icon {
  width: 22px;
  height: 22px;
}

.lgm-nav-toggle:hover,
.lgm-nav-toggle:focus-visible {
  color: var(--lgm-header-accent);
}

/* ==========================================================================
   Center — logo lockup
   ========================================================================== */

.lgm-logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--lgm-white);
  line-height: 1.15;
  text-decoration: none;
  transition: opacity var(--lgm-transition-fast);
}

.lgm-logo-lockup:hover {
  opacity: 0.88;
}

.lgm-logo-mark {
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--lgm-header-accent);
}

/* Auto-fits ANY uploaded logo image to the header, regardless of the
   file's native dimensions — this is what makes "upload any logo and
   it just fits" actually true, instead of relying on the admin to
   pre-crop it correctly. */
.lgm-logo-mark-custom {
  width: auto;
  height: 44px;
  max-width: 160px;
  object-fit: contain;
}

.lgm-logo-text-group {
  display: flex;
  flex-direction: column;
}

.lgm-logo-line {
  font-family: var(--lgm-font-heading);
  text-transform: uppercase;
  white-space: nowrap;
}

.lgm-logo-line-1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--lgm-header-text-accent);
}

.lgm-logo-line-2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--lgm-header-text-accent);
}

/* ==========================================================================
   Right — Instagram, Give, language switcher
   ========================================================================== */

.lgm-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--lgm-white);
  text-decoration: none;
}

.lgm-icon-link .lgm-icon {
  width: 22px;
  height: 22px;
  transition: color 300ms ease, transform 300ms ease;
}

.lgm-icon-link:hover .lgm-icon,
.lgm-icon-link:focus-visible .lgm-icon {
  color: var(--lgm-header-accent);
  transform: scale(1.08);
}

/* Give button — coin icon + "Give" text, matching the reference design.
   Kept as its own component (rather than reusing .lgm-icon-link) since
   it carries a visible label alongside the icon. */
.lgm-give-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lgm-white);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
}

.lgm-give-link .lgm-icon {
  width: 22px;
  height: 22px;
  flex: none;
  transition: color 300ms ease, transform 300ms ease;
}

.lgm-give-link-text {
  transition: color 300ms ease;
}

.lgm-give-link:hover .lgm-icon,
.lgm-give-link:focus-visible .lgm-icon {
  color: var(--lgm-header-accent);
  transform: scale(1.08);
}

.lgm-give-link:hover .lgm-give-link-text,
.lgm-give-link:focus-visible .lgm-give-link-text {
  color: var(--lgm-header-text-accent);
}

/* Single-button language toggle: a globe icon in a circle, with a small
   badge showing the language you'll switch TO. Stays visible in the
   fixed bar at every breakpoint, including mobile. */
.lgm-lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  padding: 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.lgm-lang-toggle-circle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: var(--lgm-white);
  transition: border-color var(--lgm-transition-fast);
}

.lgm-lang-toggle:hover .lgm-lang-toggle-circle,
.lgm-lang-toggle:focus-visible .lgm-lang-toggle-circle {
  border-color: var(--lgm-header-accent);
}

.lgm-lang-toggle-circle .lgm-icon {
  width: 16px;
  height: 16px;
}

.lgm-lang-toggle-code {
  position: absolute;
  bottom: -4px;
  right: -8px;
  background: var(--lgm-header-accent);
  color: var(--lgm-white);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.5;
  padding: 0 5px;
  border-radius: 999px;
  border: 1.5px solid var(--lgm-header-bg);
}

/* ==========================================================================
   Offcanvas mobile menu
   ========================================================================== */

.lgm-offcanvas-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10998;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.lgm-offcanvas-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lgm-offcanvas {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10999;
  width: min(320px, 85vw);
  display: flex;
  flex-direction: column;
  background: var(--lgm-header-bg);
  color: var(--lgm-white);
  box-shadow: var(--lgm-shadow-lg);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 300ms ease, visibility 0s linear 300ms;
}

.lgm-offcanvas.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 300ms ease, visibility 0s linear 0s;
}

.lgm-offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--lgm-space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.lgm-offcanvas-title {
  margin: 0;
  font-family: var(--lgm-font-heading);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lgm-white);
}

.lgm-offcanvas-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--lgm-white);
  cursor: pointer;
  transition: color 300ms ease;
}

.lgm-offcanvas-close .lgm-icon {
  width: 18px;
  height: 18px;
}

.lgm-offcanvas-close:hover,
.lgm-offcanvas-close:focus-visible {
  color: var(--lgm-header-accent);
}

.lgm-offcanvas-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--lgm-space-md);
}

.lgm-offcanvas-nav {
  list-style: none;
  margin: 0 0 var(--lgm-space-lg);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--lgm-space-sm);
}

.lgm-offcanvas-nav a {
  display: block;
  padding: 10px 0;
  color: var(--lgm-white);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: color var(--lgm-transition-fast), padding-left var(--lgm-transition-fast);
}

.lgm-offcanvas-nav a:hover,
.lgm-offcanvas-nav a:focus-visible,
.lgm-offcanvas-nav a[aria-current="page"] {
  color: var(--lgm-header-text-accent);
  padding-left: 6px;
}

/* Mobile accordion — inside the offcanvas, a submenu is NOT the
   floating white panel (no room for that in a 320px-wide slide-in
   drawer); it slides open inline, tap-to-expand/collapse, styled to
   match the dark offcanvas rather than the light desktop dropdown. */
.lgm-offcanvas-nav .menu-item-has-children > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lgm-offcanvas-nav .lgm-submenu-toggle {
  color: var(--lgm-white);
}

.lgm-offcanvas-nav .sub-menu {
  position: static;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  display: block;
  gap: 0;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease;
}

.lgm-offcanvas-nav .sub-menu::before {
  display: none;
}

.lgm-offcanvas-nav .menu-item-has-children.is-open > .sub-menu {
  max-height: 400px;
}

.lgm-offcanvas-nav .sub-menu a {
  padding: 8px 0 8px var(--lgm-space-md);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.6;
  border-bottom: none;
}

.lgm-offcanvas-nav .sub-menu a:hover,
.lgm-offcanvas-nav .sub-menu a:focus-visible {
  color: var(--lgm-header-text-accent);
  padding-left: calc(var(--lgm-space-md) + 4px);
  transform: none;
}

/* Scroll lock while the mobile menu is open. */
body.lgm-menu-open {
  overflow: hidden;
}

/* ==========================================================================
   Responsive — desktop / tablet / mobile per spec
   ========================================================================== */

/* Tablet: nav stays inline, spacing tightens. */
@media (max-width: 991.98px) {
  .lgm-header-container {
    padding-inline: var(--lgm-space-sm);
  }

  .lgm-nav-list {
    gap: 20px;
  }

  .lgm-header-right {
    gap: var(--lgm-space-md);
  }
}

/* Mobile: nav collapses into the offcanvas; only the logo, the
   language toggle, and the hamburger stay visible in the bar. Give,
   Instagram, and any other secondary/CTA link are hidden — they're
   reachable via the mobile bottom nav / offcanvas / footer instead,
   so nothing is actually lost, the top bar just stays uncluttered. */
@media (max-width: 767.98px) {
  .lgm-header-container {
    grid-template-columns: auto 1fr;
  }

  .lgm-header-left {
    display: none;
  }

  .lgm-header-center {
    justify-self: start;
  }

  .lgm-header-right {
    gap: 14px;
  }

  .lgm-header-right .lgm-icon-link,
  .lgm-header-right .lgm-give-link {
    display: none !important;
  }

  .lgm-nav-toggle {
    display: inline-flex !important;
  }
}

@media (max-width: 380px) {
  .lgm-logo-mark-custom {
    height: 34px;
  }

  .lgm-logo-line-1 {
    font-size: 15px;
    letter-spacing: 2px;
  }

  .lgm-logo-line-2 {
    font-size: 12px;
  }

  .lgm-header-right {
    gap: 10px;
  }

  .lgm-give-link-text {
    display: none;
  }
}
