/* ============================================================ */
/* Lab 07 — per-lab styles (microagent walkthrough)              */
/* ============================================================ */

.course-frame {
  font-family: var(--serif); font-size: 17px; line-height: 1.65;
  color: var(--ink-soft); margin: 10px 0 24px 0;
  padding: 6px 0 6px 16px; border-left: 3px solid var(--accent-soft);
}
.course-frame strong { color: var(--ink); }
body.presentation-mode .course-frame {
  font-size: 22px; padding-left: 22px; margin: 14px 0 32px 0;
}

.time-tag {
  display: inline-block; margin-left: 10px; padding: 2px 8px;
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  text-transform: none; letter-spacing: 0; color: var(--ink-mute);
  background: var(--bg-elev); border: 1px solid var(--rule);
  border-radius: 10px; vertical-align: 2px;
}

pre.term-snippet {
  background: #14110d; color: #e8e1d5;
  font-family: var(--mono); font-size: 13px; line-height: 1.55;
  padding: 14px 18px; border-radius: 6px;
  overflow-x: auto; margin: 14px 0;
}
pre.term-snippet .term-comment    { color: #6fab5c; }
pre.term-snippet .term-cmd        { color: #f6efe1; }
pre.term-snippet .term-prompt-echo{ color: #b2d3e8; }

/* pre code falls back to the shared lab-base.css default (14px) — perceptually matches the 18px serif body. */

/* ============================================================
   Widget · Try it (interactive ReAct trace) — #viz-try-it
   ============================================================ */
.micro-controls {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin: 14px 0;
}
.micro-presets {
  display: inline-flex; gap: 6px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.86rem;
  color: var(--ink-mute);
}
.micro-preset {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 4px 9px;
  font-family: var(--mono); font-size: 0.85rem;
  color: var(--ink-soft); cursor: pointer;
}
.micro-preset:hover { background: #ede9dc; color: var(--ink); }
.micro-preset.active {
  background: var(--accent); color: white; border-color: var(--accent);
}
.micro-buttons { display: flex; gap: 8px; margin-left: auto; }
.micro-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; margin-bottom: 14px;
}
@media (max-width: 780px) { .micro-grid { grid-template-columns: 1fr; } }

.micro-panel {
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 12px 14px;
}
.micro-panel-title {
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute); margin-bottom: 8px;
}
.micro-trace {
  font-family: var(--mono); font-size: 0.88rem;
  line-height: 1.55; min-height: 220px;
  white-space: pre-wrap; word-break: break-word;
}
.micro-trace .micro-trace-step {
  display: block; padding: 6px 9px;
  border-left: 3px solid #c7c3b5;
  margin-bottom: 6px;
  background: white;
  border-radius: 0 4px 4px 0;
  animation: micro-step-in 220ms ease-out;
}
@keyframes micro-step-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.micro-trace .micro-trace-step.micro-action   { border-left-color: #c97a3f; }
.micro-trace .micro-trace-step.micro-obs      { border-left-color: #6f9e85; }
.micro-trace .micro-trace-step.micro-final    { border-left-color: var(--accent); background: #fde0d2; }
.micro-trace .micro-trace-tag {
  display: inline-block;
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute); margin-right: 6px;
}
.micro-trace-empty {
  color: var(--ink-mute); font-style: italic;
  font-family: var(--serif); font-size: 0.92rem;
}

.micro-context {
  font-family: var(--mono); font-size: 0.82rem;
  line-height: 1.55; max-height: 280px; overflow-y: auto;
  background: #14110d; color: #d8d2c4;
  border-radius: 5px; padding: 10px 12px;
}
.micro-context .micro-msg {
  display: block;
  margin-bottom: 8px; padding: 6px 9px;
  border-left: 2px solid #555;
  background: rgba(255,255,255,0.04);
  white-space: pre-wrap; word-break: break-word;
}
.micro-context .micro-msg-system    { border-left-color: #b2d3e8; }
.micro-context .micro-msg-user      { border-left-color: #6fab5c; }
.micro-context .micro-msg-assistant { border-left-color: #c97a3f; }
.micro-context .micro-msg-role {
  font-weight: 700; color: #f6efe1;
  font-family: var(--sans); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-right: 8px;
}

/* ============================================================
   Three-column comparison table
   ============================================================ */
.msp {
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 18px 0;
}
.msp-rows { display: flex; flex-direction: column; }
.msp-row {
  display: grid; grid-template-columns: 1.1fr 1.4fr 1.4fr 1.4fr;
  gap: 14px; padding: 6px 0;
  border-bottom: 1px dashed #d8d2c0;
  font-size: 13px;
}
.msp-row:last-child { border-bottom: none; }
.msp-row.msp-head {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute);
}
.msp-row span code {
  background: var(--bg-elev); padding: 1px 5px;
  border-radius: 3px; font-size: 0.92em;
}
.msp-foot {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif); font-size: 13px;
  color: var(--ink-soft); font-style: italic;
}
@media (max-width: 760px) {
  .msp-row { grid-template-columns: 1fr; gap: 4px; }
  .msp-row.msp-head { display: none; }
}

/* ============================================================
   Annotated code blocks (hover per-line)
   ============================================================ */
.annotated-code {
  background: #14110d; color: #e8e1d5;
  border-radius: 6px;
  padding: 12px 0;
  overflow-x: auto;
  margin: 14px 0;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.55;
}
.annotated-code .code-step {
  display: block;
  padding: 2px 16px;
  white-space: pre;
  cursor: pointer;
  transition: background 120ms;
  border-left: 3px solid transparent;
}
.annotated-code .code-step:hover,
.annotated-code .code-step.active {
  background: rgba(177, 74, 46, 0.18);
  border-left-color: var(--accent);
}
.code-explain-panel {
  margin: -8px 0 14px;
  padding: 12px 16px;
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 0 0 6px 6px;
  border-top: none;
  min-height: 60px;
  font-family: var(--serif); font-size: 14px; line-height: 1.55;
  color: var(--ink);
}
.code-explain-panel .code-explain-empty {
  color: var(--ink-mute); font-style: italic; font-size: 13px;
}
.code-explain-panel .code-explain-name {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 5px;
}
.code-explain-panel code {
  background: var(--bg-elev); padding: 1px 5px; border-radius: 3px;
}

/* ============================================================
   Exercise blocks
   ============================================================ */
.exercise {
  background: var(--bg-elev);
  border-left: 3px solid var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0 5px 5px 0;
  margin: 18px 0;
}
.exercise-q {
  display: block;
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 5px;
}
.exercise details { margin-top: 8px; }
.exercise summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.exercise details[open] summary { margin-bottom: 6px; }

/* inline download chip — sits at the end of a list item */
.inline-dl {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--accent); color: white;
  border-radius: 4px;
  text-decoration: none; font-weight: 700;
  vertical-align: 1px;
  transition: filter 150ms;
}
.inline-dl:hover { filter: brightness(1.08); color: white; }

/* ============================================================
   Widget · ReAct flow diagram — #viz-react-loop
   ============================================================ */
.react-flow-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin: 14px 0;
}
@media (max-width: 780px) { .react-flow-grid { grid-template-columns: 1fr; } }
.react-flow-svg {
  width: 100%; height: auto;
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 10px;
  font-family: var(--sans);
}
.rf-bound {
  fill: rgba(177, 74, 46, 0.04);
  stroke: var(--accent-soft);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}
.rf-bound-label {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--ink-mute);
}
.rf-node rect, .rf-node polygon {
  fill: white;
  stroke: #c7c3b5;
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 180ms, stroke 180ms;
}
.rf-node text {
  font-family: var(--sans);
  font-size: 12px;
  fill: var(--ink);
  cursor: pointer;
  user-select: none;
}
.rf-node .rf-num {
  font-family: var(--mono);
  font-weight: 700;
  fill: var(--accent);
}
.rf-node .rf-sub {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--ink-mute);
}
.rf-node .rf-mono {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--accent);
}
.rf-node:hover rect,
.rf-node:hover polygon {
  fill: #fde0d2;
  stroke: var(--accent);
}
.rf-node.active rect,
.rf-node.active polygon {
  fill: var(--accent);
  stroke: var(--accent);
}
.rf-node.active text,
.rf-node.active .rf-num,
.rf-node.active .rf-sub,
.rf-node.active .rf-mono {
  fill: white;
}
.rf-arrow {
  fill: none;
  stroke: #5a564f;
  stroke-width: 1.6;
}
.rf-arrow-yes { stroke: #2f8557; }
.rf-arrow-loop {
  stroke: var(--accent);
  stroke-dasharray: 5 4;
}
.rf-branch {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  fill: var(--ink-soft);
}
.rf-loop-label {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--accent);
  font-style: italic;
}
.react-flow-detail {
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 14px 16px;
  align-self: start;
}
.react-flow-detail-title {
  font-family: var(--sans);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}
