/* =========================================================================
   VROUMDLE — identite visuelle "tableau de bord / stand de course"
   Palette asphalte nuit, accent orange clignotant, afficheurs mono.
   ========================================================================= */

:root {
    --asphalt: #14161b;
    --panel:   #1c1f27;
    --panel-2: #232732;
    --line:    #2e3441;
    --ink:     #e8eaf0;
    --ink-dim: #8a91a3;
    --signal:  #ff6b2c;  /* accent signature : orange clignotant */
    --go:      #34c759;  /* identique */
    --near:    #e6b800;  /* proche / partiel */

    --tile-w: 82px;
    --name-w: 150px;

    --radius: 10px;
    --ease: cubic-bezier(.2, .7, .2, 1);

    --font-display: "Saira Condensed", system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background:
        radial-gradient(1200px 600px at 50% -10%, #1b2330 0%, var(--asphalt) 60%) no-repeat,
        var(--asphalt);
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s var(--ease), color .25s var(--ease);
}

/* ---- Theme clair -------------------------------------------------------- */
body.light {
    --asphalt: #f4f5f8;
    --panel:   #ffffff;
    --panel-2: #eef0f5;
    --line:    #d5d9e2;
    --ink:     #1a1d24;
    --ink-dim: #63697a;
    --signal:  #e6521f;
    --go:      #1f9d4d;
    --near:    #c69200;
    background:
        radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, var(--asphalt) 60%) no-repeat,
        var(--asphalt);
}

.app {
    max-width: 1360px;
    margin: 0 auto;
    padding: 28px 18px 56px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* ---- En-tete : marque + plaque numero du jour --------------------------- */
.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.masthead__mark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(34px, 8vw, 56px);
    letter-spacing: .02em;
    line-height: .9;
    text-transform: uppercase;
}

.masthead__mark--accent { color: var(--signal); }

.masthead__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s var(--ease), border-color .2s var(--ease), transform .1s var(--ease);
    flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--signal); background: var(--panel-2); }
.theme-toggle:active { transform: scale(.92); }

.masthead__tag {
    margin: 6px 0 0;
    color: var(--ink-dim);
    font-size: 14px;
    letter-spacing: .04em;
}

/* Bandeau "voiture d'hier" */
.yesterday {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--signal);
    border-radius: var(--radius);
    padding: 10px 16px;
}
.yesterday__label {
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-dim);
}
.yesterday__name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .01em;
    color: var(--ink);
}

/* Plaque facon plaque d'immatriculation / panneau de stand */
.plate {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--signal);
}

.plate__label {
    font-size: 10px;
    letter-spacing: .28em;
    color: var(--ink-dim);
}

.plate__num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 30px;
    line-height: 1;
}

/* ---- Recherche ---------------------------------------------------------- */
.search { position: relative; }

.search__field { position: relative; }

.search__input {
    width: 100%;
    padding: 16px 18px;
    font-size: 17px;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.search__input::placeholder { color: var(--ink-dim); }

.search__input:focus {
    outline: none;
    border-color: var(--signal);
    box-shadow: 0 0 0 3px rgba(255, 107, 44, .22);
}

.search__list {
    list-style: none;
    margin: 6px 0 0;
    padding: 6px;
    position: absolute;
    inset-inline: 0;
    z-index: 20;
    max-height: 320px;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
}

.suggestion {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 7px;
    cursor: pointer;
}

.suggestion:hover,
.suggestion[aria-selected="true"] {
    background: var(--panel-2);
}

.suggestion__brand {
    color: var(--signal);
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.suggestion__name { color: var(--ink); }

.suggestion--empty {
    padding: 12px;
    color: var(--ink-dim);
    cursor: default;
}

.search__meta {
    margin: 10px 2px 0;
    color: var(--ink-dim);
    font-size: 13px;
}

.search__meta span:first-child { color: var(--ink); font-weight: 600; }

/* ---- Banniere de victoire ---------------------------------------------- */
.banner {
    border-radius: var(--radius);
    padding: 18px 20px;
    background: linear-gradient(120deg, rgba(52, 199, 89, .16), rgba(52, 199, 89, .04));
    border: 1px solid rgba(52, 199, 89, .5);
}

.banner__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 24px;
    margin: 0 0 4px;
    color: var(--go);
}

.banner__sub { margin: 0; color: var(--ink); }
.banner__sub strong { color: var(--ink); }

.banner__count {
    font-family: var(--font-mono);
    color: var(--signal);
}

/* ---- Tableau des propositions ------------------------------------------ */
.board__scroll {
    overflow-x: auto;
    padding-bottom: 6px;
}

.grid {
    min-width: max-content;
}

.grid__head,
.guess-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

/* cellule "nom" figee a gauche pendant le scroll horizontal */
.cell-name,
.head-name {
    width: var(--name-w);
    flex-shrink: 0;
    position: sticky;
    left: 0;
    z-index: 2;
}

.head-name { background: transparent; }

.col-label,
.head-name {
    display: flex;
    align-items: flex-end;
    padding: 4px 8px;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-dim);
    min-height: 28px;
}

