/* Confort sur téléphone : en-tête allégé, quatre onglets + menu « Plus », zones tactiles plus larges, tableaux en fiches.
   Chargé en dernier. Le menu « Plus » (bouton et feuille) n'existe que sur écran étroit. */

.onglet-plus { display: none; }
.feuille-plus { display: none; }

@media (max-width: 899.98px) {
  /* ---------- En-tête : nom du site, recherche, alertes, aide, photo. Le reste est dans « Plus ». ---------- */
  .barre { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .qui .etat-direct, .qui-actions #bouton-son, .qui-actions > button:last-child { display: none; }
  .qui-actions { gap: 6px; }
  .qui-actions .btn { min-width: 42px; min-height: 42px; padding: 0 10px; display: inline-grid; place-items: center; font-size: 17px; }
  .qui-actions .aide { order: 3; }
  .moi-carte .avatar { width: 38px; height: 38px; }

  /* ---------- Onglets du bas : quatre + « Plus », sans défilement ---------- */
  .barre nav { overflow: visible; background: color-mix(in srgb, var(--surface) 96%, transparent); padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .barre nav a.onglet-secondaire { display: none; }
  .barre nav a, .onglet-plus { flex: 1 1 0; min-width: 0; min-height: 52px; justify-content: center; font-size: 11px; }
  .onglet-plus {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border: 0; border-radius: 12px;
    background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
  }
  .onglet-plus.actif { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .onglet-plus .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }

  /* ---------- Feuille « Plus » : monte du bas de l'écran ---------- */
  .feuille-plus[open] { display: block; }
  .feuille-plus {
    position: fixed; inset: auto 0 0 0; width: 100%; max-width: none; max-height: 86dvh; margin: 0; overflow-y: auto;
    padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); border: 0; border-radius: 24px 24px 0 0;
    background: var(--surface); color: var(--texte); box-shadow: 0 -18px 50px rgb(0 0 0 / .35);
  }
  .feuille-plus::backdrop { background: rgb(2 6 23 / .55); backdrop-filter: blur(3px); }
  .poignee-feuille { width: 44px; height: 5px; border-radius: 99px; background: var(--bord); margin: 0 auto 12px; }
  .profil-feuille { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; color: inherit; text-decoration: none; background: var(--fond); margin-bottom: 12px; }
  .profil-feuille .avatar { width: 46px; height: 46px; font-size: 15px; flex: none; }
  .tuiles-feuille { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .tuiles-feuille form { margin: 0; display: contents; }
  .tuiles-feuille a, .tuiles-feuille button {
    position: relative; display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 78px; padding: 10px 4px; border-radius: 16px;
    border: 1px solid var(--bord); background: var(--fond); color: var(--texte); font: inherit; font-size: 13px; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer;
  }
  .tuiles-feuille a.actif { border-color: var(--accent); color: var(--accent); }
  .tuiles-feuille i { font-style: normal; font-size: 22px; line-height: 1; }
  .tuiles-feuille .icone { width: 24px; height: 24px; }
  .tuiles-feuille .badge { position: absolute; top: 6px; right: 8px; margin: 0; }
  @media (prefers-reduced-motion: no-preference) {
    .feuille-plus[open] { animation: feuille-monte .28s cubic-bezier(.2, .8, .2, 1); }
    @keyframes feuille-monte { from { transform: translateY(100%); } }
  }

  /* ---------- Pages ---------- */
  /* Catégories : une seule ligne qui défile au doigt, au lieu de trois ou quatre lignes empilées. */
  .filtres { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; scroll-snap-type: x proximity; scroll-padding: 0 16px; }
  .filtres::-webkit-scrollbar { display: none; }
  .filtres a { flex: none; padding: 9px 16px; scroll-snap-align: start; }
  /* Zones tactiles : au moins 40 px de haut pour les petits boutons, champs à 16 px (sinon l'iPhone zoome sur le champ). */
  .btn.petit { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  input, select, textarea { font-size: 16px; }
  .ligne-proc { padding-top: 14px; padding-bottom: 14px; }
  .outils-proc .btn, .outils-proc form { flex: 1 1 auto; }
  .outils-proc form .btn { width: 100%; }
  .entete { flex-wrap: wrap; }
  .recherche, .recherche input { width: 100%; }
  /* Rappel du questionnaire et alertes : au-dessus des onglets, quelle que soit leur hauteur. */
  .rappel-quiz { bottom: calc(76px + env(safe-area-inset-bottom)); left: 10px; right: 10px; max-width: none; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* ---------- Tableaux : une fiche par ligne (les titres de colonnes sont recopiés par page.js) ---------- */
  .table:has(table.en-fiches) { overflow: visible; background: none; border: 0; }
  table.en-fiches { min-width: 0; display: block; }
  table.en-fiches thead, table.en-fiches .ligne-titres { display: none; }
  table.en-fiches tbody { display: grid; gap: 12px; }
  table.en-fiches tr { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--bord); border-radius: var(--rayon, 16px); background: var(--surface); }
  table.en-fiches td { display: grid; grid-template-columns: minmax(96px, 34%) minmax(0, 1fr); gap: 10px; align-items: center; padding: 0; border: 0; overflow-wrap: anywhere; }
  table.en-fiches td::before { content: attr(data-titre); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  table.en-fiches td:not([data-titre])::before, table.en-fiches td[data-titre=""]::before { content: none; }
  table.en-fiches td:not([data-titre]), table.en-fiches td[data-titre=""] { grid-template-columns: minmax(0, 1fr); }
  table.en-fiches td form, table.en-fiches td .ligne { flex-wrap: wrap; }
  table.en-fiches td input, table.en-fiches td select { min-width: 0; max-width: 100%; }
}

/* Application installée, téléphone tenu à l'horizontale : le contenu évite l'encoche. */
@media (max-width: 899.98px) and (orientation: landscape) {
  main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* Rayons du booster : plus larges que l'écran d'un téléphone, ils ne doivent pas faire défiler la page sur le côté. */
.zone-booster { overflow-x: clip; }
@media (max-width: 899.98px) {
  table.en-fiches td form, table.en-fiches td textarea { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
}
