/* =========================================
   1. VARIABLES & THEMES
   ========================================= */

/* --- LIGHT MODE (Default & matches PDF) --- */
:root {
  --text-main: #333333;
  --heading-1: #555555;
  --heading-2: #666666;
  --heading-3: #666666;
  --heading-4: #777777;
  --heading-5-6: #888888;
  --link-color: #0055CC;
  --author-bg: #f0f0f0;
  --divider-line: #c8c8c8;
  --prompt-bg: #F8F9FA;
  --prompt-border: #E0E0E0;
  --prompt-accent: #673AB7;
  --rq-border: black;
  --inline-code-bg: #f1f3f5;
  --inline-code-text: #212529;
  --code-block-bg: #f8f9fa;
  --code-block-border: #e0e0e0;
  --code-block-text: #333333;
  --card-bg: #fafafa;
  --card-border: #e0e0e0;
  --theme-anchor: #2196F3;
  --theme-positive: #4CAF50;
  --theme-negative: #E63946;
  --quiz-bg: #fcfcfc;
  --quiz-border: #e0e0e0;
  --quiz-tag-bg: #eeeeee;
  --quiz-tag-text: #555555;
  --label-orange: #E65100;
  --label-blue: #2196F3;
  --label-dark: var(--text-main);
  --mcq-bg: #fafafa;
  --mcq-correct-border: #4CAF50;
  --mcq-correct-bg: #E8F5E9;
  --mcq-correct-text: #2E7D32;
  --algo-bg: #F8F9FA;
  --algo-border: #E0E0E0;
  --algo-hr: #cccccc;
  --hero-bg-image: url('assets/deep-isf0PELGzBE-unsplash.svg');
  --hero-text-shadow: 0 2px 2px rgba(0, 0, 0, 0.2), 0 2px 2px rgba(0, 0, 0, 0.2);
  --hero-overlay-start: rgba(255, 255, 255, 0.1);
  --hero-overlay-end: rgba(255, 255, 255, 0.1);
  --hero-text: #ffffff;
  --hero-subtitle: #ffffffe5;
  --hero-author-bg: rgba(255, 255, 255, 0.15);
  --hero-credit-text: rgba(255, 255, 255, 0.6);
}

/* --- DARK MODE (Triggered by the Quarto toggle) --- */
html[data-bs-theme="dark"], 
html[data-theme="dark"], 
html.quarto-dark,
body.quarto-dark {
  --text-main: #dfdfdf;
  --heading-1: #ffffff;
  --heading-2: #e0e0e0;
  --heading-3: #e0e0e0; 
  --heading-4: #cccccc; 
  --heading-5-6: #aaaaaa;
  --link-color: #66b3ff;
  --author-bg: #333333;
  --divider-line: #555555;
  --prompt-bg: #3f3f3f;
  --prompt-border: #444444; 
  --prompt-accent: #9575cd; 
  --rq-border: white;
  --inline-code-bg: #656b6f;
  --inline-code-text: #e9ecef;
  --code-block-bg: #282a36;
  --code-block-border: #444444;
  --code-block-text: #f8f8f2;
  --card-bg: #3f3f3f;
  --card-border: #444444;
  --theme-anchor: #64b5f6;
  --theme-positive: #81c784;
  --theme-negative: #e57373;
  --quiz-bg: #444444;
  --quiz-border: #444444;
  --quiz-tag-bg: #3a3a3a;
  --quiz-tag-text: #cccccc;
  --label-orange: #ffb74d;
  --label-blue: #64b5f6;
  --label-dark: var(--text-main); 
  --mcq-bg: #2b2b2b;
  --mcq-correct-border: #66bb6a;
  --mcq-correct-bg: #1e3323;
  --mcq-correct-text: #a5d6a7;
  --algo-bg: #353535;
  --algo-border: #444444;
  --algo-hr: #555555;
  --hero-bg-image: url('assets/deep-isf0PELGzBE-unsplash.svg'); 
  --hero-overlay-start: rgba(0, 0, 0, 0.1);
  --hero-overlay-end: rgba(0, 0, 0, 0.1);
  --hero-text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 0px 0px rgba(0, 0, 0, 0);
  --hero-text: #ffffff; 
  --hero-subtitle: #ffffffe5;
  --hero-author-bg: rgba(255, 255, 255, 0.15);
  --hero-credit-text: rgba(255, 255, 255, 0.6);
}

/* =========================================
   2. BASE HTML & TYPOGRAPHY
   ========================================= */

body {
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  color: var(--text-main);
}

h1 {
  color: var(--heading-1) !important;
  font-size: 1.8em;
  font-weight: bold;
  margin-top: 2em;
  margin-bottom: 1em;
}

h2 {
  color: var(--heading-2) !important;
  font-size: 1.4em;
  font-weight: bold;
  margin-top: 2em;
  margin-bottom: 1em;
}

