/* ====================================================
   concerne : le menu Sommaire (gauche), la table des 
   matières Sur cette page (droite) (renommé "_index")
   et le fil d'Ariane
   ==================================================== */

@media screen {

.sidebar__nav,
.toc {
  --edge: var(--text);
  --drop: var(--accent);
  --on-bar: #ffffff;
}

/* Sommaire */
.sidebar__nav {
  border: 3px solid var(--edge);
  background: var(--bg-elevated);
  box-shadow: 5px 5px 0 var(--drop);
}

.sidebar__nav .sidebar__eyebrow,
.toc__barre,
.liste__barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 0.3rem 0.75rem;
  background: var(--accent);
  color: var(--on-bar);
  border-bottom: 3px solid var(--edge);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* trois pastilles carrées */
.sidebar__nav .sidebar__eyebrow::after,
.toc__barre::after,
.liste__barre::after {
  content: "";
  flex: none;
  width: 34px;
  height: 10px;
  background: linear-gradient(90deg,
    var(--on-bar) 0 10px, transparent 10px 12px,
    var(--on-bar) 12px 22px, transparent 22px 24px,
    var(--on-bar) 24px 34px);
}

.sidebar__nav > ul { padding: 0.5rem; gap: 0; }

.sidebar__nav a,
.sidebar__submenu summary {
  margin-left: 0;
  padding: 0.4rem 0.6rem;
  border-radius: 0;
  border-left: 0;
  color: var(--text);
  transition: none;
}
.sidebar__nav a:hover,
.sidebar__submenu summary:hover { background: var(--accent); color: var(--text); }
.sidebar__nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--on-bar);
  font-weight: 600;
  border-left: 0;
}
.sidebar__submenu ul { padding-left: 0.6rem; }

