/* ============================================================
   notebook.css — DataVix Notebook (/notebook)
   Loaded alongside problems.css (shares its :root tokens, .navbar,
   .btn-gradient/.btn-outline, .pb-tbtn/.pb-status-bar/.pb-verdict/
   .pb-result-table patterns) so the notebook looks native to the site
   rather than introducing a second design system. Only notebook-specific
   layout (toolbar, sidebar, cell stack, cell chrome, outputs) lives here.
   ============================================================ */

/* ── Dark theme ───────────────────────────────────────────────────────
   Overrides the same :root tokens problems.css defines, scoped to this
   page only (notebook.css isn't loaded elsewhere) — so every reused
   .pb-tbtn/.btn-gradient/.btn-outline/.pb-status-bar/etc. class picks up
   the dark palette automatically, no per-component dark rules needed. */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --white: #141d30;
  --ink: #e5e9f0;
  --slate-900: #f1f5f9;
  --slate-800: #e2e8f0;
  --slate-700: #cbd5e1;
  --slate-600: #94a3b8;
  --slate-500: #94a3b8;
  --slate-400: #64748b;
  --slate-300: #47536a;
  --slate-200: #263349;
  --slate-100: #1b2740;
  --slate-50: #17213a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-card: 0 8px 24px rgba(0,0,0,.35);
  --shadow-hover: 0 16px 38px rgba(0,0,0,.45);
}
:root[data-theme="dark"] .nb-out-figure img { background: #fff; padding: 4px; } /* matplotlib PNGs have an opaque white background */

/* ── App shell ─────────────────────────────────────────────────────── */
/* Not position:fixed — the notebook workspace occupies one viewport-height
   screen (its own internal scroll via .nb-main), then normal page scroll
   continues past it into the SEO content section below. */
.nb-app { height: 100vh; display: flex; flex-direction: column; background: var(--bg); transition: background-color .15s ease; }

.nb-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--white); border-bottom: 1px solid var(--slate-200); box-shadow: var(--shadow-sm); flex-shrink: 0; flex-wrap: wrap; z-index: 20; transition: background-color .15s ease, border-color .15s ease; }
.nb-logo { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 18px; background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text; color: transparent; text-decoration: none; flex-shrink: 0; }
.nb-title-input { border: 1px solid transparent; background: transparent; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 15px; color: var(--slate-900); padding: 6px 10px; border-radius: var(--radius-sm); min-width: 120px; max-width: 260px; }
.nb-title-input:hover, .nb-title-input:focus { border-color: var(--slate-300); background: var(--slate-50); outline: none; }
.nb-toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nb-toolbar-sep { width: 1px; height: 22px; background: var(--slate-200); margin: 0 2px; }
.nb-toolbar-spacer { flex: 1; }
.nb-saved-indicator { font-size: 12px; color: var(--slate-400); font-weight: 600; padding: 0 4px; white-space: nowrap; }
.nb-saved-indicator.saving { color: var(--amber); }
.nb-saved-indicator.saved { color: var(--emerald); }
.nb-theme-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--slate-200); background: var(--white); color: var(--slate-700); cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nb-theme-btn:hover { border-color: var(--violet); transform: translateY(-1px); }

.nb-menu-wrap { position: relative; }
.nb-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius-sm); box-shadow: var(--shadow-hover); min-width: 160px; padding: 6px; z-index: 30; }
.nb-menu.open { display: block; }
.nb-menu button { display: flex; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; border: none; background: none; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--slate-700); cursor: pointer; }
.nb-menu button:hover { background: var(--slate-50); }

/* ── Body: sidebar + main ─────────────────────────────────────────── */
.nb-body-row { flex: 1; display: flex; min-height: 0; }

.nb-sidebar { width: 240px; flex-shrink: 0; background: var(--white); border-right: 1px solid var(--slate-200); overflow-y: auto; padding: 16px 12px; transition: background-color .15s ease, border-color .15s ease; }
.nb-sidebar-section { margin-bottom: 22px; }
.nb-sidebar-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); padding: 0 8px 8px; }
.nb-sidebar-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm); border: none; background: none; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--slate-600); cursor: pointer; text-decoration: none; }
.nb-sidebar-item:hover { background: var(--slate-50); color: var(--slate-900); }
.nb-sidebar-empty { padding: 8px 10px; font-size: 12.5px; color: var(--slate-400); }
@media (max-width: 900px) { .nb-sidebar { display: none; } }

.nb-main { flex: 1; overflow-y: auto; min-width: 0; }
.nb-cellstack { max-width: 900px; margin: 0 auto; padding: 22px 24px 120px; }

/* ── Loading skeleton (shown until Pyodide + wheels are ready) ──────── */
.nb-kernel-banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; color: var(--slate-600); font-weight: 600; }
.nb-kernel-banner.error { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.2); color: var(--red); }
.nb-spinner { width: 14px; height: 14px; border: 2px solid var(--slate-300); border-top-color: var(--violet); border-radius: 50%; animation: nb-spin .8s linear infinite; flex-shrink: 0; }
@keyframes nb-spin { to { transform: rotate(360deg); } }

