/* Exercise-type badges */
.badge {
  display: inline-block;
  padding: 0.25em 0.75em;
  border-radius: 1em;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.badge--code-along {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}

.badge--run-read {
  background: var(--md-accent-fg-color);
  color: #fff;
}

.badge--opencode {
  background: #6d4aff;
  color: #fff;
}

/* "Done when" callout */
.done-when {
  border-left: 4px solid var(--md-accent-fg-color);
  background: var(--md-accent-fg-color--transparent);
  padding: 0.5rem 1rem;
  border-radius: 0 0.25rem 0.25rem 0;
  margin: 1.5rem 0;
}

.done-when p:last-child {
  margin-bottom: 0;
}

.done-when h2:first-child {
  margin-top: 0;
  font-size: 0.8rem;
  font-weight: 600;
}

.done-when .task-list-control + .task-list-indicator + span,
.done-when li {
  font-size: 0.7rem;
  line-height: 1.5;
}

.done-when ul.task-list {
  margin-bottom: 0.25rem;
}

.done-when ul.task-list li {
  margin-bottom: 0.1em;
}

/* Full-width, compact tables */
.md-typeset__table {
  width: 100%;
}

.md-typeset table:not([class]) {
  display: table;
  width: 100%;
}

.md-typeset table td,
.md-typeset table th {
  padding: 0.5em 0.75em;
}

/* Paper-framed diagrams keep their own palette in both site modes. */
.workshop-diagram,
.workshop-diagram-dialog {
  color-scheme: light;
  color: #1f1f1f;
  background: #fbf9f5;
  border: 1px solid #d4cbbd;
  border-radius: 0.6rem;
  padding: 0.7rem;
}

.workshop-diagram {
  margin: 1.3rem 0;
  overflow-x: auto;
}

.md-typeset .workshop-mermaid,
.workshop-diagram-dialog .workshop-mermaid {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  text-align: center;
  white-space: normal;
  font-family: Roboto, sans-serif;
}

.workshop-mermaid svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: auto;
}

.workshop-diagram-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
  position: sticky;
  left: 0;
}

.workshop-diagram-toolbar button {
  background: #fbf9f5;
  color: #4a4035;
  border: 1px solid #d4cbbd;
  border-radius: 0.25rem;
  padding: 0.35rem 0.65rem;
  min-height: 2rem;
  font: 600 0.65rem/1.4 Roboto, sans-serif;
  cursor: pointer;
}

.workshop-diagram-toolbar button:hover {
  background: #e8dcc4;
}

.workshop-diagram-toolbar button:focus-visible {
  outline: 3px solid #2e6b8a;
  outline-offset: 3px;
}

.workshop-diagram-dialog {
  width: calc(100vw - 2rem);
  height: calc(100dvh - 2rem);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 1rem;
}

.workshop-diagram-dialog[open] {
  display: flex;
  flex-direction: column;
}

.workshop-diagram-dialog::backdrop {
  background: rgb(13 18 32 / 80%);
}

.workshop-diagram-dialog .workshop-mermaid {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
}

.workshop-diagram-dialog svg {
  width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.workshop-diagram-error {
  color: #b34235;
}

@media (max-width: 600px) {
  .workshop-diagram {
    padding: 0.5rem;
  }

  .workshop-diagram[data-direction="horizontal"] .workshop-mermaid svg,
  .workshop-diagram-dialog[data-direction="horizontal"] .workshop-mermaid svg {
    min-width: 900px;
    max-width: none;
  }

  .workshop-diagram-dialog[data-direction="horizontal"] .workshop-mermaid {
    display: block;
  }

  .workshop-diagram[data-direction="horizontal"]::after {
    content: "Swipe horizontally to inspect the diagram";
    display: block;
    font: 500 0.6rem/1.5 Roboto, sans-serif;
    color: #4a4035;
    margin-top: 0.5rem;
    position: sticky;
    left: 0;
  }
}

/* Compact screenshots for the memory, voting, and event pipeline exercises */
.md-typeset .memory-screenshot,
.md-typeset .consensus-screenshot,
.md-typeset .pipeline-screenshot {
  width: 100%;
  max-width: 320px;
  margin: 1.5rem auto;
}

.md-typeset .memory-screenshot a,
.md-typeset .consensus-screenshot a,
.md-typeset .pipeline-screenshot a {
  display: block;
  border-radius: 14px;
}

.md-typeset .memory-screenshot img,
.md-typeset .consensus-screenshot img,
.md-typeset .pipeline-screenshot img {
  display: block;
  width: 100%;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.md-typeset .memory-screenshot figcaption,
.md-typeset .consensus-screenshot figcaption,
.md-typeset .pipeline-screenshot figcaption {
  margin-top: 0.6rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.65rem;
  text-align: center;
}

/* Keep selected tall diagrams compact; their dialogs retain full sizing. */
:is(.quality-loop-diagram, .compact-diagram) > :is(.workshop-diagram, .lab-diagram) svg {
  width: auto;
  max-height: 800px;
}

.md-typeset img.quality-loop-report {
  display: block;
  margin: 1rem auto;
}

.md-typeset .planning-screenshot { margin: 1.2rem auto; text-align: center; }
.md-typeset .planning-screenshot figcaption { color: var(--md-default-fg-color--light); font-size: .65rem; margin-top: .6rem; }
