/* ── Custom variables ─────────────────────────────────────────────────────── */

:root {
  --font-garamond: "EB Garamond", "Cormorant Garamond", Garamond, "Apple Garamond", Georgia, serif;

  --color-page:   #f1f1ef;
  --color-bg:     #ffffff;
  --color-text:   #151515;
  --color-muted:  #6a665f;
  --color-accent: #2457a6;
  --color-rule:   #ded9ce;

  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 32px;
  --space-lg: 56px;
  --space-xl: 80px;

  --footer-size:       14px;
  --footer-logo-width: 88px;

  /* Reveal.js theme variables */
  --r-background-color:           var(--color-bg);
  --r-main-font:                  var(--font-garamond);
  --r-main-font-size:             30px;
  --r-main-color:                 var(--color-text);
  --r-block-margin:               var(--space-sm);
  --r-heading-margin:             0 0 var(--space-md) 0;
  --r-heading-font:               var(--font-garamond);
  --r-heading-color:              var(--color-text);
  --r-heading-line-height:        1.1;
  --r-heading-letter-spacing:     normal;
  --r-heading-text-transform:     none;
  --r-heading-font-weight:        700;
  --r-heading1-size:              46px;
  --r-heading2-size:              28px;
  --r-heading3-size:              24px;
  --r-link-color:                 var(--color-accent);
  --r-link-color-hover:           #1a3d7a;
  --r-selection-background-color: var(--color-accent);
  --r-selection-color:            var(--color-bg);
}

/* ── Base ─────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body, .reveal {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-page) !important;
}

.reveal {
  font-family: var(--font-garamond);
  color:       var(--color-text);
}

/* ── Slides (Reveal.js sections) ─────────────────────────────────────────── */

.reveal .slides section {
  /* Scale variable — fitSlideText() adjusts this when content overflows */
  --fit-scale: 1;

  /* Override Reveal.js defaults so sections fill the full slide canvas */
  display:        flex !important;
  flex-direction: column;
  width:          100% !important;
  height:         100% !important;
  top:            0    !important;
  left:           0    !important;

  padding:    48px var(--space-xl) var(--space-xl);
  background: var(--color-bg);
  text-align: left;
  overflow:   hidden;
  box-shadow: 0 1px 6px rgba(20, 20, 20, 0.06);
}

/* ── Slide title ──────────────────────────────────────────────────────────── */

.slide-title {
  margin:         0 0 calc(var(--space-md) * var(--fit-scale));
  font-family:    var(--font-garamond);
  font-size:      46px;
  font-weight:    700;
  line-height:    1.1;
  color:          var(--color-text);
  text-transform: none;
  letter-spacing: normal;
}

.slide-title::after {
  content:    "";
  display:    block;
  width:      88px;
  height:     3px;
  margin-top: 16px;
  background: var(--color-accent);
}

/* ── Body text ────────────────────────────────────────────────────────────── */

.markdown-block {
  max-width:   1120px;
  font-size:   calc(30px * var(--fit-scale));
  line-height: 1.35;
}

.markdown-block p { margin: 0 0 var(--space-sm); }

/* Label before a bullet list (e.g. "Various ways to introduce this topic") */
.between-bullets-label          { margin: calc(12px * var(--fit-scale)) 0; }
.between-bullets-label p        { margin: 0; padding-left: 0.38em; line-height: 1.35; }
.reveal .slides section .between-bullets-label + .markdown-block ul { margin-top: 0; }

/* Tables */
.markdown-block table {
  width:           100%;
  border-collapse: collapse;
  margin-top:      var(--space-sm);
  font-size:       calc(24px * var(--fit-scale));
}
.markdown-block th,
.markdown-block td {
  border-bottom: 1px solid var(--color-rule);
  padding:       8px 10px;
  text-align:    left;
}
.markdown-block th {
  color:       var(--color-accent);
  font-weight: 700;
}

/* Callout / blockquote */
.markdown-block blockquote {
  margin:      calc(12px * var(--fit-scale)) 0;
  padding:     calc(10px * var(--fit-scale)) calc(20px * var(--fit-scale));
  border-left: 4px solid var(--color-accent);
  background:  rgba(36, 87, 166, 0.05);
  font-style:  normal;
}

.markdown-block blockquote p { margin: 0; }

/* Horizontal rule */
.markdown-block hr {
  border:     none;
  border-top: 1px solid var(--color-rule);
  margin:     calc(16px * var(--fit-scale)) 0;
}

/* Math: keep KaTeX's standard LaTeX-style fonts. */
.katex {
  color:       var(--color-text);
  font-size:   1em;
  line-height: 1;
}

