@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap');

:root {
  --axis-x: #d62828;
  --axis-y: #2a9d3f;
  --axis-z: #2f6ed3;
}

/* Global reveal surface + typography */
.reveal {
  font-family: 'Quicksand', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f8f9fa;
  color: #333;
}

.reveal h1,
.reveal h2,
.reveal h3,
.reveal h4,
.reveal h5,
.reveal h6 {
  color: #1c5b84;
  text-transform: none;
  font-family: 'Quicksand', sans-serif;
}

.reveal .axis-x {
  color: var(--axis-x);
  font-weight: 700;
}

.reveal .axis-y {
  color: var(--axis-y);
  font-weight: 700;
}

.reveal .axis-z {
  color: var(--axis-z);
  font-weight: 700;
}

.reveal a {
  color: #007bff;
  text-decoration: none;
  transition: color .15s ease;
}

.reveal a:hover {
  color: #0056b3;
  text-decoration: underline;
}

.reveal blockquote {
  border-left: 4px solid #007bff;
  background: #f1f3f5;
  padding: 15px;
  font-style: italic;
  color: #495057;
}

.reveal .progress {
  background: rgba(0, 0, 0, .2);
  color: #007bff;
  height: 4px;
}

.reveal .slides section {
  padding-top: 40px !important;
  padding-bottom: 40px !important;
}

.reveal pre code {
  max-height: unset !important;
  overflow-y: auto !important;
}

.reveal ol li {
  list-style-position: outside !important;
  margin-left: 40px !important;
  padding-left: 0 !important;
}

.reveal ul li {
  margin-left: 40px !important;
  padding-left: 0 !important;
}

/* Nice surface for embeds (if you want an outer frame) */
.embed-surface {
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(28, 91, 132, 0.12);
}

/* Consistent treatment for photographic media cards */
.reveal img.photo-card {
  border-radius: 12px;
  border: 2px solid #d9e4ee;
  box-shadow: 0 6px 18px rgba(28, 91, 132, 0.15);
  object-fit: cover;
}

/* Section-divider slides for Part transitions */
.reveal .slides section.section-divider {
  background: linear-gradient(135deg, #0f4c75 0%, #1c5b84 55%, #3282b8 100%);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  overflow: hidden !important;
  max-height: none !important;
}

.reveal .slides section:has(> h1.section-divider) {
  background: linear-gradient(135deg, #0f4c75 0%, #1c5b84 55%, #3282b8 100%);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  overflow: hidden !important;
  max-height: none !important;
}

.reveal .slides section.section-divider h1 {
  color: #ffffff;
  font-size: 2.1em;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.reveal .slides section:has(> h1.section-divider) h1.section-divider {
  color: #ffffff;
  font-size: 2.1em;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

/* Match earlier weeks' handling of large diagrams */
.reveal .diagram-scroll {
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.reveal .diagram-scroll img {
  max-width: none;
  height: auto;
}

.reveal .diagram-scroll img.diagram-register {
  width: 115%;
}

.reveal .diagram-scroll img.diagram-moder {
  width: 130%;
}

.reveal section iframe.r-stretch {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  display: block;
}

/* Hide heading specifically for the PWM animation slide to avoid duplicate titles */
.reveal .slides section#pwm-duty-cycle-vs-mean-value-interactive>h2 {
  display: none !important;
}

/* Hide heading for STM32F401 PWM visualizer slide to avoid duplicate titles */
.reveal .slides section#pwm-visualizer>h2 {
  display: none !important;
}

/* Hide heading for PWM -> RC filter slide to avoid duplicate titles */
.reveal .slides section#pwm-rc-filter>h2 {
  display: none !important;
}

/* Hide any section explicitly marked as hidden */
.reveal .slides section.hidden {
  display: none !important;
}

/* Tighten space below lists on definition slides */
#what-is-a-timer ul:last-child {
  margin-bottom: 0.2rem;
}

/* Optional utility to make any single child fill the slide */
.fill-slide {
  height: 100%;
  width: 100%;
  display: grid;
}

.fill-slide>* {
  align-self: stretch;
  justify-self: stretch;
}

/* Quarto bundles a reset that sets `div.columns { display: initial; gap: initial }`,
 * which collapses the columns container to `display: inline` and produces a large
 * empty gap above the content on reveal.js slides. Force it back to flex, and
 * align children to the top so text columns don't get pushed down next to taller
 * image columns. */
.reveal .slides section .columns {
  display: flex !important;
  gap: 0.4rem !important;
  align-items: flex-start;
}

/* Half-slide animation: large but not full-screen */
/* Keep animation with consistent aspect ratio, not full-height */
iframe.half-anim {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: 60vh;
  display: block;
}

/* Taller embed variant for complex interactive visuals */
iframe.tall-anim {
  width: 100%;
  height: 88vh;
  max-height: 88vh;
  display: block;
}

/* Week 4 mobile checkpoints (same as Week 3): light, interactive, and sized for a 16:9 slide. */
.reveal .slides section.mobile-activity-slide {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  overflow: hidden !important;
}

.reveal .slides section.mobile-activity-slide > h2 {
  margin-top: 0 !important;
  margin-bottom: 0.2em !important;
}

.reveal .slides section.mobile-activity-slide iframe.mobile-activity {
  width: 100% !important;
  height: 72vh !important;
  max-height: 650px !important;
  display: block;
  border: 0;
  background: #ffffff;
}

/* Reduce padding and maximize vertical room on the PWM visualizer slide */
.reveal .slides section#pwm-visualizer {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}

/* Rotation Matrix Explorer slide: full-width interactive without slide scroll */
.reveal .slides section#rotation-matrix-explorer-interactive {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  overflow: hidden !important;
}

