/* ArchiExplore — feuille de style unique, sans build */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    /* Neutres : un graphite bleuté et un papier technique, jamais un crème chaud. */
    --ink: #1a2027;
    --ink-soft: #5c6672;
    --ink-faint: #8d959e;
    --line: #e3e2dc;
    --line-soft: #efeee9;
    --paper: #fafaf7;
    --paper-2: #ffffff;
    --paper-3: #f2f1ec;
    --voile-entete: rgba(250, 250, 247, .93);

    /* Deux couleurs signifiantes : la brique pour l'action et le bâti,
       le bleu de plan pour la donnée et la mesure. */
    --accent: #b4471f;
    --accent-dark: #8f3617;
    --accent-soft: #f6e7e0;
    --plan: #23557e;
    --plan-soft: #e4edf4;
    --wiki: #23557e;

    /* États d'un ouvrage, identiques sur la carte, les vignettes et les filtres. */
    --etat-built: #b4471f;
    --etat-construction: #c98a12;
    --etat-study: #2f7c5d;
    --etat-unbuilt: #5b4b8a;
    --etat-demolished: #7a7f87;

    /* Une seule échelle d'espacement, fondée sur quatre pixels. */
    --espace-1: 4px;
    --espace-2: 8px;
    --espace-3: 16px;
    --espace-4: 28px;
    --espace-5: 56px;
    --espace-6: 96px;

    --radius: 4px;
    --radius-lg: 8px;
    --shadow: 0 1px 2px rgba(26, 32, 39, .05), 0 12px 32px rgba(26, 32, 39, .07);
    --shadow-hover: 0 2px 6px rgba(26, 32, 39, .07), 0 20px 46px rgba(26, 32, 39, .12);
    --serif: 'Spectral', Georgia, 'Times New Roman', serif;
    --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.12; margin: 0 0 .6rem; letter-spacing: -.02em; text-wrap: balance; }
h1 { font-weight: 700; letter-spacing: -.035em; }
h1 { font-size: clamp(2rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); }
h3 { font-size: 1.12rem; }
p { margin: 0 0 1rem; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 26px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 26px; }

.kicker {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: .5rem;
}

/* ---------- En-tête ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: var(--voile-entete);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header .bar { display: flex; align-items: center; gap: 26px; height: 64px; }

.brand {
    font-family: var(--serif);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -.025em;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 9px;
}

.brand .pin {
    width: 11px; height: 11px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--accent);
    display: inline-block;
}

.nav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.nav a { text-decoration: none; color: var(--ink-soft); font-size: .92rem; position: relative; }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); }
.nav a.active::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: -6px;
    height: 2px; background: var(--accent);
}

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 19px;
    border-radius: var(--radius);
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
    font: inherit; font-size: .9rem; font-weight: 500;
    text-decoration: none; cursor: pointer;
    transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); opacity: .92; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { padding: 7px 13px; font-size: .82rem; }
.btn-danger { background: transparent; color: #9b2c2c; border-color: #e3c3c3; }

/* ---------- Formulaires ---------- */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin-bottom: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--paper-2); font: inherit; font-size: .92rem; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; }

/* ---------- Carte ---------- */
.map-shell { display: flex; height: calc(100vh - 64px); }
#map { flex: 1; min-height: 320px; background: #e8e4dc; }

