/**
 * En-tête.
 *
 * Cette feuille est rattachée au rendu du composant : elle n'est chargée que
 * sur les pages qui l'emploient, et rien d'autre dans le thème n'en dépend.
 *
 * Les sélecteurs visent les classes du composant et non celles que Drupal
 * pose sur ses blocs : la barre est désormais rendue d'un seul tenant, son
 * balisage lui appartient.
 */

.tc-header {
  position: relative;
  z-index: 20;
  background: var(--tc-night);
  color: var(--tc-surface);
}

/* Superposée au visuel d'ouverture. Le dégradé descend au-delà de la barre
   pour que la transition vers l'image soit insensible : une coupe nette au
   ras du texte se verrait comme un bandeau. */
.tc-header--transparent {
  position: absolute;
  inset: 0 0 auto;
  background: none;
}

.tc-header--transparent::before {
  content: "";
  position: absolute;
  inset: 0 0 -60px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.tc-header a {
  color: inherit;
  text-decoration: none;
}

.tc-header a:hover,
.tc-header a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.tc-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--tc-space-6);
  min-height: var(--tc-header-height);
  max-width: var(--tc-max-width);
  margin-inline: auto;
  padding-inline: var(--tc-gutter);
}

/* Le tiroir n'existe pas sur grand écran : `display: contents` le retire de
   la mise en page et ses deux enfants se rangent comme s'ils étaient
   directement dans la barre. Sous 900 px il redevient une boîte. */
.tc-header__drawer {
  display: contents;
}

/* Bouton d'ouverture, sans emploi tant que la barre tient en ligne. */
.tc-header__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-inline-start: auto;
  border: 0;
  border-radius: var(--tc-radius-sm);
  background: none;
  color: inherit;
  cursor: pointer;
}

.tc-header__toggle:hover,
.tc-header__toggle:focus-visible {
  background: rgba(255, 255, 255, .16);
}

.tc-header__toggle-icon {
  width: 22px;
  height: 22px;
}

.tc-header__toggle-icon--close,
.tc-header__toggle[aria-expanded="true"] .tc-header__toggle-icon--open {
  display: none;
}

.tc-header__toggle[aria-expanded="true"] .tc-header__toggle-icon--close {
  display: block;
}

/* Logo. Une hauteur fixe et une largeur libre : le fichier peut changer de
   proportions sans que la barre ne bouge. */
.tc-header__logo {
  display: flex;
  align-items: center;
  flex: none;
}

.tc-header__logo-image {
  display: block;
  height: var(--tc-logo-height);
  width: auto;
}

.tc-header__logo-text {
  font-family: var(--tc-serif);
  font-size: var(--tc-fs-lg);
  letter-spacing: .02em;
}

