/*
 * Thème commun des sites de ville. Palette par défaut : celle de Saint-Malo.info (l'émeraude de la côte, le granit
 * des remparts, l'encre des cartes marines). Chaque ville la redéfinit dans css/villes/{code}.css (variables de :root,
 * visuel de fond de l'en-tête…). Le préfixe des classes, sm-, est historique.
 */

:root {
    --principale: #0E4D4A;
    --principale-sombre: #0A3634;
    --secondaire: #2E8C83;
    --texte: #13212B;
    --neutre: #8A8578;
    --fond: #F1F4F1;
    --accent: #C8372D;
    --blanc: #FFFFFF;
    --ligne: #D9DFDA;
    --principale-claire: #9fd3c7;
    --principale-pale: #d8ece7;

    --f-titre: "IM Fell English", Georgia, serif;
    --f-texte: "Public Sans", system-ui, sans-serif;
    --f-carte: "IBM Plex Mono", ui-monospace, monospace;

    --largeur: 1200px;
    --lecture: 44rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: var(--f-texte);
    font-size: 1.0625rem;
    line-height: 1.65;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--principale); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--f-titre); font-weight: 400; line-height: 1.15; margin: 0; }

.sm-wrap { max-width: var(--largeur); margin: 0 auto; padding: 0 16px; }

.sm-skip { position: absolute; left: -999px; }
.sm-skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--blanc); padding: .5rem 1rem; }

/* Annotation façon carte marine */
.sm-carte {
    font-family: var(--f-carte);
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--neutre);
}

/* ---------- En-tête : la mer, puis les remparts ---------- */

.sm-header {
    position: relative;
    background: var(--principale) url("../img/sondes.svg") center 30% / cover no-repeat;
    color: var(--blanc);
    padding-top: 1.25rem;
    overflow: hidden;
    /* masque le liseré d'anticrénelage sous les remparts */
    box-shadow: inset 0 -3px 0 var(--fond);
}

.sm-header__top {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .25rem 1.5rem;
}

.sm-logo {
    font-family: var(--f-titre);
    font-size: 2rem;
    line-height: 1;
    color: var(--blanc);
    text-decoration: none;
}
.sm-logo span { font-family: var(--f-carte); font-size: .8rem; letter-spacing: .08em; color: var(--principale-claire); margin-left: .15rem; }
.sm-logo:hover { color: var(--blanc); }

.sm-header .sm-carte { color: var(--principale-claire); }

