/* Le Sens du Jeu — feuille de style unique, sans build ni dépendance externe.
   Thème clair volontaire : les tablettes sont utilisées en hall, en pleine lumière. */

:root {
    --bg: #f6f3ec;
    --surface: #ffffff;
    --surface-alt: #fbf8f2;
    --line: #ddd6c8;
    --text: #1d1a16;
    --muted: #6b6459;
    --accent: #c2410c;
    --accent-soft: #fdeade;
    --green: #15803d;
    --green-soft: #dcfce7;
    --red: #b91c1c;
    --red-soft: #fee2e2;
    --radius: 14px;
    --touch: 4.25rem;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    /* Évite le zoom accidentel par double tap pendant une saisie rapide. */
    touch-action: manipulation;
}

.wrap {
    max-width: 60rem;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
}

/* ---------- En-tête ---------- */

.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar__title span {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
}

.topbar__meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.tally {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: var(--accent-soft);
    border-radius: 999px;
    color: var(--text);
}

.tally b {
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

a {
    color: var(--accent);
}

.topbar__retour {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.tally--pale {
    background: var(--surface-alt);
    border: 1px solid var(--line);
}

/* ---------- Menu de la tablette ---------- */

.menu {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}

/* Trois cibles pleine largeur : au comptoir, on vise sans regarder. */
.menu__choix {
    display: block;
    min-height: 7rem;
    padding: 1.4rem 1.6rem;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--radius);
}

.menu__choix:hover {
    border-color: var(--accent);
}

.menu__choix--principal {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.menu__choix--discret {
    min-height: 5rem;
    padding: 1rem 1.6rem;
    background: var(--surface-alt);
}

.menu__titre {
    display: block;
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.1;
}

.menu__choix--discret .menu__titre {
    font-size: 1.3rem;
}

.menu__aide {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.95rem;
    color: var(--muted);
}

.menu__choix--principal .menu__aide {
    color: #fde3d1;
}

/* ---------- Messages ---------- */

.flash {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 1rem;
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 1.05rem;
}

/* Le nombre de bracelets prime sur le reste du bandeau : c'est le geste que le
   bénévole doit accomplir juste après avoir validé. */
.bracelets {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem 0.4rem 0.5rem;
    font-size: 1.15rem;
    background: #fff;
    border: 2px solid currentColor;
    border-radius: 999px;
}

.bracelets__nombre {
    font-size: 1.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.flash--succes {
    background: var(--green-soft);
    border-color: #86efac;
    color: #14532d;
}

.flash--erreur {
    background: var(--red-soft);
    border-color: #fca5a5;
    color: #7f1d1d;
}

/* Saisies conservées sur la tablette tant que le serveur n'a pas répondu. */
.attente {
    margin: 0 0 1rem;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    color: #7c4a03;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
}

/* ---------- Étapes de saisie ---------- */

.step {
    margin: 0 0 1.25rem;
    padding: 1rem 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.step__legend {
    margin: 0 0 0.85rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.step__legend small {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
}

.choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(4.25rem, 1fr));
    gap: 0.55rem;
}

.choices--cp {
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

/* Le code postal en surtitre, la commune en vedette : c'est le nom que le
   bénévole cherche des yeux, et certains sont longs (Villeneuve-sur-Yonne). */
.choice--commune {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.5rem;
    font-size: 1.05rem;
    line-height: 1.2;
}

.choice__cp {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.choice--commune[aria-pressed="true"] .choice__cp {
    color: #fbd9c4;
}

.choice__nom {
    font-size: 1.05rem;
    hyphens: auto;
}

.choice {
    min-height: var(--touch);
    padding: 0.5rem;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: var(--surface-alt);
    border: 2px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}

.choice:hover {
    border-color: var(--accent);
}

.choice[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.choice:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ---------- Compteurs ---------- */

.stepper {
    display: grid;
    grid-template-columns: 5.5rem 1fr 5.5rem;
    gap: 0.6rem;
    align-items: stretch;
    max-width: 26rem;
}

.stepper__bouton {
    min-height: 5rem;
    font: inherit;
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    background: var(--surface-alt);
    border: 2px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}

.stepper__bouton:hover {
    border-color: var(--accent);
}

.stepper__bouton:active {
    background: var(--accent-soft);
}

.stepper__champ {
    min-width: 0;
    min-height: 5rem;
    padding: 0.25rem;
    font: inherit;
    font-size: 2.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--text);
    background: var(--surface-alt);
    border: 2px solid var(--line);
    border-radius: 12px;
}

.stepper__champ:focus {
    background: var(--surface);
    border-color: var(--accent);
}

.hint {
    margin: 0.6rem 0 0;
    font-size: 0.9rem;
    color: var(--muted);
}

/* ---------- Recherche de commune ---------- */

.recherche {
    position: relative;
    margin-top: 0.85rem;
}

.recherche__champ {
    width: 100%;
    min-height: 4rem;
    padding: 0.5rem 0.9rem;
    font: inherit;
    font-size: 1.4rem;
    color: var(--text);
    background: var(--surface-alt);
    border: 2px solid var(--line);
    border-radius: 12px;
}

.recherche__champ:focus {
    background: var(--surface);
    border-color: var(--accent);
}

.recherche__etat {
    margin: 0.5rem 0 0;
    min-height: 1.2em;
    font-size: 0.9rem;
    color: var(--muted);
}

.suggestions {
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden auto;
    /* Un code postal rural peut couvrir vingt communes : la liste défile
       au lieu de repousser le bouton de validation hors de l'écran. */
    max-height: 19rem;
}

.suggestion {
    display: block;
    width: 100%;
    min-height: 3.75rem;
    padding: 0.6rem 1rem;
    font: inherit;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: left;
    color: var(--text);
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.suggestions li:last-child .suggestion {
    border-bottom: none;
}

.suggestion:hover {
    background: var(--accent-soft);
}

.selection {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin: 0.85rem 0 0;
    padding: 0.85rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-soft);
    border-radius: 12px;
}

.selection[data-vide="true"] {
    font-size: 1rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface-alt);
    border: 1px dashed var(--line);
}

/* ---------- Validation ---------- */

.submit {
    width: 100%;
    min-height: 5rem;
    font: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    background: var(--green);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.submit:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn {
    display: inline-block;
    min-height: 2.75rem;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
}

.btn--danger {
    color: var(--red);
    border-color: #fca5a5;
}

.btn--primary {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Écrans de code / connexion ---------- */

.gate {
    max-width: 26rem;
    margin: 3rem auto;
    padding: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.gate h1 {
    margin-top: 0;
    font-size: 1.35rem;
}

.field {
    display: block;
    margin-bottom: 1rem;
}

.field span {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    min-height: 3.25rem;
    padding: 0.5rem 0.75rem;
    font: inherit;
    font-size: 1.25rem;
    color: var(--text);
    background: var(--surface-alt);
    border: 2px solid var(--line);
    border-radius: 10px;
}

.error-text {
    margin: 0 0 1rem;
    padding: 0.7rem 0.9rem;
    background: var(--red-soft);
    border-radius: 10px;
    color: #7f1d1d;
}

/* ---------- Backoffice ---------- */

.card {
    margin: 0 0 1.25rem;
    padding: 1.1rem 1.25rem 1.35rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
}

.stat {
    padding: 0.9rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.stat--pale {
    background: transparent;
    border-style: dashed;
}

.stat__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat__label {
    font-size: 0.85rem;
    color: var(--muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.table-scroll {
    overflow-x: auto;
}

th,
td {
    padding: 0.55rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

/* Uniquement les en-têtes de colonne : un th de ligne porte de la donnée, que
   la capitalisation forcée déformerait (« à » devenant « À »). */
thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

tbody th {
    font-weight: 600;
}

td.num,
th.num {
    text-align: right;
}

/* Barre de proportion dans le classement des codes postaux. */
.meter {
    display: block;
    height: 0.5rem;
    min-width: 2px;
    background: var(--accent);
    border-radius: 999px;
}

/* ---------- Graphique de fréquentation ---------- */

.chart {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart__bar {
    fill: var(--accent);
}

.chart__label,
.chart__value {
    font-size: 10px;
    fill: var(--muted);
}

.chart__value {
    fill: var(--text);
    font-weight: 700;
}

.chart-title {
    margin: 1.25rem 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.empty {
    color: var(--muted);
    font-style: italic;
}

@media (max-width: 34rem) {
    .stepper {
        grid-template-columns: 4.5rem 1fr 4.5rem;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