.react-flow-detail-body {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.react-flow-detail-body strong { color: var(--ink); }
.react-flow-detail-body code {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--bg-code); padding: 1px 5px;
  border-radius: 3px;
}
.react-flow-detail-body p { margin: 0 0 8px; }
.react-flow-detail-body p:last-child { margin-bottom: 0; }
.react-flow-detail-row {
  margin-bottom: 6px;
}
.react-flow-detail-row strong {
  display: inline-block;
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-mute); margin-right: 6px;
}
/* When a flow node lights up a corresponding line in #ma-loop below */
#ma-loop .code-step.flow-active {
  background: rgba(177, 74, 46, 0.28);
  border-left-color: var(--accent);
}

/* ============================================================
   Widget · Chat with the toy agent — #viz-chat-agent
   ============================================================ */
.chat-hints {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 12px 0;
}
.chat-hint {
  background: none;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--mono); font-size: 0.82rem;
  color: var(--ink-soft); cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.chat-hint:hover {
  background: #ede9dc; color: var(--ink);
  border-color: var(--ink-mute);
}
.chat-history {
  background: #faf8f2;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 12px 14px;
  min-height: 220px; max-height: 420px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 10px;
}
.chat-bubble {
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--mono); font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  animation: chat-in 200ms ease-out;
  max-width: 88%;
}
@keyframes chat-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble-empty {
  background: none; color: var(--ink-mute);
  font-style: italic; font-family: var(--serif);
  font-size: 0.92rem; padding: 4px 0; align-self: center;
  max-width: 100%; text-align: center;
}
.chat-bubble-user {
  background: white;
  border: 1px solid var(--rule);
  align-self: flex-end;
}
.chat-bubble-think {
  background: #fde0d2;
  border-left: 3px solid var(--accent);
  align-self: flex-start;
  font-size: 0.82rem;
  color: #5a3520;
}
.chat-bubble-obs {
  background: #e3eee7;
  border-left: 3px solid #6f9e85;
  align-self: flex-start;
  font-size: 0.82rem;
  color: #2f5a47;
}
.chat-bubble-agent {
  background: var(--ink);
  color: #f6efe1;
  align-self: flex-start;
  border: 1px solid var(--ink);
}
.chat-bubble-tag {
  display: block;
  font-family: var(--sans); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  opacity: 0.75;
  margin-bottom: 4px;
}
.chat-form {
  display: flex; gap: 8px; align-items: center;
}
.chat-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--mono); font-size: 0.92rem;
  border: 1px solid var(--rule); border-radius: 5px;
  background: white; color: var(--ink);
}
.chat-form input[type="text"]:focus {
  outline: 2px solid var(--accent-soft); outline-offset: 1px;
}

