/* Tableau public des conditions (page du composant et module). */
.cs-conditions {
  --cs-ouvert: #2e7d32;
  --cs-partiel: #b8860b;
  --cs-ferme: #c62828;
  --cs-nd: #6c757d;
  --cs-line: color-mix(in srgb, currentColor 15%, transparent);
  --cs-star: #f5a623;
  /* Boutons A− / A+ du visiteur (--cs-zoom) : toutes les tailles du tableau sont en em. */
  font-size: calc(var(--cs-zoom, 1) * 100%);
}
.cs-conditions [hidden] { display: none !important; }

/*
 * Thèmes (Conditions → Paramètres → Affichage public). « Site » n'ajoute aucune classe :
 * le texte et le fond viennent du gabarit. Les autres thèmes fixent leur fond et leur
 * couleur de texte ; les lignes, le survol et la pastille du code suivent (currentColor).
 */
.cs-theme {
  padding: 1rem;
  border-radius: .75rem;
  color: var(--cs-ink);
  background: var(--cs-bg);
}
.cs-theme th,
.cs-theme td,
.cs-theme h4 { color: inherit; }
.cs-theme .cs-public thead th { color: var(--cs-head, inherit); border-bottom-color: var(--cs-head-line, var(--cs-line)); }

.cs-theme--clair {
  --cs-bg: #fff;
  --cs-ink: #1f2933;
  border: 1px solid #d9dee5;
}

/* Fond sombre : couleurs d'état plus claires pour rester lisibles. */
.cs-theme--sombre {
  --cs-bg: #10151c;
  --cs-ink: #e6e9ee;
  --cs-ouvert: #66bb6a;
  --cs-partiel: #ffca28;
  --cs-ferme: #ef5350;
  --cs-nd: #9aa5b4;
  --cs-star: #ffc107;
}

