/* ═══════════════════════════════════════════════════════════════
   ABI NEXUS — Responsive mobile-first
   Breakpoints : 1200 / 992 / 768 / 576
   ═══════════════════════════════════════════════════════════════ */

/* ── Desktop large ── */
@media (max-width: 1200px) {
  .grid--4 { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1.4fr repeat(2, 1fr); }
  .search-input { width: 180px; }
  .search-input:focus { width: 240px; }
}

/* ── Tablette ── */
@media (max-width: 992px) {
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .loadout-grid { grid-template-columns: 1fr; }
  .compare-selects { grid-template-columns: 1fr; }
  .map-explorer { height: 440px; }

  /* Navigation mobile */
  .hamburger { display: grid; }
  .nav-links {
    position: fixed; top: var(--nav-height); right: 0;
    width: min(320px, 86vw); height: calc(100svh - var(--nav-height));
    background: var(--color-bg-secondary);
    border-left: 1px solid var(--color-border);
    flex-direction: column; align-items: stretch;
    gap: 0; padding: 1rem;
    transform: translateX(105%);
    transition: transform var(--transition-med);
    overflow-y: auto;
    z-index: var(--z-dropdown);
  }
  .nav-links.open { transform: translateX(0); }
  .nav-links > li { border-bottom: 1px solid var(--color-border); }
  .nav-links a { display: block; padding: .8rem .4rem; }
  .dropdown {
    position: static; transform: none;
    opacity: 1; visibility: visible;
    border: none; box-shadow: none;
    background: transparent;
    padding: 0 0 .6rem 1rem;
    display: none;
  }
  .has-dropdown.open .dropdown { display: block; }
  .search-wrap { display: none; }
  .search-wrap.mobile { display: block; margin-bottom: 1rem; }
  .search-wrap.mobile .search-input { width: 100%; }
  .search-wrap.mobile .search-input:focus { width: 100%; }
  .search-wrap.mobile .search-results { width: 100%; position: static; margin-top: .5rem; }

  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Mobile ── */
@media (max-width: 768px) {
  :root { --nav-height: 64px; }
  .section { padding-block: var(--space-xl); }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .hero { min-height: 92svh; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }
  .hero-stat .num { font-size: 1.6rem; }
  .hero-cta .btn { flex: 1; justify-content: center; }
  .tier-row { flex-wrap: wrap; }
  .tier-row img { width: 100%; height: 120px; }
  .tier-row .t-price { margin-left: 0; }
  .audio-player .ap-label { display: none; }
  .audio-player input[type="range"] { width: 64px; }
  .footer-grid { grid-template-columns: 1fr; gap: var(--space-md); }
  .footer-bottom { flex-direction: column; text-align: center; }
  .map-explorer { height: 380px; }
  .weapon-stats { grid-template-columns: repeat(3, 1fr); }
  .toc { position: static; margin-bottom: var(--space-md); }
}

/* ── Très petit mobile ── */
@media (max-width: 480px) {
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .card-actions { flex-direction: column; }
  .card-actions .btn { justify-content: center; }
  .btn { padding: .75rem 1.2rem; }
  .audio-player { right: .5rem; bottom: .5rem; padding: .45rem .6rem; }
  .audio-player .ap-btn { width: 34px; height: 34px; }
  .weapon-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Ultrawide ── */
@media (min-width: 1800px) {
  :root { --container-max: 1560px; }
  .hero h1 { max-width: 20ch; }
}

/* ── Garde-fous mobiles (novembre 2026) ── */
/* 1. Aucun débordement horizontal : les longues chaînes (noms d'objets, URLs,
      noms de recettes) cassaient la mise en page à 360 px. */
html, body { max-width: 100%; overflow-x: hidden; }
h1, h2, h3, h4, .card-title, .tool-kpi .v, td, th { overflow-wrap: anywhere; word-break: break-word; }
code, kbd, samp, .mono { overflow-wrap: anywhere; }

/* 2. Tableaux : défilement horizontal tactile avec indicateur visuel.
      Sans ça, un tableau de 9 colonnes débordait de l'écran (les colonnes
      de droite étaient inaccessibles). */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap table { min-width: 520px; }
.table-wrap::after {
  content: ""; display: block; height: 0; clear: both;
}
@media (max-width: 768px) {
  .table-wrap { position: relative;
    background-image: linear-gradient(to left, rgba(200,168,75,.22), rgba(200,168,75,0));
    background-position: right center; background-repeat: no-repeat; background-size: 24px 100%;
    padding-right: 6px; }
  td, th { font-size: .82rem; padding: .5rem .55rem; }
}

/* 3. Cibles tactiles : 44 px minimum (recommandation WCAG 2.5.5) sur les
      contrôles souvent touchés au pouce. */
@media (max-width: 768px) {
  .btn, .icon-btn, .ap-btn, .hamburger, .gallery-tabs button, .zone-btn {
    min-height: 44px; min-width: 44px;
  }
  .audio-play, input[type="range"] { min-height: 44px; }
  .tool-field input, .tool-field select { min-height: 44px; font-size: 16px; }
  /* 16px évite le zoom automatique iOS au focus */
  .search-input, input[type="search"] { font-size: 16px; }
}

/* 4. Lecteur audio : ne doit jamais masquer le contenu utile ni déborder. */
@media (max-width: 480px) {
  .audio-player { max-width: calc(100vw - 1rem); }
  .audio-player .ap-label { max-width: 92px; font-size: .7rem; }
  .audio-player input[type="range"] { width: 56px; }
}

/* 5. Images et figures : jamais plus larges que l'écran, ratio conservé. */
.figure img, .card-media img, .item-gallery img, .poi-thumb img {
  max-width: 100%; height: auto;
}
.figure figcaption { font-size: .82rem; line-height: 1.5; }

/* 6. Hero mobile : hauteur pilotée par le contenu, pas par svh (barres
      d'adresse mobiles qui changent la hauteur au scroll). */
@media (max-width: 600px) {
  .page-hero { padding-block: 2.6rem 2rem; }
  .page-hero h1 { font-size: clamp(1.6rem, 7vw, 2.2rem); line-height: 1.15; }
  .page-hero .lead { font-size: .95rem; }
  .hero { min-height: auto; padding-block: 3rem 2.4rem; }
}

/* 7. Sommaires latéraux : en mobile, ils passent au-dessus du contenu et se
      replient (sinon 8 liens occupaient deux écrans avant le premier titre). */
@media (max-width: 768px) {
  .toc { border-radius: 12px; }
  .toc ul { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .75rem; }
  .toc li { font-size: .82rem; }
}
@media (max-width: 420px) {
  .toc ul { grid-template-columns: 1fr; }
}
