@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,400;0,600;1,400;1,600&family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&display=swap');

/* =========================================================
   Color palette
   ========================================================= */

:root {
  --bg:           #1e2330;
  --bg-alt:       #252b3b;
  --bg-code:      #191e2b;
  --border:       #364055;
  --text:         #e8e8e8;
  --text-muted:   #8a9bb0;
  --link:         #fbd46d;
  --link-hover:   #ffe08a;
  --accent:       #5aafde;
  --heading:      #eaeaea;
  --code-inline:  #b8d4f0;
  --code-sym:     #e8d44d;
  --callout-do:   #2a3d28;
  --callout-ex:   #1e2d40;
  --callout-do-b: #4a7a45;
  --callout-ex-b: #3a6090;
}

/* =========================================================
   Body & Base Font
   ========================================================= */

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

body, .main,
.refelem, .refcolumn, .refcontent, .content,
.version {
  font-family: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
}

/* =========================================================
   Headings
   ========================================================= */

h1, h2, h3, h4, h5, h6, h7, h8 {
  color: var(--heading);
  font-weight: 600;
  line-height: 1.3;
}

/* Scribble uses h3/h4/h5 for sections depending on nesting depth.
   The defaults (1.0em, 0.83em) are unreadably small — bump them up. */
h1 { font-size: 1.75em; }
h2 { font-size: 1.45em; }
h3 { font-size: 1.25em; }
h4 { font-size: 1.10em; }
h5 { font-size: 1.00em; font-style: italic; }

/* =========================================================
   Navigation bars (hidden — sidebar handles navigation)
   ========================================================= */

.navsettop, .navsetbottom, .navleft, .navright {
  display: none;
}

/* =========================================================
   Sidebar / Table of Contents
   ========================================================= */

.tocset {
  display: none;
}

/* Override Scribble's fixed 43em width with a responsive centered column.
   max-width caps comfortable line length on wide screens; 92% gives breathing
   room on narrow ones without needing explicit breakpoints for the column. */
.maincolumn {
  width: 92%;
  max-width: 60em;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* Prevent wide tables and code from breaking the layout on mobile */
.main table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* On narrow screens, margin notes don't have anywhere to float —
   pull them back into the flow as inline callouts instead */
@media (max-width: 640px) {
  .refpara, .refelem, .reffootnote {
    float: none;
    position: static;
    width: auto;
    height: auto;
    margin: 0.75em 0;
    left: 0;
  }
  .refcolumn {
    width: auto;
  }

  /* Slightly tighter headings on small screens */
  h3 { font-size: 1.15em; }
  h4 { font-size: 1.05em; }
}

/* Remove the original light background from sidebar boxes */
.tocview, .tocsub,
.tocview td, .tocset td {
  background-color: var(--bg);
}

.tocviewtitle * {
  color: var(--text);
  font-weight: 600;
}

/* Sidebar links */
.tocviewlink         { color: var(--link); text-decoration: none; }
.tocviewlink:hover   { color: var(--link-hover); text-decoration: underline; }
.tocviewselflink     { color: var(--accent); text-decoration: underline; }
.tocviewtoggle       { color: var(--text-muted); }

.tocsublink, .tocsubseclink, .tocsubnonseclink {
  color: var(--link);
  text-decoration: none;
}
.tocsublink:hover, .tocsubseclink:hover {
  color: var(--link-hover);
}
.tocsubtitle { color: var(--text-muted); }

/* Inline TOC (inside the page body) */
.toclink     { color: var(--link); text-decoration: none; }
.toclink:hover { color: var(--link-hover); }
.toptoclink  { color: var(--link); font-weight: bold; }

/* =========================================================
   Links
   ========================================================= */

.plainlink            { color: var(--link); text-decoration: none; }
a:link, a:visited     { color: var(--link); text-decoration: none; }
a:hover, a:active     { color: var(--link-hover); text-decoration: underline; }

/* =========================================================
   Inline code (tt / stt / .RktSym etc.)
   ========================================================= */

.stt {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  color: var(--code-inline);
  background-color: var(--bg-code);
  padding: 0.05em 0.3em;
  border-radius: 3px;
  font-size: 88%;
}

.RktIn, .RktRdr, .RktPn, .RktMeta, .RktMod, .RktKw,
.RktVar, .RktSym, .RktRes, .RktOut, .RktCmt, .RktVal, .RktBlk {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  color: var(--code-sym);
}

/* =========================================================
   Code blocks (codeblock)
   ========================================================= */

.SCodeFlow {
  background-color: var(--bg-code);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  padding: 0.7em 1.1em;
  margin: 0.8em 0;
  overflow-x: auto;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
}

/* verbatim / pydisp blocks */
.SubFlow {
  background-color: var(--bg-code);
  border-left: 3px solid var(--border);
  border-radius: 0 4px 4px 0;
  padding: 0.5em 1em;
  margin: 0.6em 0;
}

.SVerbatim {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  background-color: var(--bg-code);
}

/* =========================================================
   Boxed elements
   ========================================================= */

.boxed {
  background-color: var(--bg-alt);
  border-radius: 4px;
}

/* =========================================================
   Margin notes
   ========================================================= */

.refelem, .refcolumn, .refcontent {
  font-family: 'IBM Plex Serif', Georgia, serif;
}

.refcolumn {
  background-color: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 85%;
  padding: 0.3em 0.5em;
}

.refcontent p {
  margin-top: 0.3em;
  margin-bottom: 0.3em;
}

/* =========================================================
   Inline section headings (sections that stay on the parent page)
   ========================================================= */

p.InlineSection {
  font-size: 1.15em;
  font-weight: 600;
  color: var(--heading);
  margin-top: 1.6em;
  margin-bottom: 0.3em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--text-muted);
}

