/* ══════════════════════════════════════════════════════════════════════
   SIDEBAR ENHANCEMENTS — TOC + Smart Scroll + Ad Cards
   Add this file AFTER style-consolidated.css
   ══════════════════════════════════════════════════════════════════════ */

/* ── Variables (mirrors existing theme) ─────────────────────────────── */
:root {
  --flame:      #e63d0a;
  --flame-soft: rgba(230,61,10,.08);
  --ink:        #111827;
  --muted:      #6b7280;
  --paper:      #ffffff;
  --line:       #e5e7eb;
  --smoke:      #f9fafb;
  --emerald:    #10b981;
  --nav-h:      68px;
  --fm:         'JetBrains Mono', monospace;
  --fb:         'DM Sans', sans-serif;
}
[data-theme="dark"] {
  --paper:  #13131f;
  --line:   #252535;
  --smoke:  #1a1a2e;
  --ink:    #f0ede8;
  --muted:  #8a8d97;
}

/* ════════════════════════════════════════════════════════
   1. TOC — UPGRADED VISHAY SUCHI STYLING
   ════════════════════════════════════════════════════════ */

#tocBox {
  position: relative;
  overflow: visible;
}

/* TOC header: bilingual label auto-changes via JS */
#tocBox .bp-scard-head {
  font-size: .52rem;
  letter-spacing: 3px;
  color: var(--muted);
}

.bp-toc-wrap {
  padding: 8px 6px 12px;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* Step counter on each item */
.bp-toc-list {
  counter-reset: toc-counter;
}

.bp-toc-list > li {
  counter-increment: toc-counter;
}

.bp-toc-list a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--fb);
  font-size: .78rem;
  color: var(--muted);
  padding: 6px 10px 6px 8px;
  border-radius: 7px;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all .18s ease;
  line-height: 1.4;
  position: relative;
}

/* H2 items get numbered counter */
.bp-toc-list > li > a::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: var(--fm);
  font-size: .6rem;
  color: var(--line);
  letter-spacing: 0;
  min-width: 20px;
  flex-shrink: 0;
  transition: color .18s;
}

.bp-toc-list a:hover {
  color: var(--ink);
  background: var(--smoke);
}
.bp-toc-list a:hover::before {
  color: var(--flame);
}

.bp-toc-list a.active {
  color: var(--flame);
  background: var(--flame-soft);
  border-left-color: var(--flame);
  font-weight: 600;
}
.bp-toc-list a.active::before {
  color: var(--flame);
}

/* H3 — indented, no counter */
.bp-toc-list a.toc-h3 {
  padding-left: 28px;
  font-size: .72rem;
  color: var(--muted);
  opacity: .85;
}
.bp-toc-list a.toc-h3::before {
  content: '—';
  font-size: .55rem;
  letter-spacing: 0;
  min-width: 16px;
}

/* Progress spine on TOC card left edge */
#tocBox::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(to bottom, var(--flame), transparent);
  border-radius: 2px;
  opacity: .18;
  pointer-events: none;
}

/* Empty state */
.bp-toc-empty {
  color: var(--muted);
  font-style: italic;
  font-size: .75rem;
  padding: 6px 10px;
  opacity: .7;
}

/* ════════════════════════════════════════════════════════
   2. SIDEBAR SMART SCROLL — STICKY STACK BEHAVIOUR
   When sidebar overflows viewport, it scrolls naturally
   Cards don't get clipped — sidebar is a flex column
   ════════════════════════════════════════════════════════ */

.bp-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 16px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - var(--nav-h) - 32px);
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-width: none;
  padding-right: 2px; /* prevent shadow clip */
  padding-bottom: 20px;
}
.bp-sidebar::-webkit-scrollbar { display: none; }

/* When sidebar has many cards — auto scroll on hover */
.bp-sidebar:hover {
  overflow-y: auto;
}

/* ════════════════════════════════════════════════════════
   3. AD CARDS — GENERIC ADVERTISER PROMOTIONS
   Admin se koi bhi advertiser add kar sakta hai
   ════════════════════════════════════════════════════════ */

/* ── Wrapper for all ad slots ── */
.bp-ads-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Single Ad Card ── */
.bp-ad-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
  transition: box-shadow .2s, transform .2s;
  text-decoration: none;
  display: block;
  color: inherit;
  position: relative;
}
.bp-ad-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* Ad label badge */
.bp-ad-label {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: var(--fm);
  font-size: .45rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--smoke);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  z-index: 2;
}

