/* SPDX-License-Identifier: MIT */
/* Copyright (c) 2026 Evgeny Baulin */
/* The course navigation: the topic sidebar (docked from 1440px, a drawer below), the topic cards of the landing page
   and the card of the upcoming page. */

/* ---------------------------------------------------------------- toolbar toggle */
.tool-topics {
  gap: 0.4em;
}
.tool-topics .tool-icon {
  font-size: 1.05em;
  line-height: 1;
}
/* the landing page has no page links: the tools still sit on the right */
.tool-topics + .toolbar-tools {
  margin-left: auto;
}
/* only the icon shows below 1300px, and on the seminar page, whose block links need the room; screen readers
   still get the label */
.page-main .tool-topics {
  min-width: 2.1em;
}
.page-main .tool-topics .tool-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
@media (max-width: 1299.98px) {
  .tool-topics {
    min-width: 2.1em;
  }
  .tool-topics .tool-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* ---------------------------------------------------------------- the panel (docked and drawer alike) */
.course-nav {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border-right: 1px solid var(--line);
  font-size: 0.92rem;
  line-height: 1.3;
}
.course-nav-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.course-nav-title {
  margin: 0;
  font-weight: 700;
  color: var(--fg);
}
.course-nav-title a {
  color: inherit;
  text-decoration: none;
}
.course-nav-title a:hover {
  color: var(--accent);
}
.course-nav-close {
  font-size: 0.85rem;
}
.course-nav-atlas {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 10px 12px 4px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
.course-nav-atlas:hover {
  border-color: var(--accent);
}
.course-nav-group {
  margin: 12px 16px 4px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.course-nav-list {
  list-style: none;
  margin: 0;
  padding: 0 0 18px;
}
.course-nav-link {
  display: grid;
  grid-template-columns: 1.7em minmax(0, 1fr);
  gap: 0 6px;
  padding: 6px 14px 6px 13px;
  border-left: 3px solid transparent;
  color: var(--fg-soft);
  text-decoration: none;
}
a.course-nav-link:hover {
  color: var(--accent);
  background: var(--panel-2);
}
.course-nav-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* the current topic: an accent border as well as the color, like the problem cards */
.course-nav-item.is-current > .course-nav-link {
  border-left-color: var(--accent);
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 700;
}
.course-nav-item.is-current .course-nav-num {
  color: var(--accent);
}
.course-nav-link[aria-disabled="true"] {
  color: var(--muted);
  cursor: default;
}
/* italic like the "coming later" line of the topic cards: the muted color alone is too close to the links in the light theme */
.course-nav-link[aria-disabled="true"] .course-nav-name {
  font-style: italic;
  --punct-style: italic;
}
.course-nav-pages {
  list-style: none;
  margin: 0 0 6px;
  padding: 2px 0 2px calc(13px + 1.7em + 6px + 3px);
}
.course-nav-pages a {
  display: block;
  padding: 3px 8px 3px 0;
  color: var(--fg-soft);
  text-decoration: none;
  font-size: 0.88rem;
}
.course-nav-pages a:hover {
  color: var(--accent);
}
.course-nav-pages a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}
/* the scroll container would clip an outline drawn outside */
.course-nav a:focus-visible,
.course-nav button:focus-visible {
  outline-offset: -3px;
}

.course-nav-scrim {
  display: none;
}

/* ---------------------------------------------------------------- docked */
@media (min-width: 1440px) {
  body {
    padding-left: var(--sidebar-w);
  }
  .course-nav {
    z-index: 25;
  }
  .tool-topics,
  .course-nav-close {
    display: none;
  }
  /* the fourteen topics are taller than a short window: fade the bottom edge so the cut is visible.
     The extra padding keeps the last topic out of the fade once the list is scrolled to the end. */
  .course-nav {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  }
  .course-nav-list {
    padding-bottom: 32px;
  }
}

/* ---------------------------------------------------------------- drawer */
@media (max-width: 1439.98px) {
  .course-nav {
    z-index: 36;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    box-shadow: 0 0 24px rgba(8, 12, 20, 0.35);
  }
  .is-nav-open .course-nav {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }
  .is-nav-open .course-nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(8, 12, 20, 0.55);
  }
  .is-nav-open body {
    overflow: hidden;
  }
}

/* ---------------------------------------------------------------- present mode */
.is-present body {
  padding-left: 0;
}
.is-present .course-nav,
.is-present .course-nav-scrim {
  display: none;
}
/* ---------------------------------------------------------------- landing page: a card per topic */
.home-lead {
  max-width: var(--measure);
  margin-top: 1.2em;
}
.home-title {
  margin-top: 1.1em;
  font-size: 1.4rem;
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.topic-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}
.topic-card.is-later {
  border-top-color: var(--line);
  background: transparent;
}
.topic-number {
  margin: 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.topic-card.is-later .topic-number,
.topic-card.is-later .topic-title {
  color: var(--muted);
}
.topic-title {
  font-size: 1.08rem;
}
.topic-foot {
  margin-top: auto;
  padding-top: 8px;
}
.topic-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.topic-links.is-pdf {
  margin-top: 2px;
  font-size: 0.9rem;
}
.topic-later {
  margin: 0;
  color: var(--muted);
  font-style: italic;
  --punct-style: italic;
}

/* ---------------------------------------------------------------- upcoming page: the card of a seminar not out yet */
.upcoming {
  max-width: 46rem;
  margin: 36px 0 12px;
  padding: 18px 24px 22px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}
.upcoming-number {
  margin: 0;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.upcoming-title {
  margin: 0.2em 0 0;
  font-size: 1.5rem;
}
.upcoming-text {
  margin: 0.7em 0 1.2em;
  color: var(--fg-soft);
}
.upcoming-links {
  margin: 0;
}
/* a short page: the footer stays at the bottom of the window */
.page-upcoming {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page-upcoming .site-header,
.page-upcoming .content {
  width: 100%;
}
.page-upcoming .content {
  flex: 1 0 auto;
}
@media (max-width: 700px) {
  .upcoming {
    margin-top: 20px;
    padding: 14px 16px 18px;
  }
  .upcoming-title {
    font-size: 1.3rem;
  }
}