.sm-nav { margin-top: 1rem; }
.sm-nav ul {
    list-style: none;
    margin: 0;
    padding: 0 0 .25rem;
    display: flex;
    gap: .25rem 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.sm-nav ul::-webkit-scrollbar { display: none; }
.sm-nav a {
    display: inline-block;
    padding: .2rem 0;
    color: var(--principale-pale);
    text-decoration: none;
    font-size: .9rem;
    white-space: nowrap;
    border-bottom: 1px solid transparent;
}
.sm-nav a:first-letter { text-transform: uppercase; }
.sm-nav a:hover, .sm-nav a[aria-current="page"] { color: var(--blanc); border-bottom-color: var(--accent); }

.sm-header__titre { padding-top: 2.5rem; }
.sm-header__titre > * { max-width: 40rem; }
.sm-header__titre h1 { font-size: clamp(2.4rem, 6vw, 4.25rem); }
.sm-header__titre p { margin: .75rem 0 0; color: var(--principale-pale); font-size: 1.1rem; }

/* Silhouette mise à l'échelle sur sa hauteur : jamais rognée en haut (flèche de Saint-Vincent).
   Le mur, dessiné au-delà du cadre, remplit les écrans larges ; les côtés sont coupés sur mobile. */
.sm-skyline {
    --sky-h: clamp(101px, 10.1vw, 160px);
    display: block;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    height: var(--sky-h);
    width: auto;
    aspect-ratio: 1440 / 250;
    margin-top: .25rem;
    overflow: visible;
    pointer-events: none;
    fill: var(--fond);
}
.sm-header--home .sm-skyline { --sky-h: clamp(146px, 16.7vw, 290px); margin-top: .5rem; }

/* Accueil sur grand écran : la flèche monte à côté du titre au lieu d'agrandir l'en-tête
   (un tiers du dessin se trouve au-dessus des toits). Pas sur les autres pages : elle passerait sur le menu. */
@media (min-width: 1100px) {
    .sm-header--home .sm-skyline { margin-top: calc(var(--sky-h) * -0.3); }
}

/* ---------- Sections ---------- */

.sm-main { padding-bottom: 4rem; }

.sm-section { margin-top: 3.5rem; }
.sm-section:first-child { margin-top: 1rem; }

.sm-section__titre {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.sm-section__titre h2 { font-size: 1.9rem; color: var(--principale); }
.sm-section__titre::after { content: ""; flex: 1; border-top: 1px solid var(--ligne); transform: translateY(-.35rem); }

/* ---------- Article à la une ---------- */

.sm-une {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    background: var(--blanc);
    border-radius: 4px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 0 var(--ligne), 0 12px 32px -20px rgba(19, 33, 43, .35);
}
.sm-une__image { overflow: hidden; }
.sm-une__image img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 16 / 10; transition: transform .6s ease; }
.sm-une__texte { padding: 2rem 2.25rem; display: flex; flex-direction: column; justify-content: center; }
.sm-une h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); color: var(--texte); margin: .5rem 0 1rem; }
.sm-une p { margin: 0; color: #3b4a52; }
.sm-une__lire { margin-top: 1.5rem; font-weight: 600; color: var(--principale); }
.sm-une:hover .sm-une__image img { transform: scale(1.03); }
.sm-une:hover h2 { color: var(--principale); }

/* ---------- Grille de cartes ---------- */

.sm-grille {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 2.5rem 2rem;
}
.sm-grille--deux { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }

.sm-carte-article { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.sm-carte-article__image { overflow: hidden; border-radius: 3px; background: var(--ligne); }
.sm-carte-article__image img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; transition: transform .6s ease; }
.sm-carte-article h3 {
    font-size: 1.45rem;
    margin: 1rem 0 .5rem;
    color: var(--texte);
    transition: color .2s;
}
.sm-carte-article p { margin: 0; font-size: .95rem; color: #4a5860; }
.sm-carte-article:hover img { transform: scale(1.04); }
.sm-carte-article:hover h3 { color: var(--principale); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }

/* ---------- Thèmes ---------- */

.sm-themes {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    border-top: 1px solid var(--ligne);
}
.sm-themes a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: .9rem .25rem;
    border-bottom: 1px solid var(--ligne);
    text-decoration: none;
    color: var(--texte);
    font-family: var(--f-titre);
    font-size: 1.3rem;
}
.sm-themes a:first-letter { text-transform: uppercase; }
.sm-themes a:hover { color: var(--principale); }
.sm-themes .sm-carte { font-size: .7rem; }

/* ---------- Pages article, catégorie, auteur ---------- */

.sm-entete-page { max-width: var(--lecture); margin: 1rem auto 0; }
.sm-entete-page h1 { font-size: clamp(2.3rem, 5.5vw, 3.6rem); color: var(--texte); margin: .6rem 0 1rem; }
.sm-entete-page .sm-chapeau { font-size: 1.2rem; line-height: 1.55; color: #33434c; margin: 0; }
.sm-entete-page .sm-carte a { color: var(--principale); text-decoration: none; }
.sm-entete-page .sm-carte a:hover { color: var(--accent); }

.sm-visuel { max-width: 62rem; margin: 2.5rem auto 0; }
.sm-visuel img { width: 100%; border-radius: 4px; }

.sm-prose { max-width: var(--lecture); margin: 2.5rem auto 0; }
.sm-prose > :first-child { margin-top: 0; }
.sm-prose p, .sm-prose ul, .sm-prose ol { margin: 0 0 1.15rem; }
.sm-prose h2 { font-size: 2rem; color: var(--principale); margin: 2.75rem 0 1rem; }
.sm-prose h3 { font-size: 1.5rem; margin: 2rem 0 .75rem; }
.sm-prose h4 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.sm-prose li { margin-bottom: .35rem; }
.sm-prose li::marker { color: var(--secondaire); }
.sm-prose strong { font-weight: 650; }
.sm-prose img { border-radius: 3px; margin: 1.75rem 0; }
.sm-prose blockquote {
    margin: 2rem 0;
    padding: 0 0 0 1.25rem;
    border-left: 3px solid var(--secondaire);
    font-family: var(--f-titre);
    font-size: 1.35rem;
    font-style: italic;
    color: var(--principale);
}
.sm-prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: .95rem; }
.sm-prose th, .sm-prose td { padding: .55rem .5rem; border-bottom: 1px solid var(--ligne); text-align: left; }
.sm-prose th { font-weight: 600; }
.sm-prose iframe { max-width: 100%; }
.sm-prose hr { border: 0; border-top: 1px solid var(--ligne); margin: 2rem 0; }

.sm-signature {
    max-width: var(--lecture);
    margin: 2.5rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid var(--ligne);
}

.sm-apercu {
    max-width: var(--lecture);
    margin: 1rem auto 0;
    padding: .6rem 1rem;
    background: #fff4d6;
    border-left: 3px solid var(--accent);
    font-size: .9rem;
}

.sm-liste-simple { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--ligne); }
.sm-liste-simple li { border-bottom: 1px solid var(--ligne); }
.sm-liste-simple a { display: block; padding: .8rem 0; font-family: var(--f-titre); font-size: 1.3rem; text-decoration: none; color: var(--texte); }
.sm-liste-simple a:hover { color: var(--principale); }

