/* ==========================================================================
   IPESFA – Header moderno + Overlay mega-panel
   Mobile-first · System fonts · Accesible
   v4.0 – Fixed header on Home (over hero), sticky on inner pages
   ========================================================================== */

/* ---------- Tokens (inherit from style.css, fallback if missing) --------- */
:root {
  --hdr-accent:       var(--accent, #5FA9B3);
  --hdr-accent-hover: var(--accent-hover, #4d8e95);
  --hdr-accent-soft:  var(--accent-soft, #edf7f8);
  --hdr-dark:         var(--dark, #3F4656);
  --hdr-text:         var(--text, #3F4656);
  --hdr-muted:        var(--muted, #6b7280);
  --hdr-border:       var(--border, #e5e7eb);
  --hdr-surface:      #ffffff;
  --hdr-radius:       10px;
  --hdr-font:         var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto,
                        Helvetica, Arial, sans-serif);
  --hdr-height:       72px;
  --hdr-max:          1280px;
  --hdr-z:            9000;
  --ov-z:             9999;
}


/* ==============================
   1. HEADER BAR – base (all pages)
   Forced full-width regardless of #page or body layout class.
   ============================== */
#masthead.ipesfa-hdr {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  float: none;
  box-sizing: border-box;
}

.ipesfa-hdr__bar {
  position: sticky;
  top: 0;
  z-index: var(--hdr-z);
  width: 100%;
  background: var(--hdr-surface);
  border-bottom: 1px solid transparent;
  box-shadow: none;
  transition: border-color 0.25s ease,
              background-color 0.3s ease;
}

/* --- Scrolled state (all pages): subtle bottom line, no shadow --- */
.ipesfa-hdr__bar.is-scrolled {
  border-bottom-color: rgba(0, 0, 0, .08);
}

/* WP admin bar offset */
.admin-bar .ipesfa-hdr__bar { top: 32px; }
@media (max-width: 782px) {
  .admin-bar .ipesfa-hdr__bar { top: 46px; }
}

.ipesfa-hdr__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  max-width: var(--hdr-max);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--hdr-height);
  gap: 16px;
  transition: height 0.25s ease;
}

/* Shrink inner container when scrolled */
.ipesfa-hdr__bar.is-scrolled .ipesfa-hdr__inner {
  height: 58px;
}


/* ==============================
   1a. HOME – FIXED HEADER OVER HERO
   On .home only the bar is position:fixed so it sits on top of
   the hero without taking flow space. #masthead collapses to 0
   and #ipesfa-home starts from the top of the viewport.
   ============================== */
body.home .ipesfa-hdr__bar {
  position: fixed;
  left: 0;
}

/* Ensure collapsed masthead creates no gap on Home */
body.home #masthead.ipesfa-hdr {
  min-height: 0;
  height: 0;
  overflow: visible;
  border: 0;
}

/* Transparent background when not scrolled */
body.home .ipesfa-hdr__bar:not(.is-scrolled) {
  background: transparent;
  border-bottom-color: transparent;
}

/* Solid white once scrolled */
body.home .ipesfa-hdr__bar.is-scrolled {
  background: var(--hdr-surface);
}

/* --- White nav links on transparent header --- */
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__links li a {
  color: rgba(255, 255, 255, 0.92);
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__links li a:hover {
  color: var(--hdr-accent);
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__links li a:focus-visible {
  color: var(--hdr-accent);
}

/* Active item on transparent header */
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__links li.current-menu-item > a,
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__links li.current_page_item > a,
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__links li.current-menu-ancestor > a {
  color: #fff;
}

/* --- White toggle button --- */
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__toggle {
  color: rgba(255, 255, 255, 0.92);
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__toggle:hover {
  color: #fff;
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__toggle:focus-visible {
  color: #fff;
  outline-color: rgba(255, 255, 255, 0.7);
}

/* --- White site name (text fallback) --- */
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__name {
  color: #fff;
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__name:hover {
  color: var(--hdr-accent);
}

/* --- Logo: invert to white on transparent header --- */
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-hdr__brand .custom-logo-link img {
  filter: brightness(0) invert(1);
}


/* ---------- Brand ---------- */
.ipesfa-hdr__brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}

.ipesfa-hdr__brand .custom-logo-link {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  transition: opacity 0.2s ease;
}
.ipesfa-hdr__brand .custom-logo-link:hover {
  opacity: 0.85;
}
.ipesfa-hdr__brand .custom-logo-link:focus-visible {
  outline: 2px solid var(--hdr-accent);
  outline-offset: 4px;
  border-radius: 6px;
}

.ipesfa-hdr__brand .custom-logo-link img {
  height: 48px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  border-radius: 0;
  margin: 0;
  transition: height 0.25s ease, filter 0.3s ease;
}

/* Shrink logo when scrolled */
.ipesfa-hdr__bar.is-scrolled .ipesfa-hdr__brand .custom-logo-link img {
  height: 38px;
}

/* Scale logo down on smaller screens */
@media (max-width: 479px) {
  .ipesfa-hdr__brand .custom-logo-link img {
    height: 40px;
    max-width: 160px;
  }
  .ipesfa-hdr__bar.is-scrolled .ipesfa-hdr__brand .custom-logo-link img {
    height: 34px;
  }
}
@media (min-width: 1024px) {
  .ipesfa-hdr__brand .custom-logo-link img {
    height: 52px;
    max-width: 240px;
  }
  .ipesfa-hdr__bar.is-scrolled .ipesfa-hdr__brand .custom-logo-link img {
    height: 42px;
  }
}

/* Text fallback (only renders when no logo is set) */
.ipesfa-hdr__name {
  font-family: var(--hdr-font);
  font-size: clamp(17px, 1.4vw + 10px, 22px);
  font-weight: 700;
  color: var(--hdr-dark);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
  transition: color 0.25s ease, font-size 0.25s ease;
}
.ipesfa-hdr__bar.is-scrolled .ipesfa-hdr__name {
  font-size: clamp(15px, 1.2vw + 8px, 19px);
}
.ipesfa-hdr__name:hover {
  color: var(--hdr-accent);
}
.ipesfa-hdr__name:focus-visible {
  outline: 2px solid var(--hdr-accent);
  outline-offset: 4px;
  border-radius: 4px;
}


/* ---------- Desktop navigation ---------- */
.ipesfa-hdr__nav {
  display: none;
  flex: 1;
  justify-content: center;
}

.ipesfa-hdr__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}

.ipesfa-hdr__links li a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-family: var(--hdr-font);
  font-size: 15px;
  font-weight: 400;
  color: var(--hdr-dark);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transition: color 0.25s ease;
  letter-spacing: 0.005em;
}

/* ::after bar – hidden by default, slides in on hover */
.ipesfa-hdr__links li a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--hdr-accent);
  border-radius: 1px;
  transform: scaleX(0);
  transition: transform 0.25s ease, background-color 0.25s ease;
}

.ipesfa-hdr__links li a:hover {
  color: var(--hdr-accent);
  background: transparent;
  box-shadow: none;
}
.ipesfa-hdr__links li a:hover::after {
  transform: scaleX(1);
}

/* Active / current page */
.ipesfa-hdr__links li.current-menu-item > a,
.ipesfa-hdr__links li.current_page_item > a,
.ipesfa-hdr__links li.current-menu-ancestor > a {
  color: var(--hdr-accent);
}
.ipesfa-hdr__links li.current-menu-item > a::after,
.ipesfa-hdr__links li.current_page_item > a::after,
.ipesfa-hdr__links li.current-menu-ancestor > a::after {
  transform: scaleX(1);
}

/* Focus-visible: bottom bar (no outline box) */
.ipesfa-hdr__links li a:focus-visible {
  color: var(--hdr-accent);
  outline: none;
}
.ipesfa-hdr__links li a:focus-visible::after {
  transform: scaleX(1);
}

/* Show desktop nav >= 768px, limit to first 6 items */
@media (min-width: 768px) {
  .ipesfa-hdr__nav {
    display: flex;
  }
  .ipesfa-hdr__links > li:nth-child(n+7) {
    display: none;
  }
}


@media (min-width: 1024px) {
  .ipesfa-hdr__links li a {
    font-size: 15.5px;
    padding: 6px 16px;
  }
}


/* ---------- Toggle button ---------- */
.ipesfa-hdr__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none;
  padding: 6px 4px;
  cursor: pointer;
  color: var(--hdr-dark);
  font-family: var(--hdr-font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  flex-shrink: 0;
  margin-bottom: 0;
  box-shadow: none;
  transition: color 0.25s ease;
}

.ipesfa-hdr__toggle:hover {
  color: var(--hdr-accent);
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
}

.ipesfa-hdr__toggle:focus-visible {
  color: var(--hdr-accent);
  outline: 2px solid var(--hdr-accent);
  outline-offset: 4px;
}

/* Hamburger icon */
.ipesfa-hdr__hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 18px;
  height: 18px;
}
.ipesfa-hdr__hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

/* Animate to X when overlay is open */
.ipesfa-hdr__toggle[aria-expanded="true"] .ipesfa-hdr__hamburger span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.ipesfa-hdr__toggle[aria-expanded="true"] .ipesfa-hdr__hamburger span:nth-child(2) {
  opacity: 0;
}
.ipesfa-hdr__toggle[aria-expanded="true"] .ipesfa-hdr__hamburger span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Hide label text on very small screens */
.ipesfa-hdr__toggle-label {
  display: none;
}
@media (min-width: 480px) {
  .ipesfa-hdr__toggle-label {
    display: inline;
  }
}


/* Agrupa search + toggle en el lado derecho */
.ipesfa-hdr__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

/* ==============================
   SEARCH COMPONENT
   ============================== */

/* Pill container */
.ipesfa-search {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  /* Mobile: solo ícono */
  gap: 0;
  width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1.5px solid rgba(63, 70, 86, 0.18);
  background: rgba(63, 70, 86, 0.05);
  overflow: hidden;
  transition: width 0.25s ease, border-color 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
  margin: 0;
}

/* Mobile expandido */
.ipesfa-search.is-expanded {
  width: 180px;
  gap: 6px;
  padding: 0 8px 0 10px;
  border-color: var(--hdr-accent);
  background: #fff;
}
.ipesfa-search.is-expanded .ipesfa-search__input,
.ipesfa-search.is-expanded .ipesfa-search__input:focus {
  display: block !important;
}

/* Desktop: mostrar input */
@media (min-width: 768px) {
  .ipesfa-search {
    width: 140px;
    gap: 6px;
    padding: 0 8px 0 10px;
  }
}
@media (min-width: 1100px) {
  .ipesfa-search {
    width: 160px;
  }
}

.ipesfa-search:focus-within {
  border-color: var(--hdr-accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(95, 169, 179, 0.15);
}

/* Ícono lupa */
.ipesfa-search__icon {
  flex-shrink: 0;
  color: var(--hdr-muted);
  display: block;
  transition: color 0.2s ease;
}
.ipesfa-search:focus-within .ipesfa-search__icon {
  color: var(--hdr-accent);
}

/* Input — override todos los estilos WP */
.ipesfa-search__input,
.ipesfa-search__input:focus,
.ipesfa-search__input:active {
  display: none;
  flex: 1;
  min-width: 0;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  font-family: var(--hdr-font) !important;
  font-size: 13.5px !important;
  line-height: 1 !important;
  color: var(--hdr-dark) !important;
  padding: 0 !important;
  margin: 0 !important;
  height: auto !important;
  border-radius: 0 !important;
  -webkit-appearance: none;
  appearance: none;
}
/* Ocultar botón limpiar nativo en webkit */
.ipesfa-search__input::-webkit-search-cancel-button,
.ipesfa-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
}
.ipesfa-search__input::placeholder {
  color: var(--hdr-muted) !important;
}

@media (min-width: 768px) {
  .ipesfa-search__input,
  .ipesfa-search__input:focus,
  .ipesfa-search__input:active {
    display: block;
  }
}

/* Botón submit (flecha) */
.ipesfa-search__submit {
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0 0 0 2px;
  background: var(--hdr-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  box-shadow: none;
  transition: background 0.2s ease, opacity 0.2s ease;
  line-height: 1;
}
.ipesfa-search__submit:hover {
  background: var(--hdr-accent-hover);
  box-shadow: none;
}
@media (min-width: 768px) {
  .ipesfa-search:focus-within .ipesfa-search__submit {
    display: inline-flex;
  }
}

/* ---- Header transparente (home, antes de scroll) ---- */
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-search {
  border-color: rgba(255,255,255,0.40);
  background: rgba(255,255,255,0.12);
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-search:focus-within {
  border-color: rgba(255,255,255,0.80);
  background: rgba(255,255,255,0.18);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-search__icon {
  color: rgba(255,255,255,0.75);
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-search__input,
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-search__input:focus {
  color: #fff !important;
}
body.home .ipesfa-hdr__bar:not(.is-scrolled) .ipesfa-search__input::placeholder {
  color: rgba(255,255,255,0.60) !important;
}

/* ==============================
   2. OVERLAY MEGA-PANEL
   ============================== */
.ipesfa-ov {
  position: fixed;
  inset: 0;
  z-index: var(--ov-z);
  background: rgba(25, 28, 36, 0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.35s ease, opacity 0.35s ease;
}
.ipesfa-ov.is-open {
  visibility: visible;
  opacity: 1;
}

.ipesfa-ov__inner {
  max-width: var(--hdr-max);
  margin: 0 auto;
  padding: 28px 24px 56px;
  min-height: 100%;
}

/* ---------- Overlay top bar ---------- */
.ipesfa-ov__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ipesfa-ov__brand {
  font-family: var(--hdr-font);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  transition: color 0.25s ease;
}
.ipesfa-ov__brand:hover {
  color: var(--hdr-accent);
}

/* Logo variant in overlay */
.ipesfa-ov__brand-logo .custom-logo-link {
  display: inline-flex;
  align-items: center;
}
.ipesfa-ov__brand-logo .custom-logo-link img {
  height: 40px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  border-radius: 0;
  margin: 0;
}

.ipesfa-ov__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0;
  line-height: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.ipesfa-ov__close:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}
.ipesfa-ov__close:focus-visible {
  outline: 2px solid var(--hdr-accent);
  outline-offset: 2px;
}

/* ---------- Overlay menu grid ---------- */
.ipesfa-ov__menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
}

.ipesfa-ov__menu > li > a {
  display: block;
  font-family: var(--hdr-font);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--hdr-accent);
  transition: color 0.2s ease;
}
.ipesfa-ov__menu > li > a:hover {
  color: var(--hdr-accent);
}

.ipesfa-ov__menu > li:not(.menu-item-has-children) > a {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* Sub-menus */
.ipesfa-ov__menu .sub-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ipesfa-ov__menu .sub-menu li a {
  display: block;
  padding: 9px 0;
  font-family: var(--hdr-font);
  font-size: 16px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: color 0.2s ease, padding-left 0.2s ease;
}
.ipesfa-ov__menu .sub-menu li a:hover {
  color: var(--hdr-accent);
  padding-left: 8px;
}

/* Current item in overlay */
.ipesfa-ov__menu > li.current-menu-item > a,
.ipesfa-ov__menu > li.current-menu-ancestor > a {
  color: var(--hdr-accent);
}
.ipesfa-ov__menu .sub-menu li.current-menu-item > a {
  color: var(--hdr-accent);
  font-weight: 600;
}

/* Focus visible (overlay) */
.ipesfa-ov__menu a:focus-visible,
.ipesfa-ov__brand:focus-visible,
.ipesfa-ov__brand-logo .custom-logo-link:focus-visible {
  outline: 2px solid var(--hdr-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Overlay columns responsive ---------- */
@media (min-width: 768px) {
  .ipesfa-ov__inner {
    padding: 36px 40px 72px;
  }
  .ipesfa-ov__menu {
    grid-template-columns: repeat(2, 1fr);
    gap: 44px 52px;
  }
}

@media (min-width: 1024px) {
  .ipesfa-ov__inner {
    padding: 44px 48px 88px;
  }
  .ipesfa-ov__menu {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 44px 60px;
  }
  .ipesfa-ov__menu > li > a {
    font-size: 18px;
  }
}


/* ==============================
   3. BODY SCROLL LOCK
   ============================== */
body.ipesfa-ov-open {
  overflow: hidden;
}


/* ==============================
   4. HIDE PARENT HEADER ELEMENTS
   ============================== */
#header-text-nav-container,
#header-meta,
.ipesfa-hdr .header-image,
.tg-menu-extras-wrap {
  display: none;
}


/* ==============================
   5. PAGE TITLE BAR (inner pages)
   Normalized to match header inner container exactly.
   Beat ALL Spacious layout-class variants for .inner-wrap.
   ============================== */
.header-post-title-container {
  width: 100%;
  background: var(--hdr-surface);
  border-bottom: 1px solid var(--hdr-border);
}
.header-post-title-container .inner-wrap,
.wide-1218 .header-post-title-container .inner-wrap,
.narrow-1218 .header-post-title-container .inner-wrap,
.narrow-978 .header-post-title-container .inner-wrap,
.wide-978 .header-post-title-container .inner-wrap {
  max-width: var(--hdr-max);
  width: 100%;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
}
.header-post-title-container .post-title-wrapper {
  padding: 18px 0 14px;
}
.header-post-title-class {
  font-family: var(--hdr-font);
  font-weight: 700;
  color: var(--hdr-dark);
  font-size: clamp(22px, 2vw + 14px, 32px);
  margin: 0;
  padding: 0;
}
