/* ============================================================
   OSpress — Built-in Table of Contents
   Uses the same CSS custom properties as the OS-window chrome.
   ============================================================ */

.ospress-toc {
  position: relative;
  background: var(--win-titlebar, rgba(238,243,252,0.96));
  border: 1px solid var(--win-border, rgba(0,0,0,0.10));
  border-radius: var(--ospress-radius, 8px);
  margin: 0 0 1.75em;
  overflow: hidden;
  font-size: 13px;
  color: var(--win-text, #1a1a2e);
}

/* ── Reading-progress strip (top edge) ──────────────────────────── */
.ospress-toc__progress {
  height: 2px;
  background: var(--win-border, rgba(0,0,0,0.08));
  position: relative;
}
.ospress-toc__progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--ospress-accent, #0067C0);
  transition: width 0.14s linear;
  border-radius: 0 2px 2px 0;
}

/* ── Header row ─────────────────────────────────────────────────── */
.ospress-toc__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  border-bottom: 1px solid var(--win-border, rgba(0,0,0,0.08));
  user-select: none;
}

.ospress-toc__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--win-text-muted, #5a6070);
  flex: 1;
  min-width: 0;
}

.ospress-toc__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ospress-toc__readtime {
  font-size: 11px;
  color: var(--win-text-muted, #5a6070);
  white-space: nowrap;
}

.ospress-toc__toggle {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  color: var(--win-text-muted, #5a6070);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.ospress-toc__toggle:hover {
  background: var(--win-hover, rgba(0,103,192,0.09));
  border-color: var(--win-border, rgba(0,0,0,0.10));
  color: var(--win-text, #1a1a2e);
}

/* ── Collapsible body ───────────────────────────────────────────── */
.ospress-toc__body {
  padding: 6px 0 8px;
}
.ospress-toc__body.is-collapsed {
  display: none;
}

/* ── TOC list ───────────────────────────────────────────────────── */
.ospress-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ospress-toc__item {
  /* var(--toc-indent) is set inline by PHP (0 = base level, 1 = one level deep, …) */
  padding-left: calc(12px + var(--toc-indent, 0) * 14px);
}

.ospress-toc__link {
  display: block;
  padding: 3px 12px 3px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--win-link-color, #0067C0);
  text-decoration: none;
  border-radius: 4px;
  margin: 1px 8px 1px 0;
  transition: background 0.1s, color 0.1s;
}
.ospress-toc__link:hover {
  background: var(--win-hover, rgba(0,103,192,0.09));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ospress-toc__link.is-active {
  background: var(--win-selected, rgba(0,103,192,0.14));
  color: var(--ospress-accent, #0067C0);
  font-weight: 600;
}

/* ── Dark mode ──────────────────────────────────────────────────── */
[data-theme="dark"] .ospress-toc {
  background: var(--win-titlebar);
  border-color: var(--win-border);
}
[data-theme="dark"] .ospress-toc__link.is-active {
  color: var(--ospress-accent-light, #60CDFF);
}
@media (prefers-color-scheme: dark) {
  .ospress-toc__link.is-active { color: var(--ospress-accent-light, #60CDFF); }
}
