/* Section Navigation - Minimalist, Apple-style in-page nav */

/* Layout wrapper for pages using the side nav */
.home-layout {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0;
  position: relative;
}

/* ── Desktop: fixed right-side rail ─────────────── */

.section-nav {
  position: fixed;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  width: 242px;
  max-height: calc(100vh - 140px);
  overflow: hidden;
  padding: 6px 4px;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  z-index: 90;
  direction: rtl;
  transition: color 0.35s ease;
}

/* Reveal-on-scroll behavior (hidden until user scrolls past hero) */
.section-nav.is-reveal {
  opacity: 0;
  transform: translate(24px, -50%);
  pointer-events: none;
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-nav.is-reveal.is-visible {
  opacity: 1;
  transform: translate(0, -50%);
  pointer-events: auto;
}

/* Mobile toggle button - hidden on desktop */
.section-nav-toggle {
  display: none;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-list li {
  margin: 0;
}

.nav-link {
  display: block;
  padding: 11px 18px;
  text-align: right;
  text-decoration: none;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.95rem;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.35;
  transition:
    color 0.25s ease,
    background-color 0.25s ease,
    transform 0.25s ease;
  /* Allow long labels (e.g. the next-cohort item) to wrap onto a second
     line and show in full, instead of being clipped with an ellipsis. */
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.nav-link:hover {
  color: var(--text-color);
  transform: translateX(-2px);
}

.nav-link.active {
  color: var(--primary-color);
  background: var(--primary-light);
  font-weight: 600;
}

/* Dark-section variant: swap text + pill colors so the nav stays readable
   on sections with dark backgrounds (e.g. the Claude Code section).
   No container background is needed - the text alone adapts. */
.section-nav.on-dark .nav-link {
  color: rgba(255, 255, 255, 0.72);
  transition:
    color 0.35s ease,
    background-color 0.35s ease,
    transform 0.25s ease;
}

.section-nav.on-dark .nav-link:hover {
  color: #ffffff;
}

.section-nav.on-dark .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* ── Tablet / small laptop (max 1479px): horizontal pill bar ──────
   Below 1480px the desktop right rail collides with centered content,
   so we switch to a sticky overhead quick-nav - horizontally scrolling
   rounded pills, mirroring the pattern on CourseOverviewView. Both the
   toggle button and drawer are retired here. */

@media (max-width: 1479px) {
  .home-layout {
    flex-direction: column;
  }

  /* Always-visible sticky strip; override all reveal-on-scroll states. */
  .section-nav,
  .section-nav.is-reveal,
  .section-nav.is-reveal.is-visible,
  .section-nav.is-reveal:not(.is-visible) {
    position: fixed;
    /* Toolbar is 52px at this breakpoint (drops to 48px only below 768px) */
    top: 72px;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: none;
    margin: 0;
    border: none;
    border-bottom: 1px solid var(--border-default);
    border-radius: 0;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: none;
    z-index: 95;
    opacity: 1;
    pointer-events: auto;
    transition: background-color 0.35s ease, border-color 0.35s ease;
  }

  /* When scrolled over a dark-themed section, darken the whole pill bar so
     the already-whitened text/chips stay readable (otherwise white-on-white). */
  .section-nav.on-dark,
  .section-nav.on-dark.is-reveal,
  .section-nav.on-dark.is-reveal.is-visible,
  .section-nav.on-dark.is-reveal:not(.is-visible) {
    background: rgba(17, 20, 28, 0.88);
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  .section-nav-toggle {
    display: none;
  }

  .nav-list {
    display: flex;
    flex-direction: row;
    max-width: 900px;
    margin: 0 auto;
    gap: 4px;
    padding: 10px 0;
    background: transparent;
    border: none;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* `safe center` keeps the pills centered when they fit, and falls
       back to `flex-start` on overflow. In RTL flex-start = right edge,
       so Hebrew readers see the first pill at the right and scroll left
       for more - instead of losing pills to both clipped ends. */
    justify-content: safe center;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    flex-shrink: 0;
    padding: 7px 18px;
    border: 1px solid transparent;
    border-radius: 100px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    transition: all 0.2s ease;
  }

  .nav-link:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    transform: none;
  }

  .nav-link.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    border-radius: 100px;
    font-weight: 500;
  }

  /* Dark-section variant on pills: translucent white chip against the
     section beneath it shining through the blurred backdrop. */
  .section-nav.on-dark .nav-link.active {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.32);
  }
}

/* ── Phone (< 768px) ────────────────────────────── */

@media (max-width: 767px) {
  /* Match every selector the tablet block above targets, otherwise its
     three-class specificity (.section-nav.is-reveal.is-visible) beats the
     phone override and the nav sticks at 72px below a 48px toolbar,
     leaving a 24px gap. */
  .section-nav,
  .section-nav.is-reveal,
  .section-nav.is-reveal.is-visible,
  .section-nav.is-reveal:not(.is-visible) {
    top: 48px;
    padding: 0 16px;
  }

  .nav-list {
    justify-content: flex-start;
  }

  .nav-link {
    padding: 10px 16px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
  }
}
