/* Typesetting for nbconvert's `basic` template output.
   The basic template ships no CSS of its own, which is the point: everything
   below is ours, so an exported notebook reads as a page of this site rather
   than as a Jupyter screenshot. Class names come from nbconvert and must match
   it exactly — see site/tools/build_notebook.py. */

.nb-layout {
  --nb-measure: 50rem;
  max-width: calc(var(--nb-measure) + 18rem);
  margin-inline: auto;
  padding-inline: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

/* The contents column only appears once there is room for it beside both the
   sidebar and a full-width article. */
@media (min-width: 960px) { .nb-layout { padding-inline: 3rem; } }

@media (min-width: 1320px) {
  .nb-layout { grid-template-columns: minmax(0, 1fr) 14rem; }
  .nb-toc { order: 2; }
}

.nb-main { min-width: 0; max-width: var(--nb-measure); }

/* ---------- article header ---------- */

.nb-head { padding-block: 3.5rem 2rem; border-bottom: 1px solid var(--border); }

.nb-source {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--faint);
}
.nb-source a { color: var(--muted); }
.nb-source a:hover { color: var(--accent); }

.nb-head h1 {
  margin: 0;
  font-size: clamp(1.875rem, 5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.nb-head .lede {
  margin: 1rem 0 0;
  font-size: 1.0625rem;
  color: var(--muted);
}

.nb-meta {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--faint);
}
.nb-meta li { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ---------- table of contents ---------- */

.nb-toc { font-size: 0.8125rem; }

@media (min-width: 1320px) {
  .nb-toc {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding-block: 3.5rem 1rem;
  }
}

.nb-toc h2 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 0.75rem;
}

.nb-toc ol { list-style: none; margin: 0; padding: 0; }
.nb-toc li { margin: 0; }
.nb-toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
}
.nb-toc a:hover { color: var(--accent); border-left-color: var(--slate-400); }
.nb-toc .lvl-3 a { padding-left: 1.5rem; color: var(--faint); font-size: 0.78125rem; }

/* On narrow screens the TOC collapses into a disclosure above the article. */
.nb-toc-mobile {
  margin-block: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.5rem 1rem;
}
.nb-toc-mobile summary {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  padding-block: 0.35rem;
}
@media (min-width: 1320px) { .nb-toc-mobile { display: none; } }
@media (max-width: 1319px) { .nb-toc > h2, .nb-toc > ol { display: none; } }

/* ---------- cells ---------- */

.nb-body { padding-block: 2.5rem 4rem; }

/* The basic template lays every cell out as a flex row with a prompt gutter.
   We drop the gutter: "In [12]:" is editor furniture, not part of the story. */
.nb-body .cell { display: block; margin-block: 0; }
.nb-body .prompt { display: none; }
.nb-body .inner_cell { min-width: 0; }
.nb-body .input,
.nb-body .output_wrapper,
.nb-body .output,
.nb-body .output_area { display: block; min-width: 0; }

/* ---------- prose ---------- */

.rendered_html { overflow-wrap: break-word; }

.rendered_html h1,
.rendered_html h2,
.rendered_html h3,
.rendered_html h4 {
  letter-spacing: -0.02em;
  line-height: 1.25;
  scroll-margin-top: 4.5rem; /* clears the sticky mobile bar on anchor jumps */
}
@media (min-width: 960px) {
  .rendered_html h1, .rendered_html h2, .rendered_html h3, .rendered_html h4 {
    scroll-margin-top: 1.5rem;
  }
}

/* The notebook's own H1 is rendered in .nb-head instead; see build_notebook.py. */
.rendered_html h2 {
  font-size: 1.5rem;
  margin: 3.5rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.rendered_html h3 { font-size: 1.1875rem; margin: 2.25rem 0 0.75rem; }
.rendered_html h4 { font-size: 1rem; margin: 1.75rem 0 0.5rem; }

.rendered_html p { margin: 0 0 1.1rem; }
.rendered_html ul, .rendered_html ol { margin: 0 0 1.1rem; padding-left: 1.35rem; }
.rendered_html li { margin-bottom: 0.35rem; }
.rendered_html strong { font-weight: 650; color: var(--slate-900); }

.rendered_html blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--slate-300);
  color: var(--muted);
}

