/* ==========================================================================
   LOOKITSGRAPHIC — En-tête d'outil harmonisé
   --------------------------------------------------------------------------
   Feuille commune à tous les studios. Elle est chargée APRÈS le
   styles/main.css de chaque outil et surcharge sa barre d'en-tête pour
   obtenir la même composition partout (référence : outil Universal
   Converter).

   La classe .lig-header est posée sur le <header> par scripts/tool-header.js,
   qui réinjecte aussi les repères manquants. Les !important sont nécessaires :
   plusieurs outils sont livrés avec un CSS compilé très spécifique.

   La fiche ouverte par le bouton INFOS n'est plus ici : chaque studio porte la
   sienne dans <outil>/styles/fiche.css, pilotée par <outil>/scripts/fiche.js.
   ========================================================================== */

/* Hauteur du bandeau contextuel, lue aussi par le contenu qui suit. */
:root {
  --lig-strip: 46px;
}

.lig-header {
  --lig-ink: var(--ink, #11110f);
  --lig-paper: var(--paper, #f3f0e8);
  --lig-acid: var(--acid, #d9ff32);
  --lig-mono: "Courier New", ui-monospace, monospace;

  position: relative;
  display: flex !important;
  align-items: center;
  gap: 20px;
  box-sizing: border-box;
  padding: 0 24px !important;
  background: var(--lig-paper);
  border-bottom: 2px solid var(--lig-ink) !important;
}

/* Plus aucune cloison verticale entre les sections de l'en-tête. */
.lig-header > * {
  border-left: 0 !important;
  border-right: 0 !important;
}

/* Pastilles de réassurance, numéro d'outil et liens redondants : le bouton
   INFOS et le logo couvrent désormais ces informations. */
.lig-header .privacy-pill,
.lig-header .privacy-note,
.lig-header .local-pill,
.lig-header .header-center,
.lig-header .tool-number,
.lig-header .site-link,
.lig-header .lig-hidden {
  display: none !important;
}

/* --------------------------------------------------------------- Logo --- */

.lig-header .brand {
  display: flex !important;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  color: inherit;
  text-decoration: none;
}

.lig-header .logo-box {
  display: grid;
  flex: 0 0 52px;
  place-items: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  background: var(--lig-ink);
  border: 2px solid var(--lig-ink);
  box-shadow: 5px 5px 0 var(--lig-acid);
}

.lig-header .logo-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lig-header .brand > b,
.lig-header .brand > .brand-copy {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start !important;
  gap: 4px;
  min-width: 0 !important;
  font-family: inherit;
  font-size: 23px !important;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
  text-align: left !important;
  white-space: nowrap;
}

.lig-header .brand small {
  align-self: flex-start;
  font: 700 10px/1.25 var(--lig-mono) !important;
  letter-spacing: 0.19em !important;
  text-align: left !important;
  text-transform: uppercase;
}

/* ------------------------------------------------- Accroche centrale --- */

.lig-header .lig-tool-tag {
  display: flex !important;
  /* Base nulle : l'accroche occupe l'espace restant mais cède la place aux
     boutons plutôt que de faire déborder la barre. */
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  padding: 0 !important;
  font: 700 12px/1.2 var(--lig-mono) !important;
  color: var(--lig-ink);
  letter-spacing: 0.14em !important;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.lig-header .lig-tool-tag i {
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--lig-acid);
  border: 1px solid var(--lig-ink);
  border-radius: 50%;
}

.lig-header .lig-tool-tag span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------- Actions ----- */

/* Ordre commun : logo, accroche, historique, boutons. Le reste des studios
   place ses éléments par grille ; on repasse tout en flex ordonné. */
.lig-header .mobile-menu { order: 0; }
.lig-header .brand { order: 1; }
.lig-header .lig-tool-tag { order: 2; }
.lig-header .history-actions { order: 3; }
.lig-header .lig-actions { order: 4; }
.lig-header .mobile-inspector { order: 5; }

.lig-header .history-actions {
  display: flex !important;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 0 !important;
}

.lig-header .history-actions + .lig-actions {
  margin-left: 0;
}

.lig-header .lig-actions {
  display: flex !important;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  padding: 0 !important;
}

/* Les séparateurs décoratifs glissés entre les boutons. */
.lig-header .lig-actions > i,
.lig-header .lig-actions > hr {
  display: none !important;
}

/* Direct children only : les menus déroulants d'export ne doivent pas être
   forcés à l'affichage ni reprendre le gabarit des boutons de la barre. */
.lig-header .lig-actions > button,
.lig-header .lig-actions > .popover-wrap > button,
.lig-header .lig-actions > a,
.lig-header .history-actions > button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 40px !important;
  padding: 0 14px !important;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  color: var(--lig-ink);
  letter-spacing: 0.035em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  background: #fff;
  border: 2px solid var(--lig-ink) !important;
  border-radius: 0 !important;
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}

.lig-header .lig-actions > button:hover:not(:disabled),
.lig-header .lig-actions > .popover-wrap > button:hover:not(:disabled),
.lig-header .lig-actions > a:hover,
.lig-header .history-actions > button:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  background: #fff;
  box-shadow: 4px 4px 0 var(--lig-ink);
}

.lig-header .lig-actions > button:disabled,
.lig-header .history-actions > button:disabled {
  opacity: 0.35;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.lig-header .lig-actions > button > svg,
.lig-header .history-actions > button > svg {
  flex: none;
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Bandeau contextuel
   --------------------------------------------------------------------------
   Titre du document, onglets de mode et autres repères propres à l'outil
   n'ont rien à faire dans la barre de marque. Ils sont sortis en un bandeau
   pleine largeur juste sous l'en-tête. Le déplacement est fait en CSS :
   plusieurs studios rendent ces blocs depuis un bundle React, qui casserait
   si on les sortait vraiment de son arbre.
   ========================================================================== */

.lig-header .active-document,
.lig-header .document-title,
.lig-header .mode-switch,
.lig-header .mode-tabs {
  position: absolute !important;
  top: 100% !important;
  right: 0 !important;
  bottom: auto !important;
  left: 0 !important;
  z-index: 9;
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-start !important;
  gap: 12px;
  box-sizing: border-box;
  /* Sans cela, un justify-self hérité de l'outil ferait rétrécir le bandeau
     à la largeur de son contenu au lieu de le laisser occuper la ligne. */
  align-self: auto !important;
  justify-self: normal !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: var(--lig-strip) !important;
  margin: 0 !important;
  padding: 0 24px !important;
  background: var(--lig-paper);
  border: 0 !important;
  border-bottom: 2px solid var(--lig-ink) !important;
  box-shadow: none !important;
}

/* Libellé du bandeau (« PROJET ACTIF », « CARTE ACTIVE »…). */
.lig-header .active-document > span,
.lig-header .document-title > span {
  flex: none;
  font: 700 10px/1 var(--lig-mono);
  letter-spacing: 0.19em;
  text-transform: uppercase;
  opacity: 0.55;
}

.lig-header .active-document > strong,
.lig-header .document-title > strong {
  flex: 0 1 auto;
  overflow: hidden;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lig-header .document-title > input {
  flex: 0 1 320px;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  border: 2px solid var(--lig-ink);
  border-radius: 0;
}

.lig-header .active-document > small,
.lig-header .document-title > small {
  flex: none;
  margin-left: auto;
  font: 700 10px/1 var(--lig-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.65;
}

.lig-header .mode-switch button,
.lig-header .mode-tabs button {
  display: inline-flex;
  flex: 0 0 auto !important;
  align-items: center;
  gap: 7px;
  min-width: 0 !important;
  height: 30px !important;
  padding: 0 14px !important;
  font-family: inherit;
  font-size: 11px !important;
  font-weight: 900;
  color: var(--lig-ink);
  letter-spacing: 0.035em;
  text-transform: uppercase;
  background: #fff !important;
  border: 2px solid var(--lig-ink) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  cursor: pointer;
}

.lig-header .mode-switch button.active,
.lig-header .mode-tabs button.active {
  color: #fff;
  background: var(--lig-ink) !important;
}

.lig-header .mode-tabs button b {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 0 !important;
  font: 700 8px/1 var(--lig-mono);
  color: var(--lig-ink);
  background: #fff;
  border: 1px solid var(--lig-ink);
}

/* On réserve la hauteur du bandeau sur le contenu qui suit l'en-tête. */
.lig-header:has(.active-document) + *,
.lig-header:has(.document-title) + *,
.lig-header:has(.mode-switch) + *,
.lig-header:has(.mode-tabs) + * {
  padding-top: var(--lig-strip, 46px) !important;
}

/* Bouton principal de chaque outil, quelle que soit sa classe d'origine. */
.lig-header .lig-actions > .btn-solid,
.lig-header .lig-actions > .top-export,
.lig-header .lig-actions > .export-button,
.lig-header .lig-actions > .acid,
.lig-header .lig-actions > .lig-primary,
.lig-header .lig-actions > .popover-wrap > .lig-primary {
  color: #fff !important;
  background: var(--lig-ink) !important;
}

.lig-header .lig-actions > .lig-info,
.lig-header .lig-actions > .lig-info:hover {
  color: var(--lig-ink) !important;
  background: var(--lig-acid) !important;
}

.lig-header .lig-actions > .lig-info > span[aria-hidden] {
  display: grid !important;
  flex: none;
  place-items: center;
  width: 15px;
  height: 15px;
  font: 900 10px/1 var(--lig-mono);
  border: 2px solid var(--lig-ink);
  border-radius: 50%;
}

/* Le menu déroulant d'export de Markdown Studio reste ancré sous son bouton. */
.lig-header .lig-actions .popover-wrap {
  position: relative;
  display: inline-flex;
}

/* --------------------------------------------------------- Responsive -- */

@media (max-width: 1180px) {
  .lig-header {
    gap: 14px;
    padding: 0 16px !important;
  }
  .lig-header .lig-actions button,
  .lig-header .lig-actions a {
    padding: 0 10px !important;
  }
}

@media (max-width: 1024px) {
  .lig-header .lig-tool-tag {
    display: none !important;
  }
}

@media (max-width: 720px) {
  .lig-header .brand > b,
  .lig-header .brand > .brand-copy {
    font-size: 19px !important;
  }
  .lig-header .logo-box {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    box-shadow: 4px 4px 0 var(--lig-acid);
  }
}