/* Ad with image banner */
.bp-ad-image {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

/* Ad content area */
.bp-ad-body {
  padding: 14px 16px 16px;
}

/* Advertiser name — tiny eyebrow */
.bp-ad-brand {
  font-family: var(--fm);
  font-size: .5rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bp-ad-brand::before {
  content: '';
  width: 10px;
  height: 2px;
  background: var(--flame);
  border-radius: 2px;
  display: inline-block;
}

/* Ad headline */
.bp-ad-title {
  font-family: var(--fb);
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 6px;
}

/* Ad description */
.bp-ad-desc {
  font-family: var(--fb);
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* CTA Button */
.bp-ad-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--fb);
  font-size: .72rem;
  font-weight: 600;
  color: var(--flame);
  border: 1.5px solid var(--flame);
  border-radius: 6px;
  padding: 6px 14px;
  text-decoration: none;
  transition: all .18s;
  background: transparent;
}
.bp-ad-cta:hover {
  background: var(--flame);
  color: #fff;
}

/* Text-only Ad variant */
.bp-ad-card.text-only .bp-ad-body {
  padding: 16px;
}

/* Accent color override via data attr */
.bp-ad-card[data-accent] .bp-ad-cta {
  color: var(--ad-accent);
  border-color: var(--ad-accent);
}
.bp-ad-card[data-accent] .bp-ad-cta:hover {
  background: var(--ad-accent);
  color: #fff;
}
.bp-ad-card[data-accent] .bp-ad-brand::before {
  background: var(--ad-accent);
}

/* Dark mode ads */
[data-theme="dark"] .bp-ad-card {
  background: #1a1a2e;
  border-color: #252535;
}
[data-theme="dark"] .bp-ad-label {
  background: #13131f;
  border-color: #252535;
}
[data-theme="dark"] .bp-ad-title { color: #f0ede8; }
[data-theme="dark"] .bp-ad-cta { color: var(--flame); border-color: var(--flame); }

/* ── "Promoted" separator ── */
.bp-ads-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 2px;
}
.bp-ads-divider span {
  font-family: var(--fm);
  font-size: .45rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  opacity: .7;
}
.bp-ads-divider::before,
.bp-ads-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ════════════════════════════════════════════════════════
   4. RESPONSIVE — mobile mein sidebar niche aata hai
   ════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .bp-sidebar { display: none; }

  /* Mobile: Show a condensed "promoted" strip below article */
  .bp-mobile-ads {
    display: block;
    padding: 0 var(--public-pad) 40px;
  }
  .bp-mobile-ads .bp-ad-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    border-radius: 12px;
    margin-bottom: 12px;
  }
  .bp-mobile-ads .bp-ad-image {
    width: 90px;
    height: 90px;
    border-radius: 0;
    flex-shrink: 0;
  }
  .bp-mobile-ads .bp-ad-body {
    padding: 12px 14px;
    flex: 1;
  }
  .bp-mobile-ads .bp-ad-title { font-size: .82rem; }
  .bp-mobile-ads .bp-ad-desc { display: none; }
  .bp-mobile-ads .bp-ads-divider { margin: 8px 0 4px; }
}

@media (min-width: 1025px) {
  .bp-mobile-ads { display: none; }
}

/* ════════════════════════════════════════════════════════
   5. DARK MODE — additional TOC fixes
   ════════════════════════════════════════════════════════ */
[data-theme="dark"] .bp-toc-list a::before { color: #2a2a3e; }
[data-theme="dark"] .bp-toc-list a.active::before { color: var(--flame); }
[data-theme="dark"] .bp-toc-list a:hover::before { color: var(--flame); }
[data-theme="dark"] #tocBox::before { opacity: .1; }

/* ════════════════════════════════════════════════════════
   5. AD SLOT WRAPPER — always visible container
   ════════════════════════════════════════════════════════ */

.bp-ad-slot-wrap {
  margin-top: 4px;
}

/* ── Empty state (admin only) ── */
.bp-ad-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  background: var(--smoke);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}

.bp-ad-empty-icon {
  font-size: 1.6rem;
  color: var(--muted);
  opacity: .35;
}

.bp-ad-empty-text {
  font-family: var(--fb);
  font-size: .76rem;
  color: var(--muted);
  margin: 0;
}

.bp-ad-empty-link {
  font-family: var(--fb);
  font-size: .72rem;
  font-weight: 600;
  color: var(--flame);
  text-decoration: none;
  border: 1.5px solid var(--flame);
  border-radius: 6px;
  padding: 5px 14px;
  margin-top: 2px;
  transition: all .18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bp-ad-empty-link:hover {
  background: var(--flame);
  color: #fff;
}

[data-theme="dark"] .bp-ad-empty {
  background: #1a1a2e;
  border-color: #252535;
}
