:root {
  /* Catppuccin Mocha Theme */
  color-scheme: dark;

  --ctp-rosewater: #f5e0dc;
  --ctp-flamingo: #f2cdcd;
  --ctp-pink: #f5c2e7;
  --ctp-mauve: #cba6f7;
  --ctp-red: #f38ba8;
  --ctp-maroon: #eba0ac;
  --ctp-peach: #fab387;
  --ctp-yellow: #f9e2af;
  --ctp-green: #a6e3a1;
  --ctp-teal: #94e2d5;
  --ctp-sky: #89dceb;
  --ctp-sapphire: #74c7ec;
  --ctp-blue: #89b4fa;
  --ctp-lavender: #b4befe;
  --ctp-text: #cdd6f4;
  --ctp-subtext1: #bac2de;
  --ctp-subtext0: #a6adc8;
  --ctp-overlay2: #9399b2;
  --ctp-overlay1: #7f849c;
  --ctp-overlay0: #6c7086;
  --ctp-surface2: #585b70;
  --ctp-surface1: #45475a;
  --ctp-surface0: #313244;
  --ctp-base: #1e1e2e;
  --ctp-mantle: #181825;
  --ctp-crust: #11111b;

  /* Semantic Mappings */
  --bg-color: var(--ctp-base);
  --bg-gradient-start: var(--ctp-base);
  --bg-gradient-end: var(--ctp-mantle);

  --text-main: var(--ctp-text);
  --text-muted: var(--ctp-subtext1);
  --text-dim: var(--ctp-overlay2);

  --accent-primary: var(--ctp-mauve);
  --accent-secondary: var(--ctp-blue);
  --accent-tertiary: var(--ctp-pink);

  --code-bg: var(--ctp-mantle);
  --border-color: var(--ctp-surface0);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --base-size: 100%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ctp-base) 0%, var(--ctp-mantle) 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.3;
  padding: 3rem;
  overflow: hidden;
  font-size: var(--base-size);
}

/* Base Wrapper */
.content {
  position: relative;
  z-index: 10;
  width: 75%;
  max-width: 1600px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  text-align: left;
}

/* =========================================
   Typography
   ========================================= */

