/* Diagram + lesson helpers for the Microservices course. Colors come from the site theme. */
.fig {
  margin: 1rem 0 1.5rem;
}

.fig figcaption {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.lesson-video {
  margin: 0 0 2rem;
}

.lesson-video video {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.lesson-video figcaption {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.45rem;
}

.dg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.dg text {
  font-family: var(--font);
  fill: var(--text);
  font-size: 12px;
}

.dg .t {
  font-weight: 400;
}

.dg .th {
  font-weight: 650;
}

.dg .hd {
  font-weight: 650;
  font-size: 12.5px;
  fill: var(--accent);
}

.dg .ts {
  fill: var(--muted);
  font-size: 11px;
}

.dg .bx {
  stroke-width: 1;
}

.dg .bx-gray {
  fill: var(--surface-2);
  stroke: var(--border);
}

.dg .bx-teal {
  fill: color-mix(in srgb, var(--good) 16%, var(--surface));
  stroke: var(--good);
}

.dg .bx-coral {
  fill: color-mix(in srgb, var(--bad) 14%, var(--surface));
  stroke: var(--bad);
}

/* "Key idea" boxes use a fixed indigo: in some site palettes --accent is close to
   --good, which made coordinator boxes look like ordinary service boxes. */
.dg .bx-purple {
  fill: color-mix(in srgb, #6d5fd8 16%, var(--surface));
  stroke: #6d5fd8;
}

.dg .bx-amber {
  fill: color-mix(in srgb, var(--warn) 18%, var(--surface));
  stroke: var(--warn);
}

.dg .cont {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}

.dg .ln {
  stroke: var(--muted);
  stroke-width: 1.3;
  fill: none;
}

.dg .ln.dash {
  stroke-dasharray: 5 4;
}

.dg .life {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.dg .ah {
  fill: var(--muted);
}

table.plain th {
  width: auto;
  font-family: var(--font);
  color: var(--text);
  font-size: 0.9rem;
}

details {
  margin-top: 0.5rem;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 650;
}

.recap li {
  margin: 0.35rem 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.25rem 0 1rem;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: -1px;
  border: 1px solid var(--border);
}

.legend .teal::before {
  background: color-mix(in srgb, var(--good) 30%, var(--surface));
}

.legend .coral::before {
  background: color-mix(in srgb, var(--bad) 28%, var(--surface));
}

.legend .purple::before {
  background: color-mix(in srgb, #6d5fd8 30%, var(--surface));
}

.legend .amber::before {
  background: color-mix(in srgb, var(--warn) 32%, var(--surface));
}

.legend .gray::before {
  background: var(--surface-2);
}


/* Phones: keep diagram text readable by letting the figure scroll sideways
   instead of shrinking a 680-unit drawing to a few hundred pixels. */
@media (max-width: 640px) {
  .fig {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .fig .dg {
    min-width: 560px;
  }
}

.fig:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 10px;
}

/* "On this page" table of contents */
.toc {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.75rem 1rem;
  margin: 1rem 0 1.5rem;
}

.toc-title {
  margin: 0 0 0.35rem;
  font-weight: 650;
  font-size: 0.9rem;
}

.toc ol {
  margin: 0;
  padding-left: 1.25rem;
  columns: 2 14rem;
  column-gap: 2rem;
  font-size: 0.9rem;
}

.toc li {
  margin: 0.15rem 0;
  break-inside: avoid;
}

h2[id] {
  scroll-margin-top: 5rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Labels drawn across sequence-diagram lifelines get a halo in the surface color */
.dg .halo {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}
