:root {
  --fond: #fbfbfa;
  --fond-carte: #ffffff;
  --trait: #e7e7e3;
  --texte: #1c1c1a;
  --texte-doux: #86867f;
  --accent: #c1283a;
  --rayon: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--fond);
  color: var(--texte);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

#entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 18px;
  border-bottom: 1px solid var(--trait);
  background: var(--fond-carte);
}
.marque { display: flex; align-items: baseline; gap: 10px; }
.nom { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.baseline, .compteurs { font-size: 11.5px; color: var(--texte-doux); }

/* Discord invite, at the end of the header. Muted grey like the counters at rest
   and blurple on hover only: the brand colour is by far the loudest thing on this
   deliberately quiet header, and permanently lit it would pull the eye away from
   the paste bar. `flex: none` so it never gets squeezed by #barre-lien, which is
   the one item allowed to grow. */
#discord {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--rayon);
  color: var(--texte-doux);
}
#discord svg { display: block; width: 17px; height: 17px; fill: currentColor; }
#discord:hover { color: #5865f2; }

#liens-externes {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: none;
}
#extension {
  display: inline-flex;
  align-items: center;
  flex: none;
  font-size: 11.5px;
  color: var(--texte-doux);
  text-decoration: none;
  white-space: nowrap;
}
#extension:hover { color: var(--accent); }

/* Bar for pasting a Street View link. `min-width: 0` on the field: without it, an
   input's intrinsic width (~180px) stops the flex item from shrinking and pushes
   the counters out of the header on a narrow window. */
#barre-lien {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 260px;
  max-width: 520px;
}
#lien {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 11.5px;
  padding: 5px 10px;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  background: var(--fond);
}
#lien-go {
  font: inherit;
  font-size: 11px;
  padding: 5px 12px;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  background: var(--fond-carte);
  color: var(--texte-doux);
  cursor: pointer;
  white-space: nowrap;
}
#lien-go:hover { color: var(--texte); border-color: var(--texte); }
#lien-etat {
  font-size: 11px;
  color: var(--texte-doux);
  white-space: nowrap;
}
#lien-etat.echec { color: var(--accent); }
/* When empty, the element must not consume the flex gutter. */
#lien-etat:empty { display: none; }

#principal { flex: 1; display: flex; min-height: 0; }
#carte { flex: 0 0 46%; }
#panneau {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--trait);
  background: var(--fond-carte);
}

#filtres {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--trait);
}
#filtres[hidden] { display: none; }
.ligne-pastilles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
/* Separates the difficulty group from the category group above it. */
#filtres-difficulte {
  padding-top: 8px;
  border-top: 1px solid var(--trait);
}
.pastille {
  font: inherit;
  font-size: 11px;
  padding: 4px 11px;
  border: 1px solid var(--trait);
  border-radius: 99px;
  background: var(--fond-carte);
  color: var(--texte-doux);
  cursor: pointer;
}
.pastille.active { background: var(--texte); color: var(--fond-carte); border-color: var(--texte); }
#recherche {
  flex: 1;
  min-width: 140px;
  font: inherit;
  font-size: 11.5px;
  padding: 4px 10px;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
}
/* The last remaining reader of --accent since the map highlight (JS) moved to a
   hard-coded colour: keeps the variable honest rather than dead. */
#recherche:focus-visible,
.pastille:focus-visible,
.groupe > summary:focus-visible,
#lien:focus-visible,
#lien-go:focus-visible,
#discord:focus-visible,
#extension:focus-visible,
#loupe-fermer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#accueil { padding: 28px 20px; max-width: 44ch; }
#accueil h1 { font-size: 17px; font-weight: 600; margin: 0 0 8px; }
#accueil p { margin: 0; color: var(--texte-doux); }

/* #galerie is now nothing but a scrolling container: the grid moved down into
   .grille, shared by the skeletons and by each scope section. The padding is
   carried by .grille and not by #galerie, otherwise the welcome screen — where all
   the content is hidden — would keep an empty band. */
#galerie {
  flex: 1;
  overflow-y: auto;
}
.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding: 14px 16px;
}
/* Mandatory: the `display` declaration above would otherwise win over the
   `display: none` the hidden attribute gets from the browser stylesheet. */
.grille[hidden] { display: none; }

/* Header of a scope section. Sections stay expanded by default; we replace the
   native triangle with our own because `display: flex` on a <summary> hides the
   marker on some browsers — drawing it ourselves gives the same rendering
   everywhere. */
.groupe[hidden] { display: none; }
.groupe > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid var(--trait);
  /* Sticky: with two sections expanded the list is long, and the header would
     otherwise only tell you which scope you are in at the top of the page. */
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--fond-carte);
}
.groupe > summary::-webkit-details-marker { display: none; }
/* A triangle made of borders rather than a character: no dependency on a font or
   on an emoji set, and it rotates cleanly. */