/* Menu principal. */
.tc-header__nav-list {
  display: flex;
  align-items: center;
  gap: var(--tc-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tc-header__nav-list a {
  display: inline-flex;
  align-items: center;
  padding: var(--tc-space-2) var(--tc-space-3);
  border-radius: var(--tc-radius-sm);
  font-size: var(--tc-fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 160ms ease;
}

/* Le survol prend un fond plutôt qu'un soulignement : sur une barre posée sur
   une photographie, un trait fin se perd selon l'image, une surface non. */
.tc-header__nav-list a:hover,
.tc-header__nav-list a:focus-visible {
  background: rgba(255, 255, 255, .16);
  text-decoration: none;
}

.tc-header__nav-list a[aria-current] {
  background: rgba(255, 255, 255, .10);
}

/* Les services sont poussés à droite par la marge automatique plutôt que par
   un `justify-content: space-between` : la navigation garde ainsi ses éléments
   groupés à gauche même lorsqu'elle en contient peu. */
.tc-header__services {
  display: flex;
  align-items: center;
  gap: var(--tc-space-5);
  margin-inline-start: auto;
  font-size: var(--tc-fs-sm);
}

.tc-header__phone {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-2);
  font-weight: 600;
  white-space: nowrap;
}

.tc-header__phone-icon {
  width: 15px;
  height: 15px;
  flex: none;
}

.tc-header__services-list {
  display: flex;
  align-items: center;
  gap: var(--tc-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
}

/* Compte. L'entrée porte une icône parce qu'elle ne dit pas la même chose
   selon la session : le pictogramme reste stable quand le libellé change.

   La même classe habille un lien et un bouton — d'où la remise à zéro : sans
   elle, le bouton garderait la police et le fond du système. */
.tc-header__account {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-2);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.tc-header__account-icon {
  width: 15px;
  height: 15px;
  flex: none;
}

.tc-header__account-menu {
  position: relative;
}

.tc-header__account-chevron {
  width: 10px;
  height: 10px;
  flex: none;
  opacity: .7;
  transition: transform 160ms ease;
}

.tc-header__account[aria-expanded="true"] .tc-header__account-chevron {
  transform: rotate(180deg);
}

.tc-header__account-list {
  display: none;
  position: absolute;
  top: calc(100% + var(--tc-space-2));
  inset-inline-end: 0;
  z-index: 1;
  min-width: 190px;
  margin: 0;
  padding: var(--tc-space-2);
  list-style: none;
  border-radius: var(--tc-radius-sm);
  background: var(--tc-night);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
}

.tc-header__account-list.is-open {
  display: block;
}

.tc-header__account-list a {
  display: block;
  padding: var(--tc-space-2) var(--tc-space-3);
  border-radius: var(--tc-radius-sm);
  font-size: var(--tc-fs-sm);
  white-space: nowrap;
}

.tc-header__account-list a:hover,
.tc-header__account-list a:focus-visible {
  background: rgba(255, 255, 255, .16);
  text-decoration: none;
}

/* Sélecteur de langue. */
.tc-header__languages {
  display: flex;
  align-items: center;
  gap: var(--tc-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--tc-fs-2xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tc-header__languages a { opacity: .7; }

.tc-header__languages a.is-active {
  color: var(--tc-title-on-image);
  opacity: 1;
}

/* Bande intermédiaire.
 *
 * La ligne complète réclame environ 1060 px. En dessous, plutôt que de
 * basculer tout le menu derrière un bouton dès 1080 px — ce qui priverait les
 * tablettes en paysage de leur navigation — le numéro se réduit à son icône.
 * Il reste appelable, et la ligne y gagne près de 150 px. */
@media (min-width: 901px) and (max-width: 1080px) {
  .tc-header__phone-text {
    display: none;
  }

  .tc-header__inner {
    gap: var(--tc-space-5);
  }

  .tc-header__services {
    gap: var(--tc-space-4);
  }

  /* Les liens du menu se resserrent aussi : à 901 px la ligne tenait à zéro
     près, ce qui n'est pas une marge mais un hasard. */
  .tc-header__nav-list a {
    padding-inline: var(--tc-space-2);
  }
}

@media (max-width: 900px) {
  .tc-header { --tc-header-height: 64px; --tc-logo-height: 38px; }

  .tc-header__toggle { display: inline-flex; }

  /* Le tiroir redevient une boîte, posée sous la barre. Il se cale sur
     `.tc-header`, positionné dans les deux variantes — relatif en fond plein,
     absolu en superposition. */
  .tc-header__drawer {
    display: none;
    position: absolute;
    inset: 100% 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: var(--tc-space-4);
    padding: var(--tc-space-4) var(--tc-gutter) var(--tc-space-6);
    background: var(--tc-night);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  }

  .tc-header__drawer.is-open {
    display: flex;
  }

  /* En colonne, la surface de survol du menu occupe toute la largeur : sur un
     écran tactile, la cible utile est la ligne entière, pas le seul libellé. */
  .tc-header__nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .tc-header__nav-list a {
    padding: var(--tc-space-3);
    font-size: var(--tc-fs-md);
  }

  .tc-header__services {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--tc-space-4);
    margin-inline-start: 0;
    padding-top: var(--tc-space-4);
    border-top: 1px solid rgba(255, 255, 255, .16);
  }

  .tc-header__services-list {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--tc-space-3);
  }

  .tc-header__phone,
  .tc-header__account,
  .tc-header__services-list a {
    padding-block: var(--tc-space-1);
  }

  /* Dans le tiroir, la liste du compte se déroule sur place : un panneau en
     absolu déborderait du panneau qui le contient déjà. */
  .tc-header__account-list {
    position: static;
    min-width: 0;
    padding: var(--tc-space-1) 0 0 var(--tc-space-5);
    background: none;
    box-shadow: none;
  }

  .tc-header__account-list a {
    padding-inline: 0;
  }
}