h3 {
  color: var(--heading-3) !important;
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h4 {
  color: var(--heading-4) !important;
  font-size: 1em;
  font-weight: bold;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h5, h6 {
  color: var(--heading-5-6) !important;
  font-size: 1em;
  font-weight: bold;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

p, li {
  color: var(--text-main) !important;
}

a {
  color: var(--link-color) !important;
  text-decoration: underline;
}

.citation, a[role="doc-biblioref"] {
  color: var(--link-color);
  text-decoration: none; 
}

/* Scale up display block math ($$) */
.math.display {
  font-size: 1.2em;
  margin: 1.5em 0; 
}

/* Scale up inline math ($) slightly */
.math.inline {
  font-size: 1.05em;
}

/* Visual indent to perfectly match bullet point text */
.list-indent {
  margin-left: 2.2em;
  margin-bottom: 1.5em; 
}

/* =========================================
   3. CODE BLOCKS & HIGHLIGHTING
   ========================================= */

/* Target our specific Lua-injected class for adaptive inline code */
code.inline-code {
  background-color: var(--inline-code-bg) !important;
  color: var(--inline-code-text) !important;
  padding: 0.2em 0.4em !important;
  border-radius: 4px !important;
}

/* Base style for ALL outermost multi-line code blocks */
div.sourceCode, 
pre {
  background-color: var(--code-block-bg) !important;
  border: 1px solid var(--code-block-border) !important;
  color: var(--code-block-text) !important;
  padding: 15px !important;       
  border-radius: 6px !important;
  display: block !important;      
  overflow-x: auto !important;    
}

/* Strip backgrounds from nested elements so they don't double-box */
div.sourceCode pre,
div.sourceCode code,
pre code {
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Ensure the inner code text has no margin, but respects the outer padding */
div.sourceCode pre,
pre code {
  padding: 0 !important;
  margin: 0 !important;
}

/* =========================================
   4. CUSTOM COMPONENTS
   ========================================= */

/* Author Block */
.author-box {
  background-color: var(--author-bg) !important;
  padding: 5px 10px;
  border-radius: 6px;
}

.divider-line {
  border-top: 1.5px solid var(--divider-line) !important;
  margin-top: 1.2em;
  margin-bottom: 4em;
  width: 100%;
}

/* System Prompt Box */
.prompt-box {
  background-color: var(--prompt-bg) !important;
  border: 1px solid var(--prompt-border) !important;
  border-left: 4px solid var(--prompt-accent) !important;
  padding: 20px;
  border-radius: 2px 6px 6px 2px;
  margin: 2.5em 0;
  font-size: 0.95em;
}

.prompt-box > :last-child {
  margin-bottom: 0 !important;
}

/* Research Question Boxes */
.research-question-box {
  border: 1px solid var(--rq-border) !important;
  padding: 1.5em;
  margin: 2.5em 0; 
  font-style: italic;
}

.research-question-box > *:last-child {
  margin-bottom: 0 !important;
}

/* Algorithm Boxes */
div[custom-style="algorithm-box"],
.algorithm-box {
  background-color: var(--algo-bg) !important; 
  border: 1px solid var(--algo-border) !important; 
  color: var(--text-main) !important;          
  padding: 15px 20px !important;               
  border-radius: 6px !important;
  margin: 1.5em 0 !important;
  font-size: 0.95em;
  line-height: 1.5;
}

.algorithm-box hr,
div[custom-style="algorithm-box"] hr {
  border: none !important;
  border-top: 1.5px solid var(--algo-hr) !important;
  margin: 12px 0;
}

/* =========================================
   5. CARDS & MCQ SYSTEM
   ========================================= */

/* Custom Data Cards */
.custom-card {
  background-color: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  padding: 20px;
  border-radius: 6px;
  font-size: 0.9em;
  height: 100%;
  box-sizing: border-box;
}

.custom-card.anchor-theme { border-top: 4px solid var(--theme-anchor) !important; }
.custom-card.positive-theme { border-top: 4px solid var(--theme-positive) !important; }
.custom-card.negative-theme { border-top: 4px solid var(--theme-negative) !important; }

.custom-card hr {
  border: none !important;
  border-bottom: 1px solid var(--card-border) !important;
  margin: 10px 0 15px 0;
}

/* Text Badges & Subtext */
.orange-badge {
  background-color: #FFE0B2;
  color: #E65100;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 4px;
}

.subtext {
  color: #777;
  font-size: 0.9em;
}

/* Quiz Container & Tags */
.quiz-card {
  background-color: var(--quiz-bg) !important;
  border: 1px solid var(--quiz-border) !important;
  padding: 20px;
  border-radius: 8px;
  height: 100%;
  box-sizing: border-box;
}

.quiz-tag {
  background-color: var(--quiz-tag-bg) !important;
  color: var(--quiz-tag-text) !important;
  font-size: 1.2em !important;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: monospace;
  margin-right: 5px;
  display: inline-block;
  margin-bottom: 15px;
}

/* Typography Labels */
.label-orange { color: var(--label-orange) !important; font-family: monospace; font-weight: bold; }
.label-blue { color: var(--label-blue) !important; font-family: monospace; font-weight: bold; }
.label-dark { color: var(--label-dark) !important; font-family: monospace; font-weight: bold; display: block; margin-bottom: 15px; }

/* Multiple Choice Options */
.mcq-option {
  border: 1px solid var(--quiz-border) !important;
  padding: 10px 15px;
  border-radius: 6px;
  margin-top: 0 !important;       
  margin-bottom: 10px !important; 
  background-color: var(--mcq-bg) !important;
  color: var(--text-main) !important; 
}

.mcq-option > :last-child {
  margin-bottom: 0 !important;
}

.mcq-option.correct {
  border: 2px solid var(--mcq-correct-border) !important;
  background-color: var(--mcq-correct-bg) !important;
  color: var(--mcq-correct-text) !important;
}

.mcq-option.correct strong { 
  color: var(--mcq-correct-text) !important; 
}

/* =========================================
   6. FIGURES & IMAGES
   ========================================= */

figure, 
div[id^="fig-"] {
  margin-top: 2em;      
  margin-bottom: 2em;   
}

figure img, 
div[id^="fig-"] img {
  padding: 0.0em;         
}

/* =========================================
   7. DARK MODE IMAGE UTILITIES
   ========================================= */

/* Datawrapper Dark Mode: Invert Filter */
html[data-bs-theme="dark"] .datawrapper-panel-group iframe,
html[data-theme="dark"] .datawrapper-panel-group iframe,
body.quarto-dark .datawrapper-panel-group iframe,
html.quarto-dark .datawrapper-panel-group iframe {
  filter: invert(0.9) hue-rotate(180deg);
}

/* Static PNG/JPG Invert */
html[data-bs-theme="dark"] img.auto-invert,
html[data-theme="dark"] img.auto-invert,
body.quarto-dark img.auto-invert,
html.quarto-dark img.auto-invert {
  filter: invert(0.9) hue-rotate(180deg);
}

/* Static PNG/JPG Light Island */
html[data-bs-theme="dark"] img.light-island,
html[data-theme="dark"] img.light-island,
body.quarto-dark img.light-island,
html.quarto-dark img.light-island {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
}

/* Manual Light/Dark Image Toggle */
img.dark {
  display: none !important;
}

html[data-bs-theme="dark"] img.light,
html[data-theme="dark"] img.light,
body.quarto-dark img.light,
html.quarto-dark img.light {
  display: none !important;
}

html[data-bs-theme="dark"] img.dark,
html[data-theme="dark"] img.dark,
body.quarto-dark img.dark,
html.quarto-dark img.dark {
  display: inline-block !important;
}

/* =========================================
   8. HERO BANNER (HTML Cover)
   ========================================= */
.hero-banner {
  background: linear-gradient(var(--hero-overlay-start), var(--hero-overlay-end)), var(--hero-bg-image);
  background-size: cover;
  background-position: center;
  padding: 4em 3em;
  border-radius: 12px;
  margin-top: 1em;
  margin-bottom: 3em;
  color: var(--hero-text) !important; 
  position: relative; 
}

.hero-banner-title {
  /* clamp(MIN_SIZE, IDEAL_SIZE, MAX_SIZE) */
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: bold;
  line-height: 1.2;
  margin-bottom: 0.3em;
  text-shadow: var(--hero-text-shadow) !important;
  text-wrap: balance;
}

.hero-banner-subtitle {
  /* Upgrade to responsive clamp(MIN, IDEAL, MAX) */
  font-size: clamp(1.0rem, 2.5vw, 1.2rem); 
  font-weight: 500;
  color: var(--hero-subtitle) !important;
  margin-bottom: 2.5em;
  text-shadow: var(--hero-text-shadow) !important;

  text-wrap: balance;
}

/* The Frosted Glass Box */
.hero-author-box {
  background-color: var(--hero-author-bg) !important; 
  padding: 8px 12px;
  border-radius: 6px;
  display: inline-block;
  backdrop-filter: blur(4px);
  text-shadow: var(--hero-text-shadow) !important;
}

/* Adaptive text colors for the bottom row */
.hero-author-link {
  font-weight: bold; 
  text-decoration: none; 
  color: var(--hero-text) !important;
}

.hero-author-text {
  color: var(--hero-subtitle) !important;
  text-shadow: var(--hero-text-shadow) !important;
}

/* The Company Logo */
.hero-logo {
  position: absolute;
  bottom: 1em;       
  right: 1.5em;          
  max-height: 40px;    
  width: auto;
}

.hero-credit {
  position: absolute;
  bottom: 0.8em;
  left: 1em;
  font-size: 0.7em;
  color: var(--hero-credit-text) !important;
}

.hero-credit a {
  color: var(--hero-credit-text) !important;
  text-decoration: underline;
}