/* ==========================================================================
   COINDESOCOL · Cabecera del sitio
   Logo, menú principal con submenús, botón Educación, redes sociales
   y menú desplegable para móvil (≤ 921 px).
   ========================================================================== */

/* Ajustes rápidos de la cabecera */
.cabecera {
  --cab-alto: 64px;
  --cab-fondo: #0d0d0d;
  --cab-fondo-2: #17191c;       /* submenús y menú móvil */
  --cab-hover: #23262b;
  --cab-linea: #2a2d32;
  --cab-texto: #d4d6da;         /* gris claro, tirando a blanco */
  --cab-texto-activo: #ffffff;
  --cab-texto-suave: #9ca3af;
  --cab-acento: var(--color-verde);
  --cab-acento-claro: #4caf50;  /* verde que resalta sobre negro */
  --cab-acento-oscuro: #1b5e21;
  --cab-logo: 200px;

  position: relative;
  z-index: 99;
}

.cabecera__barra {
  position: relative;
  z-index: 4;
  margin: 0 auto;
  border-bottom: 1px solid var(--cab-linea);
  background-color: var(--cab-fondo);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  line-height: var(--cab-alto);
}

.cabecera__contenedor {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  align-content: center;
  column-gap: 20px;
  min-height: var(--cab-alto);
  max-width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  overflow-wrap: anywhere;
}

/* --- Logo ------------------------------------------------------------------ */
.cabecera__marca {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  height: 100%;
}

.cabecera__logo {
  display: inline-flex;
  align-items: center;
  align-self: center;
  padding: 8px 0;
  line-height: 1;
}

.cabecera__logo img {
  display: block;
  width: var(--cab-logo);
  max-width: var(--cab-logo);
  height: auto;
}

/* --- Zona derecha (menú, botón, redes) ------------------------------------- */
.cabecera__zona {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

/* En escritorio el panel no genera caja: sus hijos se alinean en la zona */
.cabecera__panel { display: contents; }

.menu-principal { padding: 0 12px 0 0; }
.cabecera__boton { padding: 0 8px; }
.redes {
  margin-left: 14px;
  padding: 0 0 0 18px;
  border-left: 1px solid var(--cab-linea);
}

/* --- Menú principal -------------------------------------------------------- */
.menu-principal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  height: 100%;
}

.menu {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-self: center;
  height: 100%;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.menu__item {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: var(--cab-alto);
}

.menu__enlace {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 .95em;
  color: var(--cab-texto);
  font-size: .9375rem;
  font-weight: 500;
  letter-spacing: .01em;
  text-decoration: none;
  transition: color .2s ease;
}

/* Línea inferior de acento al pasar el cursor o en la página actual */
.menu > .menu__item > .menu__enlace::after {
  content: "";
  position: absolute;
  left: .95em;
  right: .95em;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--cab-acento-claro);
  transform: scaleX(0);
  transition: transform .2s ease;
}

.menu > .menu__item:hover > .menu__enlace::after,
.menu > .menu__item--actual > .menu__enlace::after,
.menu > .menu__item--ancestro > .menu__enlace::after { transform: scaleX(1); }

.menu__enlace:hover,
.menu__item:hover > .menu__enlace,
.menu__item--actual > .menu__enlace,
.menu__item--ancestro > .menu__enlace { color: var(--cab-texto-activo); }

.menu__flecha {
  display: inline-flex;
  margin-right: -6px;
  padding-right: 6px;
}

.menu__flecha svg,
.submenu__icono svg {
  position: relative;
  width: .55em;
  height: .55em;
  margin-left: 8px;
  fill: currentColor;
  opacity: .6;
}

/* Botón para abrir submenús (solo en móvil) */
.menu__desplegar { display: none; }

