/* =========================================================
   MENU — Desktop styles
   - Base container + bar
   - Level 1 list/links
   - Dropdown level 2 + flyout level 3+
   - Hamburger button base (hidden by default)
========================================================= */


/* =========================================================
   1) Base container + bar
========================================================= */
.menu-container{
  grid-row: 2;
  grid-column: 1 / 17;
  height: auto; /* allow menu to grow on mobile */

  /* Local variables (scoped) */
  --menu-blue: rgb(0,57,122);
  --menu-shadow: none; /* ✅ FIX: Desactivamos la sombra */
  --dropdown-border: 1px solid rgba(0,0,0,.08);
  --dropdown-radius: 12px;

  --menu-minh: 56.8px;
  --link-h: 72px;
  --link-px: 44px;

  background: var(--menu-blue);
  position: relative;
  z-index: 10000;
  overflow: visible; /* Mantenemos visible para que el menú no se corte */
}

/* ✅ FIX: Sombra separada para evitar el desbordamiento visual */
.menu-container::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%; /* Se posiciona justo debajo de la barra de menú */
  height: 30px; /* Altura aproximada para contener la sombra */
  background: transparent;
  box-shadow: var(--menu-shadow);
  z-index: 10000; /* ✅ FIX: Por encima del dropdown para que la sombra se renderice correctamente */
  opacity: 0; /* Oculta por defecto */
  transition: opacity 0.2s ease;
}

.menu{
  min-height: var(--menu-minh);
  height: auto;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0 24px;
  box-sizing: border-box;

  position: relative;
  z-index: 10001;
}


/* =========================================================
   2) Desktop — Level 1 list + links
========================================================= */
.menu-list{
  list-style: none;
  display: flex;
  margin: 0;
  padding: 0;
}

.menu-item{ position: relative; }

.menu-link{
  display: flex;
  align-items: center;
  justify-content: center;

  height: var(--link-h);
  padding: 0 var(--link-px);

  text-decoration: none;
  color: #fff;
  font-weight: 300;
  font-size: 16.8px;
  white-space: nowrap;
}

/* ✅ FIX: Ocultar la lista principal en móvil por defecto.
   JS la mostrará con .is-open en modo colapsado. */
@media (max-width: 768px) {
  .menu-list { display: none; }
}

@media (max-width: 1200px){
  .menu-link{
    padding-inline: clamp(10px, 2.2vw, var(--link-px));
  }
}

/* Desktop hover/focus highlight */
.menu-item:hover > .menu-link,
.menu-item:focus-within > .menu-link,
.menu-link.active {
  background: #fff;
  color: var(--menu-blue);
}

/* Desktop caret indicator for items with dropdown */
.menu-item.has-dropdown > .menu-link::after{
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-left: 10px;
  margin-top: -2px;
}

/* ✅ FIX: Forzar el color de la flecha a blanco en estado hover para evitar el "falso sombreado" azul */
.menu-item:hover > .menu-link::after {
  border-color: #fff;
}


/* =========================================================
   3) Desktop — Dropdown (Level 2)
========================================================= */
.dropdown{
  list-style: none;
  margin: 0;
  padding: 4px 0;

  position: absolute;
  top: 100%; /* Restauramos la posición original */


  left: 12px;
  right: 12px;
  transform: none;
  margin-inline: auto;

  min-width: 0;
  width: min(520px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);

  background: #fff;
  border: var(--dropdown-border);
  border-radius: var(--dropdown-radius);

  display: none;
  z-index: 9999;

  box-shadow: none; /* ✅ FIX: Quitamos la sombra del dropdown */
  overflow: visible;
  box-sizing: border-box;
}

/* Center dropdown under parent on wider screens */
@media (min-width: 1025px){
  .menu-item > .dropdown{
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: min(520px, calc(100vw - 24px));
  }
}

/* Desktop open on hover/focus-within */
.menu:not(.is-collapsed) .menu-item.has-dropdown:hover > .dropdown,
.menu:not(.is-collapsed) .menu-item.has-dropdown:focus-within > .dropdown {
  display: block;
}

/* ✅ FIX: Mostramos la sombra cuando el menú está abierto (controlado por JS) */
.menu-container.is-shadow-active::after {
  opacity: 1;
}

/* Dropdown arrow */
.dropdown::before{
  content: "";
  position: absolute;
  top: -6px; /* Restauramos la posición original de la flecha */
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #fff;
  filter: none; /* ✅ FIX: Eliminamos también la sombra del triángulo */
}

.dropdown li{
  margin: 0;
  padding: 0;
}

/* Dropdown links */
.dropdown .menu-link{
  height: auto;
  padding: 8px 18px;
  justify-content: flex-start;

  color: var(--menu-blue);
  background: transparent;

  font-size: 14px;
  line-height: 1.2;

  min-width: 0;
  width: 100%;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 100%;
  box-sizing: border-box; /* ✅ FIX: Evita que el padding desborde el ancho del 100% */
}

.dropdown .menu-link:hover,
.dropdown .menu-item:hover > .menu-link{
  background: rgba(0,57,122,0.06);
  color: var(--menu-blue);
}


/* =========================================================
   4) Desktop — Level 3+ flyout (nested dropdown)
========================================================= */
.dropdown .menu-item.has-dropdown{
  position: relative;
}

.dropdown .menu-item.has-dropdown > .dropdown{
  position: absolute;
  top: 0;
  left: calc(100% - 8px); /* Posiciona a la derecha por defecto */
  right: auto;

  transform: none;
  min-width: 0;
  width: max-content;
  max-width: calc(100vw - 24px);

  display: none;
  padding: 8px 0;

  background: #fff;
  border: var(--dropdown-border);
  border-radius: var(--dropdown-radius);
  box-shadow: none; /* ✅ FIX: Eliminamos la sombra de los submenús anidados (flyouts) */

  z-index: 10010;
}

/* Clase para invertir la posición cuando el submenú se sale de la pantalla */
.dropdown .menu-item.has-dropdown > .dropdown.is-flipped {
  left: auto;
  right: calc(100% - 8px);
}

/* Flyout open on hover/focus-within */
.menu:not(.is-collapsed) .dropdown .menu-item.has-dropdown:hover > .dropdown,
.menu:not(.is-collapsed) .dropdown .menu-item.has-dropdown:focus-within > .dropdown {
  display: block;
}

/* No arrow for nested flyout */
.dropdown .menu-item.has-dropdown > .dropdown::before{
  display: none;
}

/* Heading style for flyout parent */
.dropdown .menu-item.has-dropdown > .menu-link{
  font-weight: 600;
}

.dropdown .menu-item.has-dropdown > .dropdown .menu-link{
  padding-left: 18px;
  font-size: 13.5px;
}

.dropdown .menu-item.has-dropdown > .dropdown .menu-link:hover{
  background: rgba(0,57,122,0.06);
}


/* =========================================================
   5) Menu toggle (hamburger) base
========================================================= */
.menu-toggle{
  display: none; /* JS shows this in collapsed mode */
  position: absolute;
  top: 50%;
  transform: translateY(-50%);

  width: 42px;
  height: 42px;

  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.menu-toggle span{
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  margin: 5px auto;
}