.rendered_html code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--slate-100);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.rendered_html a { overflow-wrap: break-word; }

/* The ¶ anchor sits out of the way until the heading is hovered. */
.anchor-link {
  margin-left: 0.4rem;
  color: var(--slate-300);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
h1:hover > .anchor-link,
h2:hover > .anchor-link,
h3:hover > .anchor-link,
h4:hover > .anchor-link,
.anchor-link:focus-visible { opacity: 1; }

/* ---------- markdown tables ---------- */

.rendered_html table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.rendered_html thead th {
  text-align: left;
  font-weight: 600;
  color: var(--slate-700);
  border-bottom: 2px solid var(--slate-300);
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}
.rendered_html tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}
.rendered_html tbody tr:hover { background: var(--slate-50); }
/* Right-aligned only where the column actually holds numbers. The .num class
   is added per column by build_notebook.py, which inspects the cells — prose
   tables and numeric tables are both common here, so position is no guide. */
.rendered_html th.num,
.rendered_html td.num { text-align: right; }

/* Wide tables scroll rather than forcing the page sideways.
   build_notebook.py wraps each <table> in this. */
.table-scroll { overflow-x: auto; margin: 1.5rem 0; }
.table-scroll table { margin: 0; }

/* ---------- code input ---------- */

.nb-body .input_area {
  margin: 1.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--slate-300);
  border-radius: 8px;
  overflow: hidden;
}

.nb-body .input_area pre,
.nb-body .highlight pre {
  margin: 0;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  tab-size: 4;
  color: var(--slate-800);
  background: transparent;
}
.nb-body .highlight { background: transparent; margin: 0; }

/* ---------- outputs ---------- */

.nb-body .output_area { margin: 1.25rem 0; }

.nb-body .output_stream,
.nb-body .output_text {
  font-family: var(--mono);
  font-size: 0.78125rem;
  line-height: 1.55;
}

.nb-body .output_text pre,
.nb-body .output_stdout pre {
  margin: 0;
  padding: 0.9rem 1.1rem;
  /* `pre` not `pre-wrap`: printed DataFrames are column-aligned, and wrapping
     them destroys the alignment. Overflow scrolls instead. */
  white-space: pre;
  overflow-x: auto;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--slate-700);
}

.nb-body .output_stderr pre {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.nb-body .output_png,
.nb-body .output_jpeg {
  margin: 1.75rem 0;
  text-align: center;
}
.nb-body .output_png img,
.nb-body .output_jpeg img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

/* ---------- pygments (light) ---------- */

.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: #6a737d; font-style: italic; }
.highlight .k, .highlight .kn, .highlight .kc, .highlight .kd, .highlight .kr { color: #cf222e; }
.highlight .kt { color: #953800; }
.highlight .o, .highlight .ow { color: #0550ae; }
.highlight .n, .highlight .p, .highlight .w { color: inherit; }
.highlight .nb { color: #0550ae; }
.highlight .nf, .highlight .fm { color: #6639ba; }
.highlight .nn, .highlight .nc { color: #953800; }
.highlight .nd { color: #6639ba; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sa,
.highlight .sd, .highlight .se, .highlight .si, .highlight .sb { color: #0a3069; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh { color: #0550ae; }
.highlight .err { color: #82071e; background: #ffebe9; }

@media print {
  .sidebar, .nb-toc, .nb-toc-mobile, .anchor-link { display: none !important; }
  .page, .nb-layout { display: block; max-width: none; }
  .nb-body .input_area, .nb-body .output_text pre { break-inside: avoid; }
}