.sm-vide { color: var(--neutre); font-style: italic; }

/* ---------- Pages de données (prix de l'immobilier…) ---------- */

.sm-chiffres {
    max-width: var(--lecture);
    margin: 2rem auto 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
}
.sm-chiffre {
    background: var(--blanc);
    border-radius: 4px;
    border-top: 3px solid var(--secondaire);
    padding: 1.1rem 1.25rem 1rem;
    box-shadow: 0 1px 0 var(--ligne);
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.sm-chiffre:last-child { border-top-color: var(--neutre); }
.sm-chiffre strong { font-family: var(--f-titre); font-weight: 400; font-size: 2.6rem; line-height: 1.1; color: var(--principale); }
.sm-chiffre > span:last-child { font-size: .9rem; color: #4a5860; }
.sm-chiffre__evolution { font-weight: 600; }
.sm-hausse { color: var(--principale); }
.sm-baisse { color: var(--accent); }

.sm-prose th small { font-weight: 400; color: var(--neutre); }
.sm-tableau-barres th, .sm-tableau-barres td { vertical-align: bottom; }
.sm-tableau-barres td { white-space: nowrap; }
.sm-barre {
    display: block;
    height: 6px;
    width: var(--part);
    border-radius: 3px;
    background: var(--secondaire);
    margin-bottom: .3rem;
}
.sm-barre--maison { background: var(--neutre); }

/* ---------- Pied de page ---------- */

.sm-footer {
    background: var(--texte);
    color: #c5ccd0;
    padding: 3.5rem 0 2rem;
    font-size: .95rem;
}
.sm-footer__grille { display: grid; grid-template-columns: 1.6fr; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2.5rem; }
/* Écran moyen : le texte de présentation sur toute la largeur, les listes de liens en dessous */
@media (max-width: 1100px) {
    .sm-footer__grille { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
    .sm-footer__grille > :first-child { grid-column: 1 / -1; }
}
.sm-footer p { margin: 0 0 1rem; }
.sm-footer h2 { font-family: var(--f-carte); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--principale-claire); margin-bottom: .9rem; }
.sm-footer ul { list-style: none; margin: 0; padding: 0; }
.sm-footer li { margin-bottom: .45rem; }
.sm-footer a { color: var(--blanc); text-decoration: none; }
.sm-footer a:hover { color: var(--principale-claire); text-decoration: underline; }
.sm-footer__bas {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem 1.5rem;
}
.sm-footer__bas .sm-carte { color: #8b979e; }
.sm-footer__logo { font-family: var(--f-titre); font-size: 1.5rem; color: var(--blanc); }

/* ---------- Mobile ---------- */

@media (max-width: 860px) {
    .sm-une { grid-template-columns: 1fr; }
    .sm-une__texte { padding: 1.5rem 1.25rem 1.75rem; }
    .sm-footer__grille { grid-template-columns: 1fr; gap: 2rem; }
}

@media (max-width: 560px) {
    .sm-prose table { font-size: .82rem; }
    .sm-prose th, .sm-prose td { padding: .5rem .3rem; }
    .sm-tableau-barres td { white-space: normal; }
    .sm-chiffre strong { font-size: 2.2rem; }
}

@media (max-width: 560px) {
    body { font-size: 1rem; }
    .sm-header .sm-carte { display: none; }
    .sm-header__titre { padding-top: 1.75rem; }
    .sm-section { margin-top: 2.75rem; }
    .sm-grille { gap: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* Fiches de lieux intégrées à une page thématique (ancre #type-identifiant) */
.sm-fiche { padding: 1rem 0 .25rem; border-top: 1px solid var(--ligne); scroll-margin-top: 1rem; }
.sm-fiche h3 { margin-top: 0; }
.sm-fiche p { margin-bottom: .6rem; }
.sm-fiche:target { background: #fff; box-shadow: -1rem 0 0 #fff, 1rem 0 0 #fff; }

/* Tableau trop large pour l'écran : défile seul, sans élargir la page */
.sm-defile { overflow-x: auto; margin: 1.5rem 0; }
.sm-defile table { margin: 0; }
.sm-prose abbr { text-decoration: none; }

/* Carte des lieux et leur liste, côte à côte (empilées sur mobile) */
.sm-plan {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 1.5rem;
    margin-top: 2.5rem;
    height: 34rem;
}
.sm-plan__carte { height: 100%; border-radius: 4px; background: var(--ligne); z-index: 0; }
.sm-plan__liste { overflow-y: auto; padding-right: .5rem; overscroll-behavior: contain; }
.sm-plan__liste h2 { font-size: 1.6rem; color: var(--principale); margin-bottom: .25rem; }
.sm-plan__liste .sm-fiche h3 { font-size: 1.25rem; margin-bottom: .2rem; }
.sm-plan__liste .sm-fiche h3 a { color: var(--texte); text-decoration: none; }
.sm-plan__liste .sm-fiche h3 a:hover { color: var(--principale); text-decoration: underline; }
.sm-plan__liste .sm-fiche { font-size: .92rem; padding: .85rem .75rem .35rem; border-left: 3px solid transparent; }
.sm-plan__liste .sm-fiche:target, .sm-fiche--active { background: var(--blanc); box-shadow: none; border-left-color: var(--accent); }
.sm-fiche__services { color: #4a5860; }
.sm-plan__legende { font-size: .85rem; color: #4a5860; margin: 0 0 .5rem; }
.sm-point { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; border: 2px solid var(--blanc); box-shadow: 0 0 0 1px var(--ligne); vertical-align: -.05rem; margin-left: .35rem; }
.sm-point--public { background: var(--principale); }
.sm-point--prive { background: var(--accent); }
.sm-plan__popup-nom { font-weight: 600; }
.leaflet-container { font-family: var(--f-texte); }

@media (max-width: 860px) {
    .sm-plan { grid-template-columns: 1fr; height: auto; }
    .sm-plan__carte { height: 22rem; }
    .sm-plan__liste { overflow: visible; padding-right: 0; }
}