/* ── Cells ────────────────────────────────────────────────────────── */
.nb-cell { display: flex; gap: 8px; margin-bottom: 4px; border-radius: var(--radius-md); }
.nb-cell-gutter { width: 64px; flex-shrink: 0; padding-top: 10px; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--slate-400); user-select: none; }
.nb-cell-gutter .nb-run-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--slate-300); background: var(--white); color: var(--slate-700); cursor: pointer; font-size: 11px; }
.nb-cell-gutter .nb-run-btn:hover { border-color: var(--violet); color: var(--violet); }
.nb-cell-gutter .nb-exec-label { display: block; margin-top: 6px; }
.nb-cell.running .nb-cell-gutter .nb-exec-label { color: var(--amber); }
.nb-cell.ok .nb-cell-gutter .nb-exec-label { color: var(--emerald); }
.nb-cell.error .nb-cell-gutter .nb-exec-label { color: var(--red); }

.nb-cell-body { flex: 1; min-width: 0; border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: var(--white); box-shadow: var(--shadow-sm); overflow: hidden; transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease; }
.nb-cell.focused .nb-cell-body { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(109,40,217,.1); }

.nb-cell-toolbar { display: none; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--slate-100); background: var(--slate-50); }
.nb-cell:hover .nb-cell-toolbar, .nb-cell.focused .nb-cell-toolbar { display: flex; }
.nb-cell-toolbar .nb-icon-btn { width: 26px; height: 26px; border-radius: 6px; border: none; background: none; color: var(--slate-500); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.nb-cell-toolbar .nb-icon-btn:hover { background: var(--slate-200); color: var(--slate-900); }
.nb-cell-toolbar .nb-cell-type { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--slate-400); text-transform: uppercase; letter-spacing: .05em; }

.nb-editor-host { position: relative; }
.nb-cell-textarea { width: 100%; display: block; border: none; outline: none; resize: none; overflow-y: hidden; padding: 12px 16px; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; color: var(--slate-900); background: transparent; min-height: 44px; }
.nb-cell.type-markdown .nb-cell-textarea { font-family: 'Inter', sans-serif; }

.nb-md-preview { padding: 12px 16px; color: var(--slate-800); line-height: 1.7; }
.nb-md-preview h1, .nb-md-preview h2, .nb-md-preview h3 { font-family: 'Bricolage Grotesque', sans-serif; margin: 0 0 8px; }
.nb-md-preview p { margin: 0 0 10px; }
.nb-md-preview code { font-family: var(--mono); background: var(--slate-100); padding: 1px 5px; border-radius: 4px; }

.nb-cell-output { border-top: 1px solid var(--slate-100); }
.nb-out-text, .nb-out-result { margin: 0; padding: 10px 16px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: var(--slate-700); }
.nb-out-error { margin: 0; padding: 10px 16px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; color: var(--red); background: rgba(220,38,38,.06); }
.nb-out-figure { padding: 10px 16px; }
.nb-out-figure img { border-radius: 8px; border: 1px solid var(--slate-100); max-width: 100%; }
.nb-out-table { padding: 6px 16px 12px; overflow-x: auto; }
.nb-out-table table.nb-df { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
.nb-out-table table.nb-df th { position: sticky; top: 0; background: var(--slate-100); text-align: left; padding: 6px 10px; font-weight: 700; color: var(--slate-700); border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
.nb-out-table table.nb-df td { padding: 5px 10px; border-bottom: 1px solid var(--slate-100); color: var(--slate-700); white-space: nowrap; }
.nb-out-meta { padding: 4px 16px 8px; font-size: 11px; color: var(--slate-400); font-weight: 600; }

/* Add-cell affordance between cells */
.nb-addcell-row { display: flex; justify-content: center; gap: 8px; padding: 4px 0 14px 72px; opacity: 0; transition: opacity .12s ease; }
.nb-cell:hover + .nb-addcell-row, .nb-addcell-row:hover { opacity: 1; }
.nb-addcell-row button { padding: 5px 12px; border-radius: 999px; border: 1px dashed var(--slate-300); background: var(--white); color: var(--slate-500); font-size: 12px; font-weight: 700; cursor: pointer; }
.nb-addcell-row button:hover { border-color: var(--violet); color: var(--violet); border-style: solid; }

/* ── Upload modal ─────────────────────────────────────────────────── */
.nb-modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.nb-modal-overlay.open { display: flex; }
.nb-modal { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-hover); max-width: 640px; width: 100%; max-height: 80vh; overflow-y: auto; padding: 22px 24px; color: var(--ink); }
.nb-modal h3 { margin-bottom: 12px; }
.nb-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.nb-upload-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 14px 0; }
.nb-upload-meta div { background: var(--slate-50); border-radius: var(--radius-sm); padding: 10px 12px; }
.nb-upload-meta .n { font-size: 18px; font-weight: 800; color: var(--slate-900); font-family: 'Bricolage Grotesque', sans-serif; }
.nb-upload-meta .l { font-size: 11px; color: var(--slate-500); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.nb-upload-warn { margin-top: 10px; font-size: 12.5px; color: #b45309; background: rgba(245,158,11,.1); border-radius: var(--radius-sm); padding: 8px 12px; }

/* ── SEO content section (below the app, scroll target from a footer link) ── */
.nb-seo { max-width: 900px; margin: 0 auto; padding: 56px 24px 90px; }
.nb-seo h1 { font-size: 30px; margin-bottom: 12px; }
.nb-seo h2 { font-size: 20px; margin: 30px 0 10px; }
.nb-seo p, .nb-seo li { color: var(--slate-600); font-size: 15px; line-height: 1.75; }
.nb-seo ul { padding-left: 20px; }
.nb-seo details { border: 1px solid var(--slate-200); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 10px; background: var(--white); }
.nb-seo summary { font-weight: 700; cursor: pointer; color: var(--slate-900); }

@media (max-width: 640px) {
  .nb-toolbar { padding: 8px 10px; }
  .nb-cell-gutter { width: 44px; }
}
