/**
 * Blackboard Scroller — 可滚动黑板板书样式
 * 左右分栏 + 深色黑板 Canvas + 底部讲解栏
 */

/* ── Root Layout ── */
.bb-root {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  user-select: none;
}

.bb-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Top Bar (同 manim 风格) ── */
.bb-topbar {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  z-index: 10;
  gap: 10px;
  min-height: 40px;
}

.bb-back {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #c9d1d9;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
}
.bb-back:hover { background: rgba(255, 255, 255, 0.15); }

.bb-title {
  flex: 1;
  color: #e6edf3;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bb-step-count {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Body: Two Panels + Divider ── */
.bb-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── LEFT PANEL: Problem ── */
.bb-left {
  width: 30%;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.bb-panel-header {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: #64748b;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  flex-shrink: 0;
}

.bb-panel-header-dark {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bb-problem-scroll {
  flex: 1;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── DIVIDER ── */
.bb-divider {
  width: 4px;
  cursor: col-resize;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  transition: background 0.2s;
}
.bb-divider:hover,
.bb-divider:active {
  background: rgba(251, 191, 36, 0.3);
}

/* ── RIGHT PANEL: Canvas Board ── */
.bb-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  min-width: 0;
  overflow: hidden;
}

.bb-board-wrap {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background: #1b3a1b;
  min-height: 0;
}

/* Chalkboard grain overlay (同 manim.css) */
.bb-board-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  opacity: 0.15;
  pointer-events: none;
  z-index: 1;
}

.bb-canvas {
  display: block;
}

/* Board border accent */
.bb-board-wrap::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(139, 119, 70, 0.2);
  border-radius: 4px;
  pointer-events: none;
  z-index: 3;
}

/* Scrollbar styling for the board */
.bb-board-wrap::-webkit-scrollbar {
  width: 6px;
}
.bb-board-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.bb-board-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.bb-board-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Narration Bar ── */
.bb-narration {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 16px;
  min-height: 48px;
  max-height: 90px;
  background: rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.bb-narration-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 2px;
}

.bb-narration-content {
  flex: 1;
  min-width: 0;
}

.bb-narration-name {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 1px;
  line-height: 1.3;
}
.bb-narration-name.narrator { color: #94a3b8; }
.bb-narration-name.xiaowen { color: #fbbf24; }
.bb-narration-name.xiaozhi { color: #60a5fa; }

.bb-narration-text {
  color: #d1d5db;
  font-size: 0.82rem;
  line-height: 1.55;
}
.bb-narration-text p { margin: 0 0 4px; }

.bb-narration-step {
  flex-shrink: 0;
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: right;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Progress Bar ── */
.bb-progress-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.bb-progress-dots {
  display: flex;
  gap: 3px;
  flex: 1;
  justify-content: center;
}

.bb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.3s ease;
}
.bb-dot.active { background: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, 0.5); }
.bb-dot.done { background: rgba(255, 255, 255, 0.35); }
.bb-dot:hover { transform: scale(1.3); }

.bb-progress-label {
  color: #8b949e;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  min-width: 54px;
  text-align: right;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .bb-left { display: none; }
  .bb-divider { display: none; }
  .bb-right { width: 100% !important; }
  .bb-narration-text { font-size: 0.78rem; }
}