/* ============================================================
   Collapsible callout — `<details class="callout note callout-collapsible">`
   ============================================================ */
.callout-collapsible { padding: 0; }
.callout-collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex; align-items: baseline; gap: 12px;
  flex-wrap: wrap;
  border-radius: 5px;
  transition: background 150ms;
}
.callout-collapsible > summary::-webkit-details-marker { display: none; }
.callout-collapsible > summary::marker { display: none; }
.callout-collapsible > summary::before {
  content: "▸";
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin-right: -6px;
  display: inline-block;
  transition: transform 180ms;
}
.callout-collapsible[open] > summary::before { transform: rotate(90deg); }
.callout-collapsible > summary:hover { background: rgba(177, 74, 46, 0.05); }
.callout-collapsible > summary .callout-toggle {
  margin-left: auto;
  font-family: var(--sans); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute); font-weight: 700;
}
.callout-collapsible[open] > summary .callout-toggle::before { content: ""; }
.callout-collapsible[open] > summary .callout-toggle { content: "click to collapse"; }
.callout-collapsible > *:not(summary) {
  padding-left: 16px; padding-right: 16px;
}
.callout-collapsible > *:last-child { padding-bottom: 14px; }

/* ============================================================ */
/*  Figures (screenshots) — e.g. the API-key setup shot         */
/* ============================================================ */
figure.lab-figure {
  margin: 14px auto 22px auto;
  max-width: 560px;
  padding: 0;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
figure.lab-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  background: #f0eee5;
}
figure.lab-figure figcaption {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-mute);
  padding: 9px 14px 10px;
  border-top: 1px solid var(--rule);
}
figure.lab-figure figcaption strong { color: var(--ink); }
figure.lab-figure figcaption code {
  background: var(--bg-code); padding: 1px 5px; border-radius: 3px;
  font-family: var(--mono); font-size: 0.92em;
}