.markdown-block .katex-display {
  max-width: 100%;
  margin:    calc(10px * var(--fit-scale)) 0 calc(14px * var(--fit-scale));
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

.markdown-block .katex-display > .katex {
  max-width: 100%;
  font-size: 1.04em;
}

.markdown-block li .katex-display {
  margin-top: calc(8px * var(--fit-scale));
}

/* Code */
.markdown-block code { font-size: 0.82em; }
.markdown-block pre {
  max-width:    100%;
  overflow:     auto;
  border-left:  3px solid var(--color-accent);
  padding-left: var(--space-sm);
  font-size:    calc(22px * var(--fit-scale));
}

/* ── Lists ────────────────────────────────────────────────────────────────── */

.reveal .slides section ul {
  margin:       calc(var(--space-sm) * var(--fit-scale)) 0 0;
  padding-left: 1.2em;
  font-size:    calc(30px * var(--fit-scale));
  line-height:  1.35;
}

.reveal .slides section li + li { margin-top: calc(12px * var(--fit-scale)); }

/* ── Title slide ──────────────────────────────────────────────────────────── */

.title-slide {
  justify-content: center !important;
  align-items:     center !important;
  text-align:      center !important;
}

.title-slide .slide-title {
  max-width:     1080px;
  margin-bottom: var(--space-sm);
  font-size:     52px;
}

.title-slide .slide-title::after {
  margin-right: auto;
  margin-left:  auto;
}

.title-slide .slide-subtitle {
  margin-top:      10px;
  color:           var(--color-text);
  font-size:       calc(27px * var(--fit-scale));
  display:         flex;
  flex-wrap:       wrap;
  justify-content: center;
  gap:             12px;
}

.title-meta-item { display: inline-flex; align-items: center; }

.title-meta-item + .title-meta-item::before {
  content:       "";
  width:         0.28em;
  height:        0.28em;
  border-radius: 50%;
  margin-right:  12px;
  background:    var(--color-accent);
}

/* ── Section slide ────────────────────────────────────────────────────────── */

.section-slide {
  justify-content: center !important;
  align-items:     center !important;
  text-align:      center !important;
}

.section-slide .slide-title { margin-bottom: 0; }
.section-slide .slide-title::after { margin-right: auto; margin-left: auto; }

/* ── Two-column layout ────────────────────────────────────────────────────── */

/* Give two-column slides more footer clearance so the column content doesn't
   bleed into the footer area, while preserving the standard slide frame. */
.reveal .slides section:has(.two-column-grid) {
  padding-bottom: 100px;
}

.two-column-grid {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   var(--space-md);
  flex:                  1;
  min-height:            0;
  overflow:              hidden;
}

.column { display: flex; flex-direction: column; overflow: hidden; }

.column h2 {
  margin:      0 0 var(--space-sm);
  color:       var(--color-accent);
  font-size:   calc(28px * var(--fit-scale));
  line-height: 1.2;
  min-height:  34px;
}

.column ul { margin-top: 0; }

/* ── Diagram layout ───────────────────────────────────────────────────────── */

.diagram-frame {
  flex:        1;
  min-height:  0;
  display:     grid;
  place-items: start center;
}

.diagram-frame .mermaid {
  width:       100%;
  margin:      0;
  display:     grid;
  place-items: center;
}

.diagram-frame svg {
  width:      100%;
  height:     auto;
  max-width:  100%;
  max-height: 480px;
}

.diagram-frame .diagram-error {
  max-width:   100%;
  color:       #9d1c1c;
  font-size:   18px;
  white-space: pre-wrap;
}

/* Reduce title spacing on diagram slides to bring the figure up */
.reveal .slides section:has(.diagram-frame) .slide-title {
  margin-bottom: calc(4px * var(--fit-scale));
}

/* Give diagram slides more room by reducing top padding */
.reveal .slides section:has(.diagram-frame) {
  padding-top: 24px;
  padding-bottom: 112px;
}

/* Image-heavy slides need explicit bounds because many images come from
   Markdown with inline max-height values. Keep them clear of the footer. */
.markdown-block img {
  display:    block;
  max-width:  100%;
  max-height: 400px !important;
  width:      auto;
  height:     auto;
  margin:     calc(12px * var(--fit-scale)) auto 0;
  object-fit: contain;
}

.reveal .slides section:has(.markdown-block img) .slide-title {
  margin-bottom: calc(12px * var(--fit-scale));
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

.slide-footer {
  position:    absolute;
  right:       var(--space-xl);
  bottom:      22px;
  left:        var(--space-xl);
  display:     grid;
  grid-template-columns: 1fr auto;
  grid-template-rows:    auto auto;
  align-items:  center;
  row-gap:      8px;
  column-gap:   var(--space-md);
  border-top:   1px solid var(--color-rule);
  padding-top:  9px;
  color:        var(--color-muted);
  font-size:    var(--footer-size);
  letter-spacing: 0.01em;
}

.section-nav {
  grid-column:     1 / -1;
  display:         flex;
  justify-content: center;
  gap:             18px;
  min-height:      18px;
}

.section-nav-item {
  appearance:    none;
  border:        0;
  border-bottom: 2px solid transparent;
  padding:       0 0 3px;
  background:    transparent;
  color:         var(--color-muted);
  cursor:        pointer;
  font:          inherit;
  font-size:     13px;
  line-height:   1;
  opacity:       0.55;
}

.section-nav-item:hover,
.section-nav-item:focus-visible {
  color:   var(--color-accent);
  opacity: 1;
}

.section-nav-item.is-active {
  border-bottom-color: var(--color-accent);
  color:               var(--color-accent);
  opacity:             1;
}

.slide-footer > :last-child { justify-self: end; }

.footer-logo {
  width:   var(--footer-logo-width);
  height:  auto;
  display: block;
}

/* ── Reveal.js chrome (we don't use) ─────────────────────────────────────── */

.reveal .controls { display: none !important; }
.reveal .progress  { display: none !important; }

/* ── PDF export ───────────────────────────────────────────────────────────── */

@media print {
  body { background: #fff !important; }
}
