/* =============================================================
   NAV — Navegación principal
   WordPress: header.php + nav walker
   ============================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  transition: box-shadow var(--t);
}

/* Sombra al hacer scroll */
.site-header--scrolled {
  box-shadow: var(--shadow);
}

/* ── Barra de navegación ─────────────────────────────────────── */
.nav {
  height: var(--nav-h);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding-inline: var(--pad-x);
}

/* ── Logo ────────────────────────────────────────────────────── */
.nav__logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  flex-shrink: 0;
}

.nav__logo-img {
  max-height: 50px;
  width: auto;
  display: block;
}

.nav__logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background-color: var(--c-dark);
  border-radius: var(--r-sm);
}

.nav__logo-dot {
  display: block;
  width: 11px;
  height: 11px;
  background-color: var(--c-accent);
  border-radius: var(--r-xs);
}

.nav__logo-name {
  font-family: var(--f-ui);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.19em;
  color: var(--c-dark);
}

/* ── Derecha del nav ─────────────────────────────────────────── */
.nav__right {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

/* ── Links desktop ───────────────────────────────────────────── */
.nav__links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav__link {
  font-family: var(--f-ui);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--c-text-2);
  text-decoration: none;
  transition: color var(--t);
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.nav__link:hover,
.nav__link:focus-visible {
  color: var(--c-dark);
}

.nav__link--active {
  font-weight: 700;
  color: var(--c-dark);
}

/* Ícono chevron en dropdown toggle */
.nav__chevron {
  transition: transform var(--t);
  flex-shrink: 0;
}

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

/* ── Dropdown desktop ────────────────────────────────────────── */
.nav__item--has-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

/*
 * Puente invisible que cubre el hueco entre el <li> y el <ul> del dropdown.
 * Sin este ::before, el ratón "sale" del <li> al cruzar el gap de 0.75rem
 * y el :hover se desactiva antes de llegar al dropdown.
 */
.nav__item--has-dropdown::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 0.875rem; /* ≥ gap del dropdown */
}

/* Botón chevron — tab-stop 2, solo el ícono */
.nav__dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-2);
  transition: color var(--t);
  flex-shrink: 0;
  border-radius: var(--r-sm);
}

.nav__dropdown-toggle:hover,
.nav__dropdown-toggle:focus-visible {
  color: var(--c-dark);
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.nav__chevron {
  transition: transform var(--t);
  display: block;
  flex-shrink: 0;
}

/* Chevron rota cuando el <li> está en hover o abierto por teclado */
.nav__item--has-dropdown:hover .nav__chevron,
.nav__item--has-dropdown.is-open .nav__chevron {
  transform: rotate(180deg);
}

.nav__dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  left: 50%;
  min-width: 220px;
  background-color: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  list-style: none;
  padding: 0.5rem 0;
  /* Estado oculto */
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity var(--t), visibility var(--t), transform var(--t);
  pointer-events: none;
}

/*
 * Mostrar dropdown:
 *   1. Hover con ratón  → :hover en el <li>
 *   2. Teclado / touch  → clase .is-open añadida por JS
 */
.nav__item--has-dropdown:hover > .nav__dropdown,
.nav__item--has-dropdown.is-open > .nav__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.nav__dropdown-link {
  display: block;
  padding: 0.625rem 1.25rem;
  font-family: var(--f-ui);
  font-size: 0.9375rem;
  color: var(--c-text-2);
  text-decoration: none;
  transition: color var(--t), background-color var(--t);
}

.nav__dropdown-link:hover {
  color: var(--c-dark);
  background-color: var(--c-gray);
}

/* ── Selector de idioma ──────────────────────────────────────── */
.nav__lang-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  flex-shrink: 0;
}

.nav__lang-switcher li:not(:last-child)::after {
  content: '·';
  margin-left: 0.5rem;
  color: var(--c-border);
}

.nav__lang-switcher li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav__lang-link {
  font-family: var(--f-ui);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--c-text-2);
  text-decoration: none;
  transition: color var(--t);
}

.nav__lang-link:hover,
.nav__lang-link:focus-visible {
  color: var(--c-dark);
}

.nav__lang-link--active {
  font-weight: 700;
  color: var(--c-dark);
  pointer-events: none;
}

/* ── CTA Button ──────────────────────────────────────────────── */
.nav__cta {
  font-size: 1rem;
  padding: 0.625rem 1.5rem;
}

/* ── Hamburguesa (mobile) ────────────────────────────────────── */
.nav__hamburger {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t);
  flex-shrink: 0;
}

.nav__hamburger:hover {
  border-color: var(--c-dark);
}

.nav__hamburger-line {
  display: block;
  width: 18px;   /* ancho fijo idéntico en las 3 líneas */
  height: 2px;
  background-color: var(--c-dark);
  border-radius: 1px;
  transition: transform var(--t), opacity var(--t);
  transform-origin: center;
}

