/* ==========================================================================
   Energesia — adaptations tablette & mobile
   Les pages utilisent des styles en ligne : les règles ci-dessous les
   surchargent (!important) uniquement sous les points de rupture.
   ========================================================================== */

img, video, iframe, svg { max-width: 100%; }
[style*="display:grid"] > *, [style*="display: grid"] > * { min-width: 0; }

/* ---------- Bouton menu + panneau mobile (injectés par responsive.js) ---------- */
.ens-burger, .ens-mnav { display: none; }

/* ======================= TABLETTE (≤ 1080 px) ======================= */
@media (max-width: 1080px) {
  /* Navigation : on masque le menu horizontal, on affiche le bouton menu */
  [data-nav-desktop], [data-navphone] { display: none !important; }
  #ens-navcta, [data-ens-nav] a[href$="#contact"][style*="--solar"],
  [data-ens-nav] a[style*="background:var(--solar)"] { display: none !important; }
  .ens-burger {
    display: inline-flex; position: fixed; top: 14px; right: 16px; z-index: 1001;
    width: 46px; height: 46px; align-items: center; justify-content: center;
    border: 1px solid rgba(11,42,61,.14); border-radius: 12px; background: rgba(255,255,255,.96);
    box-shadow: 0 8px 22px -10px rgba(11,42,61,.45); cursor: pointer; padding: 0; color: #0b2a3d;
  }
  .ens-burger svg { width: 22px; height: 22px; }

  /* Grilles 4 et 6 colonnes -> 2 colonnes */
  [style*="grid-template-columns:repeat(4"], [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(6"], [style*="grid-template-columns:1.5fr 1fr 1fr 1fr"],
  [style*="grid-template-columns:1.4fr 1fr 1fr 1fr"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* Colonne fixe + contenu */
  [style*="grid-template-columns:250px 1fr"] { grid-template-columns: 1fr !important; }
}

/* ======================= MOBILE (≤ 760 px) ======================= */
@media (max-width: 760px) {
  /* Toutes les grilles en ligne passent sur une colonne… */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  /* …sauf les petites grilles de chiffres, gardées sur 2 colonnes */
  [style*="grid-template-columns:repeat(4"], [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(6"], [data-stats-grid], [data-modal-grid] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  [style*="grid-template-columns"]:not([style*="gap:1px"]) { row-gap: 18px !important; }

  /* Lignes « libellé / valeur » (mentions légales, confidentialité) */
  [style*="grid-template-columns:220px 1fr"], [style*="grid-template-columns:200px 1fr"],
  [style*="grid-template-columns:1fr 1.4fr .7fr"] { gap: 4px !important; }

  /* Rangées flex qui débordent */
  [style*="justify-content:space-between"] { flex-wrap: wrap; }

  /* Marges verticales un peu plus compactes */
  section[style*="padding:clamp(80px"], section[style*="padding:clamp(72px"],
  section[style*="padding:clamp(64px"] { padding-top: 56px !important; padding-bottom: 56px !important; }

  /* Hauteurs minimales pensées pour le bureau */
  [style*="min-height:100vh"] { min-height: 92svh !important; }
  [style*="min-height:340px"] { min-height: 220px !important; }

  /* Cartes « à la une » des actualités */
  [data-featured] { grid-template-columns: 1fr !important; }

  /* Carte des centrales */
  #ens-map { height: 420px !important; }

  /* Menus déroulants desktop jamais affichés */
  [data-dropdown] { display: none !important; }

  /* Boutons pleine largeur dans les bandeaux d'appel à l'action */
  section a[style*="padding:16px 30px"], section a[style*="padding:15px 26px"] { justify-content: center; }

  /* Fenêtre de contact */
  [role="dialog"] { max-width: 100% !important; border-radius: 14px !important; }
}

/* ======================= PETIT MOBILE (≤ 420 px) ======================= */
@media (max-width: 420px) {
  [data-modal-grid] { grid-template-columns: 1fr !important; }
  h1 { font-size: clamp(30px, 9vw, 40px) !important; }
}

/* ======================= PANNEAU MENU MOBILE ======================= */
@media (max-width: 1080px) {
  .ens-mnav {
    display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(8,34,47,.5);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .ens-mnav.is-open { opacity: 1; pointer-events: auto; }
  .ens-mnav__panel {
    position: absolute; top: 0; right: 0; bottom: 0; width: min(88vw, 380px); background: #fff;
    overflow-y: auto; padding: 78px 22px 28px; box-shadow: -20px 0 50px -20px rgba(8,34,47,.5);
    transform: translateX(100%); transition: transform .25s cubic-bezier(0.23,1,0.32,1);
    font-family: 'Geist', system-ui, -apple-system, sans-serif;
  }
  .ens-mnav.is-open .ens-mnav__panel { transform: none; }
  .ens-mnav__group { border-top: 1px solid #e6e8ea; padding: 12px 0; }
  .ens-mnav__top { display: block; font-size: 17px; font-weight: 600; color: #0b2a3d; text-decoration: none; padding: 8px 2px; }
  .ens-mnav__sub { display: block; font-size: 15px; color: #45535c; text-decoration: none; padding: 7px 2px 7px 14px; }
  .ens-mnav__cta { display: flex; justify-content: center; margin-top: 18px; background: #f4a72c; color: #2a1c05; font-weight: 600;
    font-size: 16px; text-decoration: none; padding: 14px 18px; border-radius: 11px; }
  .ens-mnav__tel { display: flex; justify-content: center; margin-top: 10px; color: #0b2a3d; font-weight: 600; text-decoration: none;
    padding: 12px; border: 1px solid #dfe3e6; border-radius: 11px; font-family: 'Geist Mono', monospace; }
  body.ens-mnav-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .ens-mnav, .ens-mnav__panel { transition: none; }
}
