/* =================================================================
   TOC — Table of Contents sidebar card
   Append this block to blog-page.css
   ================================================================= */

/* ── Container (re-uses .sidebar-card chrome) ──────────────────── */
.toc {
  padding: 0;
  overflow: hidden;
}

/* ── Toggle button (header row) ────────────────────────────────── */
.toc__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.toc__toggle:hover { background: var(--surface-2); }

.toc__toggle-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}

.toc__toggle-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: var(--text-3);
  transition: transform 0.22s ease;
}
.toc__toggle--collapsed .toc__toggle-icon {
  transform: rotate(-90deg);
}

/* ── List ───────────────────────────────────────────────────────── */
.toc__list {
  list-style: none;
  margin: 0;
  padding: 10px 0 12px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  max-height: 1200px;
  opacity: 1;
}
.toc__list--collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
}

/* ── Items ──────────────────────────────────────────────────────── */
.toc__item {
  position: relative;
}
.toc__item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
  border-radius: 0 2px 2px 0;
  transition: background 0.2s;
}
.toc__item--active::before {
  background: var(--accent);
}

/* ── Links ──────────────────────────────────────────────────────── */
.toc__link {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 6px 20px 6px 16px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.toc__link:hover { background: var(--surface-2); }

.toc__num {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  min-width: 20px;
  transition: color 0.15s;
}
.toc__text {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.45;
  transition: color 0.15s;
}
.toc__item--active .toc__link { background: var(--accent-soft); }
.toc__item--active .toc__num,
.toc__item--active .toc__text { color: var(--accent); font-weight: 500; }
.toc__item--active .toc__link:hover { background: rgba(37,87,247,0.12); }


/* =================================================================
   MOBILE FLOATING TOC  (≤ 1100px)
   A pill button fixed just below the navbar that opens a dropdown
   ================================================================= */

.toc-fab      { display: none; }
.toc-backdrop { display: none; }
.toc-dropdown { display: none; }

@media (max-width: 1100px) {

  /* Hide the TOC card inside the sidebar (sidebar is already hidden) */
  #post-toc.toc { display: none; }

  /* ── Floating pill button ─────────────────────────────────────── */
  .toc-fab {
    display: flex;
    align-items: center;
    gap: 7px;
    position: fixed;
    top: calc(var(--navbar) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    background: var(--surface);
    border: 1px solid var(--border-h);
    border-radius: 99px;
    padding: 8px 18px 8px 14px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(30,25,20,0.10);
    transition: box-shadow 0.18s, background 0.15s;
    white-space: nowrap;
  }
  .toc-fab:hover {
    background: var(--surface-2);
    box-shadow: 0 4px 18px rgba(30,25,20,0.13);
  }
  .toc-fab__icon {
    width: 15px;
    height: 15px;
    stroke: var(--accent);
    fill: none;
    flex-shrink: 0;
    transition: transform 0.22s ease;
  }
  .toc-fab--open .toc-fab__icon { transform: rotate(180deg); }

  .toc-fab__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-2);
    line-height: 1;
  }
  .toc-fab__sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--border-h);
    flex-shrink: 0;
  }
  .toc-fab__current {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-3);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── Dropdown panel ───────────────────────────────────────────── */
  .toc-dropdown {
    display: block;             /* visible in DOM, hidden via opacity */
    position: fixed;
    top: calc(var(--navbar) + 54px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    z-index: 899;
    width: min(480px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--border-h);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(30,25,20,0.12);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
  }
  .toc-dropdown--open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }

  .toc-dropdown__list {
    list-style: none;
    margin: 0;
    padding: 8px 0 10px;
    max-height: 60vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .toc-dropdown__list .toc__item::before { display: none; }
  .toc-dropdown__list .toc__item--active .toc__link { background: var(--accent-soft); }
  .toc-dropdown__list .toc__link { padding: 9px 22px; }
  .toc-dropdown__list .toc__num { font-size: 12px; }
  .toc-dropdown__list .toc__text { font-size: 14px; }

  /* Backdrop */
  .toc-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 898;
  }
  .toc-backdrop--visible { display: block; }
}

@media (max-width: 760px) {
  .toc-fab { top: calc(var(--navbar) + 8px); }
  .toc-dropdown { top: calc(var(--navbar) + 50px); }
  .toc-fab__current { max-width: 130px; }
}