:root {
  --fond: #fbfaf8;
  --fond-carte: #ffffff;
  --texte: #1f1d1a;
  --texte-doux: #6b665e;
  --bord: #e4e0d9;
  --accent: #9a5b34;
  --ombre: 0 1px 2px rgba(31, 29, 26, .05), 0 4px 12px rgba(31, 29, 26, .04);
  --rayon: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #171614;
    --fond-carte: #201e1b;
    --texte: #ece8e1;
    --texte-doux: #9c958a;
    --bord: #322f2a;
    --accent: #d3855a;
    --ombre: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.5rem 4rem;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.6 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.tete {
  max-width: 62rem;
  margin: 0 auto;
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--bord);
}

.tete h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -.02em;
}

.sous-titre {
  margin: .5rem 0 0;
  color: var(--texte-doux);
}

main { max-width: 62rem; margin: 0 auto; }

/* Deux niveaux de regroupement : le pôle, puis le thème. */

.pole { margin-top: 3.5rem; }
.pole:first-of-type { margin-top: 2.5rem; }

.pole > h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.theme { margin-top: 2rem; }

.theme h3 {
  margin: 0 0 1rem;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--texte-doux);
}

.annexes {
  margin: .5rem 0 0;
  padding: 0 .35rem;
  font-size: .82rem;
  color: var(--texte-doux);
}

.annexes a { color: inherit; }

.grille {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.carte { display: flex; flex-direction: column; }

.carte > a {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex: 1 1 auto;
  padding: 1.25rem;
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease;
}

.carte > a:hover,
.carte > a:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.emoji { font-size: 1.6rem; line-height: 1; }
.titre { font-weight: 600; letter-spacing: -.01em; }
.cadenas { margin-left: .4rem; font-size: .8em; }
.desc { color: var(--texte-doux); font-size: .92rem; }

.tags { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }

.tag {
  font-size: .72rem;
  padding: .15rem .5rem;
  border: 1px solid var(--bord);
  border-radius: 999px;
  color: var(--texte-doux);
}

.vide {
  margin-top: 3rem;
  padding: 2rem;
  border: 1px dashed var(--bord);
  border-radius: var(--rayon);
  color: var(--texte-doux);
}

.vide p { margin: 0 0 .5rem; }
.vide strong { color: var(--texte); }

a { color: var(--accent); }

footer {
  max-width: 62rem;
  margin: 4rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--bord);
  color: var(--texte-doux);
  font-size: .85rem;
}

/* ---- Pages d'index de projet et d'archives ---- */

.fil {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.75rem 0 0;
  font-size: .85rem;
  color: var(--texte-doux);
}

.fil a { color: inherit; text-decoration: none; }
.fil a:hover, .fil a:focus-visible { text-decoration: underline; }

.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }

.liste a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .75rem;
  padding: .85rem 1.1rem;
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease;
}

.liste a:hover, .liste a:focus-visible { border-color: var(--accent); }

.liste .ver {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 3.25rem;
}

.liste .desc { flex: 1 1 16rem; }

.annexe { margin-top: 1.5rem; font-size: .9rem; }
.note { max-width: 62rem; margin: 2rem auto 0; color: var(--texte-doux); font-size: .92rem; }

/* ---- Recherche du catalogue ---------------------------------------- */

/* .carte et .pole ont un display explicite : sans cette regle, l'attribut
   hidden pose par le filtre resterait sans effet. */
[hidden] { display: none !important; }

.recherche { margin-top: 2rem; }

.champ {
  position: relative;
  display: flex;
  align-items: center;
}

.loupe {
  position: absolute;
  left: 1rem;
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: var(--texte-doux);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.champ input {
  width: 100%;
  padding: .8rem 2.6rem;
  font: inherit;
  color: inherit;
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: 999px;
  box-shadow: var(--ombre);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s ease;
}

.champ input::placeholder { color: var(--texte-doux); }
.champ input::-webkit-search-cancel-button { display: none; }

.champ input:focus {
  outline: none;
  border-color: var(--accent);
}

.effacer {
  position: absolute;
  right: .6rem;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--texte-doux);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.effacer:hover { color: var(--texte); background: var(--fond); }

.filtres {
  margin-top: .85rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.filtre {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .28rem .7rem;
  font: inherit;
  font-size: .8rem;
  color: var(--texte-doux);
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.filtre:hover:not(:disabled) { border-color: var(--accent); color: var(--texte); }

.filtre.actif {
  color: var(--fond-carte);
  background: var(--accent);
  border-color: var(--accent);
}

.filtre.actif .filtre-n { opacity: .75; }

.filtre-n { font-size: .72em; font-variant-numeric: tabular-nums; opacity: .6; }

.filtre.sterile { opacity: .35; cursor: default; }

.reinit {
  padding: .28rem .7rem;
  font: inherit;
  font-size: .8rem;
  color: var(--accent);
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: .18em;
}

.aide {
  margin: .85rem 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .2rem 1.5rem;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--texte-doux);
}

.aide kbd {
  padding: .05rem .35rem;
  font: inherit;
  font-size: .92em;
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.resultat { color: var(--accent); white-space: nowrap; }
.resultat:empty { display: none; }

.sans-resultat {
  margin: 2.5rem 0 0;
  padding: 2rem;
  border: 1px dashed var(--bord);
  border-radius: var(--rayon);
  color: var(--texte-doux);
  text-align: center;
}

.sans-resultat strong { color: var(--texte); }