.groupe > summary::before {
  content: '';
  border-left: 4.5px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform 0.15s;
}
.groupe[open] > summary::before { transform: rotate(90deg); }
.groupe .compte {
  font-weight: 400;
  letter-spacing: 0;
  color: var(--texte-doux);
}

.carte-meta { cursor: zoom-in; position: relative; }
/* A pinned card takes the colour of its footprint on the map: the outline is the
   legend, there is no separate one. The colour arrives through a custom property set
   by the script — plain CSS here, unlike the SVG attributes Leaflet writes. */
.carte-meta.epinglee { outline: 2px solid var(--couleur-epingle); outline-offset: 3px; border-radius: var(--rayon); }
.epingle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--trait);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--texte-doux);
  cursor: pointer;
}
.epingle svg { width: 15px; height: 15px; fill: currentColor; }
.epingle:hover { color: var(--texte); }
.epingle[aria-pressed="true"] { color: var(--couleur-epingle); border-color: var(--couleur-epingle); background: var(--fond-carte); }
.epingle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Pushed to the end of the difficulty row, apart from the pills it does not belong to. */
#epingles-vider { margin-left: auto; }
#epingles-vider[hidden] { display: none; }
.carte-meta img {
  width: 100%;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  border-radius: var(--rayon);
  display: block;
  background: #eeeeeb;
}
.carte-meta p {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.code-pays {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--texte);
  color: var(--fond-carte);
  margin-right: 5px;
}
/* Below the title: grey and abbreviated, no colour coding by difficulty level. */
.badge-difficulte {
  display: inline-block;
  margin-top: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--trait);
  color: var(--texte);
}

.squelette {
  aspect-ratio: 16 / 8;
  border-radius: var(--rayon);
  background: linear-gradient(90deg, #efefec 25%, #f7f7f4 50%, #efefec 75%);
  background-size: 200% 100%;
  animation: glisse 1.2s infinite;
}
@keyframes glisse { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Out of the grid: the message now sits in #galerie directly, so `grid-column` is
   no longer needed to span the full width. */
#vide { padding: 24px 20px; color: var(--texte-doux); margin: 0; }

#pied {
  padding: 7px 18px;
  border-top: 1px solid var(--trait);
  background: var(--fond-carte);
  font-size: 10.5px;
  color: var(--texte-doux);
}
#pied a { color: inherit; }

#loupe {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 20, 18, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
}
#loupe[hidden] { display: none; }
#loupe img { max-width: 100%; max-height: 76vh; object-fit: contain; border-radius: var(--rayon); }
#loupe p { color: #f2f2ee; max-width: 80ch; text-align: center; margin: 0; font-size: 13px; }
#loupe p a { color: #f2f2ee; }
#loupe-description {
  /* A handful of descriptions carry deliberate line breaks (lists of clues): pre-line
     keeps them without letting the source's incidental spacing dictate the layout. */
  white-space: pre-line;
  /* Centred text reads fine for a one-line title, not for several sentences. */
  text-align: left;
  color: #d9d9d3;
  line-height: 1.45;
  /* The image already claims up to 76vh: without this cap, a long description pushes
     the whole overlay past the viewport with no way to scroll to it. */
  max-height: 22vh;
  overflow-y: auto;
}
#loupe-fermer {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 26px;
  line-height: 1;
  background: none;
  border: none;
  color: #f2f2ee;
  cursor: pointer;
}

/* Base map switch, in the corner of the map: two adjoining buttons, the active one
   in reverse video. It is now the site's only segmented control — the scope filter
   that lent it this vocabulary gave way to the gallery's collapsible sections.
   `box-shadow` rather than `border` alone: the control floats above the tiles, where
   a plain light line would disappear over a busy background. */
.choix-fond {
  display: flex;
  border-radius: var(--rayon);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .28);
}
.choix-fond button {
  font: inherit;
  font-size: 11px;
  padding: 5px 10px;
  border: 0;
  background: var(--fond-carte);
  color: var(--texte-doux);
  cursor: pointer;
}
.choix-fond button + button { border-left: 1px solid var(--trait); }
.choix-fond button.actif { background: var(--texte); color: var(--fond-carte); }
.choix-fond button:disabled { cursor: not-allowed; opacity: .5; }

/* --- Anki integration (inside the lightbox) ------------------------------- */
#anki-zone {
  color: #f2f2ee;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 80ch;
}
#anki-zone button {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid #f2f2ee;
  border-radius: var(--rayon);
  background: none;
  color: #f2f2ee;
  cursor: pointer;
}
#anki-zone button:disabled { opacity: 0.55; cursor: default; }
#anki-panneau { display: flex; gap: 8px; align-items: center; }
#anki-paquets { font: inherit; max-width: 32ch; }
#anki-guide { text-align: left; }
#anki-guide summary { cursor: pointer; text-align: center; }
#anki-guide a { color: #f2f2ee; }
#anki-guide code { font-size: 12px; }