.reveal .slides section#rotation-matrix-explorer-interactive iframe {
  width: 100% !important;
  height: 68vh !important;
  max-height: 68vh !important;
  display: block;
}

.reveal .slides section#rotation-matrix-explorer-interactive > p {
  margin: 0.25rem 0 0.35rem !important;
  font-size: 0.8em !important;
}

/* RC filter slide: ensure no scroll and tighter padding; slightly shorter iframe */
.reveal .slides section#pwm-rc-filter {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  overflow: hidden !important;
}

.reveal .slides section#pwm-rc-filter iframe {
  height: 88vh;
  max-height: 88vh;
}

/* Input Capture interactive slide: no scroll, larger iframe */
.reveal .slides section#input-capture-interactive {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  overflow: hidden !important;
}

.reveal .slides section#input-capture-interactive>h2 {
  display: none !important;
}

.reveal .slides section#input-capture-interactive iframe {
  height: 88vh;
  max-height: 88vh;
}

/* Aliasing animation slide: hide title and maximize iframe */
.reveal .slides section#aliasing-in-action {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  overflow: hidden !important;
}

.reveal .slides section#aliasing-in-action>h2 {
  display: none !important;
}

.reveal .slides section#aliasing-in-action iframe {
  height: 88vh !important;
  max-height: 88vh !important;
  width: 100% !important;
  display: block;
}

/* ============================================
   TABLES: Clean bordered style
   ============================================ */
.reveal table {
  border-collapse: collapse;
  width: auto;
  margin: 0.5em auto;
  font-size: 0.85em;
}

.reveal table th,
.reveal table td {
  border: 1px solid #c8d6e5;
  padding: 0.35em 0.7em;
  text-align: center;
}

.reveal table th {
  background: #1c5b84;
  color: #ffffff;
  font-weight: 600;
}

/* Inline code inside dark header cells: the default code colour is too dark on #1c5b84 */
.reveal table th code {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  padding: 0 0.2em;
  border-radius: 3px;
}

.reveal table tr:nth-child(even) {
  background: #eef3f8;
}

.reveal table tr:nth-child(odd) {
  background: #ffffff;
}

/* Compact table: shrink first two columns, let last column expand */
.reveal .compact-params table th:nth-child(1),
.reveal .compact-params table td:nth-child(1) {
  white-space: nowrap;
  width: 1%;
}

.reveal .compact-params table th:nth-child(2),
.reveal .compact-params table td:nth-child(2) {
  white-space: nowrap;
  width: 1%;
}

/* ============================================
   FANUC TP Syntax Highlighting (pastel palette)
   ============================================ */
