/* Master course-book stylesheet — teaching-content/shell/theme.css
 *
 * MASTER COPY (pointer pattern, like book.mk): assemble.py copies this file
 * into each shell's docs/_static/theme.css at build time; shells gitignore
 * that copy and NEVER fork it. Edit HERE, then push canonical + `make pin`
 * in each shell before deploying (CI builds at the pinned content_sha).
 *
 * Every color reads a --theme-color-* variable. A shell's entire brand is
 * its docs/_static/custom.css :root block:
 *
 *   :root {
 *     --theme-color-primary:     #1b4d3e;   dark saturated brand color
 *     --theme-color-accent:      #b64c33;   warm/luminous accent
 *     --theme-color-secondary:   #e9f2ec;   pale wash (hover/current bg)
 *     --theme-color-dark:        #12362b;   darker primary (hover states)
 *     --theme-color-accent-fill: #b64c33;   accent as a SOLID FILL (literal =
 *                                           light accent; never remapped, so
 *                                           white-text buttons keep the true
 *                                           brand color in dark mode)
 *     --theme-dark-primary:      #7cc7a9;   dark-mode tint of primary
 *     --theme-dark-accent:       #e39274;   dark-mode tint of accent
 *     --theme-dark-secondary:    #1e2a25;   dark-mode wash (dark surface)
 *   }
 *
 * The dark remap below applies to TEXT uses of the brand colors (headings,
 * bold, links, inline code), where light tints are needed for contrast.
 * Solid accent fills under white text (landing-page buttons) reference
 * --theme-color-accent-fill / --theme-color-accent-dark instead — those
 * hold the true light-mode accent in both modes.
 *
 * Dark-mode tints: lighten primary/accent until they carry on a near-black
 * page (roughly 55-70% toward white); the dark secondary is a deep tinted
 * surface, not a pale wash. The html[data-theme="dark"] remap at the bottom
 * of this file consumes them — shells never write dark-mode rules.
 * Neutral chrome (borders, surfaces, text) uses the pydata theme's --pst-*
 * variables so it follows the light/dark toggle on its own.
 */

/* Derived accent-fill hover (used by landing-page button onmouseover).
   Derives from the non-remapping fill so hovers stay brand-true in dark. */
:root {
  --theme-color-accent-dark: color-mix(in srgb, var(--theme-color-accent-fill, var(--theme-color-accent)) 82%, black);
}

/* Brand the theme's own link color: prev/next footer links, in-article
   links, and TOC links otherwise render pydata default blue. Same-
   specificity override works because this sheet loads after the theme's.
   In dark mode --theme-color-primary/dark already resolve to the light
   tints, so links stay readable there too. */
html[data-theme="light"],
html[data-theme="dark"] {
  --pst-color-link: var(--theme-color-primary);
  --pst-color-link-hover: var(--theme-color-dark);
}

