/* WoWGoldFarms — Table of Contents (sticky) — M48
   Canonical CSS for .toc (sidebar) and .toc-mobile (disclosure) components.
   Token source: static/css/_tokens.css  — never add :root{} blocks here.
   Brand gold: var(--wgf-gold-primary) / rgb(240,192,64) via var(--wgf-gold-primary). */

/* ── TOC widget ──────────────────────────────────────────────────────────────
   Used for both the desktop sidebar and as the inner shell of the mobile
   disclosure variant. */

.toc {
  background: var(--wgf-panel-1);
  border: 1px solid var(--wgf-border-neutral);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-3) var(--space-2);
  box-shadow: var(--shadow-1);
}

.toc__title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--wgf-muted);
  margin: 0 0 var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--wgf-border-neutral-soft);
}

/* ── nav list ─────────────────────────────────────────────────────────────── */

.toc__nav {
  margin: 0;
  padding: 0;
}

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

/* ── link ─────────────────────────────────────────────────────────────────── */

.toc__link {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--wgf-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
  line-height: 1.4;
  transition:
    color var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    background var(--motion-fast) var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  .toc__link { transition: none; }
}

.toc__link:hover {
  color: var(--wgf-text);
  background: var(--wgf-panel-2);
}

.toc__link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-control);
}

/* ── active state: gold left bar + weight bump, no filled pill ────────────── */

.toc__link[aria-current="true"] {
  color: var(--wgf-gold-bright);
  border-left-color: var(--wgf-gold-accent);
  font-weight: 600;
  background: transparent;
}

/* ── nested level-3 items ─────────────────────────────────────────────────── */

.toc__list--nested {
  list-style: none;
  margin: 1px 0 1px var(--space-3);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 1px solid var(--wgf-border-neutral-soft);
}

.toc__list--nested .toc__link {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  color: var(--wgf-muted);
}

.toc__list--nested .toc__link:hover { color: var(--wgf-text); }

.toc__list--nested .toc__link[aria-current="true"] {
  color: var(--wgf-gold-bright);
  border-left-color: var(--wgf-gold-accent);
  font-weight: 600;
}

/* ── Sticky sidebar layout ────────────────────────────────────────────────── */

/* The sidebar wrapper — callers place this in a grid or flex parent.
   position:sticky is relative to the nearest scroll container (the page). */

.toc-sidebar {
  position: sticky;
  top: var(--space-4);
  max-height: calc(100vh - 2 * var(--space-4));
  overflow-y: auto;
  /* min-width keeps the sidebar from collapsing in narrow grid cells */
  min-width: 180px;
  max-width: 240px;
}

/* Guide detail two-column layout: [toc-sidebar] [guide body] */
.gsh-guide-toc-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-5);
  align-items: start;
  max-width: 1060px;
}

@media (max-width: 860px) {
  /* Sidebar disappears; mobile disclosure (below) takes over */
  .gsh-guide-toc-layout {
    grid-template-columns: 1fr;
  }
  .toc-sidebar {
    display: none;
  }
}

/* ── Mobile disclosure ────────────────────────────────────────────────────── */

.toc-mobile {
  background: var(--wgf-panel-1);
  border: 1px solid var(--wgf-border-neutral);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  /* Hidden above the breakpoint where sidebar is shown */
  display: none;
}

@media (max-width: 860px) {
  .toc-mobile {
    display: block;
    margin-bottom: var(--space-4);
  }
}

.toc-mobile__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: var(--space-3);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--wgf-muted);
  gap: var(--space-2);
}

.toc-mobile__toggle:hover { color: var(--wgf-text); }

.toc-mobile__toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-control);
}

.toc-mobile__icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wgf-muted);
  transition: transform var(--motion-fast) var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  .toc-mobile__icon { transition: none; }
}

.toc-mobile__toggle[aria-expanded="true"] .toc-mobile__icon {
  transform: rotate(180deg);
}

.toc-mobile__body {
  border-top: 1px solid var(--wgf-border-neutral-soft);
  padding: var(--space-2) var(--space-3) var(--space-3);
  /* collapsed: hide via height + opacity so transition can run */
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height var(--motion-base) var(--ease-standard),
    opacity var(--motion-fast) var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  .toc-mobile__body { transition: none; }
}

.toc-mobile__body.is-open {
  /* generous cap — real guide TOCs are roughly 200px */
  max-height: 600px;
  opacity: 1;
}

.toc-mobile .toc__list { padding-top: var(--space-1); }
