/*
 * Ajustements responsive communs à toutes les pages publiques.
 * Chargé en dernier : corrige ce que les styles propres à chaque page laissent
 * passer, du plus petit téléphone (iPhone 5/SE, 320 px) aux grands écrans.
 *
 * Repères : 320 (iPhone 5/SE) · 375 (iPhone 8, 11 Pro, 12/13 mini) ·
 * 390–402 (iPhone 12 → 17 Pro) · 414–440 (iPhone 11, Plus, Pro Max) ·
 * 768–1024 (tablettes) · 1280+ (ordinateurs).
 */

/* ---------- Toutes tailles ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body .page-hero {
  width: 100%;
  max-width: 100%;
  margin-inline: 0;
}

img,
video,
iframe {
  max-width: 100%;
}

/* Liens et boutons : pas de délai de double-tap ni de surlignage gris sur iOS. */
a,
button,
[role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Le logo du menu mobile garde sa taille, mais sa zone de tap est agrandie. */
.mobile-logo-wrap::after {
  content: '';
  position: absolute;
  inset: -12px -10px;
}

/* ---------- Écrans tactiles jusqu'aux tablettes (iPad compris) ---------- */
@media (max-width: 1024px), (pointer: coarse) {
  /* Sommaire des pages légales : une ligne = une cible confortable au pouce. */
  .toc ol li a {
    display: block;
    padding: 9px 0;
  }

  .toc ol li {
    margin: 0;
  }

  /* « ← Retour » (connexion, inscription, compte, résultats) : lisible et facile à toucher. */
  .back-link {
    min-height: 44px;
    padding: 0 6px;
    margin: -12px -6px;
    font-size: 0.72rem !important;
  }
}

@media (pointer: coarse) {
  /* Logo du menu ordinateur (affiché sur iPad Air/Pro) et flèches catégorie précédente/suivante */
  /* (#prev-cat / #next-cat sont déjà positionnés en absolu.) */
  .header-logo-wrap {
    position: relative;
  }

  .header-logo-wrap::after,
  #prev-cat::after,
  #next-cat::after {
    content: '';
    position: absolute;
    inset: -10px;
  }
}

/* ---------- Téléphones et petites tablettes ---------- */
@media (max-width: 768px) {
  /* Lien « Déjà un compte ? Se connecter » */
  a[href="login.html"][style*="color: var(--primary)"],
  a[href="register.html"][style*="color: var(--primary)"] {
    display: inline-block;
    padding: 12px 4px;
  }

  /* Bouton « Quitter » de la page de vote */
  .btn-quit,
  .btn-quit span {
    min-height: 40px;
    font-size: 0.7rem !important;
  }

  .btn-quit span {
    min-height: 0;
  }

  /* Libellés des nominés (carrousels de la page Catégories) : jamais sous 11 px. */
  .nominee-sub-label {
    font-size: max(0.6rem, 11px);
  }

  .nominee-project-label {
    font-size: max(0.55rem, 10.5px);
  }

  /* Champs de formulaire : 16 px minimum, sinon iOS zoome sur la page au focus. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: max(16px, 1em);
  }
}

/* ---------- Titres : échelle fluide plafonnée selon l'écran ----------
 * Sur téléphone, les titres H1/H2 des pages restaient à 32–48 px et passaient
 * sur 3 à 5 lignes. Ils suivent maintenant la largeur de l'écran :
 * H1 ≈ 24 px (iPhone 5) → 29 px (Pro Max), H2 ≈ 21 → 24 px. */
@media (max-width: 600px) {
  h1 {
    font-size: clamp(1.5rem, 6.6vw, 1.85rem) !important;
    line-height: 1.05 !important;
    letter-spacing: -0.01em;
  }

  h2:not(.sika-dialog__title):not(.cat-title) {
    font-size: clamp(1.3rem, 5.4vw, 1.55rem) !important;
    line-height: 1.1 !important;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  h1 {
    font-size: clamp(2.1rem, 5vw, 2.75rem) !important;
    line-height: 1.05 !important;
  }

  h2:not(.sika-dialog__title):not(.cat-title) {
    font-size: clamp(1.6rem, 3.6vw, 2.1rem) !important;
    line-height: 1.1 !important;
  }
}

/* ---------- iPhone 5 / SE (1re génération) : 320 px ---------- */
@media (max-width: 340px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .mobile-logo-wrap {
    left: 16px !important;
  }

  h1 {
    overflow-wrap: break-word;
    hyphens: manual;
  }
}

/* ---------- Écrans peu hauts (iPhone 5/SE, 8 en paysage…) ---------- */
@media (max-height: 600px) and (max-width: 1024px) {
  .sika-dialog {
    max-height: calc(100dvh - 16px);
  }
}

/* ---------- Très grands écrans : le contenu ne s'étire pas à l'infini ---------- */
@media (min-width: 1920px) {
  .container {
    max-width: 1680px;
  }
}
