/*
 * Header : logo hors barre + top barre (menu liens et menu reseaux sociaux)
 * + barre de menu principale blanche.
 */

/* Largeur ajustee au contenu, ensemble logo + menu centre dans la page */
.header-main {
  display: flex;
  align-items: flex-end;
  width: fit-content;
  max-width: 95%;
  margin: 0 auto;
  gap: 20px;
}

/* Logo hors de la barre de menu, sans fond, aligne sur la barre blanche */
.header-logo-card {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  height: 100px;
  padding: 0 20px;
  transition: background-color 0.35s ease;
}

.header-logo-card a {
  display: block;
  line-height: 0;
  padding: 0;
  margin: 0;
}

.header-logo-card img {
  display: block;
  width: 230px;
  height: auto;
}

/* Colonne contenant la top barre et la barre de menu */
.header-bars {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Top barre : bleu fonce, largeur ajustee au nombre d'items, alignee a droite */
.header-topbar {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  width: fit-content;
  max-width: 100%;
  align-self: flex-end;
  background-color: var(--pes-blue-darker);
  border-radius: 10px 10px 0 0;
  padding: 0.5rem 2.25rem;
}

/* Aplatit les wrappers region/bloc de Drupal dans la top barre */
.header-topbar .region,
.header-topbar .block-menu {
  display: contents;
}

.topbar-menu,
.social-menu {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.social-menu {
  gap: 1rem;
}

.topbar-menu-item,
.social-menu-item {
  display: flex;
  align-items: center;
}

.topbar-menu-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  /* Typo top barre alignee sur montpellier.fr : 12px / 600 / uppercase / 0.06em */
  font-family: 'Montpellier', sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

/* !important requis : main.css force a:hover { color: inherit !important },
   ce qui rendait le texte gris fonce sur le fond bleu. Survol = blanc souligne
   (le soulignement vient de la regle globale a:hover). */
.topbar-menu-link:hover {
  color: white !important;
}

.topbar-external-icon {
  font-size: 11px;
}

.social-menu-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: white;
  font-size: 16px;
  text-decoration: none !important;
}

.social-menu-link:hover {
  color: var(--pes-green) !important;
}

/* Espace entre le haut du site et la top barre */
@media screen and (min-width: 992px) {
  #header {
    padding-top: 16px;
  }
}

/* Logo blanc sur le hero via filtre, couleurs d'origine sur fond blanc */
.header-logo-card img {
  filter: brightness(0) invert(1);
  transition: filter 0.35s ease;
}

/*
 * Comportement au scroll :
 * - vers le bas : le header glisse vers le haut et disparait
 * - vers le haut : il redescend avec un fond blanc et le logo couleur
 * - en haut de page : retour au header d'origine (transitions)
 */
#header {
  transition: transform 0.35s ease, background-color 0.35s ease, box-shadow 0.35s ease;
}

#header.header-fixed {
  position: fixed;
  top: 0;
  transform: translateY(-100%);
}

/*
 * Utilisateur connecte : la barre d'administration Drupal (fixe, 46px,
 * + tiroir horizontal 40px) recouvrait le header positionne a top: 0.
 * Decalage du header, y compris sa variante fixe au scroll.
 */
body.toolbar-fixed #header,
body.toolbar-fixed #header.header-fixed {
  top: 46px;
}

body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open #header,
body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open #header.header-fixed {
  top: 86px;
}

#header.header-fixed.header-revealed {
  transform: translateY(0);
}

/* Fond blanc uniquement derriere le logo */
#header.header-fixed.header-revealed .header-logo-card {
  background-color: white;
  border-radius: 0 0 10px 10px;
}

#header.header-fixed.header-revealed .header-logo-card img {
  filter: none;
}

@media screen and (max-width: 991.9px) {
  .header-main {
    width: 100%;
    gap: 8px;
    align-items: center;
  }

  /* Bande bleue pleine sur mobile */
  #header {
    background-color: var(--pes-blue-darker);
    box-shadow: 0 2px 10px rgba(21, 45, 104, 0.15);
  }

  .header-logo-card {
    height: auto;
    padding: 8px 0 8px 12px;
  }

  .header-logo-card img {
    width: 160px;
  }

  /* La barre blanche disparait : seul le burger reste visible */
  .menu-bar {
    background-color: transparent;
    border-radius: 0;
  }
}
