/* ═══════════════════════════════════════════════════════════════
   mobile.css — adaptation des diaporamas aux smartphones
   ───────────────────────────────────────────────────────────────
   Ne s'applique QU'AUX petits écrans (téléphone en portrait ou en
   paysage). Vidéoprojecteur, ordinateurs et iPads : rien ne change.

   À inclure APRÈS le <style> de la page, pour qu'il ait le dernier mot :
   <link rel="stylesheet" href="../../../mobile.css?v=1">
   (augmenter ?v=… à chaque modif : le CSS est mis en cache 1 mois)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px), (orientation: landscape) and (max-height: 480px) {

  /* ─── 1. L'écran « site non adapté » disparaît ─── */
  #portrait-warning { display: none !important; }
  #app {
    display: flex !important;
    height: 100vh;   /* repli pour vieux navigateurs */
    height: 100dvh;  /* hauteur réelle, barre d'adresse comprise */
  }

  /* Les diapos cachées sont décalées hors écran pour l'animation :
     la page ne doit jamais défiler sur le côté. */
  html, body { overflow-x: hidden; }

  /* Sur iPhone, 100vh inclut la zone sous la barre d'adresse : le bas de
     la page (et la navigation) passerait dessous. 100dvh = hauteur visible. */
  body:has(.diapo-header) { height: 100vh; height: 100dvh !important; }

  /* ─── 2. Tailles de base ─── */
  /* La règle des 1.6rem sert au vidéoprojecteur ; sur téléphone,
     on lit à 30 cm : 1.05rem (≈ 17 px) suffit largement. */
  :root {
    --font-min: 1.05rem;
    --header-h: 52px;
    --footer-h: 54px;
  }
  .slide { padding: 1rem 0.9rem 1.5rem !important; }

  /* ─── 3. En-tête et pied de page ─── */
  header { padding: 0 0.7rem; }
  .header-logo img { height: 34px !important; }
  .badge-seq, .badge-corrige { display: none; }
  .btn-corrige, .btn-retour { font-size: 0.85rem; padding: 0.45rem 0.7rem; }

  footer { gap: 0.5rem; padding: 0 0.5rem; }
  .nav-btn { min-height: 44px; padding: 0.4rem 0.9rem; font-size: 1rem; }
  .dots { display: none; }          /* trop de points pour la largeur : le compteur suffit */

  /* ─── 4. Titres ─── */
  .slide-rappel .seq-label, .slide-activite .act-num { font-size: 1rem; }
  .slide-rappel h1 { font-size: 2rem; }
  .slide-activite .problematique { font-size: 1.25rem; padding: 0.9rem 1rem; }
  .exo-title, .corr-title { font-size: 1.1rem; }
  .exo-num, .corr-num { width: 38px; height: 38px; font-size: 1.05rem; }
  .slide-synthese h2 { font-size: 1.3rem; margin-bottom: 1rem; }

  /* ─── 5. Blocs de texte ─── */
  .objectifs { flex-direction: column; }
  .obj-item, .consigne-box, .rep-box { padding: 0.7rem 0.9rem; }
  .exo-content, .corr-content { line-height: 1.55; }
  .exo-content ul, .exo-content ol { margin-left: 1.1rem; }
  .def-box { font-size: 1.1rem; padding: 1rem; }
  .blank-word { min-width: 5.5em; }
  .chip { font-size: 0.9rem; }

  /* ─── 6. Images ─── */
  .img-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .img-grid img { height: 100px; }
  /* Images dont la largeur est écrite en dur dans la page (width:200px…) */
  .slide img[style*="width"] {
    width: min(40vw, 200px) !important;
    height: auto !important;
  }
  .slide img { max-width: 100%; }

  /* ─── 7. Tableaux ─── */
  /* Les mots ne sont jamais coupés : si le tableau est trop large, il
     défile horizontalement dans son cadre (mobile.js l'entoure de
     .tableau-defile et empêche le glissement de changer de diapo). */
  .slide table { font-size: 0.95rem !important; }
  .slide th, .slide td {
    padding: 0.45rem 0.6rem !important;
    overflow-wrap: normal;
    hyphens: manual;
  }
  .slide th { white-space: nowrap; }        /* en-têtes sur une ligne */
  .slide td { min-width: 6.5em; }           /* place pour écrire / lire */

  .tableau-defile {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin: 0.6rem 0;
    padding-bottom: 6px;                    /* place pour l'ascenseur */
    scrollbar-width: thin;
  }
  .tableau-defile > table { margin: 0 !important; width: max-content; min-width: 100%; }
  .tableau-defile::-webkit-scrollbar { height: 8px; }
  .tableau-defile::-webkit-scrollbar-thumb { background: rgba(128,128,128,.55); border-radius: 6px; }

  /* Schémas trop larges (chaînes, frises…) : même principe que les
     tableaux, ils défilent horizontalement dans leur cadre. */
  .cb-branches, .etages, .modele, .frise-correction, .ets-row, .fct-table {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    padding-bottom: 6px;
  }
  .ets-row > * { flex-shrink: 0; }

  /* Zones à compléter de largeur fixe : on les laisse s'adapter */
  .trace-box .blank { min-width: 0 !important; width: 100% !important; }
  /* Miniature vidéo (5e S2-A3) : taille naturelle, légende toujours visible */
  .video-link { flex: 0 0 auto !important; }
  .video-link img { flex: none !important; height: auto !important; }

  /* Fiche d'observation (5e S2-A1) : libellé long → la ligne passe dessous */
  .family-row { flex-wrap: wrap; }
  .family-row .row-label { white-space: normal !important; flex-shrink: 1 !important; }
  .family-row .row-blank { min-width: 5em; min-height: 1.4em !important; }

  /* Indication affichée seulement quand le tableau déborde vraiment */
  .indice-defile {
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.7;
    margin: 0.4rem 0 -0.3rem;
  }

  /* ─── 8. Fenêtre du mot de passe ─── */
  .pwd-box { padding: 1.5rem 1.2rem; }

  /* ═════════════════════════════════════════════════════════════
     MODÈLE « diapo-nav.js » (5e séq. 2, 3e demi-groupe)
     style.css ne définit l'en-tête et la navigation qu'au-dessus de
     768 px : on en donne ici une version compacte pour téléphone.
     Tailles en px : ces pages ont des bases de police très variables.
     ═════════════════════════════════════════════════════════════ */
  .diapo-header {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; height: 52px; padding: 0 0.7rem; flex-shrink: 0;
    background: var(--bg-nav); border-bottom: 2px solid var(--border-default);
  }
  .diapo-header__home { display: flex; align-items: center; }
  .diapo-header__logo {
    height: 36px !important; width: auto !important; display: block;
    border: 1px solid var(--border-default); border-radius: 6px; padding: 2px;
  }
  .diapo-header__correction {
    background: transparent; color: var(--text-accent);
    border: 1px solid var(--text-accent); border-radius: 6px;
    padding: 8px 12px; font: 700 14px/1 'Segoe UI', Arial, sans-serif;
  }
  .diapo-nav {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    width: 100%; height: 56px; flex-shrink: 0;
    background: var(--bg-nav); border-top: 2px solid var(--border-default);
  }
  .diapo-nav__btn {
    min-width: 64px; min-height: 44px;
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-default); border-radius: 6px;
    font: 700 20px/1 'Segoe UI', Arial, sans-serif;
  }
  .diapo-nav__btn:disabled { opacity: 0.3; }
  .diapo-nav__counter {
    min-width: 64px; text-align: center;
    font: 600 15px/1 'Segoe UI', Arial, sans-serif; color: var(--text-mid);
  }

  /* 5e séq. 2 activités 1 et 3 : tout est en « em » à partir d'une base
     de 1.5em × 1.5em (≈ 36 px). On ramène la base à 16 px. */
  html:has(.slideshow .slide-cover),
  html:has(.slideshow .slide-cover) body { font-size: 16px !important; }

  /* Marges latérales prévues pour grand écran */
  .slide-header { padding-left: 14px !important; padding-right: 14px !important; }
  .slide-content { padding-left: 12px !important; padding-right: 12px !important; }

  /* Grilles et rangées à plusieurs colonnes → une seule colonne
     (minmax(0,1fr) : la colonne ne peut pas dépasser l'écran) */
  .families-grid, .alt-grid, .bilan-grid, .def-grid, .ex-body,
  .objectifs-grid, .synthese-grid, .three-col {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .questions-row, .slide-content.two-col, .two-col { flex-direction: column !important; }

  /* ═════════════════════════════════════════════════════════════
     3e DEMI-GROUPE (activités HTML et Python) : tailles en px
     pensées pour le vidéoprojecteur → divisées par ~1,6 environ.
     Toutes les règles sont limitées aux pages qui ont .ex-body.
     ═════════════════════════════════════════════════════════════ */
  body:has(.ex-body) .slide { padding: 14px 12px !important; }
  body:has(.ex-body) .intro-title  { font-size: 40px !important; }
  body:has(.ex-body) .intro-badge  { font-size: 16px !important; padding: 4px 12px !important; }
  body:has(.ex-body) .intro-sub    { font-size: 16px !important; }
  body:has(.ex-body) .intro-site   { font-size: 14px !important; padding: 8px 14px !important; }
  body:has(.ex-body) .intro-hint   { font-size: 13px !important; position: static !important; margin-top: 16px; }
  body:has(.ex-body) .ex-header, body:has(.ex-body) .ex-head { flex-wrap: wrap; gap: 6px 10px; }
  body:has(.ex-body) .ex-num       { font-size: 14px !important; }
  body:has(.ex-body) .ex-title     { font-size: 20px !important; }
  body:has(.ex-body) .ex-stars     { font-size: 18px !important; }
  body:has(.ex-body) .panel-title  { font-size: 14px !important; }
  body:has(.ex-body) .panel-body   { padding: 12px !important; }
  body:has(.ex-body) .consigne-label, body:has(.ex-body) .notion-label,
  body:has(.ex-body) .aide-label,     body:has(.ex-body) .code-label { font-size: 13px !important; }
  body:has(.ex-body) .consigne-text, body:has(.ex-body) .notion-text,
  body:has(.ex-body) .aide-text,     body:has(.ex-body) .bilan-cell  { font-size: 16px !important; }
  body:has(.ex-body) .notion-text code, body:has(.ex-body) .aide-text code { font-size: 14px !important; }
  body:has(.ex-body) .shot-caption, body:has(.ex-body) .step-done label,
  body:has(.ex-body) .run-btn, body:has(.ex-body) .run-status { font-size: 14px !important; }
  body:has(.ex-body) .bilan-footer { font-size: 16px !important; }
  body:has(.ex-body) .bilan-grid   { grid-template-columns: 1fr auto !important; }
  body:has(.ex-body) pre, body:has(.ex-body) .code-block { font-size: 13px !important; overflow-x: auto; }
  body:has(.ex-body) .ex-body      { min-height: auto !important; }
  body:has(.ex-body) textarea      { font-size: 14px !important; }
  body:has(.ex-body) .modal-title  { font-size: 20px !important; }
  body:has(.ex-body) .modal-sub, body:has(.ex-body) .modal-btn { font-size: 15px !important; }

  /* ═════════════════════════════════════════════════════════════
     5e « Choix des matériaux » (modèle unique, tailles en px)
     Limité aux pages qui ont .slide-titre-body.
     ═════════════════════════════════════════════════════════════ */
  body:has(.slide-titre-body) .slide-header {
    flex-wrap: wrap; gap: 6px; padding: 12px 14px !important;
  }
  body:has(.slide-titre-body) .slide-header .badge { font-size: 12px !important; padding: 3px 10px !important; }
  body:has(.slide-titre-body) .slide-header .titre-principal { font-size: 20px !important; flex-basis: 100%; order: 2; }
  body:has(.slide-titre-body) .slide-header .numero-slide { font-size: 13px !important; margin-left: auto; }
  body:has(.slide-titre-body) .slide-content { padding: 16px 12px !important; gap: 14px !important; }
  body:has(.slide-titre-body) .slide-footer { padding: 10px 14px !important; }
  body:has(.slide-titre-body) .slide-footer span { font-size: 15px !important; }
  body:has(.slide-titre-body) .slide-titre-body { padding: 16px 12px !important; gap: 14px !important; }
  body:has(.slide-titre-body) .titre-activite-badge { flex-wrap: wrap; justify-content: center; font-size: 16px !important; padding: 8px 16px !important; }
  body:has(.slide-titre-body) .titre-problematique { padding: 16px !important; }
  body:has(.slide-titre-body) .titre-problematique .prob-texte { font-size: 20px !important; }
  body:has(.slide-titre-body) .titre-footer-info { flex-wrap: wrap; justify-content: center; gap: 6px 14px; }
  body:has(.slide-titre-body) .titre-footer-info, body:has(.slide-titre-body) .tf-item { font-size: 13px !important; }
  body:has(.slide-titre-body) .question-card { padding: 16px !important; }
  body:has(.slide-titre-body) .question-card .emoji { font-size: 40px !important; }
  body:has(.slide-titre-body) .question-card .q-text { font-size: 20px !important; }
  body:has(.slide-titre-body) .question-card .q-sub { font-size: 16px !important; }
  body:has(.slide-titre-body) .objet-card { padding: 12px !important; }
  body:has(.slide-titre-body) .objet-card .emoji { font-size: 40px !important; }
  body:has(.slide-titre-body) .objet-card .label { font-size: 18px !important; }
  body:has(.slide-titre-body) .objet-card .sublabel { font-size: 15px !important; }
  body:has(.slide-titre-body) .section-title { font-size: 18px !important; padding: 8px 12px !important; }
  body:has(.slide-titre-body) .step-item { padding: 10px !important; gap: 10px !important; }
  body:has(.slide-titre-body) .step-item .step-emoji { font-size: 22px !important; }
  body:has(.slide-titre-body) .step-item .step-text,
  body:has(.slide-titre-body) .debat-question .dq-text,
  body:has(.slide-titre-body) .critere-card .c-content .c-desc { font-size: 16px !important; }
  body:has(.slide-titre-body) .critere-card { padding: 12px !important; gap: 10px !important; }
  body:has(.slide-titre-body) .critere-card .c-emoji { font-size: 30px !important; }
  body:has(.slide-titre-body) .critere-card .c-content .c-label { font-size: 18px !important; }
  body:has(.slide-titre-body) .highlight-box { font-size: 18px !important; padding: 14px !important; }
  body:has(.slide-titre-body) .mat-chip { font-size: 15px !important; }
  body:has(.slide-titre-body) .obj-card { padding: 12px !important; }
  body:has(.slide-titre-body) .obj-card * { font-size: 16px; }
  body:has(.slide-titre-body) .obj-card .obj-emoji { font-size: 30px; }
  body:has(.slide-titre-body) .tableau-proj th,
  body:has(.slide-titre-body) .tableau-proj td { font-size: 15px !important; }
  body:has(.slide-titre-body) .slide { padding-bottom: 0 !important; }
  /* Diapo de titre : seule diapo sans zone défilante → on lui en donne une */
  body:has(.slide-titre-body) .slide-titre-body {
    overflow-y: auto !important; min-height: 0 !important;
    justify-content: safe center !important;
  }
  body:has(.slide-titre-body) .slide-titre-body > * { flex-shrink: 0; }
}