/* Submenú de escritorio */
.submenu {
  position: absolute;
  top: 100%;
  left: -999em;
  z-index: 99999;
  visibility: hidden;
  width: 240px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  border: 1px solid var(--cab-linea);
  border-radius: 0 0 8px 8px;
  background: var(--cab-fondo-2);
  box-shadow: 0 14px 30px -8px rgba(0, 0, 0, .6);
  line-height: 1.45;
}

.submenu::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 7px;
  transform: translateY(-100%);
}

.menu__item:hover > .submenu,
.menu__item:focus-within > .submenu {
  left: 0;
  right: auto;
  visibility: visible;
}

.submenu .menu__item { line-height: 1.45; }

.submenu .menu__enlace {
  display: block;
  padding: .6em 1.1em;
  font-size: .9rem;
  font-weight: 400;
  overflow-wrap: break-word;
  transition: background-color .15s ease, color .15s ease;
}

.submenu .menu__enlace:hover,
.submenu .menu__item--actual > .menu__enlace {
  background: var(--cab-hover);
  color: var(--cab-acento-claro);
}

.submenu__icono { display: none; }

/* --- Botón Educación ------------------------------------------------------- */
.cabecera__boton {
  display: flex;
  align-items: center;
}

.boton-educacion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 6px;
  background: var(--cab-acento, var(--color-verde));
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
  transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.boton-educacion:hover,
.boton-educacion:focus-visible {
  background: var(--cab-acento-oscuro, #1b5e21);
  color: #fff;
  box-shadow: 0 4px 10px rgba(36, 119, 43, .28);
  transform: translateY(-1px);
}

.boton-educacion__icono {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Redes sociales -------------------------------------------------------- */
.redes {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}

.redes__enlace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--cab-texto-suave);
  line-height: 1;
  transition: color .2s ease, background-color .2s ease;
}

.redes__enlace:hover,
.redes__enlace:focus-visible {
  background: var(--cab-hover);
  color: var(--cab-texto-activo);
}

.redes__enlace svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* --- Botón Usuario (dentro del menú móvil) --------------------------------- */
.cabecera__usuario { display: none; }

.boton-usuario,
.boton-usuario:link,
.boton-usuario:visited,
.boton-usuario:hover,
.boton-usuario:active {
  color: #fff;
  text-decoration: none;
}

.boton-usuario {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 6px;
  background-color: var(--cab-hover);
  border: 1px solid var(--cab-linea);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease;
}