h1,
h2,
h3,
h4,
h5,
h6 {
  text-align: center;
  width: 100%;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

h1 {
  font-size: 5em;
  font-weight: 800;
  line-height: 1.1;
  /* Catppuccin Mauve to Pink Gradient */
  background: linear-gradient(to bottom right, var(--ctp-mauve) 20%, var(--ctp-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3em;
  filter: drop-shadow(0 0 20px rgba(203, 166, 247, 0.2));
}

h2 {
  font-size: 3.8em;
  font-weight: 700;
  line-height: 1.2;
  /* Complementary Lavender to Sapphire Gradient */
  background: linear-gradient(to bottom right, var(--ctp-lavender) 30%, var(--ctp-sapphire) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5em;
  opacity: 0.95;
}

h3 {
  font-size: 2.8em;
  margin-bottom: 0.4em;
  color: var(--ctp-blue);
}

h4 {
  font-size: 2.2em;
  margin-bottom: 0.4em;
  color: var(--ctp-sapphire);
}

p {
  font-size: 2.5em;
  line-height: 1.4;
  margin-bottom: 0.8em;
  color: var(--ctp-subtext1);
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* =========================================
   Code Blocks (Catppuccin Syntax Highlighting)
   ========================================= */

/* The Window Container */
div.sourceCode,
div.code-window {
  background: var(--ctp-mantle);
  border: 1px solid var(--border-color);
  border-radius: 0.6em;
  margin: 1.5em 0;
  width: 100%;
  position: relative;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* The Window Header (Generated by JS) */
.code-header {
  height: 2.5rem;
  min-height: 2.5rem;
  background: var(--ctp-crust);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5em;

  color: var(--ctp-overlay2);
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* The Code Content */
pre {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 1.5em 2rem !important;
  width: 100%;
  overflow-x: auto;
}

/* Remove old fake header */
pre::before {
  content: none !important;
}

pre code {
  font-family: var(--font-mono);
  font-size: 1.1em;
  color: var(--ctp-text);
  line-height: 1.5;

  /* Reset inline code styles to prevent "box inside box" artifacts */
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* --- Pandoc Syntax Highlighting Classes --- */
.kw {
  color: var(--ctp-mauve) !important;
  font-weight: bold !important;
}

/* Keyword */
.dt {
  color: var(--ctp-yellow) !important;
}

/* DataType */
.dv {
  color: var(--ctp-peach) !important;
}

/* DecVal */
.bn {
  color: var(--ctp-peach) !important;
}

/* BaseN */
.fl {
  color: var(--ctp-peach) !important;
}

/* Float */
.ch {
  color: var(--ctp-green) !important;
}

/* Char */
.st {
  color: var(--ctp-green) !important;
}

/* String */
.co {
  color: var(--ctp-overlay0) !important;
  font-style: italic !important;
}

/* Comment */
.ot {
  color: var(--ctp-mauve) !important;
}

/* Other */
.al {
  color: var(--ctp-red) !important;
  font-weight: bold !important;
}

/* Alert */
.fu {
  color: var(--ctp-blue) !important;
}

/* Function */
.er {
  color: var(--ctp-red) !important;
  font-weight: bold !important;
}

/* Error */
.wa {
  color: var(--ctp-yellow) !important;
  font-weight: bold !important;
}

/* Warning */
.cf {
  color: var(--ctp-mauve) !important;
  font-weight: bold !important;
}

/* ControlFlow */
.op {
  color: var(--ctp-sky) !important;
}

/* Operator */
.bu {
  color: var(--ctp-blue) !important;
}

/* BuiltIn */
.ex {
  color: var(--ctp-blue) !important;
}

/* Extension */
.pp {
  color: var(--ctp-flamingo) !important;
}

/* Preprocessor */
.at {
  color: var(--ctp-rosewater) !important;
}

/* Attribute */
.do {
  color: var(--ctp-overlay0) !important;
  font-style: italic !important;
}

/* Documentation */
.an {
  color: var(--ctp-pink) !important;
}

/* Annotation */
.cv {
  color: var(--ctp-pink) !important;
}

/* CommentVar */
.va {
  color: var(--ctp-text) !important;
}

/* Variable */
.vs {
  color: var(--ctp-green) !important;
}

/* VerbatimString */
.sc {
  color: var(--ctp-pink) !important;
}

/* SpecialChar */
.ss {
  color: var(--ctp-green) !important;
}

/* SpecialString */
.im {
  color: var(--ctp-mauve) !important;
}

/* Import */

/* Constant (Some, None, true, false, etc) */
.cn {
  color: var(--ctp-peach) !important;
}

/* Information */
.in {
  color: var(--ctp-blue) !important;
}

/* Region Marker */
.re {
  color: var(--ctp-overlay1) !important;
}

/* Catch-all: override any remaining Pandoc default colors */
pre code span {
  background: transparent !important;
}

/* Inline Code */
code {
  font-family: var(--font-mono);
  background: var(--ctp-surface0);
  color: var(--ctp-peach);
  padding: 0.1em 0.3em;
  border-radius: 0.25em;
  border: 1px solid var(--ctp-surface1);
  font-size: 0.9em;
}

/* =========================================
   Elements
   ========================================= */

ul,
ol {
  font-size: 2.5em;
  line-height: 1.4;
  margin: 1em 0;
  padding-left: 1.5em;
  color: var(--ctp-subtext1);
}

li {
  margin-bottom: 0.5em;
  padding-left: 0.5em;
}

ul li::marker {
  color: var(--ctp-teal);
  font-size: 0.8em;
}

ol li::marker {
  color: var(--ctp-teal);
  font-weight: 700;
  font-family: var(--font-mono);
}

blockquote {
  border-left: 0.2em solid var(--ctp-mauve);
  background: linear-gradient(90deg, rgba(203, 166, 247, 0.1) 0%, transparent 100%);
  padding: 1em 1.5em;
  margin: 1.5em 0;
  font-size: 2.5em;
  font-style: italic;
  color: var(--ctp-text);
  border-radius: 0 0.5em 0.5em 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2em 0;
  font-size: 2em;
  border: 1px solid var(--border-color);
  border-radius: 0.5em;
  overflow: hidden;
}

th {
  background: var(--ctp-surface0);
  color: var(--ctp-mauve);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.8em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.8em;
  border-bottom: 1px solid var(--border-color);
  color: var(--ctp-subtext1);
}

/* =========================================
   Layout Variants
   ========================================= */

/* Hero Layout */
body.layout-hero .content {
  transform: scale(1.1);
  text-align: center;
  align-items: center;
}

body.layout-hero h1 {
  font-size: 8.5em;
  margin-bottom: 0.15em;
  line-height: 1.2;
  background: linear-gradient(to bottom, var(--ctp-text) 40%, var(--ctp-mauve) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.layout-hero h2 {
  font-size: 5.5em;
  margin-bottom: 0.3em;
  background: linear-gradient(to bottom, var(--ctp-subtext1) 40%, var(--ctp-lavender) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.layout-hero p {
  font-size: 4em;
  text-align: center;
  color: var(--ctp-subtext0);
  max-width: 90%;
}

/* Quote Layout - Modern, fancy Catppuccin design */
body.layout-quote .content {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body.layout-quote blockquote {
  position: relative;
  font-size: 3.2em;
  font-style: italic;
  font-weight: 300;
  line-height: 1.5;
  text-align: center;
  color: var(--ctp-text);
  padding: 1.5em 2.5em;
  margin: 0;
  border-left: 0.15em solid var(--ctp-mauve);
  background: linear-gradient(90deg, rgba(203, 166, 247, 0.1) 0%, transparent 50%);
  border-radius: 0 1em 1em 0;
}

/* Decorative quote marks */
body.layout-quote blockquote::before,
body.layout-quote blockquote::after {
  font-family: Georgia, serif;
  font-size: 5em;
  font-style: normal;
  line-height: 1;
  position: absolute;
  color: var(--ctp-mauve);
  opacity: 0.3;
}

body.layout-quote blockquote::before {
  content: '"';
  top: -0.1em;
  left: 0.3em;
}

body.layout-quote blockquote::after {
  content: '"';
  bottom: -0.3em;
  right: 0.3em;
}

/* Quote text */
body.layout-quote blockquote p {
  margin: 0;
}

/* Image Layout */
body.layout-image {
  padding: 0;
}

body.layout-image .content {
  width: 100%;
  height: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Pandoc wraps images in <figure> or <p> - style both */
body.layout-image .content figure,
body.layout-image .content p {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Hide alt text / figcaption for image-only slides */
body.layout-image .content figcaption {
  display: none;
}

body.layout-image img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  display: block;
}

/* Dense Layout */
body.layout-dense {
  padding: 1.5rem;
}

body.layout-dense .content {
  width: 80%;
  justify-content: center;
  padding-top: 1rem;
}

body.layout-dense h1 {
  margin-bottom: 0.2em;
}

body.layout-dense h2 {
  margin-bottom: 0.3em;
}

body.layout-dense p {
  margin-bottom: 0.5em;
  font-size: 2.2em;
}

body.layout-dense pre {
  padding-top: 3rem;
  margin: 1em 0;
}

/* =========================================
   Responsive Design / Reels Support
   ========================================= */

/* Portrait / Vertical Video (9:16 aspect ratio) */
@media (aspect-ratio < 1/1) {
  body {
    /* Unequal padding to clear UI elements (Reels/TikTok captions & buttons) */
    padding-top: 15vh;
    padding-bottom: 30vh;
    padding-left: 6vw;
    padding-right: 6vw;
    
    /* Adjust base size for narrow screens to keep relative units sane */
    --base-size: 85%;
  }

  .content {
    /* Use full available width (minus body padding) */
    width: 100%;
    max-width: 100%;
  }

  /* Adjust typography scaling for vertical layout */
  h1 {
    font-size: 6em; 
    line-height: 1.15;
  }

  h2 {
    font-size: 4.5em;
  }

  h3 {
    font-size: 3.5em;
  }

  p {
    font-size: 3.2em;
    line-height: 1.5;
  }

  ul, ol {
    font-size: 3.2em;
    padding-left: 1.2em;
  }

  /* Adjust code blocks for narrow width */
  div.sourceCode,
  div.code-window {
    margin: 1em 0;
  }

  pre code {
    font-size: 1.4em;
  }

  /* Layout specifics adjustments */
  body.layout-hero .content {
    transform: none; /* Disable scaling transform which might clip */
    width: 100%;
  }

  body.layout-hero h1 {
    font-size: 9em; /* Slightly smaller than 10em to avoid excessive wrapping */
    line-height: 1.2;
  }

  body.layout-hero p {
    font-size: 4.5em;
  }

  body.layout-quote blockquote {
    font-size: 4em;
    padding: 1.5em 1.5em;
    margin: 1em 0;
  }
}
