/* ============================================================================
   lab.css — Polished lab-page styling
   Loaded only by lab pages (or globally — small footprint).
   Builds on styles.css; adds exercise cards, file-tab code blocks,
   terminal output panels, hint reveals, and the copy-guard visual treatment.
   ============================================================================ */

/* --- Page width: labs are narrow for readability ---------------------------- */
.quarto-title-block { max-width: 920px; margin-left: auto; margin-right: auto; }

main#quarto-document-content { max-width: 920px; margin-left: auto; margin-right: auto; }

/* --- Lab header card (the at-a-glance block at the top of every lab) -------- */
.sdpd-lab-header {
  padding: 1.5rem 1.75rem;
  background: linear-gradient(135deg, #f8f9fc 0%, #eef2f9 100%);
  border: 1px solid #dde3ee;
  border-left: 5px solid var(--sdpd-orange, #fd7e14);
  border-radius: 8px;
  margin: 0 0 2rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.sdpd-lab-header .sdpd-lab-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0 0;
  font-size: 0.9em;
  color: #555f70;
}
.sdpd-lab-header .sdpd-lab-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.sdpd-lab-header .sdpd-rung-pill {
  display: inline-block;
  padding: 0.15rem 0.7rem;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
  color: white;
  letter-spacing: 0.03em;
}
.sdpd-rung-pill.rung-1 { background: var(--sdpd-green, #2c8c4f); }
.sdpd-rung-pill.rung-2 { background: var(--sdpd-blue, #2780e3); }
.sdpd-rung-pill.rung-3 { background: var(--sdpd-purple, #6f42c1); }
.sdpd-rung-pill.rung-4 { background: var(--sdpd-red, #c0392b); }

.sdpd-lab-header h1, .sdpd-lab-header .title { margin: 0; font-size: 1.5em; }
.sdpd-lab-header .lab-subtitle { margin: 0.25rem 0 0 0; color: #6c757d; font-size: 1.05em; }

/* --- Preflight checklist ---------------------------------------------------- */
.sdpd-preflight {
  padding: 1rem 1.25rem;
  background: #f7fbff;
  border: 1px solid #cfe2ff;
  border-radius: 6px;
  margin: 1.5rem 0;
}
.sdpd-preflight h3 { margin-top: 0; font-size: 1em; text-transform: uppercase; letter-spacing: 0.05em; color: #084298; }
.sdpd-preflight ul { list-style: none; padding-left: 0; margin: 0.5rem 0 0 0; }
.sdpd-preflight li { padding: 0.25rem 0; padding-left: 1.6rem; position: relative; }
.sdpd-preflight li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: #6c757d;
  font-size: 1.1em;
}

/* --- Exercise card (the big one) -------------------------------------------- */
.sdpd-exercise {
  background: white;
  border: 1px solid #e5e9f0;
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
}
.sdpd-exercise::before {
  content: attr(data-exercise);
  position: absolute;
  top: -0.7rem;
  left: 1.5rem;
  background: var(--sdpd-blue, #2780e3);
  color: white;
  padding: 0.2rem 0.85rem;
  border-radius: 12px;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.sdpd-exercise h2,
.sdpd-exercise h3 {
  margin-top: 0.3rem;
  font-size: 1.25em;
  color: #1a2540;
}
.sdpd-exercise .sdpd-goal {
  padding: 0.6rem 0.9rem;
  background: #fffaf0;
  border-left: 3px solid var(--sdpd-amber, #e0a800);
  border-radius: 0 4px 4px 0;
  margin: 0.5rem 0 1.25rem 0;
  font-size: 0.95em;
}
.sdpd-exercise .sdpd-goal::before {
  content: "🎯 Goal — ";
  font-weight: 600;
  color: #856404;
}

/* --- Steps within an exercise ----------------------------------------------- */
.sdpd-exercise ol > li,
.sdpd-exercise .sdpd-stepnum {
  margin: 1rem 0;
}

/* --- Code blocks: VS Code Dark+ style, with filename tab -------------------- */
/* Approximates VS Code's default Dark+ theme colours so the lab pages match
   what students see in their editor. Pandoc emits Skylighting class names
   (.kw, .dt, .st, etc.) — we override them directly.                          */
div.sourceCode {
  position: relative;
  margin: 1rem 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  background: #1e1e1e;
}
pre.sourceCode {
  margin: 0;
  padding: 1rem 1.1rem;
  background: #1e1e1e;
  color: #d4d4d4;
  font-size: 0.92em;
  line-height: 1.6;
  overflow-x: auto;
  border-radius: 6px;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", "SF Mono", "Menlo", "Consolas", monospace;
}
pre.sourceCode code { color: inherit; background: transparent; }

/* VS Code Dark+ token colours.
   See https://code.visualstudio.com/api/extension-guides/color-theme */
pre.sourceCode .kw  { color: #569cd6; }            /* keyword: public, class, static, void, return, if, else */
pre.sourceCode .cf  { color: #c586c0; }            /* control flow: for, while, switch, break */
pre.sourceCode .dt  { color: #4ec9b0; }            /* data type: int, double, String, char, boolean */
pre.sourceCode .bu  { color: #4ec9b0; }            /* builtin (System, Math, etc.) */
pre.sourceCode .at  { color: #9cdcfe; }            /* attribute / member access */
pre.sourceCode .va  { color: #9cdcfe; }            /* variable / identifier */
pre.sourceCode .fu  { color: #dcdcaa; }            /* function / method name */
pre.sourceCode .st  { color: #ce9178; }            /* string literal */
pre.sourceCode .vs  { color: #ce9178; }            /* verbatim string */
pre.sourceCode .ch  { color: #ce9178; }            /* character literal */
pre.sourceCode .sc  { color: #d7ba7d; }            /* special character (escape sequence) */
pre.sourceCode .ss  { color: #d7ba7d; }            /* special string */
pre.sourceCode .dv  { color: #b5cea8; }            /* decimal value (number) */
pre.sourceCode .fl  { color: #b5cea8; }            /* float */
pre.sourceCode .bn  { color: #b5cea8; }            /* base-N number */
pre.sourceCode .cn  { color: #569cd6; }            /* constant (true, false, null) */
pre.sourceCode .co  { color: #6a9955; font-style: italic; }  /* comment */
pre.sourceCode .do  { color: #6a9955; font-style: italic; }  /* documentation */
pre.sourceCode .an  { color: #6a9955; font-style: italic; }  /* annotation */
pre.sourceCode .cv  { color: #6a9955; font-style: italic; }  /* comment variable */
pre.sourceCode .op  { color: #d4d4d4; }            /* operator (default text) */
pre.sourceCode .er  { color: #f48771; text-decoration: underline; }  /* error */
pre.sourceCode .wa  { color: #cca700; font-weight: bold; }    /* warning */
pre.sourceCode .al  { color: #f48771; font-weight: bold; }    /* alert */
pre.sourceCode .im  { color: #569cd6; }            /* import */
pre.sourceCode .pp  { color: #569cd6; }            /* preprocessor */

/* Filename tab — when Quarto's filename="X" attribute is used, it generates
   a .code-with-filename-title <p>. Style it like a VS Code editor tab. */
.code-with-filename {
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin: 1rem 0;
}
.code-with-filename-title {
  display: inline-block;
  margin: 0 !important;
  padding: 0.4rem 1rem !important;
  background: #2d2d30;
  color: #d4d4d4 !important;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82em;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid #007acc;  /* VS Code blue accent on active tab */
}
.code-with-filename > div.sourceCode > pre.sourceCode {
  border-radius: 0 0 6px 6px;
  margin-top: -1px;
}

/* --- Copy guard visual treatment -------------------------------------------- */
pre.sourceCode.sdpd-no-copy {
  cursor: default;
  position: relative;
}
.sdpd-type-in-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  background: rgba(255, 140, 80, 0.18);
  color: #ce9178;
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.03em;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.sdpd-copy-ok-badge {
  position: absolute;
  top: 0.5rem;
  right: 2.6rem;  /* leaves room for the copy button */
  background: rgba(140, 220, 140, 0.18);
  color: #6a9955;
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.03em;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Terminal output panel (VS Code-style integrated terminal) -------------- */
.sdpd-output {
  background: #0c0c0c;
  color: #cccccc;
  padding: 0.95rem 1.1rem 0.85rem 1.1rem;
  border-radius: 6px;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.88em;
  line-height: 1.5;
  margin: 1rem 0;
  white-space: pre;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: relative;
  padding-top: 2.1rem;  /* room for the title bar */
}
.sdpd-output::before {
  content: "● ● ●   TERMINAL — expected output";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 1rem;
  background: #252526;
  color: #cccccc;
  font-size: 0.72em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0.04em;
  font-weight: 500;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #3e3e42;
}

/* --- Reveal-on-click hint --------------------------------------------------- */
details.sdpd-hint {
  margin: 1rem 0;
  padding: 0.6rem 0.9rem;
  background: #fff3cd;
  border-left: 3px solid var(--sdpd-amber, #e0a800);
  border-radius: 0 6px 6px 0;
}
details.sdpd-hint summary {
  cursor: pointer;
  font-weight: 600;
  color: #856404;
  list-style: none;
}
details.sdpd-hint summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
  font-size: 0.85em;
}
details.sdpd-hint[open] summary::before { content: "▾ "; }

/* --- Pitfalls callout ------------------------------------------------------- */
.sdpd-pitfalls {
  padding: 1rem 1.25rem;
  background: #fdf2f2;
  border: 1px solid #f5c2c7;
  border-left: 4px solid var(--sdpd-red, #c0392b);
  border-radius: 6px;
  margin: 2rem 0 1rem 0;
}
.sdpd-pitfalls h3 { margin-top: 0; font-size: 1em; color: #842029; text-transform: uppercase; letter-spacing: 0.04em; }
.sdpd-pitfalls ul { margin: 0.5rem 0 0 0; padding-left: 1.2rem; }
.sdpd-pitfalls li { margin: 0.4rem 0; }
.sdpd-pitfalls code { background: rgba(192, 57, 43, 0.08); color: #842029; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.95em; }

/* --- Grader rubric ---------------------------------------------------------- */
.sdpd-grader {
  padding: 1rem 1.25rem;
  background: #e6f4ea;
  border: 1px solid #c6e6cf;
  border-left: 4px solid var(--sdpd-green, #2c8c4f);
  border-radius: 6px;
  margin: 1.5rem 0;
}
.sdpd-grader h3 { margin-top: 0; font-size: 1em; color: #1f5d3a; text-transform: uppercase; letter-spacing: 0.04em; }
.sdpd-grader ul { list-style: none; padding-left: 0; margin: 0.5rem 0 0 0; }
.sdpd-grader li { padding: 0.25rem 0; padding-left: 1.6rem; position: relative; }
.sdpd-grader li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--sdpd-green, #2c8c4f);
  font-weight: 700;
}

/* --- Stretch tasks ---------------------------------------------------------- */
.sdpd-stretch {
  padding: 1rem 1.25rem;
  background: #f3f0ff;
  border: 1px solid #d9d0ff;
  border-left: 4px solid var(--sdpd-purple, #6f42c1);
  border-radius: 6px;
  margin: 2rem 0;
}
.sdpd-stretch h3 { margin-top: 0; font-size: 1em; color: #4d2c91; text-transform: uppercase; letter-spacing: 0.04em; }
.sdpd-stretch h3::before { content: "🚀 "; }

/* --- Submit panel ----------------------------------------------------------- */
.sdpd-submit {
  padding: 1.25rem 1.5rem;
  background: #fff8e1;
  border: 1px solid #ffe066;
  border-left: 4px solid var(--sdpd-amber, #e0a800);
  border-radius: 6px;
  margin: 2rem 0;
}
.sdpd-submit h3 { margin-top: 0; font-size: 1em; color: #664d03; text-transform: uppercase; letter-spacing: 0.04em; }
.sdpd-submit h3::before { content: "📤 "; }

/* --- Where to ask ----------------------------------------------------------- */
.sdpd-ask {
  padding: 1rem 1.25rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-left: 4px solid var(--sdpd-grey, #6c757d);
  border-radius: 6px;
  margin: 1.5rem 0;
  font-size: 0.95em;
  color: #495057;
}
.sdpd-ask h3 { margin-top: 0; font-size: 1em; color: #343a40; text-transform: uppercase; letter-spacing: 0.04em; }
.sdpd-ask h3::before { content: "💬 "; }

/* --- Annotated screenshot placeholder (used until VS Code screenshots done) - */
.sdpd-screenshot {
  padding: 1.5rem;
  background: #f8f9fa;
  border: 1px dashed #adb5bd;
  border-radius: 6px;
  margin: 1rem 0;
  text-align: center;
  color: #6c757d;
  font-size: 0.9em;
}
.sdpd-screenshot::before {
  content: "🖼 What you should see — ";
  font-weight: 600;
  color: #495057;
}

/* --- Tighter typography in labs --------------------------------------------- */
main#quarto-document-content > h2 {
  margin-top: 2.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e9f0;
}

/* ============================================================================
   Collapsible exercises — only one visible at a time.
   ============================================================================ */

/* FOUC guard: until JS marks the body ready, hide all exercises. */
body:not(.sdpd-exercises-ready) .sdpd-exercise { visibility: hidden; }

/* Default exercise card — when "current" */
.sdpd-exercise.is-current {
  border-left: 4px solid var(--sdpd-blue, #2780e3);
  scroll-margin-top: 5rem;
}

/* Locked exercises: hidden completely */
.sdpd-exercise.is-locked { display: none !important; }

/* Completed (collapsed): show a slim bar, allow re-expand on click */
.sdpd-exercise.is-done {
  padding: 0;
  background: #f0f9f3;
  border: 1px solid #c6e6cf;
  border-left: 4px solid var(--sdpd-green, #2c8c4f);
  margin: 1rem 0;
  cursor: pointer;
  transition: background-color 0.15s;
}
.sdpd-exercise.is-done:hover { background: #e6f3eb; }
.sdpd-exercise.is-done > * { display: none !important; }
.sdpd-exercise.is-done::before {
  position: static;
  display: inline-block;
  margin: 0;
}

/* The "done bar" injected by JS */
.sdpd-exercise.is-done .sdpd-done-bar {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1.25rem;
}
.sdpd-exercise .sdpd-done-bar { display: none; }
.sdpd-done-bar .sdpd-done-check {
  color: var(--sdpd-green, #2c8c4f);
  font-size: 1.2em;
  font-weight: 700;
}
.sdpd-done-bar .sdpd-done-num {
  color: var(--sdpd-green, #2c8c4f);
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sdpd-done-bar .sdpd-done-title {
  flex: 1;
  font-weight: 500;
  color: #1f5d3a;
}
.sdpd-done-bar .sdpd-done-reopen {
  font-size: 0.85em;
  color: #6c757d;
}

/* When a done exercise is re-expanded, JS adds .is-reopened to override */
.sdpd-exercise.is-done.is-reopened {
  padding: 1.5rem 1.75rem;
  background: white;
  border-left: 4px solid var(--sdpd-green, #2c8c4f);
  cursor: default;
}
.sdpd-exercise.is-done.is-reopened > * { display: revert !important; }
.sdpd-exercise.is-done.is-reopened .sdpd-done-bar { display: none !important; }

/* --- "Mark complete" button --------------------------------------------------- */
.sdpd-mark-complete {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.9rem 1.5rem;
  background: var(--sdpd-green, #2c8c4f);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
}
.sdpd-mark-complete:hover  { background: #25733f; }
.sdpd-mark-complete:active { transform: translateY(1px); }
.sdpd-mark-complete::before { content: "✓  "; font-weight: 700; }

/* ============================================================================
   Progress widget — floats top-left on desktop, hidden on narrow screens.
   ============================================================================ */
.sdpd-progress {
  position: fixed;
  top: 100px;
  left: 1.25rem;
  width: 200px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  background: white;
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.85em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  z-index: 50;
}
.sdpd-progress h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6c757d;
}
.sdpd-progress ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: pr;
}
.sdpd-progress li {
  position: relative;
  padding: 0.4rem 0 0.4rem 1.9rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.1s;
  line-height: 1.3;
}
.sdpd-progress li:hover { background: #f8f9fa; }
.sdpd-progress li::before {
  counter-increment: pr;
  content: counter(pr);
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #e9ecef;
  color: #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  font-weight: 600;
  transition: background-color 0.15s;
}
.sdpd-progress li.is-done::before {
  content: "✓";
  background: var(--sdpd-green, #2c8c4f);
  color: white;
}
.sdpd-progress li.is-current::before {
  background: var(--sdpd-blue, #2780e3);
  color: white;
}
.sdpd-progress li.is-locked {
  color: #adb5bd;
  cursor: not-allowed;
}
.sdpd-progress li.is-locked::before {
  background: #f1f3f5;
  color: #ced4da;
}
.sdpd-progress li .sdpd-progress-title {
  display: block;
  font-size: 0.95em;
  color: #495057;
}
.sdpd-progress li.is-current .sdpd-progress-title { color: #084298; font-weight: 600; }
.sdpd-progress li.is-done .sdpd-progress-title    { color: #1f5d3a; }
.sdpd-progress li.is-locked .sdpd-progress-title  { color: #adb5bd; }

.sdpd-progress-summary {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e9ecef;
  font-size: 0.8em;
  color: #6c757d;
  text-align: center;
}

/* Hide on narrow screens — TOC and content take priority */
@media (max-width: 1280px) {
  .sdpd-progress { display: none; }
}
