/* =========================================================================
   base.css - Variables de thème, remise à zéro, typographie
   -------------------------------------------------------------------------
   Les couleurs utilisent light-dark() : une seule déclaration par jeton,
   la variante est choisie par color-scheme (système, ou forcée par
   l'attribut data-theme posé sur <html> par assets/js/theme-init.js).
   ========================================================================= */

:root {
    color-scheme: light dark;

    /* Surfaces */
    --bg:            light-dark(#f4f3ef, #111110);
    --panel:         light-dark(#ffffff, #181816);
    --raised:        light-dark(#ffffff, #2c2b28);
    --field:         light-dark(#f6f5f1, #201f1d);
    --hover:         light-dark(#efede8, #252421);
    --stage:         light-dark(#e8e6e0, #0b0b0a);
    --stage-dot:     light-dark(rgb(0 0 0 / .075), rgb(255 255 255 / .05));

    /* Filets */
    --line:          light-dark(#e4e1da, #2a2926);
    --line-strong:   light-dark(#cfcbc2, #3b3a36);

    /* Texte */
    --text:          light-dark(#1a1917, #edece8);
    --text-2:        light-dark(#5d5a53, #aaa79f);
    --text-3:        light-dark(#8b877e, #77746d);

    /* Accent : ocre "chambre noire" */
    --accent:        light-dark(#a35c0a, #e3a44f);
    --accent-hover:  light-dark(#874b07, #f0b868);
    --accent-soft:   light-dark(rgb(163 92 10 / .10), rgb(227 164 79 / .14));
    --accent-ring:   light-dark(rgb(163 92 10 / .32), rgb(227 164 79 / .38));
    --on-accent:     light-dark(#ffffff, #1b1307);

    /* Notifications (contraste inversé) */
    --ink:           light-dark(#1f1e1b, #f1f0ec);
    --on-ink:        light-dark(#f4f3ef, #1a1917);
    --on-ink-2:      light-dark(#b9b6ae, #5d5a53);

    --danger:        light-dark(#b42318, #f2836b);
    --success:       light-dark(#2f7d4f, #7fcf9c);

    /* Contour des pastilles de couleur (visible sur fond clair comme sombre) */
    --swatch-ring:   light-dark(rgb(0 0 0 / .14), rgb(255 255 255 / .2));

    /* Damier (transparence) */
    --checker-a:     light-dark(#ffffff, #2a2926);
    --checker-b:     light-dark(#e7e4dd, #201f1d);

    /* Ombres */
    --shadow-color:  light-dark(rgb(40 30 10 / .08), rgb(0 0 0 / .45));
    --shadow-sm:     0 1px 2px var(--shadow-color);
    --shadow-md:     0 1px 2px var(--shadow-color), 0 6px 18px var(--shadow-color);
    --shadow-lg:     0 2px 6px var(--shadow-color), 0 18px 48px light-dark(rgb(40 30 10 / .16), rgb(0 0 0 / .6));

    /* Formes et mouvements */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --t-fast: 120ms;
    --t: 200ms;

    /* Typographie (polices système : aucun téléchargement, fonctionne hors ligne) */
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* Navigateurs sans light-dark() (antérieurs à 2024) : thème clair seulement,
   plutôt qu'une page sans couleurs. Le bouton de thème y est masqué. */
@supports not (color: light-dark(#000, #fff)) {
    :root {
        --bg: #f4f3ef;
        --panel: #ffffff;
        --raised: #ffffff;
        --field: #f6f5f1;
        --hover: #efede8;
        --stage: #e8e6e0;
        --stage-dot: rgb(0 0 0 / .075);
        --line: #e4e1da;
        --line-strong: #cfcbc2;
        --text: #1a1917;
        --text-2: #5d5a53;
        --text-3: #8b877e;
        --accent: #a35c0a;
        --accent-hover: #874b07;
        --accent-soft: rgb(163 92 10 / .10);
        --accent-ring: rgb(163 92 10 / .32);
        --on-accent: #ffffff;
        --ink: #1f1e1b;
        --on-ink: #f4f3ef;
        --on-ink-2: #b9b6ae;
        --danger: #b42318;
        --success: #2f7d4f;
        --swatch-ring: rgb(0 0 0 / .14);
        --checker-a: #ffffff;
        --checker-b: #e7e4dd;
        --shadow-color: rgb(40 30 10 / .08);
        --shadow-lg: 0 2px 6px var(--shadow-color), 0 18px 48px rgb(40 30 10 / .16);
        color-scheme: light;
    }
    .theme-btn { display: none; }
}

/* -------------------------------------------------------------------------
   Remise à zéro
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
    font: 14px/1.45 var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-synthesis-weight: none;
}

img, svg, canvas { display: block; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
}

button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}
button:disabled { cursor: not-allowed; }

ul, ol { list-style: none; padding: 0; }

[hidden] { display: none !important; }

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

::selection { background: var(--accent-soft); }

/* Barres de défilement discrètes */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

/* -------------------------------------------------------------------------
   Utilitaires
   ------------------------------------------------------------------------- */
.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Champ radio masqué mais accessible au clavier et aux lecteurs d'écran */
.choice-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Damier pour visualiser la transparence */
.checker {
    background-color: var(--checker-a);
    background-image: conic-gradient(var(--checker-b) 25%, transparent 0 50%, var(--checker-b) 0 75%, transparent 0);
    background-size: 16px 16px;
}

kbd {
    display: inline-block;
    min-width: 1.7em;
    padding: 1px 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--panel);
    color: var(--text);
    font: 600 11.5px/1.5 var(--font);
    text-align: center;
    white-space: nowrap;
}

/* Pas de transitions avant le démarrage de l'appli : sur une connexion lente,
   la page peut s'afficher avant le JavaScript, qui coche ensuite les réglages
   mémorisés ; sans ce garde-fou, ces changements seraient animés. */
:root:not(.is-ready) *,
:root:not(.is-ready) *::before,
:root:not(.is-ready) *::after {
    transition: none !important;
}

/* Pendant un tri ou un échange : curseur et sélection de texte figés */
body.is-dragging,
body.is-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
