:root {
  --title-height: 11%;
  --footer-height: 6%;
  --slide-padding-x: 4.5%;
  --slide-padding-top: 3.2%;
  --slide-padding-bottom: 2.4%;
  --grid-gap: 2.2%;
  --content-font-size: 0.72em;
  --content-line-height: 1.4;
  --content-block-gap: 0.52em;
  --list-indent: 1.28em;
}

.reveal {
  font-size: 32px;
}

/* Reveal keeps non-current sections hidden for accessibility during normal
   navigation. Overview needs the real slide surfaces, not only its transparent
   background proxies, so restore them while the overview is active. */
.reveal.overview .slides section[hidden] {
  display: block !important;
}

.reveal .slides section.scientific-slide {
  box-sizing: border-box;
  height: 100%;
  isolation: isolate;
  padding: var(--slide-padding-top) var(--slide-padding-x) var(--slide-padding-bottom);
  color: var(--slide-foreground);
  background: var(--slide-background);
  font-family: var(--font-sans);
  text-align: left;
}

/* Reveal's PDF layout resets every slide section to padding: 0 !important.
   Restore Quarkfoil's slide box explicitly so print/PDF uses the same content
   viewport as screen presentation mode. */
html.reveal-print .reveal .slides section.scientific-slide {
  padding: var(--slide-padding-top) var(--slide-padding-x) var(--slide-padding-bottom) !important;
}

/* Reveal's core stylesheet intentionally leaves document typography mostly
   untouched. Reset browser margins and padding inside slides so presentation
   spacing does not depend on the browser's user-agent stylesheet. */
.scientific-slide :where(h1, h2, h3, h4, h5, h6, p, ul, ol, li, blockquote, pre, figure) {
  margin: 0;
  padding: 0;
}
.scientific-slide a { color: var(--accent); text-decoration-thickness: 0.06em; text-underline-offset: 0.12em; }
.scientific-slide :where(strong, b) { font-weight: 700; }
.scientific-slide :where(em, i) { font-style: italic; }
.scientific-slide code { font-family: var(--font-mono); font-size: 0.9em; }
.scientific-slide pre {
  padding: 0.45em 0.6em;
  overflow: auto;
  background: color-mix(in srgb, var(--slide-foreground), transparent 95%);
  border-radius: 0.16em;
}
.scientific-slide pre code { font-size: inherit; }
.scientific-slide blockquote {
  padding-inline-start: 0.72em;
  color: var(--muted);
  border-inline-start: 0.12em solid var(--accent);
}

.scientific-slide .slide-frame {
  display: grid;
  grid-template-areas:
    "title"
    "core"
    "footer";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--title-height) minmax(0, 1fr) var(--footer-height);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.scientific-slide.no-title .slide-frame { grid-template-rows: 0 minmax(0, 1fr) var(--footer-height); }
.scientific-slide.no-footer .slide-frame { grid-template-rows: var(--title-height) minmax(0, 1fr) 0; }
.scientific-slide.no-title.no-footer .slide-frame { grid-template-rows: 0 minmax(0, 1fr) 0; }

.scientific-slide .slide-title {
  grid-area: title;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  margin: 0;
  color: var(--slide-foreground);
  font-family: var(--font-sans);
  font-size: 1em;
  font-weight: 650;
  line-height: 1.05;
  text-align: left;
  text-transform: none;
}
.scientific-slide .slide-title > * { width: 100%; margin: 0; color: inherit; font-family: inherit; font-weight: inherit; line-height: 1.05; text-align: inherit; text-transform: none; }
.scientific-slide .slide-title h1 { font-size: 1.55em; }
.scientific-slide .slide-title h2 { font-size: 1.28em; }
.scientific-slide .slide-title h3 { font-size: 1.05em; }
.scientific-slide .slide-title h4 { font-size: 0.9em; }
.scientific-slide .slide-title h5 { font-size: 0.78em; }
.scientific-slide .slide-title h6 { font-size: 0.68em; }
.scientific-slide .slide-title-spacer { flex: 0 0 0.65em; width: 100%; height: 0.65em; }

.scientific-slide .slide-core {
  grid-area: core;
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.slide-grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: var(--grid-gap);
}

