/* ---------- F5 : navigation mobile ----------
 * Actif seulement quand l'interrupteur F5 est ouvert (classe « f5 » sur <html>) et sous 768 px.
 * Au-dessus de 768 px, rien ne change. Couleurs et polices : celles de index.html.
 */
.barre-mobile, .panneau-plus, button.ouvrir-chat-mobile, button.fermer-chat-mobile, .kc-entete { display: none; } /* button.… : plus fort que .btn */

@media (max-width: 767px) {
  .f5 { --haut-barre: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .f5 body { padding-bottom: var(--haut-barre); }
  .f5 .toast { bottom: var(--haut-barre); }

  /* En-tête : logo, solde de KC, compte. Le menu horizontal disparaît. */
  .f5 .entete .nav, .f5 .entete .icone-boutique[data-lien="boutique"] { display: none; }
  .f5 .kc-entete:not([hidden]) {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
    background: var(--plaque-2); border: 1px solid var(--trait); color: var(--texte); text-decoration: none;
    font: 700 14px/1 var(--f-chiffre);
  }
  .f5 .kc-entete::after { content: "KC"; font: 600 11px/1 var(--f-titre); letter-spacing: .1em; color: var(--or); }

  /* Le bouton Discord flottant passe dans « Plus » pour ne rien masquer. */
  .f5 .bouton-discord { display: none; }

  .f5 .barre-mobile {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: var(--haut-barre); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(13, 10, 11, .96); border-top: 1px solid var(--trait);
    backdrop-filter: blur(10px);
    transition: transform .2s ease;
  }
  /* Clavier ouvert (chat, saisie) : la barre se retire pour ne pas couvrir le champ. */
  .f5.clavier-ouvert .barre-mobile { transform: translateY(100%); }
  .f5.clavier-ouvert body { padding-bottom: 0; }

  .barre-mobile a, .barre-mobile button {
    position: relative; display: grid; place-items: center; align-content: center; gap: 4px;
    min-width: 44px; min-height: 44px; padding: 6px 0 0;
    background: none; border: 0; border-top: 2px solid transparent; cursor: pointer;
    color: var(--gris); text-decoration: none; font: 600 10px/1 var(--f-titre); letter-spacing: .06em; text-transform: uppercase;
  }
  .barre-mobile svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .barre-mobile [aria-current="page"], .barre-mobile button[aria-expanded="true"] { color: var(--texte); border-top-color: var(--rouge); }
  .barre-mobile [aria-current="page"] svg { color: var(--rouge-vif); }
  .barre-mobile a:focus-visible, .barre-mobile button:focus-visible { outline-offset: -3px; }
  .barre-mobile .pastille { position: absolute; padding: 0; border: 0; top: 8px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--rouge-vif); box-shadow: 0 0 0 2px var(--sol); }

  /* Panneau « Plus » : monte du bas, se ferme par glissement, clic à côté ou Échap. */
  .f5 .panneau-plus:not([hidden]) { display: block; position: fixed; z-index: 35; inset: 0; } /* sous la barre : « Plus » reste visible pour refermer */
  .voile-plus { position: absolute; inset: 0; background: rgba(5, 3, 4, .7); }
  .feuille-plus {
    position: absolute; left: 0; right: 0; bottom: 0; display: grid;
    padding: 10px 16px calc(var(--haut-barre) + 12px);
    background: var(--plaque); border-top: 3px solid var(--rouge);
    animation: monter .22s ease-out; touch-action: pan-x;
  }
  .poignee { justify-self: center; width: 44px; height: 4px; margin: 2px 0 10px; border-radius: 2px; background: var(--trait); }
  .feuille-plus a {
    display: flex; align-items: center; min-height: 52px; padding: 0 8px; border-bottom: 1px solid var(--trait);
    color: var(--texte); text-decoration: none; font: 700 16px/1 var(--f-titre); letter-spacing: .06em; text-transform: uppercase;
  }
  .feuille-plus a[aria-current="page"] { color: var(--rouge-vif); }
  .feuille-plus .lien-discord { color: #9aa4ff; border-bottom: 0; }
  @keyframes monter { from { transform: translateY(100%); } to { transform: none; } }

  /* Chat : plein écran sur demande au lieu d'une colonne écrasée. */
  /* Le chat s'ouvre depuis « Plus › Chat » : le bouton posé seul sous « Partie sans Elo » est retiré (revue mobile du 18 nov.). */
  .f5 .ouvrir-chat-mobile { display: none; }
  .f5 .colonne-chat .bascule-chat { display: none; }
  .f5 .jouer-grille:not(.chat-plein) .colonne-chat { display: none; }
  .f5 .chat-plein .colonne-chat {
    position: fixed !important; z-index: 50; inset: 0; display: flex; flex-direction: column; gap: 8px;
    height: auto !important; padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
    background: var(--sol);
  }
  .f5 .chat-plein .fermer-chat-mobile { display: inline-flex; align-self: flex-end; min-height: 44px; }
  .f5 .chat-plein .panneau-chat { display: flex !important; flex: 1; height: auto; opacity: 1; visibility: visible; }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .feuille-plus { animation: none; }
  .f5 .barre-mobile { transition: none; }
}