/* Fil d'Ariane */
.chemin {
  margin: 0.5rem 0 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.chemin ol {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  row-gap: 0.15rem;
  margin: 0;
  padding: 0;
}
.chemin li { display: inline-flex; align-items: baseline; min-width: 0; }
.chemin li + li::before {
  content: "/";
  padding: 0 0.5em;
  color: var(--text-faint);
  opacity: 0.6;
}
.chemin a {
  padding: 0.1em 0.25em;
  margin: 0 -0.25em;
  color: var(--text-muted);
}
.chemin a:hover { background: var(--text); color: var(--bg); }
.chemin li:first-child a { font-weight: 700; color: var(--text); }
.chemin [aria-current="page"] {
  color: var(--accent);
  max-width: 42ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* curseur de terminal en fin de chemin */
.chemin li:last-child::after {
  content: "";
  align-self: center;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.35em;
  background: var(--accent);
  animation: chemin-curseur 1.1s steps(1) infinite;
}
@keyframes chemin-curseur { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .chemin li:last-child::after { animation: none; }
}

/* Page + table des matières à droite */
.page--toc { display: grid; grid-template-columns: minmax(0, 1fr); }

/* sur petit écran la table passe au-dessus de l'article, repliée */
.page--toc > .toc { order: -1; margin-bottom: 1.75rem; }

@media (min-width: 1200px) {
  .page--toc { grid-template-columns: minmax(0, 1fr) 232px; column-gap: 2.5rem; align-items: start; }
  .page--toc > .post { grid-column: 1; grid-row: 1; }
  .page--toc > .toc {
    grid-column: 2;
    grid-row: 1;
    order: 0;
    margin: 0;
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    max-height: calc(100vh - var(--header-h) - var(--footer-h) - 8rem);
    max-height: calc(100dvh - var(--header-h) - var(--footer-h) - 8rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.toc__fen {
  border: 3px solid var(--edge);
  background: var(--bg-elevated);
  box-shadow: 5px 5px 0 var(--drop);
}
.toc__barre { cursor: pointer; list-style: none; }
.toc__barre::-webkit-details-marker { display: none; }
.toc__fen:not([open]) .toc__barre { border-bottom: 0; }

.toc__liste { padding: 0.5rem; margin: 0; }
.toc__liste ul { margin: 0; padding: 0 0 0 0.9rem; }
.toc__liste a {
  display: block;
  padding: 0.28rem 0.5rem;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.toc__liste ul a { font-size: 0.8rem; }
.toc__liste a:hover { background: var(--accent); color: var(--text); }
.toc__liste a[aria-current="true"] { background: var(--accent); color: var(--on-bar); font-weight: 600; }


/* Pixel animé sous le Sommaire */
.sidebar__pixel {
  --edge: var(--text);
  --drop: var(--accent);
  margin: 1.75rem 0 auto;
  padding: 0.9rem 0.75rem 0.6rem;
  display: grid;
  place-items: center;
  border: 3px solid var(--edge);
  background: var(--bg-elevated);
  box-shadow: 5px 5px 0 var(--drop);
}

/* défilement */
:root { --header-h: 74px; --footer-h: 52px; }

.sidebar, .toc, .home-recent {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

@media (min-width: 821px) {
  html {
    scroll-padding-top: calc(var(--header-h) + 1rem);
    scroll-padding-bottom: calc(var(--footer-h) + 1rem);
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg);
  }

  .site-footer {
    position: sticky;
    bottom: 0;
    z-index: 35;
    background: var(--bg);
    padding: 0.55rem 1.5rem;
  }

  .sidebar {
    position: sticky;
    top: var(--header-h);
    align-self: start;
    min-height: 0;
    height: calc(100vh - var(--header-h) - var(--footer-h));
    height: calc(100dvh - var(--header-h) - var(--footer-h));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .home-recent {
    top: calc(var(--header-h) + 1.5rem);
    max-height: calc(100vh - var(--header-h) - var(--footer-h) - 8rem);
    max-height: calc(100dvh - var(--header-h) - var(--footer-h) - 8rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}


/* Réparation du collant */
body { overflow-x: clip; }

/* Bouton « remonter » (bas gauche) */
.remonter {
  --edge: var(--text);
  --drop: var(--accent);
  position: fixed;
  right: 1.5rem;
  bottom: calc(var(--footer-h) + 1.25rem);
  z-index: 50;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  color: var(--text);
  background: var(--bg-elevated);
  border: 3px solid var(--edge);
  border-radius: 0;
  box-shadow: 5px 5px 0 var(--drop);
  cursor: pointer;
  /* caché tant qu'on n'a pas défilé ; apparition par paliers */
  visibility: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.15s steps(3), transform 0.15s steps(3), visibility 0s 0.15s;
}
.remonter.is-visible {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity 0.15s steps(3), transform 0.15s steps(3);
}
.remonter:hover { background: var(--bg-hover); }
.remonter:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--drop); }
.remonter [data-pixel] { --px-w: 36px; transition: transform 0.1s steps(2); }
.remonter [data-pixel] rect { opacity: 1; }
.remonter:hover [data-pixel] { transform: translateY(-3px); }

@media (max-width: 820px) {
  .remonter { right: 1rem; bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .remonter, .remonter.is-visible, .remonter [data-pixel] { transition: none; }
}


/* Listes d'articles : une fenêtre avec barre, outils et lignes cliquables */
.liste {
  --edge: var(--text);
  --drop: var(--accent);
  --on-bar: #ffffff;
  margin-bottom: 2rem;
  border: 3px solid var(--edge);
  background: var(--bg-elevated);
  box-shadow: 5px 5px 0 var(--drop);
}
.liste__compte { margin: 0 auto 0 0.75rem; opacity: 0.9; }

.liste__outils {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 3px solid var(--edge);
  background: var(--bg);
}
.liste__outils[hidden] { display: none; }
.liste .filter-bar { margin: 0; gap: 0.4rem; }

.liste .filter-bar__btn {
  padding: 0.3rem 0.65rem;
  border: 2px solid var(--edge);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  transition: none;
}
.liste .filter-bar__btn:hover { background: var(--text); color: var(--bg); border-color: var(--edge); }
.liste .filter-bar__btn.is-active { background: var(--accent); color: var(--on-bar); border-color: var(--edge); }
.filter-bar__n { margin-left: 0.45em; opacity: 0.7; }
.filter-bar__btn.is-active .filter-bar__n { opacity: 1; }

.liste__champs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-left: auto; }
.liste__q,
.liste__tri {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 2px solid var(--edge);
  border-radius: 0;
  padding: 0.3rem 0.5rem;
}
.liste__q { width: 11rem; max-width: 100%; }
.liste__q::placeholder { color: var(--text-faint); }

/* lignes : toute la ligne est cliquable, le survol inverse les couleurs */
.liste .post-list__items { margin: 0; padding: 0; list-style: none; }
.liste .post-list__item {
  position: relative;
  padding: 1rem 1rem;
  border-bottom: 2px solid var(--rule);
}
.liste .post-list__item:last-child { border-bottom: 0; }
.liste .post-list__link::after { content: ""; position: absolute; inset: 0; }

.liste .post-list__item:hover,
.liste .post-list__item:focus-within { background: var(--text); color: var(--bg); }
.liste .post-list__item:hover .post-list__title,
.liste .post-list__item:hover .post-list__desc,
.liste .post-list__item:hover .post-list__num,
.liste .post-list__item:hover .post-list__date,
.liste .post-list__item:focus-within .post-list__title,
.liste .post-list__item:focus-within .post-list__desc,
.liste .post-list__item:focus-within .post-list__num,
.liste .post-list__item:focus-within .post-list__date { color: inherit; }
.liste .post-list__item:focus-within { outline: 3px solid var(--accent); outline-offset: -3px; }

.liste .post-list__title,
.liste .tag { transition: none; }
.liste .post-list__item:hover .post-list__link,
.liste .post-list__item:focus-within .post-list__link { color: inherit; }
.liste .tag { border-radius: 0; }
.liste .post-list__item:hover .tag,
.liste .post-list__item:focus-within .tag {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 0 0 1px currentColor;
}

.liste .post-list--empty { margin: 0; padding: 1.25rem 1rem; }
.liste .post-list--empty[hidden] { display: none; }


/* Recherche : liste déroulante du header + page de résultats */
.search-results {
  border: 3px solid var(--text);
  border-radius: 0;
  background: var(--bg-elevated);
  box-shadow: 5px 5px 0 var(--accent);
  max-height: min(420px, 70vh);
  padding: 0;
  top: calc(100% + 0.9rem);
}
.search-results li a { border-radius: 0; padding: 0.55rem 0.75rem; }
.search-results li a:hover,
.search-results li[aria-selected="true"] a { background: var(--text); color: var(--bg); }
.search-results li a:hover .search-results__cat,
.search-results li[aria-selected="true"] .search-results__cat { color: inherit; }
.search-results__more a {
  justify-content: flex-start;
  border-top: 2px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
}
.search-results__empty { padding: 0.75rem; font-size: 0.88rem; color: var(--text-muted); }

mark.search-highlight { background: var(--accent); color: #fff; padding: 0 0.12em; border-radius: 0; }

.liste__q--large { width: 16rem; }
.liste--recherche .post-list__desc {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.liste--recherche .post-list__item:hover .search-highlight { background: var(--accent); color: #fff; }

}