/* ==========================================================================
   RESPONSIVE — Desktop-first
   ========================================================================== */

/* --- Protection globale contre le débordement horizontal --- */
html, body {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}
body {
  position: relative;
}
/* Empêche n'importe quel enfant direct de dépasser la largeur viewport */
body > * {
  max-width: 100vw;
}

/* --- Tablette (< 960px) --- */
@media (max-width: 960px) {
  .comprendre-layout {
    grid-template-columns: 220px 1fr;
    gap: 32px;
  }

  .counters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .counters-grid--hero {
    grid-template-columns: repeat(2, 1fr);
  }

  .intro-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Mobile large (< 768px) --- */
@media (max-width: 768px) {
  /* Propositions */
  .prop-grid {
    grid-template-columns: 1fr;
  }
  .prop-grid > article:last-child:nth-child(odd) {
    grid-column: auto;
    max-width: 100%;
    margin: 0;
  }
  /* Header */
  .site-header {
    padding: 0 16px;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-white);
    flex-direction: column;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    padding: 8px 0;
  }
  .site-nav.open {
    display: flex;
  }
  .site-nav a {
    padding: 14px 24px;
    border-bottom: none;
    border-left: 3px solid transparent;
  }
  .site-nav a:hover,
  .site-nav a.active {
    border-bottom: none;
    border-left-color: var(--accent);
    background: #f9fafb;
  }

  .menu-toggle {
    display: block;
  }

  /* Hero */
  .hero {
    padding: 48px 20px 40px;
  }
  .hero h1 {
    font-size: 1.8rem;
  }
  .hero .subtitle {
    font-size: 0.95rem;
    margin-bottom: 32px;
  }

  /* Compteurs */
  .counters-grid,
  .counters-grid--hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .counter-value {
    font-size: 1.7rem;
  }
  .counter-card--large .counter-value {
    font-size: 2rem;
  }

  /* Comprendre */
  .comprendre-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .comprendre-nav {
    position: static;
    margin-bottom: 32px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 12px;
  }
  .comprendre-nav h3 {
    width: 100%;
    margin-bottom: 8px;
  }
  .comprendre-nav a {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  /* Blocs argument */
  .arg-block {
    padding: 18px 20px;
    font-size: 0.9rem;
  }

  /* Intro grid */
  .intro-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Section padding */
  .section {
    padding: 48px 0;
  }
  .container {
    padding: 0 16px;
  }

  /* Tableaux : scroll horizontal contenu dans la largeur parent */
  .data-table {
    display: block;
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table td,
  .data-table th {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Contenu texte long : empêcher les URLs et mots longs de pousser la largeur */
  .comprendre-section,
  .comprendre-section p,
  .comprendre-section li,
  .arg-block,
  .prop-card,
  main {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
  }
  .comprendre-section a,
  .arg-block a {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  /* Tooltip source : ne doit pas déborder en mobile */
  .source-ref:hover::after,
  .source-ref:focus::after {
    white-space: normal;
    max-width: calc(100vw - 48px);
    width: max-content;
    left: 0;
    transform: none;
  }

  /* Hero : contenir le cercle décoratif qui pouvait fuir */
  .hero {
    max-width: 100%;
    overflow: hidden;
  }
  .hero h1 {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .section-title {
    font-size: 1.5rem;
  }

  /* Cards */
  .cards-grid {
    grid-template-columns: 1fr;
  }

  /* Footer */
  .site-footer {
    padding: 32px 16px;
  }
  .site-footer .footer-links {
    flex-direction: column;
    gap: 8px;
  }
}

/* --- Blog --- */
@media (max-width: 640px) {
  .blog-grid {
    column-count: 1;
  }
}

/* --- Petit mobile (< 480px) --- */
@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.5rem;
  }

  .counter-value {
    font-size: 1.4rem;
  }

  .counter-card {
    padding: 24px 16px;
  }

  .site-logo {
    font-size: 1.1rem;
  }

  .comprendre-section h2 {
    font-size: 1.2rem;
  }
}
