/* Bulganest TOC — Frontend Styles */
/* Uses WordPress theme colors automatically */

:root {
  --btoc-bg: var(--wp--preset--color--base, #fff);
  --btoc-border: var(--wp--preset--color--contrast, #e2e8f0);
  --btoc-accent: var(--wp--preset--color--primary, #2563eb);
  --btoc-text: var(--wp--preset--color--contrast, #1e293b);
  --btoc-muted: #64748b;
  --btoc-hover-bg: rgba(37,99,235,0.06);
  --btoc-active: var(--wp--preset--color--primary, #2563eb);
  --btoc-radius: 8px;
  --btoc-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

/* ── WRAP ── */
.btoc-wrap {
  margin: 1.8rem 0;
  clear: both;
}
.btoc-wrap.btoc-align-center { display: flex; justify-content: center; }
.btoc-wrap.btoc-align-right  { display: flex; justify-content: flex-end; }
.btoc-wrap.btoc-align-full .btoc-box { width: 100%; max-width: 100%; }

/* ── BOX ── */
.btoc-box {
  background: var(--btoc-bg);
  border: 1px solid var(--btoc-border);
  border-radius: var(--btoc-radius);
  box-shadow: var(--btoc-shadow);
  overflow: hidden;
  max-width: 480px;
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  position: relative;
}

/* ── HEADER ── */
.btoc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--btoc-border);
  background: var(--btoc-hover-bg);
}
.btoc-title {
  font-weight: 600;
  color: var(--btoc-text);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

/* ── TOGGLE BUTTON ── */
.btoc-toggle {
  background: none;
  border: 1px solid var(--btoc-border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
  color: var(--btoc-muted);
}
.btoc-toggle:hover { background: var(--btoc-border); }
.btoc-toggle-icon {
  display: block;
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-top: -3px;
}
.btoc-toggle.btoc-collapsed .btoc-toggle-icon {
  transform: rotate(-135deg);
  margin-top: 3px;
}

/* ── LIST WRAP ── */
.btoc-list-wrap {
  padding: 0.8rem 1.1rem;
  transition: max-height 0.3s ease, opacity 0.2s;
  max-height: 1000px;
  overflow: hidden;
}
.btoc-list-wrap.btoc-hidden {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── LIST ── */
.btoc-list,
.btoc-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}
.btoc-sub { padding-left: 1.1rem; margin-top: 2px; }
.btoc-item { margin: 0; padding: 0; }

/* ── LINKS ── */
.btoc-link {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--btoc-text);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.5;
  transition: background 0.15s, color 0.15s, padding-left 0.15s;
  word-break: break-word;
}
.btoc-link:hover {
  background: var(--btoc-hover-bg);
  color: var(--btoc-active);
  text-decoration: none;
  padding-left: 12px;
}
.btoc-link.btoc-active {
  color: var(--btoc-active);
  font-weight: 600;
  background: var(--btoc-hover-bg);
  border-left: 3px solid var(--btoc-active);
  padding-left: 10px;
}

/* Depth styles */
.btoc-depth-0 .btoc-link { font-weight: 500; }
.btoc-depth-1 .btoc-link { font-size: 0.84rem; color: var(--btoc-muted); }
.btoc-depth-2 .btoc-link { font-size: 0.8rem; color: var(--btoc-muted); }

/* Number */
.btoc-num { 
  color: var(--btoc-active); 
  font-weight: 600; 
  font-size: 0.82em;
  min-width: 1.4em;
  display: inline-block;
}

/* ── PROGRESS BAR ── */
.btoc-progress-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(0,0,0,0.08);
  z-index: 9999;
  pointer-events: none;
}
.btoc-progress-fill {
  height: 100%;
  background: var(--btoc-active);
  width: 0%;
  transition: width 0.1s linear;
}

/* ── BACK TO TOP ── */
.btoc-back-top {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--btoc-active);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 100px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 999;
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0;
  transform: translateY(8px);
}
.btoc-back-top.btoc-visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
.btoc-back-top:hover {
  opacity: 0.88;
  color: #fff;
  text-decoration: none;
}

/* ── STICKY ── */
.btoc-wrap.btoc-sticky {
  position: sticky;
  top: 80px;
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  .btoc-box { max-width: 100%; }
  .btoc-back-top { bottom: 1rem; right: 1rem; }
  .btoc-wrap.btoc-align-center,
  .btoc-wrap.btoc-align-right { display: block; }
  .btoc-hide-mobile { display: none !important; }
}

/* ── DARK MODE SUPPORT ── */
@media (prefers-color-scheme: dark) {
  :root {
    --btoc-bg: #1e293b;
    --btoc-border: #334155;
    --btoc-text: #e2e8f0;
    --btoc-muted: #94a3b8;
    --btoc-hover-bg: rgba(96,165,250,0.1);
    --btoc-shadow: 0 1px 6px rgba(0,0,0,0.3);
  }
}
