/* =============================================================================
   modal.css — Modal AJAX qui zoome au centre
   =============================================================================
   Activé au clic sur une tuile (intercepté par modal.js).
   Le contenu est chargé en AJAX depuis modules/<slug>.php
   ============================================================================= */

/* =============================================================================
   OVERLAY (fond sombre flouté)
   ============================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-overlay-in 0.25s ease;
}

.modal-overlay[hidden] { display: none; }

.modal-overlay.closing {
  animation: modal-overlay-out 0.25s ease forwards;
}

@keyframes modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* =============================================================================
   LA BOÎTE DU MODAL (qui zoome)
   ============================================================================= */
.content-modal {
  background: #f5f5f7;
  color: #1b1b1b;
  width: 100%;
  max-width: 1200px;
  /* Hauteur fixe pour éviter que la modale ne saute en fonction du contenu.
     min/max identiques = hauteur stable, peu importe ce qu'on charge dedans. */
  height: 80vh;
  min-height: 550px;
  max-height: 80vh;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: modal-zoom-in 0.45s cubic-bezier(.22, 1, .36, 1);
}

.modal-overlay.closing .content-modal {
  animation: modal-zoom-out 0.25s ease forwards;
}

@keyframes modal-zoom-in {
  from { transform: translateY(40px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes modal-zoom-out {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to   { transform: translateY(20px) scale(0.96); opacity: 0; }
}

/* =============================================================================
   HEADER DU MODAL (barre bleue avec titre + X)
   ============================================================================= */
.content-modal-header {
  background: var(--bg-tile-blue);
  color: #fff;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.content-modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.2;
  flex: 1;
  /* Coupe proprement les titres trop longs sur mobile */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.2s ease;
  font-family: inherit;
}

.content-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* =============================================================================
   CORPS DU MODAL (zone scrollable)
   ============================================================================= */
.content-modal-body {
  padding: 28px 32px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px;
  line-height: 1.6;
  color: #1b1b1b;
}

/* Styles de base du contenu (utilisés par les stubs et plus tard tous les modals) */
.content-modal-body h1,
.content-modal-body h2,
.content-modal-body h3 {
  color: #1b1b1b;
  margin: 16px 0 10px;
}

.content-modal-body h1 { font-size: 24px; }
.content-modal-body h2 { font-size: 20px; }
.content-modal-body h3 { font-size: 17px; }

.content-modal-body p {
  margin-bottom: 12px;
}

.content-modal-body a {
  color: var(--bg-tile-blue);
  text-decoration: underline;
}

/* Indicateur de chargement (affiché pendant le fetch AJAX) */
.modal-loading {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.modal-loading::after {
  content: '';
  display: inline-block;
  width: 32px;
  height: 32px;
  margin-top: 16px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--bg-tile-blue);
  border-radius: 50%;
  animation: modal-spinner 0.8s linear infinite;
}

@keyframes modal-spinner {
  to { transform: rotate(360deg); }
}

/* Message d'erreur si le fetch échoue */
.modal-error {
  text-align: center;
  padding: 40px 20px;
  color: #c5221f;
}

.modal-error a {
  display: inline-block;
  margin-top: 10px;
  color: var(--bg-tile-blue);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

/* Écrans pas très hauts (laptops, tablettes paysage) : on assouplit le min-height
   pour ne pas dépasser la fenêtre */
@media (max-height: 700px) {
  .content-modal {
    min-height: 0;
    height: 92vh;
    max-height: 92vh;
  }
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 0;
    /* Ancré en haut plutôt que centré : même si la hauteur calculée déborde
       légèrement (barre d'adresse mobile qui apparaît/disparaît), c'est le
       BAS qui déborde, jamais l'en-tête — la croix de fermeture reste
       toujours visible. */
    align-items: flex-start;
  }
  .content-modal {
    max-width: 100%;
    /* dvh = hauteur réellement visible sur mobile (tient compte de la barre
       d'adresse) ; 100vh reste en repli pour les navigateurs plus anciens. */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 100vh;  /* écrase le min-height: 600px du desktop */
    min-height: 100dvh;
    border-radius: 0;
  }
  .content-modal-header { padding: 16px 20px; }
  .content-modal-header h2 { font-size: 18px; letter-spacing: 0.5px; }
  .content-modal-body { padding: 20px; font-size: 14px; }
}

/* Quand un modal est ouvert : on bloque le scroll du body */
body.modal-open {
  overflow: hidden;
}
