/* ============================================
   ADES SA — RESPONSIVE
   ============================================ */

/* === TABLETTE (≤ 1024px) === */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .gov-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-item:nth-child(2) { border-right: none; }
  .stat-item:nth-child(1), .stat-item:nth-child(2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--space-8); }
  .grid-split { gap: var(--space-8); }
  .mega-menu-grid { grid-template-columns: 1fr 1fr; }
}

/* === MOBILE (≤ 768px) === */
@media (max-width: 768px) {
  :root { --header-height: var(--header-height-mobile); }

  .container, .container-narrow { padding-left: 1.25rem; padding-right: 1.25rem; }
  .section { padding-top: var(--space-10); padding-bottom: var(--space-10); }
  .section-lg { padding-top: var(--space-12); padding-bottom: var(--space-12); }

  /* === HEADER MOBILE === */
  .header-inner { height: var(--header-height-mobile); }
  .site-logo img { height: 40px; }

  .menu-toggle {
    display: block;
    position: relative;
    z-index: 1100;
  }

  /* Menu mobile : par-dessus tout, glisse depuis la droite */
  .site-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 360px;
    height: 100vh;
    height: 100dvh;
    background-color: var(--ades-white);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: calc(var(--header-height-mobile) + var(--space-4)) var(--space-5) var(--space-8);
    transform: translateX(100%);
    transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1050;
    box-shadow: -8px 0 32px rgba(0,0,0,0.2);
    -webkit-overflow-scrolling: touch;
  }
  .site-nav.active { transform: translateX(0); }

  /* Backdrop quand menu ouvert */
  body.nav-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    animation: fadeBackdrop 350ms ease;
    /* CRITIQUE : sans ça, le backdrop intercepte les clics dans le panneau
       car le <header> crée un stacking context qui plafonne le z-index du
       .site-nav à 200, alors que le backdrop est à 1040 en contexte global.
       pointer-events: none laisse le rôle visuel mais libère les clics. */
    pointer-events: none;
  }
  @keyframes fadeBackdrop {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
  }
  .nav-list > li { border-bottom: 1px solid var(--border); }
  .nav-list > li:last-child { border-bottom: none; }

  .nav-link {
    display: block;
    padding: var(--space-4) 0;
    font-size: var(--fs-base);
  }
  .nav-link::after { display: none; }

  /* === DROPDOWN TRIGGER MOBILE === */
  .nav-dropdown-trigger {
    width: 100%;
    justify-content: space-between;
    padding: var(--space-4) 0;
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
  }
  /* Forcer la taille du chevron en mobile */
  .nav-dropdown-trigger::after {
    width: 6px !important;
    height: 6px !important;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.6;
  }

  /* === MEGA MENU EN ACCORDION MOBILE === */
  .mega-menu {
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: none;
    border: none;
    background-color: var(--bg-secondary);
    width: 100%;
    min-width: 0;
    max-height: 0;
    overflow: hidden;
    padding: 0 var(--space-3);
    transition: max-height 400ms ease, padding 400ms ease;
  }
  .nav-dropdown.open .mega-menu {
    max-height: 2000px;
    padding: var(--space-3);
  }

  .mega-menu-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .mega-menu-column h4 {
    margin-top: var(--space-3);
    margin-bottom: var(--space-2);
    color: var(--ades-red);
  }
  .mega-menu-column a { padding: var(--space-2) var(--space-3); }

  .site-nav .btn { margin-top: var(--space-6); width: 100%; }

  /* === HERO MOBILE === */
  .hero { min-height: 90vh; }
  .hero-title { font-size: clamp(2rem, 9vw, 3rem); max-width: 100%; }
  .hero-subtitle { font-size: var(--fs-base); }
  .hero-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .hero-actions .btn { width: 100%; }
  .hero-dots { bottom: var(--space-8); }
  .hero-dot { width: 24px; }
  .hero-dot.active { width: 36px; }
  .hero-signature {
    bottom: var(--space-3);
    font-size: 9px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 var(--space-4);
    gap: var(--space-2);
  }
  .hero-signature .divider { display: none; }

  /* === GRIDS MOBILES === */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .gov-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-item {
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  }
  .stat-item:last-child { border-bottom: none; }
  .grid-split { grid-template-columns: 1fr; gap: var(--space-8); }
  .approche-image::before, .approche-image::after { width: 50px; height: 50px; }
  .approche-image { min-height: 280px; }

  /* === FOOTER MOBILE === */
  .footer-grid { grid-template-columns: 1fr; gap: var(--space-6); }
  .footer-bottom { flex-direction: column; gap: var(--space-3); text-align: center; }

  .section-header { margin-bottom: var(--space-8); }

  .btn { padding: var(--space-3) var(--space-5); font-size: var(--fs-xs); }
}