/* Couleurs du club, comme la page des patrouilleurs. */
.cs-theme--club {
  --cs-bg: #0b1b33;
  --cs-ink: #f3f5f8;
  --cs-head: #d9b15f;
  --cs-head-line: #d9b15f;
  --cs-ouvert: #81c784;
  --cs-partiel: #ffd54f;
  --cs-ferme: #ff8a80;
  --cs-nd: #b0bac6;
  --cs-star: #d9b15f;
}
.cs-theme--club .cs-code { color: #0b1b33; background: #d9b15f; }
.cs-theme--club .cs-legend h4 { color: #d9b15f; }

/* Forêt : vert foncé, accents dorés. */
.cs-theme--foret {
  --cs-bg: #12261b;
  --cs-ink: #eef3ea;
  --cs-head: #e0c27a;
  --cs-head-line: #e0c27a;
  --cs-ouvert: #8bd48f;
  --cs-partiel: #ffd54f;
  --cs-ferme: #ff8a80;
  --cs-nd: #b5c1b8;
  --cs-star: #e6c35c;
}
.cs-theme--foret .cs-code { color: #12261b; background: #e0c27a; }
.cs-theme--foret .cs-legend h4 { color: #e0c27a; }

/* Glacier : fond bleu glace, texte bleu nuit. */
.cs-theme--glacier {
  --cs-bg: #eaf4fb;
  --cs-ink: #0f2a3d;
  --cs-head: #1559a6;
  --cs-head-line: #1559a6;
  --cs-ouvert: #1b7a2e;
  --cs-partiel: #9a6b00;
  --cs-ferme: #b71c1c;
  --cs-nd: #55697a;
  --cs-star: #d48806;
  border: 1px solid #c4dcee;
}
.cs-theme--glacier .cs-code { color: #fff; background: #1559a6; }
.cs-theme--glacier .cs-legend h4 { color: #1559a6; }

/* Érable : blanc, en-têtes et pastilles rouges. */
.cs-theme--erable {
  --cs-bg: #fff;
  --cs-ink: #2b1d1d;
  --cs-head: #b3151b;
  --cs-head-line: #b3151b;
  --cs-ouvert: #2e7d32;
  --cs-partiel: #9a6b00;
  --cs-ferme: #b3151b;
  --cs-nd: #6d6464;
  --cs-star: #d48806;
  border: 2px solid #b3151b;
}
.cs-theme--erable .cs-code { color: #fff; background: #b3151b; }
.cs-theme--erable .cs-legend h4 { color: #b3151b; }

/* Contraste élevé : noir, blanc et jaune, lignes bien marquées. */
.cs-theme--contraste {
  --cs-bg: #000;
  --cs-ink: #fff;
  --cs-head: #ffe600;
  --cs-head-line: #ffe600;
  --cs-line: rgba(255, 255, 255, .55);
  --cs-ouvert: #5dff8f;
  --cs-partiel: #ffe600;
  --cs-ferme: #ff6b6b;
  --cs-nd: #e0e0e0;
  --cs-star: #ffe600;
  border: 2px solid #fff;
}
.cs-theme--contraste .cs-public { font-size: 1.05em; }
.cs-theme--contraste .cs-code { color: #000; background: #ffe600; }
.cs-theme--contraste .cs-legend h4 { color: #ffe600; }
.cs-theme--contraste .cs-cond-label { opacity: 1; }

/* Aurore boréale : nuit bleu profond, accents vert turquoise. */
.cs-theme--aurore {
  --cs-bg: #0a1626;
  --cs-ink: #e8f1f8;
  --cs-head: #4fe0c0;
  --cs-head-line: #4fe0c0;
  --cs-ouvert: #6ee79a;
  --cs-partiel: #ffd666;
  --cs-ferme: #ff8fa3;
  --cs-nd: #a9b8c8;
  --cs-star: #4fe0c0;
  background: linear-gradient(160deg, #0a1626 0%, #10263a 60%, #0f3340 100%);
}
.cs-theme--aurore .cs-code { color: #0a1626; background: #4fe0c0; }
.cs-theme--aurore .cs-legend h4 { color: #4fe0c0; }

/* Chalet : beige chaud, accents bois. */
.cs-theme--chalet {
  --cs-bg: #f6efe4;
  --cs-ink: #3a2a1c;
  --cs-head: #7a4a24;
  --cs-head-line: #7a4a24;
  --cs-ouvert: #2f6f2a;
  --cs-partiel: #8f6100;
  --cs-ferme: #a8201a;
  --cs-nd: #6f6255;
  --cs-star: #b8730a;
  border: 1px solid #dccbb2;
}
.cs-theme--chalet .cs-code { color: #fff; background: #7a4a24; }
.cs-theme--chalet .cs-legend h4 { color: #7a4a24; }

/* Ardoise : gris anthracite, accents bleu ciel. */
.cs-theme--ardoise {
  --cs-bg: #2b3138;
  --cs-ink: #eef1f4;
  --cs-head: #8cc8ff;
  --cs-head-line: #8cc8ff;
  --cs-ouvert: #7fd88a;
  --cs-partiel: #ffd25e;
  --cs-ferme: #ff8a80;
  --cs-nd: #b8c0c8;
  --cs-star: #ffc94d;
}
.cs-theme--ardoise .cs-code { color: #1d2227; background: #8cc8ff; }
.cs-theme--ardoise .cs-legend h4 { color: #8cc8ff; }

/* Sécurité : blanc, accents orange vif (comme les vestes de patrouille). */
.cs-theme--securite {
  --cs-bg: #fff;
  --cs-ink: #1f1f1f;
  --cs-head: #c2410c;
  --cs-head-line: #f97316;
  --cs-ouvert: #1f7a35;
  --cs-partiel: #8f6100;
  --cs-ferme: #b91c1c;
  --cs-nd: #5f6368;
  --cs-star: #ea580c;
  border: 3px solid #f97316;
}
.cs-theme--securite .cs-code { color: #1f1f1f; background: #fdba74; }
.cs-theme--securite .cs-legend h4 { color: #c2410c; }

/* Barre du haut : résumé (« 8 ouverts · 3 partiels ») et boutons A− / A+. */
.cs-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  margin-bottom: .75rem;
}
.cs-summary { margin: 0; font-size: 1.05em; }
.cs-summary__item { white-space: nowrap; }
.cs-summary__sep { opacity: .5; }
.cs-zoom { display: inline-flex; gap: .35rem; margin-left: auto; }
.cs-zoom__btn {
  min-width: 2.75rem;
  min-height: 2.5rem;
  padding: 0 .6rem;
  border: 1px solid var(--cs-line);
  border-radius: .5rem;
  color: inherit;
  background: color-mix(in srgb, currentColor 6%, transparent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.cs-zoom__btn--big { font-size: 1.2em; }
.cs-zoom__btn:disabled { opacity: .4; cursor: default; }

/* Filtres et recherche, comme sur la page des patrouilleurs. */
.cs-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  margin-bottom: .75rem;
}
.cs-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.cs-chip {
  --c: var(--cs-head, currentColor);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 2.25rem;
  padding: .2rem .8rem;
  border: 1px solid var(--c);
  border-radius: 999px;
  color: inherit;
  background: none;
  font: inherit;
  font-size: .9em;
  font-weight: 600;
  cursor: pointer;
}
.cs-chip span { opacity: .75; font-weight: 400; }
.cs-chip--ouvert  { --c: var(--cs-ouvert); }
.cs-chip--partiel { --c: var(--cs-partiel); }
.cs-chip--ferme   { --c: var(--cs-ferme); }
.cs-chip--nd      { --c: var(--cs-nd); }
.cs-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 22%, transparent); box-shadow: inset 0 0 0 1px var(--c); }
.cs-search {
  flex: 1 1 14rem;
  min-height: 2.25rem;
  padding: .3rem .75rem;
  border: 1px solid var(--cs-line);
  border-radius: .5rem;
  color: inherit;
  background: color-mix(in srgb, currentColor 4%, transparent);
  font: inherit;
}
.cs-none { margin: .75rem 0; font-style: italic; opacity: .8; }

/* Commandes du visiteur : type d'affichage, thème, A− / A+. */
.cs-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-left: auto; }
.cs-controls .cs-zoom { margin-left: 0; }
.cs-views {
  display: inline-flex;
  border: 1px solid var(--cs-line);
  border-radius: .5rem;
  overflow: hidden;
}
.cs-view-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 2.5rem;
  padding: 0 .75rem;
  border: 0;
  color: inherit;
  background: none;
  font: inherit;
  font-size: .9em;
  font-weight: 600;
  cursor: pointer;
}
.cs-view-btn + .cs-view-btn { border-left: 1px solid var(--cs-line); }
.cs-view-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--cs-head, currentColor) 22%, transparent); }
.cs-theme-pick { display: inline-flex; align-items: center; gap: .4rem; font-size: .9em; font-weight: 600; }
.cs-theme-select {
  min-height: 2.5rem;
  padding: .2rem .5rem;
  border: 1px solid var(--cs-line);
  border-radius: .5rem;
  color: inherit;
  background: var(--cs-bg, transparent);
  font: inherit;
  font-weight: 400;
}
.cs-theme-select option { color: #1f2933; background: #fff; }

/*
 * Types d'affichage. « Cartes » et « Regroupé par état » (classe cs-is-cards) : une carte
 * par sentier, en grille, avec une bande de couleur selon l'état. Le tableau reste le même
 * HTML : on passe de l'un à l'autre sans recharger la page.
 */
.cs-conditions:not(.cs-view--grouped) .cs-group { display: none; }
.cs-is-cards .cs-public thead { display: none; }
.cs-is-cards .cs-public { display: block; }
.cs-is-cards .cs-public tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr));
  gap: .75rem;
  align-items: start;
}
.cs-is-cards .cs-public tr.cs-trail {
  --cs-band: var(--cs-nd);
  display: block;
  margin: 0;
  border: 1px solid var(--cs-line);
  border-top: 4px solid var(--cs-band);
  border-radius: .6rem;
  overflow: hidden;
}
.cs-is-cards .cs-public tr[data-etat="etat-1"] { --cs-band: var(--cs-ouvert); }
.cs-is-cards .cs-public tr[data-etat="etat-2"] { --cs-band: var(--cs-partiel); }
.cs-is-cards .cs-public tr[data-etat="etat-3"] { --cs-band: var(--cs-ferme); }
.cs-is-cards .cs-public tr.cs-trail > th,
.cs-is-cards .cs-public tr.cs-trail > td { display: block; width: auto; }
.cs-is-cards .cs-public tr.cs-trail > th { font-size: 1.1em; background: color-mix(in srgb, currentColor 5%, transparent); }
.cs-is-cards .cs-public tr.cs-trail > td { display: flex; justify-content: space-between; gap: 1rem; }
.cs-is-cards .cs-public tr.cs-trail > td::before { content: attr(data-label); font-weight: 600; opacity: .7; }
.cs-is-cards .cs-public tr.cs-trail > :last-child { border-bottom: 0; }
.cs-is-cards .cs-public tr.cs-trail:has(td.cs-icon) { display: grid; grid-template-columns: auto 1fr; }
.cs-is-cards .cs-public tr.cs-trail:has(td.cs-icon) > :not(.cs-icon, th) { grid-column: 1 / -1; }
.cs-is-cards .cs-public td.cs-icon {
  display: flex;
  align-items: center;
  width: auto;
  padding-right: 0;
  background: color-mix(in srgb, currentColor 5%, transparent);
}
.cs-is-cards .cs-public td.cs-icon::before { content: none; }
.cs-is-cards .cs-public td.cs-icon.is-empty { padding: 0; }
.cs-is-cards .cs-cond-label { display: inline; margin-left: .4rem; }
.cs-is-cards .cs-rem__text,
.cs-is-cards .cs-rem__more p { max-width: none; }
.cs-is-cards .cs-public td.cs-rem { flex-wrap: wrap; }
.cs-is-cards .cs-rem__more { text-align: right; }

/* Regroupé par état : ouverts d'abord, chaque groupe avec son titre. */
.cs-view--grouped .cs-public tbody > tr { order: var(--cs-go, 0); }
.cs-view--grouped .cs-public tr.cs-group { display: block; grid-column: 1 / -1; margin: 0; border: 0; border-radius: 0; overflow: visible; }
.cs-view--grouped .cs-public tr.cs-group > th {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .9rem 0 .3rem;
  border-bottom: 2px solid var(--cs-line);
  font-size: 1.15em;
  background: none;
}
.cs-view--grouped .cs-public tr.cs-group:first-child > th { padding-top: 0; }
.cs-group__count {
  padding: 0 .5rem;
  border-radius: 999px;
  font-size: .8em;
  font-weight: 600;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.cs-public {
  width: 100%;
  border-collapse: collapse;
  font-size: .95em;
}
/* Espacement des lignes (Paramètres → Affichage public) : --cs-pad-y est donné par la page.
   Niveaux 1 à 3 : lignes de texte plus serrées, note des conditions à côté des étoiles. */
.cs-conditions { --cs-pad-y: .6rem; }
.cs-spacing--tight .cs-public th,
.cs-spacing--tight .cs-public td { line-height: 1.25; }
.cs-spacing--tight .cs-cond-label { display: inline; margin-left: .4rem; }
.cs-spacing--tight .cs-photos { margin-top: .2rem; }

.cs-public th,
.cs-public td {
  padding: var(--cs-pad-y) .75rem;
  border-bottom: 1px solid var(--cs-line);
  text-align: left;
  vertical-align: middle;
}
.cs-public thead th {
  font-size: .8em;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom-width: 2px;
}
.cs-public tbody th { font-weight: 600; }
.cs-public tbody tr:hover { background: color-mix(in srgb, currentColor 4%, transparent); }

/* Texte lu par les lecteurs d'écran seulement (ne dépend pas des classes du gabarit). */
.cs-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Icône du sentier (colonne optionnelle, devant le nom) */
.cs-public .cs-icon { width: calc(var(--cs-icon-size, 32px) + .75rem); padding-right: 0; }
/* Petite marge verticale et pas d'espace de ligne : la ligne ne grandit que de la taille de l'icône. */
.cs-public td.cs-icon { padding-top: calc(var(--cs-pad-y) / 3); padding-bottom: calc(var(--cs-pad-y) / 3); line-height: 0; }
/* Taille fixe (Paramètres → Affichage public → Taille des icônes) : beaucoup de gabarits
   mettent « img { max-width: 100%; height: auto } », ce qui, dans une colonne étroite,
   réduit l'icône à un point. */
.cs-conditions .cs-icon img {
  display: block;
  flex: none;
  width: var(--cs-icon-size, 32px);
  min-width: var(--cs-icon-size, 32px);
  max-width: none;
  height: var(--cs-icon-size, 32px);
  margin: 0;
  padding: 0;
  border: 0;
  object-fit: contain;
}

.cs-code {
  display: inline-block;
  margin-right: .4rem;
  padding: .05rem .45rem;
  border-radius: .25rem;
  font-size: .8em;
  font-weight: 700;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.cs-etat {
  --cs-c: var(--cs-nd);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
  font-weight: 600;
  color: var(--cs-c);
}
.cs-etat::before {
  content: "";
  width: .75rem;
  height: .75rem;
  border-radius: 50%;
  background: var(--cs-c);
}
.cs-etat--ouvert  { --cs-c: var(--cs-ouvert); }
.cs-etat--partiel { --cs-c: var(--cs-partiel); }
.cs-etat--ferme   { --cs-c: var(--cs-ferme); }
.cs-etat--nd      { --cs-c: var(--cs-nd); }

/* Photos du sentier : miniatures sous le nom */
.cs-photos { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.cs-photos a { display: block; border-radius: .35rem; overflow: hidden; line-height: 0; }
.cs-photos img { width: 96px; height: 72px; object-fit: cover; transition: transform .15s; }
.cs-photos a:hover img, .cs-photos a:focus-visible img { transform: scale(1.05); }

/* Remarques (Paramètres → Affichage public → Affichage des remarques) */
.cs-rem__text { max-width: var(--cs-rem-width, 20em); white-space: normal; overflow-wrap: anywhere; }
.cs-rem__more summary {
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  color: var(--cs-head, inherit);
  text-decoration: underline;
  text-underline-offset: .15em;
}
.cs-rem__more p { margin: .35rem 0 0; max-width: 24em; font-size: var(--cs-modal-font, 100%); line-height: 1.45; white-space: normal; }

/* Remarque en fenêtre : bouton de la ligne, puis la fenêtre par-dessus la page. */
.cs-rem__open {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--cs-head, inherit);
  text-decoration: underline;
  text-underline-offset: .15em;
  white-space: nowrap;
  cursor: pointer;
}
.cs-modal {
  width: min(32rem, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  border-radius: .75rem;
  color: var(--cs-ink, #1f2933);
  background: var(--cs-bg, #fff);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, .35);
}
.cs-modal::backdrop { background: rgba(0, 0, 0, .55); }
.cs-modal__box { padding: 1rem 1.25rem 1.25rem; }
.cs-modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.cs-modal__title { margin: 0; font-size: 1.15em; line-height: 1.3; color: var(--cs-head, inherit); }
.cs-modal__close {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--cs-line);
  border-radius: 50%;
  color: inherit;
  background: none;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.cs-modal__text {
  margin: .75rem 0 0;
  font-size: var(--cs-modal-font, 100%);
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.cs-stars { color: var(--cs-star); letter-spacing: .1em; white-space: nowrap; }
.cs-cond-label { display: block; font-size: .85em; opacity: .8; }
.cs-date { white-space: nowrap; }

.cs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 3rem;
  margin-top: 1.25rem;
  font-size: .9em;
}
.cs-legend h4 { margin: 0 0 .4rem; font-size: 1.1em; }
.cs-legend ul { margin: 0; padding: 0; list-style: none; }
.cs-legend li { margin: .2rem 0; }

/* Mobile : chaque sentier devient une carte */
@media (max-width: 640px) {
  .cs-public thead { display: none; }
  .cs-public,
  .cs-public tbody,
  .cs-public tr,
  .cs-public th,
  .cs-public td { display: block; width: 100%; }
  .cs-public tr {
    margin-bottom: .75rem;
    border: 1px solid var(--cs-line);
    border-radius: .5rem;
    overflow: hidden;
  }
  .cs-public tbody th { font-size: 1.1em; background: color-mix(in srgb, currentColor 5%, transparent); }
  .cs-public td { display: flex; justify-content: space-between; gap: 1rem; }
  .cs-public td::before {
    content: attr(data-label);
    font-weight: 600;
    opacity: .7;
  }
  .cs-public td:last-child { border-bottom: 0; }
  /* Sur la carte, l'icône se place à gauche du nom, dans la même bande. */
  .cs-public tr:has(td.cs-icon) { display: grid; grid-template-columns: auto 1fr; }
  .cs-public tr:has(td.cs-icon) > :not(.cs-icon, th) { grid-column: 1 / -1; }
  .cs-public td.cs-icon {
    display: flex;
    align-items: center;
    width: auto;
    padding-right: 0;
    background: color-mix(in srgb, currentColor 5%, transparent);
  }
  .cs-public td.cs-icon::before { content: none; }
  .cs-public td.cs-icon.is-empty { padding: 0; }
  .cs-cond-label { display: inline; margin-left: .4rem; }
  /* Sur la carte, la remarque prend toute la largeur. */
  .cs-rem__text,
  .cs-rem__more p { max-width: none; }
  .cs-public td.cs-rem { flex-wrap: wrap; }
  .cs-rem__more { text-align: right; }
}