.layout-1 .slide-grid {
  grid-template-areas: "core";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.layout-1-1 .slide-grid {
  grid-template-areas: "left right";
  grid-template-columns: minmax(0, var(--column-a)) minmax(0, var(--column-b));
  grid-template-rows: minmax(0, 1fr);
}
.layout-1-2 .slide-grid {
  grid-template-areas:
    "left top-right"
    "left bottom-right";
  grid-template-columns: minmax(0, var(--column-a)) minmax(0, var(--column-b));
  grid-template-rows: minmax(0, var(--row-a)) minmax(0, var(--row-b));
}
.layout-2-1 .slide-grid {
  grid-template-areas:
    "top-left right"
    "bottom-left right";
  grid-template-columns: minmax(0, var(--column-a)) minmax(0, var(--column-b));
  grid-template-rows: minmax(0, var(--row-a)) minmax(0, var(--row-b));
}
.layout-front .slide-grid {
  grid-template-areas: "core";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.layout-0 .slide-grid { display: none; }
.layout-free .slide-grid { display: none; }
.layout-free .slide-frame { display: none; }

.scientific-slide.layout-front { --title-height: 50%; --footer-height: 0%; }
.scientific-slide.layout-front .slide-title {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  height: 100%;
  line-height: 1.08;
}
.scientific-slide.layout-front .slide-title h1 { font-size: 1.8em; }
.scientific-slide.layout-front .slide-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.scientific-slide.layout-front .slide-footer { display: none; }

.cell-core { grid-area: core; }
.cell-left { grid-area: left; }
.cell-right { grid-area: right; }
.cell-top-left { grid-area: top-left; }
.cell-bottom-left { grid-area: bottom-left; }
.cell-top-right { grid-area: top-right; }
.cell-bottom-right { grid-area: bottom-right; }

.slide-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  font-size: var(--content-font-size);
  line-height: var(--content-line-height);
  overflow: hidden;
}

.slide-cell :where(p, li, ul, ol, blockquote, pre) { font-size: inherit; line-height: inherit; }
.slide-cell :where(h1, h2, h3, h4, h5, h6) { line-height: 1.15; text-transform: none; }
.slide-cell h1 { font-size: 1.6em; }
.slide-cell h2 { font-size: 1.35em; }
.slide-cell h3 { color: var(--accent); font-size: 1.15em; }
.slide-cell h4 { font-size: 1em; }
.slide-cell h5 { font-size: 0.9em; }
.slide-cell h6 { color: var(--muted); font-size: 0.82em; }
.slide-cell :where(ul, ol) { padding-inline-start: var(--list-indent); list-style-position: outside; }
.slide-cell li + li { margin-top: 0.18em; }
.slide-cell li > :where(ul, ol) { margin-top: 0.18em; }
.slide-cell :where(p, ul, ol, blockquote, pre, table) + :where(p, ul, ol, blockquote, pre, table) { margin-top: var(--content-block-gap); }
.slide-cell :where(h1, h2, h3, h4, h5, h6) + :where(p, ul, ol, blockquote, pre, table) { margin-top: 0.32em; }
.slide-cell :where(p, ul, ol, blockquote, pre, table) + :where(h1, h2, h3, h4, h5, h6) { margin-top: 0.72em; }
.slide-cell > .slide-content-spacer,
.overlay-markdown > .slide-content-spacer,
.shape-label > .slide-content-spacer { height: 1.4em; }
.slide-cell > :where(p, ul, ol, blockquote, pre, table) + .slide-content-spacer,
.overlay-markdown > :where(p, ul, ol, blockquote, pre) + .slide-content-spacer,
.shape-label > :where(p, ul, ol, blockquote, pre) + .slide-content-spacer { margin-top: var(--content-block-gap); }

.scientific-slide table {
  width: 100%;
  margin: 0;
  overflow: hidden;
  color: inherit;
  background: var(--slide-background);
  border: 1px solid var(--table-border);
  border-spacing: 0;
  border-radius: 0.18em;
  font-size: 0.72em;
  line-height: 1.3;
}
.scientific-slide th,
.scientific-slide td { padding: 0.48em 0.68em; text-align: left; vertical-align: top; }
.scientific-slide th {
  color: var(--slide-foreground);
  background: var(--table-header-background);
  border-bottom: 2px solid var(--accent);
  font-weight: 650;
}
.scientific-slide tbody tr:nth-child(even) { background: var(--table-stripe-background); }
.scientific-slide tbody tr:not(:last-child) td { border-bottom: 1px solid var(--table-border); }
.scientific-slide caption { margin-top: 0.45em; color: var(--muted); font-size: 0.82em; text-align: left; }
.scientific-slide table code { font-family: var(--font-mono); font-size: 0.9em; }

.slide-image,
.slide-video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
}
.slide-video { background: transparent; }
.slide-image[data-fit="contain"], .slide-video[data-fit="contain"] { object-fit: contain; }
.slide-image[data-fit="cover"], .slide-video[data-fit="cover"] { object-fit: cover; }
.slide-image[data-fit="stretch"] { overflow: hidden; }
.slide-image[data-fit="width"] {
  position: absolute;
  top: var(--image-focus-y);
  left: 0;
  width: 100%;
  height: auto;
  object-fit: contain;
  transform: translateY(var(--image-focus-y-offset));
}
.slide-image[data-fit="height"] {
  position: absolute;
  top: 0;
  left: var(--image-focus-x);
  width: auto;
  height: 100%;
  object-fit: contain;
  transform: translateX(var(--image-focus-x-offset));
}
.slide-image[data-fit="native"] {
  position: absolute;
  top: var(--image-focus-y);
  left: var(--image-focus-x);
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  transform: translate(var(--image-focus-x-offset), var(--image-focus-y-offset));
}
.arrow-svg { position: absolute; display: block; overflow: visible; pointer-events: none; }
.overlay-arrow { pointer-events: none; }

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.slide-overlay {
  position: absolute;
  box-sizing: border-box;
  min-width: 1%;
  min-height: 1%;
  pointer-events: auto;
  overflow: visible;
}
.overlay-markdown { display: block; }
.overlay-markdown > :where(p, ul, ol, blockquote, pre),
.shape-label > :where(p, ul, ol, blockquote, pre) { font-size: 0.68em; line-height: 1.38; }
.slide-overlay :where(ul, ol) { padding-inline-start: var(--list-indent); list-style-position: outside; }
.slide-overlay li { font-size: inherit; line-height: inherit; }
.slide-overlay li + li { margin-top: 0.18em; }
.slide-overlay li > :where(ul, ol) { margin-top: 0.18em; }
.overlay-markdown > :where(p, ul, ol, blockquote, pre) + :where(p, ul, ol, blockquote, pre),
.shape-label > :where(p, ul, ol, blockquote, pre) + :where(p, ul, ol, blockquote, pre) { margin-top: 0.52em; }
.slide-overlay .katex-display { margin: 0; }
.slide-overlay[data-align="left"] .katex-display,
.slide-overlay[data-align="left"] .katex-display > .katex { text-align: left; }
.slide-overlay[data-align="center"] .katex-display,
.slide-overlay[data-align="center"] .katex-display > .katex { text-align: center; }
.slide-overlay[data-align="right"] .katex-display,
.slide-overlay[data-align="right"] .katex-display > .katex { text-align: right; }
.overlay-image, .overlay-video { overflow: visible; }
.overlay-media-clip { position: absolute; inset: 0; overflow: hidden; }
.overlay-citation {
  padding: 0.35em 0.5em;
  color: var(--muted);
  background: color-mix(in srgb, var(--slide-background), transparent 8%);
  border-left: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
  font-size: 0.7em;
  line-height: 1.2;
  overflow: hidden;
}
.overlay-citation[data-citation-display="brief"] {
  padding: 0;
  background: transparent;
  border-left: 0;
  box-shadow: none;
}
.citation { color: inherit; text-decoration: none; }
.citation:hover { text-decoration: underline; }
.citation-pdf { color: inherit; font-size: 0.8em; text-decoration: none; vertical-align: 0.08em; }
.overlay-citation a { color: inherit; }
.citation-pdf:hover { filter: brightness(1.2); }
.citation-missing { color: #c92a2a; font-weight: 700; }

.overlay-shape {
  display: grid;
  place-items: center;
  isolation: isolate;
}
.shape-background {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.overlay-shape[data-shadow="true"] .shape-background {
  filter: drop-shadow(0.14em 0.18em 0.14em rgb(0 0 0 / 0.28));
}
.shape-surface {
  fill: var(--shape-fill, var(--shape-default-fill));
  stroke: var(--shape-stroke, var(--shape-default-stroke));
  stroke-width: var(--shape-stroke-width);
  stroke-dasharray: var(--shape-stroke-dasharray, none);
  stroke-linecap: var(--shape-stroke-linecap, butt);
  stroke-linejoin: round;
}
.shape-arc, .shape-brace { fill: none; }
.shape-arrow-head { fill: var(--shape-stroke, var(--shape-default-stroke)); stroke: none; }
.shape-label {
  position: absolute;
  z-index: 1;
  inset: var(--shape-label-top, 0) var(--shape-label-right, 0) var(--shape-label-bottom, 0) var(--shape-label-left, 0);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0;
  overflow: hidden;
}
.shape-label > :first-child { margin-top: 0; }
.shape-label > :last-child { margin-bottom: 0; }
.shape-label > * { width: 100%; }
.slide-footer {
  grid-area: footer;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  padding-top: 0.7%;
  color: var(--muted);
  font-size: 0.36em;
  line-height: 1.2;
}
.slide-footer p { margin: 0; }

.empty-cell-label { display: none; }
.render-error { color: #a61e4d; white-space: pre-wrap; }
