/* styles/section-outline.css
 * On-page section outline. Desktop (>=1100px): a fixed rail in a reserved left
 * column. Narrow/phone (<1100px): a hamburger button opening a slide-in drawer.
 * Colors reuse the site's dark-theme tokens from base.css.
 */
:root {
  --outline-rail-w: 160px;
  --outline-rail-gap: 16px;
  --outline-scroll-offset: 16px;
  --outline-accent: #6ea8fe;
}

.section-outline-list { list-style: none; margin: 0; padding: 0; }
.section-outline-list a {
  display: block;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.3;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.section-outline-list a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.section-outline-list a.active {
  color: #fff;
  border-left-color: var(--outline-accent);
  background: rgba(110, 168, 254, 0.16);
  font-weight: 600;
}
.section-outline-list a:focus-visible,
.section-outline-toggle:focus-visible {
  outline: 2px solid var(--outline-accent);
  outline-offset: 2px;
}

/* ---- Desktop: reserved column + fixed rail (>=1100px) ---- */
/* JS (positionDesktopRail) sets `top` and `max-height` so the rail starts level
   with the first panel and sticks near the top on scroll. */
@media (min-width: 1100px) {
  body.has-section-outline {
    padding-left: calc(var(--outline-rail-w) + var(--outline-rail-gap) * 2);
  }
  .section-outline-toggle,
  .section-outline-backdrop { display: none; }
  .section-outline-panel {
    position: fixed;
    left: 0;
    width: var(--outline-rail-w);
    overflow-y: auto;
    padding: 0 var(--outline-rail-gap);
    box-sizing: border-box;
  }
}

/* ---- Narrow/phone: hamburger + drawer (<1100px) ---- */
@media (max-width: 1099px) {
  body.has-section-outline { padding-left: 0; }
  .section-outline-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  }
  .section-outline-bars,
  .section-outline-bars::before,
  .section-outline-bars::after {
    content: "";
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    position: relative;
  }
  .section-outline-bars::before { position: absolute; top: -6px; }
  .section-outline-bars::after { position: absolute; top: 6px; }

  .section-outline-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
  }
  .section-outline-panel {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1002;
    width: 78%;
    max-width: 320px;
    height: 100vh;
    overflow-y: auto;
    padding: 56px 16px 24px;
    box-sizing: border-box;
    background: var(--bg);
    border-right: 1px solid var(--border-light);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .section-outline.open .section-outline-panel { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .section-outline-panel { transition: none; }
  html { scroll-behavior: auto; }
}