.col-label {
    width: var(--tile-w);
    flex-shrink: 0;
    justify-content: center;
    text-align: center;
}

.cell-name {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8px 12px;
}

.cell-name__brand {
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--signal);
}

.cell-name__model {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

/* tuile = afficheur d'instrument */
.tile {
    width: var(--tile-w);
    flex-shrink: 0;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    text-align: center;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
}

.tile__value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    word-break: break-word;
}

.tile__arrow {
    font-size: 13px;
    line-height: 1;
    opacity: .9;
}

.tile--correct {
    background: rgba(52, 199, 89, .18);
    border-color: var(--go);
    color: #d6ffe2;
}

.tile--close,
.tile--partial {
    background: rgba(230, 184, 0, .16);
    border-color: var(--near);
    color: #fff2c2;
}

.tile--wrong {
    background: var(--panel);
    border-color: var(--line);
    color: var(--ink-dim);
}

/* revele anime de chaque ligne / tuile */
.guess-row { animation: rowIn .35s var(--ease) both; }

.tile {
    animation: tileIn .32s var(--ease) both;
    animation-delay: calc(var(--i, 0) * 55ms);
}

@keyframes rowIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes tileIn {
    from { opacity: 0; transform: scale(.82) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.board__empty {
    color: var(--ink-dim);
    text-align: center;
    padding: 26px 12px;
    font-size: 15px;
}

/* ---- Legende ------------------------------------------------------------ */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--ink-dim);
}

.legend__item { display: inline-flex; align-items: center; gap: 7px; }

.chip { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.chip--correct { background: var(--go); }
.chip--close   { background: var(--near); }
.chip--wrong   { background: var(--line); }

.legend .arrow { color: var(--near); font-size: 12px; }

/* ---- Regles ------------------------------------------------------------- */
.rules {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 16px;
}

.rules summary {
    cursor: pointer;
    padding: 12px 0;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: .04em;
    font-size: 17px;
    list-style: none;
}

.rules summary::-webkit-details-marker { display: none; }
.rules summary::before { content: "▸ "; color: var(--signal); }
.rules[open] summary::before { content: "▾ "; }

.rules__body { padding-bottom: 12px; color: var(--ink-dim); font-size: 14px; }
.rules__body strong { color: var(--ink); }

/* ---- Pied --------------------------------------------------------------- */
.foot {
    text-align: center;
    color: var(--ink-dim);
    font-size: 13px;
    letter-spacing: .03em;
}

.foot strong {
    font-family: var(--font-mono);
    color: var(--ink);
}

/* ---- Tablette : tuiles un peu plus serrees ----------------------------- */
@media (max-width: 900px) {
    :root { --tile-w: 76px; --name-w: 136px; }
}

/* ---- Mobile : vue en cartes empilees ------------------------------------ */
@media (max-width: 640px) {
    :root { --tile-w: 72px; --name-w: 120px; }

    .app { padding: 16px 10px 40px; gap: 14px; }

    .masthead { flex-direction: row; align-items: flex-start; gap: 8px; }
    .masthead__mark { font-size: clamp(26px, 8vw, 40px); }
    .masthead__right { flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
    .theme-toggle { width: 38px; height: 38px; font-size: 16px; }

    .search__input { padding: 13px 14px; font-size: 15px; }

    /* Le tableau devient une pile de cartes */
    .board__scroll { overflow-x: visible; }

    .grid { min-width: 0; }

    /* On masque l'en-tete de colonnes : les labels passent dans chaque tuile */
    .grid__head { display: none; }

    .guess-row {
        flex-wrap: wrap;
        gap: 5px;
        background: var(--panel-2);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 8px;
        margin-bottom: 8px;
    }

    /* Nom de la voiture : toute la largeur */
    .cell-name {
        width: 100%;
        position: static;
        background: transparent;
        border: none;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        padding: 4px 4px 8px;
        margin-bottom: 4px;
    }

    /* Tuiles : 3 par ligne, avec le label au-dessus */
    .tile {
        width: calc(33.333% - 4px);
        min-height: 60px;
        gap: 2px;
        padding: 5px 3px 4px;
        animation: none; /* evite un bug de layout sur iOS */
    }

    .tile::before {
        content: attr(data-label);
        display: block;
        font-size: 9px;
        letter-spacing: .07em;
        text-transform: uppercase;
        color: var(--ink-dim);
        line-height: 1;
    }

    .tile__value { font-size: 12px; }
    .tile__arrow { font-size: 11px; }

    .legend { font-size: 11px; gap: 8px 14px; }
}

/* ---- Accessibilite : mouvement reduit ----------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .guess-row,
    .tile {
        animation: none;
    }
}
