/* ============================================================
   COMMUN.CSS — Design system partagé
   Calcul Mental & ses défis multi-classes
   ------------------------------------------------------------
   Chargé par LES 4 PAGES (eleve.html, defi.html, inscription.html,
   admin.html), toujours avant le CSS propre à chacune. Modifier
   une couleur, un rayon ou un style de bouton ici le change
   partout d'un coup — c'est tout l'intérêt de ce fichier.

   Sommaire :
     1. Variables & réinitialisation
     2. Header (bandeau sombre + vague + badge)
     3. Conteneur de page / titres
     4. Boutons (pilule, ombre portée "neo-brutaliste")
     5. Champs de formulaire
     6. Bannière d'information
     7. Modales (fenêtre + en-tête + pied, contenu = à chaque page)
     8. Clavier PIN tactile (défis)
     9. Footer
    10. Responsive (petits écrans)
   ============================================================ */

/* ── 1. Variables & réinitialisation ──
   Palette reprise telle quelle de l'appli de jeu : c'est elle qui
   donne le ton visuel à tout le site. Les couleurs --n1 à --n8
   (dégradé des niveaux) restent définies uniquement dans eleve.css,
   propres au jeu. */
   :root {
    --amber:   #FFB627;
    --amber-d: #E89A0C;
    --amber-l: #FFF1D0;
    --ink:     #2C2A4A;
    --ink-2:   #4A4768;
    --ink-3:   #837FA0;
    --surface: #FFFFFF;
    --bg:      #FFFBF2;
    --border:  #EAE0CB;
    --green:   #22B8A0;
    --blue:    #3D8BEB;
    --red:     #FF5D73;
    --purple:  #6C63FF;
    --radius:  18px;
  }
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'Nunito', sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; line-height: 1.5; -webkit-font-smoothing: antialiased; }
  .hidden { display: none !important; }
  
  /* ── 2. Header ──
     Bandeau sombre sticky, mascotte + nom de marque à gauche, badge
     d'état à droite, vague décorative en bas. Le badge texte (ex.
     "ENTRAÎNEMENT", "DÉFI") et l'emoji mascotte sont définis par
     chaque page dans son HTML — seule l'apparence est commune. */
  header {
    background: var(--ink);
    position: sticky; top: 0; z-index: 50;
  }
  .header-inner {
    max-width: 560px; margin: 0 auto; padding: 14px 24px 12px;
    display: flex; align-items: center; justify-content: space-between;
  }
  .header-brand { display: flex; align-items: center; gap: 10px; }
  .header-mascot {
    width: 34px; height: 34px; border-radius: 50%; background: var(--amber);
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
    box-shadow: 2px 2px 0 rgba(0,0,0,.22); flex-shrink: 0;
  }
  .header-word { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1rem; color: #fff; }
  .header-accent { color: var(--amber); }
  .header-badge {
    font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .66rem;
    background: rgba(255,255,255,.12); color: #fff; border: 1.5px solid rgba(255,255,255,.2);
    border-radius: 999px; padding: 5px 12px; letter-spacing: .04em; text-transform: uppercase;
  }
  /* Bouton optionnel dans le header (ex. déconnexion admin) : même famille
     visuelle que le badge, mais cliquable. */
  .header-btn {
    font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .66rem;
    background: none; color: #fff; border: 1.5px solid rgba(255,255,255,.3);
    border-radius: 999px; padding: 5px 12px; letter-spacing: .04em; cursor: pointer;
    transition: background .15s;
  }
  .header-btn:hover { background: rgba(255,255,255,.12); }
  /* Nom du défi affiché dans l'en-tête (defi.html, eleve.html en mode
     défi) — utilisé à la place d'un titre dans le corps de la page, pour
     gagner de la hauteur. */
  .header-defi-name {
    font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 1.3rem; line-height: 1.15;
    color: var(--amber); letter-spacing: .01em;
    max-width: 60%; text-align: right; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-shadow: 0 1px 0 rgba(0,0,0,.2);
  }
  .header-wave { display: block; width: 100%; height: 20px; }
  .header-wave path { fill: var(--bg); }
  
  /* ── 3. Conteneur de page / titres ── */
  .content { max-width: 560px; margin: 0 auto; padding: 22px 22px 48px; }
  .page-eyebrow { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .68rem; color: var(--amber-d); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
  .page-title { font-family: 'Fredoka', sans-serif; font-size: 1.5rem; font-weight: 600; color: var(--ink); margin-bottom: 22px; line-height: 1.25; }
  .page-sub { font-size: .88rem; color: var(--ink-3); margin-top: -14px; margin-bottom: 22px; font-weight: 600; }
  
  /* Carte structurelle générique (compteurs, tableaux, blocs d'info) —
     plus sobre qu'un .action-card cliquable : bordure fine, ombre légère
     plutôt que la grosse ombre colorée réservée aux éléments interactifs. */
  .panel { background: var(--surface); border: 2.5px solid var(--ink); border-radius: var(--radius); padding: 20px; box-shadow: 3px 3px 0 rgba(44,42,74,.12); }
  .panel h2 { font-family: 'Fredoka', sans-serif; font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }
  
  /* ── 4. Boutons ──
     Style "neo-brutaliste" : contour épais + ombre portée franche qui
     se réduit et se déplace au clic, comme un vrai bouton qu'on enfonce. */
  .btn {
    display: block; width: 100%; padding: 14px 18px; font-family: 'Fredoka', sans-serif; font-size: .95rem; font-weight: 600;
    border: 2.5px solid var(--ink); border-radius: 999px; cursor: pointer; color: #fff; text-align: center;
    box-shadow: 4px 4px 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease;
  }
  .btn:hover  { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
  .btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
  .btn-amber { background: var(--amber); color: var(--ink); }
  .btn-amber:hover { background: var(--amber-d); }
  .btn-ghost { background: var(--surface); color: var(--ink-3); border: 1.5px solid var(--border); box-shadow: none; }
  .btn-ghost:hover { background: var(--bg); border-color: var(--ink-3); color: var(--ink); transform: none; box-shadow: none; }
  .btn-green { background: var(--green); }
  .btn-green:hover { background: #1a9c86; }
  .mt { margin-top: 12px; }
  .mt2 { margin-top: 22px; }
  .g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .btn-linklike { background: none; border: none; box-shadow: none; color: var(--amber-d); font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .7rem; cursor: pointer; text-decoration: underline; padding: 0; }
  
  /* ── 5. Champs de formulaire ──
     Base générique text/nombre/mot de passe. Une page peut ajouter ses
     propres compléments (ex. select, variantes) dans son propre CSS. */
  .field-group { margin-bottom: 18px; }
  .field-label { display: block; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 7px; }
  .field-input, select {
    width: 100%; padding: 11px 14px; border: 2px solid var(--border); border-radius: var(--radius);
    font-family: 'Nunito', sans-serif; font-size: .95rem; color: var(--ink); background: var(--surface);
    outline: none; transition: border-color .2s;
  }
  .field-input:focus, select:focus { border-color: var(--amber); }
  .field-input.mono { font-family: 'Fredoka', sans-serif; letter-spacing: .05em; }
  .field-input::-webkit-inner-spin-button, .field-input::-webkit-outer-spin-button { -webkit-appearance: none; }
  .field-hint { font-size: .74rem; color: var(--ink-3); margin-top: 4px; font-weight: 600; }
  
  /* Champ PIN masqué + bouton "afficher/masquer" (inscription) */
  .pin-field-wrap { position: relative; }
  .pin-field-wrap .field-input { padding-right: 46px; }
  .pin-toggle-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 6px 8px; color: var(--ink-3); line-height: 1; }
  .pin-toggle-btn:hover { color: var(--ink); }
  
  /* ── 6. Bannière d'information ──
     Encart discret pour un message contextuel (résumé, avertissement). */
  .info-banner { background: var(--bg); border-left: 4px solid var(--amber); border-radius: 0 10px 10px 0; padding: 10px 13px; font-family: 'Nunito', sans-serif; font-size: .74rem; font-weight: 600; color: var(--ink-3); margin-top: 8px; }
  .info-banner.warn { border-left-color: var(--red); color: var(--ink-2); }
  
  /* ── 7. Modales ──
     Fenêtre + en-tête + pied communs à toutes les popups du site
     (réglages de niveau, infos programme, saisie de PIN...). Le
     contenu du corps (.modal-body) est propre à chaque popup et
     stylé dans le CSS de la page qui l'utilise. */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(44,42,74,.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 300; padding: 20px;
  }
  .modal-box {
    background: var(--surface); border: 3px solid var(--ink); border-radius: var(--radius);
    max-width: 480px; width: 100%; max-height: 85vh;
    display: flex; flex-direction: column;
    box-shadow: 6px 6px 0 var(--ink);
  }
  .modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 2px solid var(--border); flex-shrink: 0;
  }
  .modal-title-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .modal-title { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1.05rem; color: var(--ink); }
  .modal-close { background: none; border: none; font-size: 1.2rem; color: var(--ink-3); cursor: pointer; line-height: 1; padding: 4px; }
  .modal-close:hover { color: var(--ink); }
  .modal-body { padding: 6px 18px; overflow-y: auto; flex: 1; }
  .modal-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 18px; border-top: 2px solid var(--border); flex-shrink: 0;
  }
  .modal-footer .btn { width: auto; padding: 10px 20px; margin: 0; }
  .modal-msg { font-size: .82rem; margin-top: 10px; min-height: 1.2em; font-weight: 600; }
  .modal-msg.err { color: var(--red); }
  .modal-msg.ok { color: var(--green); }
  
  /* ── 8. Clavier PIN tactile (défis) ──
     Composant partagé par defi.html (saisir des points, modifier
     l'objectif) et eleve.html (valider les points d'une partie) : le
     PIN n'est jamais tapé au clavier physique ni affiché en clair,
     seulement composé au doigt sur ce pavé numérique. */
  .pin-keypad-display { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
  .pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); background: transparent; transition: background .15s, border-color .15s; }
  .pin-dot.filled { background: var(--ink); border-color: var(--ink); }
  .pin-keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
  .pin-key {
    padding: 16px 0; font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 600;
    background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
    cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s;
  }
  .pin-key:hover { background: var(--amber-l); border-color: var(--amber); }
  .pin-key.pin-key-empty { visibility: hidden; cursor: default; }
  .pin-key.pin-key-del { font-size: 1rem; color: var(--ink-3); }
  
  /* ── 9. Footer ── */
  footer { text-align: center; font-size: .74rem; color: var(--ink-3); padding: 18px 24px 26px; font-family: 'Nunito', sans-serif; font-weight: 600; }
  footer a { color: var(--ink-3); }
  
  /* ── 10. Responsive (petits écrans) ── */
  @media (max-width: 520px) {
    .header-inner { padding: 12px 18px 10px; }
    .content { padding: 18px 16px 32px; }
  }