/* =========================================================
   "Do Now!" (Incercise) and Exercise callout boxes
   ========================================================= */

.Incercise {
  background-color: var(--callout-do);
  border-left: 4px solid var(--callout-do-b);
  border-radius: 0 4px 4px 0;
  padding: 0.6em 1em;
  margin: 0.8em 0;
}

.Exercise {
  background-color: var(--callout-ex);
  border-left: 4px solid var(--callout-ex-b);
  border-radius: 0 4px 4px 0;
  padding: 0.6em 1em;
  margin: 0.8em 0;
}

/* =========================================================
   Question/Answer (used in placement AFQ)
   ========================================================= */

p.Question {
  font-weight: 600;
  color: var(--heading);
  background-color: var(--bg-alt);
  border-left: 3px solid var(--link);
  border-radius: 0 4px 4px 0;
  padding: 0.45em 0.9em;
  margin-top: 2em;
  margin-bottom: 0.3em;
}

p.Question::before {
  content: "Q\00a0\00a0";   /* "Q" + two non-breaking spaces */
  color: var(--link);
  font-weight: 700;
}

/* =========================================================
   Sub-sub-sub section labels (Read/view, Write, etc.)
   ========================================================= */

.SSubSubSubSection {
  font-weight: bold;
  color: var(--accent);
  font-size: 0.88em;
  display: block;
  margin-top: 1em;
  letter-spacing: 0.02em;
}

/* =========================================================
   Lists
   ========================================================= */

ul, ol {
  padding-left: 1.5em;
}

ul li, ol li {
  margin-bottom: 0.35em;
}

/* =========================================================
   Tables (data / task tables)
   ========================================================= */

.StaffTable td { padding: 10px; }

/* Give inline content tables (e.g., docdiff vector table) a bit of room */
.main table td {
  padding: 2px 6px;
  /* Scribble emits `border-bottom: 1px solid black` as an inline style for
     tabular bottom-border rows; !important is required to override it. */
  border-bottom-color: var(--text-muted) !important;
}

/* =========================================================
   Quoted / inset blocks
   ========================================================= */

blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1em;
  color: var(--text-muted);
  margin-left: 1em;
}

/* Scribble emits align="right" on colspan'd header cells; override to center. */
blockquote.SCentered table td[colspan] {
  text-align: center;
}

/* SCentered is a blockquote only by Scribble convention — undo the quote
   styling and actually center the content with flexbox. */
blockquote.SCentered {
  border-left: none;
  padding-left: 0;
  color: inherit;
  margin-left: 0;
  display: flex;
  justify-content: center;
}
