/* ==================================================================
   karpathy.css — Jupyter-notebook aesthetic, scoped to .notebook-section
   Inspired by classic IPython / Jupyter; not Colab, not VSCode.
   ================================================================== */

.notebook-section {
  --nb-paper:    #fbf8f1;
  --nb-cell-bg:  #ffffff;
  --nb-cell-bd:  #d8d4c8;
  --nb-out-bg:   #f3efe6;
  --nb-out-bd:   #e2dccd;
  --nb-in-label: #8a8a8a;
  --nb-out-label:#3d6c98;   /* iPython-style blue prompt */
  --nb-accent:   #ff6b35;
  --nb-takeaway: #d4521e;
  --nb-mono:     "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;

  background: var(--nb-paper);
  border-top: 1px solid var(--nb-cell-bd);
  border-bottom: 1px solid var(--nb-cell-bd);
  padding: 3rem 0 3.5rem;
  margin: 3rem auto 0;
  /* break out of the narrow column */
  max-width: none !important;
}

.notebook-section > * {
  max-width: var(--col);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.notebook-section > .notebook-cell {
  max-width: 980px;
}

.notebook-section h2 {
  border-bottom: 1px solid var(--nb-cell-bd);
}

.notebook-section .lede-nb {
  color: #444;
  font-style: italic;
}

/* ---------- Cells --------------------------------------------------- */

.notebook-cell {
  margin: 2.2rem auto;
  display: grid;
  grid-template-columns: 70px 1fr;
  column-gap: 12px;
  align-items: start;
}

.notebook-cell .prose {
  grid-column: 2 / 3;
  margin-bottom: 0.6rem;
  color: #2a2a2a;
}

.notebook-cell .nb-label {
  font-family: var(--nb-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  padding-top: 0.6rem;
  user-select: none;
  white-space: nowrap;
}
.notebook-cell .nb-label.in  { color: var(--nb-in-label); }
.notebook-cell .nb-label.out { color: var(--nb-out-label); }

.notebook-cell .nb-code {
  background: var(--nb-cell-bg);
  border: 1px solid var(--nb-cell-bd);
  border-radius: 6px;
  font-family: var(--nb-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  margin: 0;
  padding: 10px 14px;
  overflow-x: auto;
  white-space: pre;
  color: #1f1f1f;
}

.notebook-cell .nb-code code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  color: inherit;
}

/* Prism light theme override inside the notebook scope */
.notebook-section .token.comment,
.notebook-section .token.prolog,
.notebook-section .token.doctype,
.notebook-section .token.cdata { color: #8a8a8a; font-style: italic; }
.notebook-section .token.keyword { color: #b15a00; font-weight: 600; }
.notebook-section .token.builtin { color: #2c5aa0; }
.notebook-section .token.string  { color: #2e7d32; }
.notebook-section .token.number  { color: #b3261e; }
.notebook-section .token.operator,
.notebook-section .token.punctuation { color: #444; }
.notebook-section .token.function { color: #1f5fa8; }

/* ---------- Cell controls ------------------------------------------- */

.notebook-cell .nb-controls {
  grid-column: 2 / 3;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}

.notebook-cell .nb-run {
  background: var(--nb-accent);
  color: #fff;
  border: none;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.notebook-cell .nb-run:hover { background: var(--accent-dk, #d4521e); }
.notebook-cell .nb-run:active { transform: translateY(1px); }
.notebook-cell .nb-run.ran { background: #6c6c6c; }

.notebook-cell .nb-static-pill {
  display: inline-block;
  font-family: var(--nb-mono);
  font-size: 0.7rem;
  color: #6c6c6c;
  background: #ede8da;
  border: 1px solid var(--nb-out-bd);
  padding: 3px 9px;
  border-radius: 999px;
}

.notebook-cell .nb-hint {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: #888;
}

/* ---------- Output area --------------------------------------------- */

.notebook-cell .nb-out-wrap {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: 70px 1fr;
  column-gap: 12px;
  margin-top: 6px;
}

.notebook-cell .nb-out {
  grid-column: 2 / 3;
  background: var(--nb-out-bg);
  border-left: 3px solid var(--nb-out-bd);
  border-radius: 4px;
  font-family: var(--nb-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 10px 14px;
  white-space: pre-wrap;
  color: #1a1a1a;
  min-height: 1.2em;
}

.notebook-cell .nb-out.empty {
  color: #aaa;
  font-style: italic;
}

.notebook-cell .nb-out .nb-out-line {
  display: block;
}
.notebook-cell .nb-out .nb-out-line.dim  { color: #777; }
.notebook-cell .nb-out .nb-out-line.warn { color: #b3261e; }
.notebook-cell .nb-out .nb-out-line.ok   { color: #1f7a3a; }

.notebook-cell .nb-out svg { display: block; margin-top: 8px; }

/* ---------- Takeaway ------------------------------------------------ */

.notebook-cell .nb-takeaway {
  grid-column: 2 / 3;
  margin: 10px 0 0;
  padding: 6px 14px;
  border-left: 3px solid var(--nb-takeaway);
  font-family: var(--serif);
  font-style: italic;
  color: #3a3a3a;
  background: rgba(255,107,53,0.04);
}

/* ---------- Subsection break --------------------------------------- */

.notebook-section .nb-meta {
  margin-top: 0.4rem;
  color: #666;
  font-size: 0.85rem;
}

.notebook-section h2 .nb-sub {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: #666;
  margin-top: 0.3rem;
  font-style: italic;
  font-family: var(--serif);
}

/* responsive */
@media (max-width: 720px) {
  .notebook-cell {
    grid-template-columns: 48px 1fr;
    column-gap: 8px;
  }
  .notebook-cell .nb-out-wrap {
    grid-template-columns: 48px 1fr;
    column-gap: 8px;
  }
  .notebook-cell .nb-label { font-size: 0.7rem; }
}