/* Motion commands: J, L, C — soft green */
.reveal pre code span.kw { color: #27856a; font-weight: 600; }
/* Control flow: IF, FOR, JMP, WAIT, LBL — muted purple */
.reveal pre code span.cf { color: #8e6aad; font-weight: 600; }
/* I/O: DI[], DO[], ON, OFF, PULSE — soft coral */
.reveal pre code span.bu { color: #c0392b; font-weight: 600; }
/* Data: R[], PR[], P[] — soft blue */
.reveal pre code span.va { color: #4a86c8; }
/* Termination: FINE, CNT — teal */
.reveal pre code span.at { color: #2a8a8a; font-weight: 600; }
/* Speed/time values: 100%, 500mm/sec, .50(sec) — muted brown */
.reveal pre code span.fl { color: #8a6d3b; }
/* Numbers inside brackets — keep default */
.reveal pre code span.dv { color: #555; }
/* Directives: /PROG, /END, OWNER — muted gray italic */
.reveal pre code span.pp { color: #888; font-style: italic; }
/* Comments: ! ... — light gray italic */
.reveal pre code span.co { color: #999; font-style: italic; }
/* Strings — muted blue */
.reveal pre code span.st { color: #4a86c8; }
/* Labels :Home, :Gripper — same as numbers */
.reveal pre code span.an { color: #555; }
/* Line numbers — very subtle */
.reveal pre code span.sc { color: #aaa; }

/* Larger code blocks — use absolute size to override .smaller scaling */
.reveal .slides section.larger-code pre code {
  font-size: 22px !important;
  line-height: 1.45 !important;
}

/* Smaller text utility */
.reveal .smaller-text {
  font-size: 0.7em !important;
}

/* Even smaller text utility */
.reveal .tiny-text {
  font-size: 0.5em !important;
}

/* Force vertical scrolling for slides with .scrollable class */
.reveal .slides section.scrollable {
  overflow-y: auto !important;
  display: block !important;
  height: 100% !important;
  max-height: 850px !important;
  /* Slightly less than 900 to avoid bottom clip */
  padding-bottom: 50px !important;
  /* Ensure last line is not right at edge */
  box-sizing: border-box !important;
}

/* ============================================
   DEFAULT: Scroll only when content overflows
   ============================================ */
.reveal .slides section {
  overflow-y: auto !important;
  max-height: 850px !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Hide scrollbars while preserving scroll behavior */
.reveal .slides section::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* ============================================
   MERMAID DIAGRAMS: Light background + larger text
   ============================================ */
.reveal .mermaid {
  background: #f8f9fa !important;
  border-radius: 8px;
  padding: 20px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Force light node backgrounds */
.reveal .mermaid .node rect,
.reveal .mermaid .node circle,
.reveal .mermaid .node ellipse,
.reveal .mermaid .node polygon,
.reveal .mermaid .node path {
  fill: #e9ecef !important;
  stroke: #1c5b84 !important;
  stroke-width: 2px !important;
}

/* Subgraph backgrounds */
.reveal .mermaid .cluster rect {
  fill: #ffffff !important;
  stroke: #1c5b84 !important;
}

/* Make text 50% larger */
.reveal .mermaid text {
  font-size: 18px !important;
}

.reveal .mermaid .nodeLabel,
.reveal .mermaid .label,
.reveal .mermaid .edgeLabel,
.reveal .mermaid .cluster-label {
  font-size: 18px !important;
}

.reveal .mermaid .edgeLabel {
  background-color: #f8f9fa !important;
}

/* Flowchart specific */
.reveal .mermaid .flowchart-link {
  stroke: #1c5b84 !important;
}

.reveal .mermaid marker path {
  fill: #1c5b84 !important;
}

/* ============================================
   PART TITLE SLIDES: Vertically centered
   ============================================ */
.reveal .slides section.center-vertical,
.reveal .slides section[data-vertical-center="true"] {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  text-align: center !important;
  height: 100% !important;
}

/* Auto-detect "Part X:" slides - these have only an h2 with "Part" in it */
.reveal .slides section > h2:only-child {
  margin-top: auto !important;
  margin-bottom: auto !important;
}

/* ============================================
   FLOW UTILITIES + OPTIONAL TRACK MARKERS
   ============================================ */
.reveal .slides section.flow-bridge {
  background: linear-gradient(135deg, #eef6ff 0%, #dbeeff 100%);
  border-left: 8px solid #1c5b84;
}

.reveal .slides section.checkpoint {
  background: linear-gradient(135deg, #f4f8fb 0%, #eaf2f9 100%);
  border: 2px dashed #5d88a8;
  border-radius: 14px;
  box-sizing: border-box !important;
  overflow-y: hidden !important;
}

.reveal .slides section.appendix-gateway {
  background: linear-gradient(135deg, #fff8e8 0%, #fff2cf 100%);
  border-left: 8px solid #b98200;
}

.reveal .slides section.backup:not(.section-divider) {
  background: linear-gradient(180deg, #fff9ef 0%, #fff3dc 100%);
  border-left: 6px solid #d39522;
}

.reveal .slides section.backup:not(.section-divider)::before {
  content: "BACKUP";
  position: absolute;
  top: 10px;
  right: 14px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #d39522;
  color: #fff;
  font-size: 0.48em;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.reveal .slides section.async:not(.section-divider) {
  background: linear-gradient(180deg, #eefaf4 0%, #e2f5ea 100%);
  border-left: 6px solid #1f8b5c;
}

.reveal .slides section.async:not(.section-divider)::before {
  content: "POST-CLASS";
  position: absolute;
  top: 10px;
  right: 14px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #1f8b5c;
  color: #fff;
  font-size: 0.48em;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* Week 4 programming utilities */
.reveal pre {
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}

.reveal pre code {
  display: block;
  white-space: pre;
  font-size: 0.9em;
}

.reveal code {
  color: #111;
}

.reveal li code:not(.sourceCode):not([class*="language-"]) {
  color: #1c5b84;
  font-weight: 700;
}

.reveal div.checkpoint {
  margin-top: 0.8rem;
  padding: 0.65rem 0.9rem;
  border-left: 6px solid #1c5b84;
  border-radius: 8px;
  background: #eaf2f9;
}

.reveal .reference-diagram {
  display: grid;
  grid-template-columns: 42% 58%;
  align-items: center;
  gap: 1rem;
  margin: 1rem auto;
  max-width: 78%;
}

.reveal .reference-name,
.reveal .reference-object {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8em;
  line-height: 1.7;
}

.reveal .reference-name {
  text-align: right;
  background: #eef4f8;
}

.reveal .reference-object {
  border: 3px solid #1c5b84;
  background: #fff;
  text-align: center;
}

.reveal table {
  font-size: 0.72em;
}

.reveal .columns .column pre {
  margin-top: 0.25rem;
}

.reveal svg.ref-svg {
  display: block;
  width: 900px;
  max-width: 100%;
  height: auto;
  margin: 0.8rem auto;
}