/* Animación al abrir — translateY = height(2px) + gap(5px) = 7px */
.nav__hamburger[aria-expanded="true"] .nav__hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav__hamburger[aria-expanded="true"] .nav__hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav__hamburger[aria-expanded="true"] .nav__hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Menú mobile ─────────────────────────────────────────────── */
.mobile-menu {
  position: fixed;
  inset: 0;
  top: var(--nav-h);
  z-index: 99;
  background-color: var(--c-white);
  transform: translateX(100%);
  transition: transform var(--t-med);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--c-border);
}

.mobile-menu--open {
  transform: translateX(0);
}

.mobile-menu__inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1.5rem var(--pad-x) 2.5rem;
}

.mobile-menu__links {
  list-style: none;
  display: flex;
  flex-direction: column;
  margin-bottom: 2rem;
}

.mobile-menu__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 0;
  font-family: var(--f-ui);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--c-text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--c-border);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  transition: color var(--t);
}

.mobile-menu__link--active {
  font-weight: 700;
  color: var(--c-dark);
}

.mobile-menu__link:hover { color: var(--c-dark); }

.mobile-menu__chevron {
  transition: transform var(--t);
  flex-shrink: 0;
}

.mobile-menu__dropdown-toggle[aria-expanded="true"] .mobile-menu__chevron {
  transform: rotate(180deg);
}

.mobile-menu__dropdown {
  list-style: none;
  padding: 0.5rem 0 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mobile-menu__dropdown-link {
  display: block;
  padding: 0.75rem 0;
  font-family: var(--f-ui);
  font-size: var(--text-base);
  color: var(--c-text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--c-border);
  transition: color var(--t);
}

.mobile-menu__dropdown-link:hover { color: var(--c-dark); }

/* Selector de idioma dentro del menú móvil desplegado */
.mobile-menu__inner .nav__lang-switcher {
  margin-bottom: 1.5rem;
}

.mobile-menu__inner .nav__lang-link {
  font-size: var(--text-base);
}

.mobile-menu__cta {
  align-self: flex-start;
  margin-top: 0.5rem;
}

/* ── Mobile menu — clases generadas por WordPress (sin walker) ── */

/* Ítem de nivel 0 sin hijos — solo el <a> */
.mobile-menu__links > .menu-item:not(.menu-item-has-children) > a {
  display: block;
  width: 100%;
  padding: 1rem 0;
  font-family: var(--f-ui);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--c-text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--c-border);
  transition: color var(--t);
}

.mobile-menu__links > .menu-item:not(.menu-item-has-children) > a:hover {
  color: var(--c-dark);
}

/* Ítem de nivel 0 CON hijos — flex para [a][button] en la misma fila */
.mobile-menu__links > .menu-item-has-children {
  display: flex;
  flex-wrap: wrap;        /* el sub-menu cae a la siguiente línea */
  align-items: center;
  border-bottom: 1px solid var(--c-border);
}

.mobile-menu__links > .menu-item-has-children > a {
  flex: 1;
  padding: 1rem 0;
  font-family: var(--f-ui);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--c-text-2);
  text-decoration: none;
  transition: color var(--t);
  /* Sin border-bottom propio: lo tiene el <li> */
}

.mobile-menu__links > .menu-item-has-children > a:hover {
  color: var(--c-dark);
}

/* Botón chevron inyectado por JS */
.mobile-menu__dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-2);
  transition: color var(--t);
  flex-shrink: 0;
}

.mobile-menu__dropdown-toggle:hover,
.mobile-menu__dropdown-toggle:focus-visible {
  color: var(--c-dark);
}

.mobile-menu__chevron {
  transition: transform var(--t);
}

.mobile-menu__dropdown-toggle[aria-expanded="true"] .mobile-menu__chevron {
  transform: rotate(180deg);
}

/* Sub-menu — ocupa el ancho completo del <li> flex-wrap */
.mobile-menu__links .sub-menu {
  flex-basis: 100%;
  list-style: none;
  padding: 0.5rem 0 0.5rem 1rem;
  display: flex;
  flex-direction: column;
}

.mobile-menu__links .sub-menu .menu-item a {
  display: block;
  padding: 0.75rem 0;
  font-family: var(--f-ui);
  font-size: var(--text-base);
  color: var(--c-text-2);
  text-decoration: none;
  border-bottom: 1px solid var(--c-border);
  transition: color var(--t);
}

.mobile-menu__links .sub-menu .menu-item a:hover { color: var(--c-dark); }

.mobile-menu__links > .current-menu-item > a,
.mobile-menu__links > .current-page-ancestor > a {
  font-weight: 700;
  color: var(--c-dark);
}

/* ── Responsive ──────────────────────────────────────────────── */
/* Breakpoint = 1px por debajo del ancho máximo del contenedor (1400px) */
@media (max-width: 1399px) {
  .nav__links,
  .nav__cta,
  .nav__right > .nav__lang-switcher {
    display: none;
  }

  .nav__hamburger {
    display: flex;
  }

  .nav__right {
    gap: 1rem;
  }
}
