/* WTech — navigation de lecture sur ordinateur, tablette et téléphone. */
.toc {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 144px);
  max-height: calc(100dvh - 144px);
}

.toc > .aside-eyebrow { flex: 0 0 auto; }
.toc-toggle, .article-mobile-navigation, .article-mobile-navigation-space { display: none; }
.article-mobile-navigation[hidden], .article-mobile-navigation-space[hidden], .toc nav[hidden] { display: none; }

.toc nav {
  display: grid;
  gap: 5px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--theme-border) transparent;
}

.toc nav::-webkit-scrollbar { width: 5px; }
.toc nav::-webkit-scrollbar-thumb {
  background: var(--theme-border);
  border-radius: 999px;
}

/* Les images gardent leur format et les légendes restent sous la photo. */
@media (max-width: 1024px) {
  .hero-image img, .article-figure img {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: auto;
    object-fit: contain;
  }

  .hero-image figcaption,
  html[data-theme] .hero-image figcaption {
    position: static;
    padding: 14px 18px;
    background: var(--surface);
    color: var(--muted);
    font-size: .76rem;
    line-height: 1.6;
  }

  .prose { overflow-wrap: anywhere; }
}

@media (max-width: 1024px) {
  /* Sans JavaScript, la liste reste accessible au-dessus du texte. */
  .aside .toc {
    display: flex;
    max-height: 360px;
    max-height: min(50dvh, 360px);
  }

  html.article-toc-ready {
    scroll-padding-top: var(--article-scroll-offset, 175px);
  }

  .article-toc-ready .content-layout > .aside { display: none; }
  .article-toc-ready .content-layout { grid-template-columns: minmax(0, 1fr); gap: 22px; }

  .article-toc-ready .site-header {
    transition: transform .24s ease, opacity .2s ease;
  }

  html.article-reading .site-header {
    transform: translate(-50%, calc(-100% - 24px));
    opacity: 0;
    pointer-events: none;
  }

  .article-mobile-navigation-space {
    display: block;
    height: var(--article-toc-height, 66px);
    margin-top: 28px;
  }

  .article-mobile-navigation {
    display: block;
    position: sticky;
    top: var(--article-toc-top, 95px);
    z-index: 84;
    margin-top: 28px;
    transition: top .24s ease;
  }

  html.article-toc-pinned .article-mobile-navigation {
    position: fixed;
    left: 50%;
    top: var(--article-toc-top, 8px);
    margin-top: 0;
    transform: translateX(-50%);
  }

  .article-mobile-navigation .toc {
    position: relative;
    max-height: none;
    padding: 10px 14px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  }

  .article-mobile-navigation .aside-eyebrow { display: none; }
  .article-mobile-navigation .toc-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .toc-toggle-copy { display: grid; gap: 4px; min-width: 0; flex: 1; }
  .toc-toggle-label {
    font-size: .64rem;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .toc-current {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    height: 1.4em;
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .toc-toggle:focus-visible {
    outline: 2px solid var(--theme-focus);
    outline-offset: 5px;
    border-radius: 4px;
  }

  .article-mobile-navigation .toc nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: min(52vh, calc(100vh - var(--article-toc-top, 95px) - var(--article-toc-height, 66px) - 100px));
    max-height: min(52dvh, calc(100dvh - var(--article-toc-top, 95px) - var(--article-toc-height, 66px) - 100px));
    padding: 12px;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 12px 38px rgba(0, 0, 0, .2);
  }

  .article-mobile-navigation .toc nav a {
    display: block;
    min-height: 44px;
    padding: 10px 0 10px 12px;
    border-left: 2px solid transparent;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.48;
    overflow-wrap: anywhere;
  }

  .article-mobile-navigation .toc nav a:hover,
  .article-mobile-navigation .toc nav a.active {
    border-color: var(--text);
    color: var(--text);
  }

  .article-toc-ready .content-layout { padding-top: 28px; }
}