.boton-usuario:hover { background-color: #2f333a; }

.boton-usuario__icono {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Botón hamburguesa ----------------------------------------------------- */
.cabecera__abrir { display: none; }

/* ==========================================================================
   Escritorio (≥ 922 px)
   ========================================================================== */
@media (min-width: 922px) {
  .cabecera__contenedor { max-width: 1240px; }
  .menu > .menu__item:last-child > .menu__enlace { margin-right: 0; }
}

/* Pantallas medianas: se compacta un poco para que todo quepa en una línea */
@media (min-width: 922px) and (max-width: 1100px) {
  .cabecera { --cab-logo: 170px; }
  .menu__enlace { padding: 0 .7em; }
  .menu > .menu__item > .menu__enlace::after { left: .7em; right: .7em; }
  .redes { margin-left: 8px; padding-left: 12px; }
}

/* ==========================================================================
   Móvil y tableta (≤ 921 px)
   ========================================================================== */
@media (max-width: 921px) {
  .cabecera__barra { line-height: 3; }

  .cabecera { --cab-alto: 60px; --cab-logo: 170px; }

  .cabecera__contenedor {
    min-height: var(--cab-alto);
    padding: 0 16px;
  }

  .cabecera__marca { flex: 1 1 0%; }

  .cabecera__logo {
    width: 100%;
    padding: 8px 0;
  }

  .redes { display: none; }

  /* Botón que abre y cierra el menú */
  .cabecera__abrir {
    display: flex;
    align-items: center;
    width: auto;
    height: auto;
    padding: .5em;
    border: none;
    border-radius: 2px;
    background: transparent;
    box-shadow: none;
    color: var(--cab-texto);
    font-size: 1.5em;
    font-weight: 400;
    line-height: 1.85714;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
  }

  .cabecera__abrir:hover,
  .cabecera__abrir:focus {
    border: none;
    background: transparent;
    color: var(--cab-texto-activo);
  }

  .cabecera__abrir svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: currentColor;
  }

  .cabecera__abrir .icono-cerrar { display: none; }
  .cabecera--abierta .cabecera__abrir .icono-menu { display: none; }
  .cabecera--abierta .cabecera__abrir .icono-cerrar { display: block; }

  /* Panel desplegable */
  .cabecera__zona { position: static; }

  .cabecera__panel {
    position: absolute;
    top: 100%;
    left: 0;
    display: none;
    width: 100%;
    height: auto;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--cab-linea);
    background-color: var(--cab-fondo-2);
    box-shadow: 0 14px 24px -12px rgba(0, 0, 0, .6);
    line-height: var(--interlineado);
  }

  .cabecera--abierta .cabecera__panel { display: block; }

  .cabecera__panel > * { padding: 0; }

  .menu-principal,
  .menu {
    display: block;
    width: 100%;
    height: auto;
  }

  .menu { line-height: 3; }

  .menu__item {
    display: block;
    width: 100%;
    line-height: 3;
  }

  .menu__enlace {
    display: block;
    width: 100%;
    padding: 0 20px;
    background-color: var(--cab-fondo-2);
    color: var(--cab-texto);
  }

  .menu__item--actual > .menu__enlace,
  .menu__item--ancestro > .menu__enlace {
    background: var(--cab-hover);
    color: var(--cab-acento-claro);
  }

  .menu__enlace:hover,
  .menu__item:hover > .menu__enlace {
    background: var(--cab-hover);
    color: var(--cab-texto-activo);
  }

  .menu__flecha { display: none; }
  .menu > .menu__item > .menu__enlace::after { display: none; }

  .menu__desplegar {
    position: absolute;
    top: 0;
    right: 20px;
    display: inline-block;
    padding: 0 .907em;
    border: 0 dotted transparent;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: var(--cab-texto);
    font-size: inherit;
    font-weight: 400;
    line-height: inherit;
    cursor: pointer;
  }

  .menu__desplegar:hover,
  .menu__desplegar:focus {
    border-color: inherit;
    background: transparent;
    color: var(--cab-texto-activo);
  }

  .menu__item--actual > .menu__desplegar,
  .menu__item--ancestro > .menu__desplegar { color: var(--cab-acento-claro); }

  .menu__desplegar svg {
    position: relative;
    width: .95em;
    height: .85em;
    margin-left: 10px;
    fill: currentColor;
    pointer-events: none;
  }

  .submenu {
    position: static;
    display: none;
    visibility: visible;
    width: auto;
    border: 0;
    background-color: var(--cab-fondo-2);
    box-shadow: none;
    opacity: 1;
    line-height: 3;
  }

  .submenu::before { display: none; }
  .menu__item--desplegado > .submenu { display: block; }

  .submenu .menu__item { line-height: 3; }

  .submenu .menu__enlace {
    display: block;
    padding: 0 20px 0 30px;
  }

  .submenu__icono {
    display: inline;
    margin-right: 5px;
  }

  .submenu__icono svg {
    top: .2em;
    width: .65em;
    height: .85em;
    margin: 0;
    transform: translate(0, -2px) rotateZ(270deg);
  }

  .cabecera__boton { padding: 12px 20px 4px; }
  .cabecera__usuario { display: block; padding: 8px 20px; }
  .boton-usuario { margin-left: 0; }
}

@media (max-width: 544px) {
  .menu__enlace:hover,
  .menu__item:hover > .menu__enlace {
    background: var(--cab-hover);
    color: var(--cab-texto-activo);
  }

  .menu__item:hover > .menu__desplegar { color: var(--cab-texto-activo); }
}
