/**
 * Onify Theme - Alert / Callout / Banner
 * ----------------------------------------------------------------------------
 * Banner d'information contextuelle (info/success/warning/critical/neutral).
 * Theme-agnostic, zero hardcoded color (tout via tokens).
 *
 * USAGE :
 *   <div class="alert info">
 *     <div class="alert-icon"><svg/></div>
 *     <div class="alert-body">
 *       <div class="alert-title">Titre</div>
 *       <div class="alert-text">Message detaille...</div>
 *     </div>
 *     <a class="alert-action" href="...">CTA</a>
 *   </div>
 *
 * VARIANTES TONALES :
 *   .alert.info     -> accent
 *   .alert.positive -> positive (success)
 *   .alert.warning  -> warning
 *   .alert.critical -> critical (danger/error)
 *   .alert.neutral  -> ink-soft (default sobre)
 *
 * MODIFICATEURS :
 *   .alert.compact  -> padding reduit
 *   .alert.banner   -> full-width sans border-radius (top of page)
 */

.alert {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  font-family: 'Inter Tight', sans-serif;
  margin-bottom: 18px;
}

.alert.compact { padding: 10px 14px; gap: 12px; }

.alert.banner {
  border-radius: 0;
  margin-bottom: 0;
  border-left: none;
  border-right: none;
}

/* === Variantes tonales : la teinte sur le fond et l'icône, l'encre du thème sur le texte ===
   Mesure du 01/11/2026 : en teinte, le texte tombait à 2,60:1 (warning) ; à l'encre, 13,2:1 au
   moins pour le titre et 6,6:1 pour le texte (WCAG 1.4.3, 4,5:1). Le fond est opaque, teinte
   posée sur --bg-1 : là où midnight assombrit --paper (page par page), une teinte translucide
   devenait sombre sous une encre sombre (1,3:1). Le sens ne tient pas à la couleur seule :
   l'icône le porte (WCAG 1.4.1). */
.alert.info,
.alert.positive,
.alert.warning,
.alert.critical {
  border-color: transparent;
  color: var(--ink);
}
.alert.info     { background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--bg-1); }
.alert.positive { background: linear-gradient(var(--positive-soft), var(--positive-soft)), var(--bg-1); }
.alert.warning  { background: linear-gradient(var(--warning-soft), var(--warning-soft)), var(--bg-1); }
.alert.critical { background: linear-gradient(var(--critical-soft), var(--critical-soft)), var(--bg-1); }

.alert.info .alert-icon     { background: var(--accent); color: var(--bg-1); }
.alert.positive .alert-icon { background: var(--positive); color: var(--bg-1); }
.alert.warning .alert-icon  { background: var(--warning); color: var(--bg-1); }
.alert.critical .alert-icon { background: var(--critical); color: var(--bg-1); }

.alert.neutral {
  background: var(--bg-1);
  border-color: var(--line);
  color: var(--ink-soft);
}
.alert.neutral .alert-icon { background: var(--ink-soft); color: var(--bg-1); }

/* === Sous-composants =================================================== */
.alert-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink-soft);
  color: var(--paper);
  flex-shrink: 0;
}
.alert-icon svg { width: 16px; height: 16px; }

.alert-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.alert-title {
  font-size: var(--texte-courant, 14px);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}

.alert-text {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.alert-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--ink);
  color: var(--bg-1);
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--duree-courte, 120ms), box-shadow var(--duree-courte, 120ms);
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .alert-action:hover {
    box-shadow: var(--shadow-soft);
  }
}

.alert-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity var(--duree-courte, 120ms), background var(--duree-courte, 120ms);
  flex-shrink: 0;
}
.alert-close:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.alert-close svg { width: 14px; height: 14px; }

/* === Responsive ======================================================== */
/* Téléphone : 16 px pour ce qui se lit, 44 px sous le doigt (jetons de tokens.css, section 12).
   La hauteur de .alert-close passe par height et non min-height : les toasts d'alertMessages.js
   portent la même classe et gardent leur taille, fixée par #alert-container. */
@media (max-width: 767.98px) {
  .alert-title { font-size: var(--texte-courant); }
  .alert-text,
  .alert-action { font-size: var(--texte-secondaire); }
  .alert-action { min-height: var(--cible-tactile); }
  .alert-close { width: var(--cible-tactile); height: var(--cible-tactile); }
}

@media (max-width: 639.98px) {
  .alert {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 10px 12px;
    padding: 12px 14px;
  }
  .alert-icon  { grid-row: 1; grid-column: 1; width: 28px; height: 28px; }
  /* Sans icône, le message démarre au bord : sa colonne ne se réserve que derrière une icône. */
  .alert-body  { grid-row: 1; grid-column: 1 / -1; }
  .alert-icon + .alert-body { grid-column: 2; }
  .alert-action { grid-row: 2; grid-column: 1 / -1; justify-self: flex-end; }
  /* La fermeture reste à droite du message, dans une colonne implicite : deux colonnes déclarées
     pour .alert, car les alertes Bootstrap portent cette classe sans ces sous-éléments. */
  .alert-close { grid-row: 1; grid-column: 3; }
}
