/*
 * Design tokens PTMBox — « L'atelier cartographique » (direction validée jalon 1).
 * Palette : neutres papier/pierre, accent unique vert-de-gris (cuivre oxydé des
 * plaques gravées de Cassini). Deux thèmes : clair « papier » (défaut), sombre
 * « table lumineuse ». Le thème système (prefers-color-scheme) est suivi par
 * défaut ; :root[data-theme] permet une bascule manuelle (cf. ui-components.js).
 *
 * Tout le design system (components.css, macros Jinja) consomme exclusivement
 * ces variables : ne jamais coder une couleur/dimension en dur ailleurs.
 */

:root {
    /* --- Couleur : thème clair (papier) --- */
    --bg: #f4f2ec;
    --surface: #fdfcf9;
    --surface-2: #ece9df;
    --ink: #22261f;
    --muted: #666b5c; /* jalon 8 : assombri depuis #6d7263 pour 4.5:1 (WCAG AA) sur --bg/--surface-2 */
    --line: #dcd8cb;
    --accent: #3d7068;
    --accent-soft: rgba(61, 112, 104, .14);
    --accent-strong: #2c5751;
    --on-accent: #f6f5ef;

    /* Couleurs de données (réservées aux couches carto, jamais à l'UI) */
    --data-ocre: #c08a3e;
    --data-eau: #7a99a3;
    --data-voie: #8a6d4f;

    /* Sémantique (distincte de l'accent) */
    --ok: #4c8a54;
    --ok-soft: rgba(76, 138, 84, .14);
    --warn: #b4533a;
    --warn-soft: rgba(180, 83, 58, .14);
    --info: #3d6a8a;
    --info-soft: rgba(61, 106, 138, .14);

    --shadow-sm: 0 1px 2px rgba(30, 32, 26, .07);
    --shadow: 0 1px 2px rgba(30, 32, 26, .08), 0 10px 28px rgba(30, 32, 26, .12);
    --glass: rgba(253, 252, 249, .88);

    /* --- Typographie --- */
    --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Roboto Mono', Consolas, 'DejaVu Sans Mono', monospace;

    --text-xs: .75rem;      /* 12px — légendes, métadonnées */
    --text-sm: .8125rem;    /* 13px — libellés, UI dense */
    --text-base: 1rem;      /* 16px — corps de texte */
    --text-md: 1.125rem;    /* 18px — sous-titres */
    --text-lg: 1.375rem;    /* 22px — titres de section */
    --text-xl: 1.75rem;     /* 28px — titres de page */
    --text-2xl: 2.25rem;    /* 36px — titres d'accroche */
    --leading-tight: 1.15;
    --leading-normal: 1.55;

    /* --- Espacement (base 4px) --- */
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 3rem;

    /* --- Rayons --- */
    --radius-sm: 4px;
    --radius-md: 7px;
    --radius-lg: 10px;
    --radius-full: 999px;

    /* --- Transitions (respectent prefers-reduced-motion, cf. components.css) --- */
    --ease: cubic-bezier(.3, .7, .2, 1);
    --duration-fast: .15s;
    --duration-base: .25s;

    /* --- Breakpoints (documentés ici, utilisés en dur dans les media queries) --- */
    /* mobile : < 640px · tablette : < 1024px · desktop : >= 1024px */
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #151814;
        --surface: #1e221d;
        --surface-2: #262b24;
        --ink: #e8e6db;
        --muted: #989e8e;
        --line: #31372e;
        --accent: #6fa89c;
        --accent-soft: rgba(111, 168, 156, .16);
        --accent-strong: #8fc0b5;
        --on-accent: #131613;

        --data-ocre: #d9a441;
        --data-eau: #6d95a1;
        --data-voie: #b08f6a;

        --ok: #6fae76;
        --ok-soft: rgba(111, 174, 118, .16);
        --warn: #cf7257;
        --warn-soft: rgba(207, 114, 87, .16);
        --info: #6d95c0;
        --info-soft: rgba(109, 149, 192, .16);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
        --glass: rgba(30, 34, 29, .88);
    }
}

:root[data-theme="dark"] {
    --bg: #151814;
    --surface: #1e221d;
    --surface-2: #262b24;
    --ink: #e8e6db;
    --muted: #989e8e;
    --line: #31372e;
    --accent: #6fa89c;
    --accent-soft: rgba(111, 168, 156, .16);
    --accent-strong: #8fc0b5;
    --on-accent: #131613;

    --data-ocre: #d9a441;
    --data-eau: #6d95a1;
    --data-voie: #b08f6a;

    --ok: #6fae76;
    --ok-soft: rgba(111, 174, 118, .16);
    --warn: #cf7257;
    --warn-soft: rgba(207, 114, 87, .16);
    --info: #6d95c0;
    --info-soft: rgba(109, 149, 192, .16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
    --glass: rgba(30, 34, 29, .88);
}

:root[data-theme="light"] {
    --bg: #f4f2ec;
    --surface: #fdfcf9;
    --surface-2: #ece9df;
    --ink: #22261f;
    --muted: #666b5c; /* jalon 8 : assombri depuis #6d7263 pour 4.5:1 (WCAG AA) sur --bg/--surface-2 */
    --line: #dcd8cb;
    --accent: #3d7068;
    --accent-soft: rgba(61, 112, 104, .14);
    --accent-strong: #2c5751;
    --on-accent: #f6f5ef;

    --data-ocre: #c08a3e;
    --data-eau: #7a99a3;
    --data-voie: #8a6d4f;

    --ok: #4c8a54;
    --ok-soft: rgba(76, 138, 84, .14);
    --warn: #b4533a;
    --warn-soft: rgba(180, 83, 58, .14);
    --info: #3d6a8a;
    --info-soft: rgba(61, 106, 138, .14);

    --shadow-sm: 0 1px 2px rgba(30, 32, 26, .07);
    --shadow: 0 1px 2px rgba(30, 32, 26, .08), 0 10px 28px rgba(30, 32, 26, .12);
    --glass: rgba(253, 252, 249, .88);
}

/* Base document : neutres + typo par défaut pour toute page héritant de base.html */
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

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

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