/* === PETIT MOBILE (≤ 480px) === */
@media (max-width: 480px) {
  .gov-grid { grid-template-columns: 1fr; }
  .hero-content { padding: var(--space-8) 0; }
  .hero-title { font-size: clamp(1.75rem, 8vw, 2.5rem); }
}

/* === ÉCRANS LARGES === */
@media (min-width: 1440px) { .container { max-width: 1320px; } }

/* === ACCESSIBILITÉ === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .fade-in { opacity: 1; transform: none; }
  .hero-slide { transition: none !important; }
}

/* === PRINT === */
@media print {
  .site-header, .site-footer, .menu-toggle, .hero-actions, .cta-section { display: none; }
  body { color: #000; background: #fff; }
}

/* ============================================
   ============ V4 — FIX MENU MOBILE ============
   ============================================ */

@media (max-width: 768px) {
  /* Bouton dropdown : alignement gauche comme les autres liens */
  .nav-dropdown-trigger {
    width: 100%;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    padding: var(--space-4) 0 !important;
    font-size: var(--fs-base) !important;
    color: var(--text-primary) !important;
  }
  .nav-dropdown-trigger > span { flex: 1; text-align: left; }
  .dropdown-chevron {
    width: 18px;
    height: 18px;
    margin-left: auto;
  }

  /* Cacher le bouton CTA "Nous contacter" en mobile (doublon avec lien Contact) */
  .nav-cta-item { display: none !important; }

  /* Cacher les sous-titres <small> dans le mega-menu mobile (allège la liste) */
  .mega-menu-column a small { display: none; }
  .mega-menu-column a strong { margin-bottom: 0; }
  .mega-menu-column a {
    padding: var(--space-3) var(--space-3) !important;
    border-left-width: 2px;
  }

  /* Indicateur page courante en mobile : barre rouge à gauche */
  .nav-list > li > .nav-link.active,
  .nav-list > li > .nav-dropdown-trigger.active {
    border-left: 3px solid var(--ades-red);
    padding-left: var(--space-3) !important;
    background-color: rgba(227, 6, 19, 0.04);
  }
  .mega-menu-column a.active {
    background-color: rgba(227, 6, 19, 0.08) !important;
    border-left-color: var(--ades-red) !important;
  }
  .mega-menu-column a.active strong { color: var(--ades-red); }
}


/* ============================================
   ============ V5 — MEGA MENU MOBILE =========
   ============================================
   Layout différent du desktop : pas de grille,
   tout en colonne unique, items plus compacts. */

@media (max-width: 768px) {
  /* Le mega-menu prend toute la largeur du panneau mobile */
  .mega-menu {
    width: 100% !important;
    max-width: 100% !important;
    background: var(--bg-secondary) !important;
    padding: 0 !important;
  }

  /* Sections compactes en mobile */
  .mega-menu-section {
    padding: var(--space-3) var(--space-3);
  }
  .mega-menu-section + .mega-menu-section {
    border-top: 1px solid var(--border);
  }

  /* Tête de section mobile : compacte */
  .mega-menu-section-head {
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-2);
    border-bottom: none;
    gap: var(--space-2);
  }
  .mega-menu-section-icon {
    width: 24px;
    height: 24px;
  }
  .mega-menu-section-icon svg {
    width: 14px !important;
    height: 14px !important;
  }
  .mega-menu-section-title { font-size: 10px; }
  .mega-menu-section-count { display: none; } /* masqué pour gagner place */

  /* Row : 2 sections empilées en mobile (pas côte à côte) */
  .mega-menu-row {
    grid-template-columns: 1fr;
  }
  .mega-menu-row > .mega-menu-section + .mega-menu-section {
    border-top: 1px solid var(--border);
    border-left: none;
  }

  /* TOUTES les grilles → 1 colonne en mobile */
  .mega-menu-items-4col,
  .mega-menu-items-2col,
  .mega-menu-items-1col {
    grid-template-columns: 1fr !important;
  }

  /* Item mobile : layout horizontal (icône à gauche, texte à droite) */
  .mega-menu-item {
    flex-direction: row !important;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3) !important;
    min-height: 0;
  }
  .mega-menu-item-icon {
    width: 20px !important;
    height: 20px !important;
    margin-bottom: 0;
    flex-shrink: 0;
  }
  .mega-menu-item-name {
    font-size: 13px;
    flex-grow: 1;
  }
  /* Description cachée en mobile pour alléger (gardée desktop) */
  .mega-menu-item-desc { display: none; }

  /* Case vide cachée en mobile (pas pertinente) */
  .mega-menu-item-empty { display: none !important; }
}
