/* Custom styles for the textbook */

/* Code blocks */
.sourceCode {
  background-color: #f8f8f8;
  border-left: 3px solid #2780e3;
  padding: 10px;
  border-radius: 4px;
}

/* Callout boxes */
.callout {
  margin: 1.5em 0;
  padding: 1em;
  border-radius: 5px;
}

.callout-note {
  background-color: #e3f2fd;
  border-left: 4px solid #2196f3;
}

/* Figure captions */
figcaption {
  font-style: italic;
  color: #666;
  text-align: center;
  margin-top: 0.5em;
  font-size: 0.9em;
}

/* Tables */
table {
  margin: 1em auto;
  border-collapse: collapse;
  width: 90%;
}

thead {
  background-color: #d5e8f0;
  font-weight: bold;
}

th, td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  text-align: left;
}

tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* Exercise styling */
h3:has(+ p:contains("⭐")) {
  color: #2780e3;
}

/* Sidebar styling */
.sidebar nav[role=doc-toc] ul {
  padding-left: 0;
}

/* Responsive images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
}

/* Section numbering */
.header-section-number {
  color: #2780e3;
  font-weight: bold;
  margin-right: 0.5em;
}

/* Links */
a {
  color: #2780e3;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Code inline */
code {
  background-color: #f4f4f4;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

/* Quiz card styling */
.quiz-card {
  border: 1px solid #d4cfc9;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.09);
  margin: 1.5em 0 2em 0;
  overflow: hidden;
}

.quiz-card-title {
  background: #e8e4de;
  color: #3a3530;
  padding: 10px 18px;
  font-size: 0.92em;
  font-weight: 600;
  font-family: Georgia, 'Times New Roman', serif;
  border-bottom: 1px solid #d4cfc9;
  margin: 0;
}

.quiz-card-body {
  background: #fdfcfa;
  padding: 16px 20px;
}

.quiz-card-body > *:last-child {
  margin-bottom: 0;
}

/* Blockquotes for important notes */
blockquote {
  border-left: 4px solid #ffa726;
  background-color: #fff3e0;
  padding: 10px 15px;
  margin: 1em 0;
  font-style: italic;
}

/* ============================================================
   DARK MODE OVERRIDES  (body.quarto-dark is set by Quarto JS)
   ============================================================ */

body.quarto-dark .sourceCode {
  background-color: #1e1e2e;
  border-left-color: #5a9cf5;
}

body.quarto-dark code {
  background-color: #2a2a3a;
  color: #c9d1d9;
}

body.quarto-dark .callout-note {
  background-color: #0d1f2d;
  border-left-color: #3b80c4;
}

body.quarto-dark blockquote {
  background-color: #2a1f10;
  border-left-color: #d4863a;
}

body.quarto-dark thead {
  background-color: #1a2535;
}

body.quarto-dark th,
body.quarto-dark td {
  border-color: #3a3f4a;
}

body.quarto-dark tr:nth-child(even) {
  background-color: #1c1c24;
}

/* Quiz cards in dark mode */
body.quarto-dark .quiz-card {
  border-color: #4a4540;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
}

body.quarto-dark .quiz-card-title {
  background: #2c2825;
  color: #d8d4ce;
  border-bottom-color: #4a4540;
}

body.quarto-dark .quiz-card-body {
  background: #1a1815;
  color: #d8d4ce;
}

body.quarto-dark .quiz-card-body label {
  color: #d8d4ce;
}

body.quarto-dark .quiz-card-body button {
  background-color: #2c3a2c;
  color: #a8c4a8;
  border: 1px solid #3a5a3a;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
}

body.quarto-dark .quiz-card-body button:hover {
  background-color: #3a4e3a;
}

/* Pyodide editor font size — match static code block size */
.qpyodide-editor {
  font-size: 13px;
}

/* Pyodide interactive cells in dark mode */
body.quarto-dark .qpyodide-editor {
  border-color: #3a3a3a;
}

body.quarto-dark .qpyodide-editor-toolbar {
  background-color: #252526;
  border-bottom: 1px solid #3a3a3a;
}

body.quarto-dark .qpyodide-button {
  background-color: #2d2d2d;
  color: #cccccc;
  border-color: #3a3a3a;
}

body.quarto-dark .qpyodide-button:hover {
  background-color: #3a3a3a;
  color: #ffffff;
  border-color: #555555;
}

body.quarto-dark .qpyodide-button-reset,
body.quarto-dark .qpyodide-button-copy {
  color: #858585;
}

body.quarto-dark .qpyodide-output-code-area {
  background-color: #1e1e1e;
}

body.quarto-dark .qpyodide-output-code-area pre {
  background-color: #1e1e1e;
  color: #d4d4d4;
}

body.quarto-dark .qpyodide-output-code-stdout {
  color: #d4d4d4;
}

body.quarto-dark .qpyodide-output-code-stderr {
  color: #f48771;
}

body.quarto-dark .qpyodide-non-interactive-loading-container {
  background-color: rgba(30, 30, 30, 0.75);
  border-color: rgba(60, 60, 60, 0.65);
}

/* Sidebar toggle pill — fixed to left edge, vertically centered */
#sidebar-toggle-btn {
  position: fixed;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1050;
  width: 20px;
  height: 48px;
  border: 1px solid #ccc;
  border-radius: 0 6px 6px 0;
  background: #f8f9fa;
  color: #555;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.12);
  transition: background 0.15s, color 0.15s;
}
#sidebar-toggle-btn:hover {
  background: #e2e6ea;
  color: #222;
}
body.quarto-dark #sidebar-toggle-btn {
  background: #2d2d2d;
  border-color: #444;
  color: #ccc;
}
body.quarto-dark #sidebar-toggle-btn:hover {
  background: #3a3a3a;
  color: #fff;
}

/* --- Sidebar hide via body class toggle --- */

/* Hide both the sidebar nav and the glass overlay */
body.cvmath-sidebar-hidden #quarto-sidebar,
body.cvmath-sidebar-hidden #quarto-sidebar-glass {
  display: none !important;
}

/* Collapse left gutter only — content shifts left, right panel stays put */
body.cvmath-sidebar-hidden.floating .page-columns {
  grid-template-columns:
    [screen-start screen-start-inset page-start page-start-inset body-start-outset body-start] 1.5em
    [body-content-start] minmax(500px, calc(800px - 3em))
    [body-content-end] 1.5em [body-end] minmax(25px, 50px) [body-end-outset] minmax(50px, 150px) [page-end-inset] minmax(25px, 50px) [page-end] 5fr [screen-end-inset] 1.5em [screen-end] !important;
}

/* Pixel Explorer — matrix pre blocks (light + dark mode) */
.pe-matrix {
  font-size: 0.65rem;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  overflow-x: auto;
  margin-bottom: 8px;
  line-height: 1.5;
  background: var(--bs-secondary-bg, #f8f9fa);
  color: var(--bs-body-color, #212529);
}
body.quarto-dark .pe-matrix {
  background: #000;
  color: #f8f8f2;
  border-color: #444;
}