/* Enhanced footer styling */
.bd-footer-content {
  border-top: 1px solid var(--pst-color-border, #e0e0e0);
  padding-top: 15px;
  margin-top: 30px;
}

/* Simple footer formatting */
.bd-footer-content p {
  margin-bottom: 5px !important;
}

/* Customize "Skip to main content" accessibility link */
.skip-link {
  position: absolute !important;
  top: -40px !important;
  left: 6px !important;
  background-color: var(--theme-color-primary) !important;
  color: var(--pst-color-background, #fff) !important;
  padding: 8px 12px !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  font-size: 14px !important;
  z-index: 10000 !important;
  transition: top 0.3s ease !important;
}

.skip-link:focus {
  top: 6px !important;
  color: var(--pst-color-background, #fff) !important;
  text-decoration: none !important;
}

/* Landing-page action buttons (course-action-row in docs/index.md) */
.course-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1rem 0 1.25rem;
}

.course-button {
  display: inline-block;
  background-color: var(--theme-color-primary);
  color: var(--pst-color-background, #fff) !important;
  border: 1px solid var(--theme-color-primary);
  border-radius: 4px;
  padding: 0.52rem 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.course-button:hover,
.course-button:focus {
  background-color: var(--theme-color-dark);
  border-color: var(--theme-color-accent);
  color: var(--pst-color-background, #fff) !important;
  text-decoration: none !important;
}

.course-button-secondary {
  background-color: var(--pst-color-background, #fff);
  border-color: var(--theme-color-accent);
  color: var(--theme-color-primary) !important;
  box-shadow: none;
}

.course-button-secondary:hover,
.course-button-secondary:focus {
  background-color: var(--theme-color-secondary);
  border-color: var(--theme-color-primary);
  color: var(--theme-color-primary) !important;
}

.course-button-disabled {
  background-color: var(--pst-color-surface, #e0e0e0);
  border-color: var(--pst-color-border, #d1d5da);
  color: var(--pst-color-text-muted, #666) !important;
  box-shadow: none;
  cursor: not-allowed;
}

.pdf-embed iframe {
  max-width: 100%;
}

.slide-embed {
  margin-top: 1rem;
  border: 1px solid var(--pst-color-border, #d6e6e8);
  border-radius: 4px;
  overflow: hidden;
  background: var(--pst-color-background, #fff);
}

.slide-embed iframe {
  display: block;
  width: 100%;
  height: min(78vh, 820px);
  min-height: 520px;
  border: 0;
}

/* Title page styling */
.bd-main .bd-content .bd-article-container .bd-article[role="main"] h1:first-of-type {
  border-bottom: 2px solid var(--theme-color-primary);
  padding-bottom: 10px;
  margin-bottom: 20px;
}

/* Consistent header styling across pages */
.bd-sidebar-primary .bd-sidebar-header {
  border-bottom: 1px solid var(--pst-color-border, #e0e0e0);
  padding-bottom: 10px;
}

/* 1. De-emphasize code blocks */
.jp-Cell-inputWrapper {
  background-color: var(--pst-color-surface, #f8f8f8) !important;
  border: 1px solid var(--pst-color-border, #ddd) !important;
  opacity: 0.7;
}

.jp-Cell-inputWrapper pre,
.jp-Cell-inputWrapper code,
.jp-Cell-inputWrapper .highlight,
.jp-Cell-inputWrapper .highlight * {
  opacity: 0.5 !important;
  color: #999 !important;
}

/* Override any green borders in code blocks */
.jp-Cell-inputWrapper,
.jp-Cell-inputWrapper *,
.jp-Cell-inputWrapper pre,
.jp-Cell-inputWrapper code,
.jp-Cell-inputWrapper .highlight,
.jp-Cell-inputWrapper .highlight * {
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
}

/* 2. Header hierarchy */
h2 {
  color: var(--theme-color-accent) !important;
}

h3 {
  color: var(--theme-color-primary) !important;
}

/* 3. Brand-colored bold markdown and inline code */
strong, b {
  color: var(--theme-color-primary) !important;
}

code {
  color: var(--theme-color-accent) !important;
  background-color: color-mix(in srgb, var(--theme-color-secondary) 30%, transparent) !important;
}

/* 4. TOC link colors */
.sidebar a {
  color: var(--pst-color-text-base, #000) !important;
}

.sidebar a[href*="/exercises/E."] {
  color: var(--theme-color-primary) !important;
}

.sidebar a[href*="/exercises/S."] {
  color: var(--theme-color-accent) !important;
}

/* 5. Active page and navigation links */
.sidebar .current {
  color: var(--theme-color-primary) !important;
  background-color: var(--theme-color-secondary) !important;
}

.sidebar .current a {
  color: var(--theme-color-primary) !important;
}

/* Navigation links at bottom (.prev-next-bottom is the legacy selector;
   current sphinx-book-theme markup uses .prev-next-area) */
.prev-next-bottom a,
.prev-next-area a {
  color: var(--theme-color-primary) !important;
}

.prev-next-bottom a:hover,
.prev-next-area a:hover {
  color: var(--theme-color-dark) !important;
}

/* 6. Brand hover effects */
a:hover,
.sidebar a:hover,
.sidebar a:focus {
  color: var(--theme-color-primary) !important;
  background-color: color-mix(in srgb, var(--theme-color-secondary) 30%, transparent) !important;
}

.sidebar a[href*="/exercises/E."]:hover {
  color: var(--theme-color-dark) !important;
}

.sidebar a[href*="/exercises/S."]:hover {
  color: color-mix(in srgb, var(--theme-color-accent) 82%, black) !important;
}

/* 7. Floating kill server button */
.kill-server-btn {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  z-index: 1000 !important;
  background-color: #dc3545 !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  width: 60px !important;
  height: 60px !important;
  font-size: 24px !important;
  cursor: pointer !important;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
  transition: all 0.3s ease !important;
}

.kill-server-btn:hover {
  background-color: #c82333 !important;
  transform: scale(1.1) !important;
  box-shadow: 0 6px 12px rgba(0,0,0,0.4) !important;
}

.kill-server-btn:active {
  transform: scale(0.95) !important;
}

/* 8. Individual code toggle buttons - very subtle and muted */
.code-toggle-button {
  background-color: transparent !important;
  color: var(--pst-color-text-muted, #999) !important;
  border: 1px solid var(--pst-color-border, #e0e0e0) !important;
  padding: 2px 6px !important;
  border-radius: 3px !important;
  font-size: 10px !important;
  cursor: pointer !important;
  margin-bottom: 3px !important;
  transition: all 0.2s ease !important;
  opacity: 0.6 !important;
  float: right !important;
  margin-left: 10px !important;
}

.code-toggle-button:hover {
  background-color: var(--pst-color-surface, #f5f5f5) !important;
  color: var(--pst-color-text-base, #666) !important;
  border-color: var(--pst-color-border, #ccc) !important;
  opacity: 0.8 !important;
}

/* 9. Global code toggle button styling */
.global-code-toggle:hover {
  background-color: var(--theme-color-dark) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px color-mix(in srgb, var(--theme-color-primary) 30%, transparent) !important;
}

/* 10. Style code cells for better visibility when shown */
.cell_input {
  background-color: var(--pst-color-surface, #f8f9fa) !important;
  border: 1px solid var(--pst-color-border, #e9ecef) !important;
  border-radius: 4px !important;
  margin-bottom: 10px !important;
  transition: all 0.3s ease !important;
  clear: both !important;
}

.cell_input:hover {
  border-color: var(--theme-color-primary) !important;
  box-shadow: 0 2px 4px color-mix(in srgb, var(--theme-color-primary) 15%, transparent) !important;
}

/* 11. Dataframe styling - brand hover colors */
.dataframe tbody tr:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
}

.dataframe thead th:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 15%, transparent) !important;
}

.dataframe tbody td:hover {
  background-color: color-mix(in srgb, var(--theme-color-accent) 10%, transparent) !important;
}

/* Additional dataframe hover styles for different table classes */
table.dataframe tbody tr:hover,
.output_html table tbody tr:hover,
.jp-RenderedHTMLCommon table tbody tr:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
}

table.dataframe thead th:hover,
.output_html table thead th:hover,
.jp-RenderedHTMLCommon table thead th:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 15%, transparent) !important;
}

/* Override any purple/violet hover colors specifically */
.dataframe tr:hover,
.dataframe td:hover,
.dataframe th:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
  color: var(--theme-color-primary) !important;
}

/* CRITICAL: Override pandas default purple hover with maximum specificity */
table[id^="T_"] tbody tr:hover,
table[id^="T_"] tbody tr:hover td,
table[id^="T_"] tbody td:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
  color: inherit !important;
}

table[id^="T_"] thead th:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 15%, transparent) !important;
  color: var(--theme-color-primary) !important;
}

/* Additional comprehensive overrides for DataFrame-specific table types */
.bd-content table tbody tr:hover,
.bd-content table.dataframe tbody tr:hover,
.bd-content table[class*="dataframe"] tbody tr:hover,
div[data-mime-type="text/html"] table tbody tr:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
}

/* Override any inline styles or default pandas styles */
table[class*="dataframe"] tbody tr:hover,
table[class*="dataframe"] tbody tr:hover td,
table[class*="dataframe"] tbody td:hover,
table[border="1"] tbody tr:hover,
table[border="1"] tbody tr:hover td,
table[border="1"] tbody td:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
}

/* 11.1 DataFrame text selection (tie selection highlight to theme) */
.dataframe ::selection,
table.dataframe ::selection,
.output_html table ::selection,
.output.text_html table ::selection,
.cell_output table ::selection,
.jp-RenderedHTMLCommon table ::selection {
  background: color-mix(in srgb, var(--theme-color-accent) 25%, transparent) !important;
  color: var(--pst-color-text-base, #000) !important;
}

/* Firefox variant */
.dataframe ::-moz-selection,
table.dataframe ::-moz-selection,
.output_html table ::-moz-selection,
.output.text_html table ::-moz-selection,
.cell_output table ::-moz-selection,
.jp-RenderedHTMLCommon table ::-moz-selection {
  background: color-mix(in srgb, var(--theme-color-accent) 25%, transparent) !important;
  color: var(--pst-color-text-base, #000) !important;
}

/* 12. Enhanced DataFrame Sticky Headers and Index */
/* Universal table scrolling containers - covers all DataFrame output formats */
.output_html,
.output.text_html,
.cell_output,
div.output,
.jp-RenderedHTMLCommon,
.jp-OutputArea-output,
div[data-mime-type="text/html"] {
  overflow-x: auto !important;
  overflow-y: visible !important;
  max-width: 100% !important;
  /* outputs create a BFC (overflow:auto); without clear they shrink to
     fit beside stacked floated .code-toggle-button elements */
  clear: both !important;
}

/* Ensure all tables can scroll and have consistent layout */
.output_html table,
.output.text_html table,
.cell_output table,
div.output table,
.jp-RenderedHTMLCommon table,
table.dataframe,
table[border="1"].dataframe {
  min-width: 100% !important;
  table-layout: auto !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  position: relative !important;
}

/* STICKY COLUMN HEADERS (horizontal scrolling) */
/* Sticky cells need OPAQUE backgrounds: mix the wash over the page color */
.output_html table thead th,
.output.text_html table thead th,
.cell_output table thead th,
div.output table thead th,
.jp-RenderedHTMLCommon table thead th,
table.dataframe thead th,
table[border="1"].dataframe thead th,
table thead th.col_heading {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background-color: color-mix(in srgb, var(--theme-color-secondary) 30%, var(--pst-color-background, #fff)) !important;
  border-bottom: 2px solid var(--theme-color-primary) !important;
  box-shadow: 0 2px 4px color-mix(in srgb, var(--theme-color-primary) 15%, transparent) !important;
}

/* STICKY INDEX COLUMNS (vertical scrolling) */
.output_html table .row_heading,
.output_html table th.row_heading,
.output.text_html table .row_heading,
.output.text_html table th.row_heading,
.cell_output table .row_heading,
.cell_output table th.row_heading,
div.output table .row_heading,
div.output table th.row_heading,
.jp-RenderedHTMLCommon table .row_heading,
.jp-RenderedHTMLCommon table th.row_heading,
table .row_heading,
table th.row_heading,
table.dataframe .row_heading,
table[border="1"].dataframe .row_heading {
  position: sticky !important;
  left: 0 !important;
  z-index: 10 !important;
  background-color: var(--pst-color-background, #fff) !important;
  border-right: 2px solid var(--pst-color-border, #e0e0e0) !important;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* CORNER CELL - highest z-index for top-left intersection */
.output_html table thead th.blank,
.output.text_html table thead th.blank,
.cell_output table thead th.blank,
div.output table thead th.blank,
.jp-RenderedHTMLCommon table thead th.blank,
table thead th.blank,
table.dataframe thead th.blank,
table[border="1"].dataframe thead th.blank,
table thead th.index_name {
  position: sticky !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 30 !important;
  background-color: var(--pst-color-surface, #f0f0f0) !important;
  border-right: 2px solid var(--pst-color-border, #e0e0e0) !important;
  border-bottom: 2px solid var(--theme-color-primary) !important;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* MULTI-LEVEL INDEX SUPPORT */
/* Handle multi-level column headers */
.output_html table thead th[class*="level"],
.output.text_html table thead th[class*="level"],
.cell_output table thead th[class*="level"],
div.output table thead th[class*="level"],
table thead th[class*="level"] {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background-color: var(--pst-color-surface, #f8f9fa) !important;
  border-bottom: 2px solid var(--theme-color-primary) !important;
}

/* Handle multi-level row headers */
.output_html table th[class*="level0"],
.output.text_html table th[class*="level0"],
.cell_output table th[class*="level0"],
div.output table th[class*="level0"],
table th[class*="level0"] {
  position: sticky !important;
  left: 0 !important;
  z-index: 15 !important;
  background-color: var(--pst-color-background, #fff) !important;
  border-right: 2px solid var(--pst-color-border, #e0e0e0) !important;
}

/* HOVER EFFECTS for sticky elements */
.output_html table .row_heading:hover,
.output.text_html table .row_heading:hover,
.cell_output table .row_heading:hover,
div.output table .row_heading:hover,
.jp-RenderedHTMLCommon table .row_heading:hover,
table .row_heading:hover,
table.dataframe .row_heading:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 15%, var(--pst-color-background, #fff)) !important;
  color: var(--theme-color-primary) !important;
}

.output_html table thead th:hover,
.output.text_html table thead th:hover,
.cell_output table thead th:hover,
div.output table thead th:hover,
.jp-RenderedHTMLCommon table thead th:hover,
table.dataframe thead th:hover {
  background-color: color-mix(in srgb, var(--theme-color-primary) 20%, var(--pst-color-background, #fff)) !important;
  color: var(--theme-color-primary) !important;
}

/* PANDAS STYLER SPECIFIC */
/* Handle pandas Styler tables (with id like T_xxxxx) */
table[id^="T_"] {
  min-width: 100% !important;
  table-layout: auto !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

table[id^="T_"] thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background-color: var(--pst-color-surface, #f8f9fa) !important;
  border-bottom: 2px solid var(--theme-color-primary) !important;
  box-shadow: 0 2px 4px color-mix(in srgb, var(--theme-color-primary) 10%, transparent) !important;
}

table[id^="T_"] th.row_heading {
  position: sticky !important;
  left: 0 !important;
  z-index: 10 !important;
  background-color: var(--pst-color-background, #fff) !important;
  border-right: 2px solid var(--pst-color-border, #e0e0e0) !important;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

table[id^="T_"] th.blank {
  position: sticky !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 30 !important;
  background-color: var(--pst-color-surface, #f0f0f0) !important;
  border-right: 2px solid var(--pst-color-border, #e0e0e0) !important;
  border-bottom: 2px solid var(--theme-color-primary) !important;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* 13. Sphinx Design Cards - distinctive styling */
.sd-card {
  background-color: var(--pst-color-surface, #f8f9fa) !important;
  border: 2px solid var(--pst-color-border, #e9ecef) !important;
  border-left: 4px solid var(--theme-color-primary) !important;
  border-radius: 8px !important;
  padding: 20px !important;
  margin-bottom: 20px !important;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--theme-color-primary) 12%, transparent) !important;
  transition: all 0.3s ease !important;
}

.sd-card:hover {
  background-color: var(--theme-color-secondary) !important;
  border-color: var(--pst-color-border, #e9ecef) !important;
  border-left-color: var(--theme-color-accent) !important;
  box-shadow: 0 5px 15px color-mix(in srgb, var(--theme-color-primary) 18%, transparent) !important;
  transform: translateY(-2px) !important;
}

/* Keep the existing font color and links styling within cards */
.sd-card a {
  color: var(--theme-color-primary) !important;
  text-decoration: none !important;
}

.sd-card a:hover {
  color: var(--theme-color-dark) !important;
  text-decoration: underline !important;
}

/* Card title styling */
.sd-card-title {
  color: var(--theme-color-primary) !important;
  margin-bottom: 8px !important;
}

/* Make card headlines bigger and more prominent */
.sd-card strong,
.sd-card-body strong {
  font-size: 1.2em !important;
  line-height: 1.3 !important;
  display: block !important;
  margin-bottom: 10px !important;
  color: var(--theme-color-primary) !important;
}

/* Ensure linked headlines maintain proper styling */
.sd-card strong a,
.sd-card-body strong a {
  font-size: inherit !important;
  color: inherit !important;
  text-decoration: none !important;
}

.sd-card strong a:hover,
.sd-card-body strong a:hover {
  color: var(--theme-color-dark) !important;
  text-decoration: none !important;
}

/* Grid layout cards - ensure consistent spacing */
.sd-container-fluid .sd-card {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Hide URL display from sphinx cards with :link: directive */
.sd-card-body a[href*="wsj.com"][href*="?"] {
  display: none !important;
}

/* Alternative: Hide any standalone URL links in card bodies */
.sd-card-body > p > a:only-child[href^="https://"] {
  display: none !important;
}

/* Hide paragraph containing only a URL */
.sd-card-body > p:has(> a:only-child[href^="https://"]) {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* DARK MODE (pydata theme sets html[data-theme="dark"])               */
/* The single remap for every course book: brand variables swap to the */
/* shell-declared --theme-dark-* tints so bold text, h3 headings, and  */
/* links stop rendering dark-on-dark. Shells declare tints only; all   */
/* dark-mode RULES live here.                                          */
/* ------------------------------------------------------------------ */
html[data-theme="dark"] {
  --theme-color-primary: var(--theme-dark-primary, #a9c2d1);
  --theme-color-accent: var(--theme-dark-accent, #ddab8e);
  --theme-color-secondary: var(--theme-dark-secondary, #232930);
  --theme-color-dark: color-mix(in srgb, var(--theme-dark-primary, #a9c2d1) 70%, white);
}

/* Buttons keep a light-tint background in dark mode: flip their text dark */
html[data-theme="dark"] .skip-link,
html[data-theme="dark"] .skip-link:focus,
html[data-theme="dark"] .course-button,
html[data-theme="dark"] .course-button:hover,
html[data-theme="dark"] .course-button:focus {
  color: #14181e !important;
}

/* De-emphasized code inputs: keep the dimming, drop the light surface */
html[data-theme="dark"] .jp-Cell-inputWrapper {
  background-color: #1b1f24 !important;
}

html[data-theme="dark"] .cell_input {
  background-color: #1b1f24 !important;
}