.map-side {
    width: 392px; border-right: 1px solid var(--line);
    background: var(--paper-2); display: flex; flex-direction: column; overflow: hidden;
}
.map-side .filters { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.map-side .intro { font-size: .86rem; color: var(--ink-soft); margin-bottom: 12px; }
.map-side .intro b { font-family: var(--serif); font-size: 1.05rem; color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
    padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
    font-size: .8rem; background: var(--paper-2); cursor: pointer; text-decoration: none;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.chip:hover { border-color: var(--ink-soft); }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.result-list { overflow-y: auto; flex: 1; }
.result { display: flex; gap: 13px; padding: 13px 22px; border-bottom: 1px solid var(--line-soft); cursor: pointer; text-decoration: none; }
.result:hover { background: var(--paper); }
.result img { width: 78px; height: 58px; object-fit: cover; border-radius: 3px; background: var(--line); flex: none; }
.result .ph { width: 78px; height: 58px; border-radius: 3px; flex: none; background: repeating-linear-gradient(45deg, #eeebe4, #eeebe4 6px, #e6e2d9 6px, #e6e2d9 12px); }
.result h4 { font-size: .96rem; margin: 0 0 2px; font-family: var(--serif); }
.result p { margin: 0; font-size: .8rem; color: var(--ink-soft); }

.count-bar { padding: 10px 22px; font-size: .8rem; color: var(--ink-soft); border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.count-bar .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.leaflet-popup-content-wrapper { border-radius: var(--radius); }
.leaflet-popup-content { margin: 0; width: 250px !important; }
.pop img { width: 100%; height: 136px; object-fit: cover; display: block; }
.pop .body { padding: 11px 13px 13px; }
.pop h4 { margin: 0 0 3px; font-size: 1.02rem; font-family: var(--serif); }
.pop p { margin: 0 0 9px; font-size: .8rem; color: var(--ink-soft); }
.pop a { font-size: .82rem; font-weight: 500; color: var(--accent); text-decoration: none; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: .72rem; letter-spacing: .02em;
    background: var(--accent-soft); color: var(--accent-dark);
}
.badge-wiki { background: #e3edf4; color: var(--wiki); }
.badge-muted { background: var(--paper-3); color: var(--ink-soft); border-color: var(--line); }
.badge-ok { background: #ddefe3; color: #226b3a; }
.badge-warn { background: #fbeed7; color: #8a5a12; }
.badge-no { background: #f7dede; color: #9b2c2c; }

/* ---------- Contenu ---------- */
.page { padding: 46px 0 80px; }
.lede { font-family: var(--serif); font-size: 1.18rem; color: var(--ink-soft); max-width: 62ch; }

.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

.section { margin-top: 58px; }
.section-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head a { margin-left: auto; font-size: .86rem; color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.section-head a:hover { color: var(--accent); }

.grid { display: grid; gap: 22px; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }

/* Cartes projet */
.tile {
    background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; text-decoration: none; display: flex; flex-direction: column;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: transparent; }
.tile .thumb-wrap { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: repeating-linear-gradient(45deg, #eeebe4, #eeebe4 8px, #e6e2d9 8px, #e6e2d9 16px); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.tile:hover img { transform: scale(1.04); }
.tile .flag { position: absolute; top: 10px; left: 10px; }
.tile .body { padding: 15px 17px 17px; flex: 1; display: flex; flex-direction: column; }
.tile h3 { margin: 0 0 5px; font-size: 1.06rem; }
.tile p { margin: 0; font-size: .84rem; color: var(--ink-soft); }
.tile .foot { margin-top: auto; padding-top: 11px; display: flex; gap: 6px; flex-wrap: wrap; }

/* Liens de navigation en pastilles */
.pills { display: flex; flex-wrap: wrap; gap: 9px; }
.pill {
    display: inline-flex; align-items: baseline; gap: 7px;
    padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--paper-2); text-decoration: none; font-size: .9rem;
    transition: border-color .14s ease, transform .14s ease;
}
.pill:hover { border-color: var(--ink); transform: translateY(-1px); }
.pill b { font-weight: 500; }
.pill span { font-size: .78rem; color: var(--ink-faint); }

/* Hero d'exploration */
.hero { padding: 54px 0 10px; }
.hero h1 { max-width: 16ch; }
.hero .lede { margin-top: 14px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; margin: 30px 0; }
.stat { border-left: 2px solid var(--accent); padding-left: 15px; }
.stat b { display: block; font-family: var(--serif); font-size: 2rem; line-height: 1.05; }
.stat span { font-size: .82rem; color: var(--ink-soft); }

/* Fiche projet */
.project-hero img { width: 100%; max-height: 66vh; object-fit: cover; display: block; border-radius: var(--radius); }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 20px 0; margin: 28px 0; }
.meta dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.meta dd { margin: 4px 0 0; font-size: .96rem; }

.prose { font-family: var(--serif); font-size: 1.06rem; }
.prose p { margin-bottom: 1.1rem; }
.prose h2 { margin-top: 2rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 13px; }
.gallery img { width: 100%; height: 250px; object-fit: cover; border-radius: var(--radius); }

.mini-map { height: 330px; border-radius: var(--radius); border: 1px solid var(--line); }
.mini-map-lg { height: 420px; }

.alert { padding: 13px 17px; border-radius: var(--radius); background: #ddefe3; color: #1e5c33; margin-bottom: 20px; font-size: .9rem; }
.errors { background: #f7dede; color: #9b2c2c; padding: 13px 17px; border-radius: var(--radius); margin-bottom: 18px; font-size: .88rem; }
.errors ul { margin: 0; padding-left: 18px; }

.table { width: 100%; border-collapse: collapse; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 12px 15px; border-bottom: 1px solid var(--line-soft); font-size: .9rem; vertical-align: top; }
.table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); background: var(--paper); }

.faq-item { border-bottom: 1px solid var(--line); padding: 20px 0; }
.faq-item h3 { margin-bottom: .35rem; }
.faq-item p { margin: 0; color: var(--ink-soft); }

.site-footer { border-top: 1px solid var(--line); padding: 34px 0; font-size: .86rem; color: var(--ink-soft); margin-top: 40px; }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 26px; }
.site-footer h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink); font-family: var(--sans); font-weight: 600; }
.site-footer a { text-decoration: none; display: block; padding: 2px 0; }
.site-footer a:hover { color: var(--accent); }
.site-footer .legal { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line-soft); font-size: .8rem; color: var(--ink-faint); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb img { width: 120px; height: 90px; object-fit: cover; border-radius: 3px; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; list-style: none; padding: 0; }
.pagination svg { width: 14px; height: 14px; }

@media (max-width: 900px) {
    .map-shell { flex-direction: column; height: auto; }
    .map-side { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); max-height: 48vh; }
    #map { height: 56vh; }
    .form-grid { grid-template-columns: 1fr; }
    .nav { gap: 14px; font-size: .85rem; }
    .nav .hide-sm { display: none; }
    .site-header .bar { gap: 14px; }
}

/* --------------------------------------------------------------
   Thème sombre. Le visiteur a trois états : un choix explicite, ou
   le réglage du système qui ne marque rien sur la racine. On couvre
   les trois en ne redéfinissant que les jetons.
   -------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #e9eae6;
        --ink-soft: #adb5be;
        --ink-faint: #8b939d;
        --line: #2a323c;
        --line-soft: #222933;
        --paper: #10151b;
        --paper-2: #161c24;
        --paper-3: #1d242d;
        --voile-entete: rgba(16, 21, 27, .93);
        --accent: #d9683c;
        --accent-dark: #e88a62;
        --accent-soft: #2b1a14;
        --plan: #6fa3ce;
        --plan-soft: #16222e;
        --etat-built: #d9683c;
        --etat-construction: #e0a63a;
        --etat-study: #4fa37e;
        --etat-unbuilt: #8c7cc0;
        --etat-demolished: #98a0a9;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .38);
        --shadow-hover: 0 2px 6px rgba(0, 0, 0, .34), 0 20px 46px rgba(0, 0, 0, .46);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --ink: #e9eae6;
    --ink-soft: #adb5be;
    --ink-faint: #8b939d;
    --line: #2a323c;
    --line-soft: #222933;
    --paper: #10151b;
    --paper-2: #161c24;
    --paper-3: #1d242d;
    --voile-entete: rgba(16, 21, 27, .93);
    --accent: #d9683c;
    --accent-dark: #e88a62;
    --accent-soft: #2b1a14;
    --plan: #6fa3ce;
    --plan-soft: #16222e;
    --etat-built: #d9683c;
    --etat-construction: #e0a63a;
    --etat-study: #4fa37e;
    --etat-unbuilt: #8c7cc0;
    --etat-demolished: #98a0a9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .38);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, .34), 0 20px 46px rgba(0, 0, 0, .46);
    color-scheme: dark;
}

:root[data-theme="light"] { color-scheme: light; }

/* Les tuiles de carte sont dessinées pour un fond clair : on les adoucit
   plutôt que de les inverser, ce qui rendrait le texte illisible. */
:root[data-theme="dark"] .leaflet-tile-pane,
:root:not([data-theme="light"]) .leaflet-tile-pane {
    filter: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(.78) saturate(.85) contrast(1.05); }
}

:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.78) saturate(.85) contrast(1.05); }
:root[data-theme="light"] .leaflet-tile-pane { filter: none; }
