/* AMC Reasoning Lab — diagram styling.
   Inherits the app's tokens from index.html (--line, --muted, --blue, …). */

.dg {
  margin: 0;
  border: 1px solid var(--line, #e5eaf1);
  border-radius: 20px;
  background: linear-gradient(160deg, #fdfdff, #f7f9fe);
  overflow: hidden;
}

.dg-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 15px 18px 0;
  flex-wrap: wrap;
}
.dg-kind {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--blue, #4568f2);
  background: var(--blue-soft, #eef2ff);
  border-radius: 999px;
  padding: 4px 9px;
}
.dg-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.012em;
  color: var(--ink, #172033);
  min-width: 0;
}

.dg-canvas {
  padding: 14px 18px 4px;
  display: block;
}
.dg-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 460px;
  /* max-width is set inline per-diagram (see syncSvgBounds in diagram.js) to
     match the content's real aspect ratio, so a portrait-shaped diagram
     (taller than wide) shrinks in width along with height instead of
     leaving the height clamp squeeze it while width stays at 100%. */
  margin: 0 auto;
  overflow: visible;
  font-family: 'DM Sans', sans-serif;
}
.dg-compact .dg-canvas { padding: 10px; }
.dg-compact .dg-svg { max-height: 220px; margin: 0; }

/* White halo behind labels keeps them readable over shaded regions. */
.dg-label.dg-halo {
  paint-order: stroke fill;
  stroke: #ffffff;
  stroke-width: 3.5px;
  stroke-linejoin: round;
}

/* Reveal sequencing --------------------------------------------------- */

.dg-item {
  transition: opacity .34s ease, transform .34s cubic-bezier(.2, .8, .25, 1);
  transform-box: fill-box;
  transform-origin: center;
}
.dg-item.dg-pending {
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
}
.dg-item.dg-off { display: none; }

.dg-xray { mix-blend-mode: multiply; }

.dg-pulse-key [data-key] .dg-face-mark,
.dg-pulse-key [data-key] > polygon:last-of-type { animation: dgPulse 2.1s ease-in-out infinite; }
@keyframes dgPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* Legend and caption --------------------------------------------------- */

.dg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 18px 2px;
}
.dg-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: #55617a;
  background: #ffffff;
  border: 1px solid var(--line, #e5eaf1);
  border-radius: 999px;
  padding: 4px 10px 4px 7px;
}
.dg-chip i {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  border: 1.5px solid;
  flex: 0 0 auto;
}

.dg-caption {
  padding: 9px 18px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted, #6f7b91);
}
.dg-compact .dg-caption { padding: 4px 10px 10px; font-size: 12px; }

/* Controls ------------------------------------------------------------- */

.dg-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 16px;
  border-top: 1px solid var(--line, #e5eaf1);
  background: rgba(255, 255, 255, .8);
}
.dg-spacer { flex: 1; }

.dg-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--blue-soft, #eef2ff);
  color: var(--blue, #4568f2);
  transition: background .15s ease, color .15s ease;
}
.dg-btn:hover { background: #e2e9ff; }
.dg-btn-ghost {
  background: transparent;
  border-color: var(--line, #e5eaf1);
  color: var(--muted, #6f7b91);
}
.dg-btn-ghost:hover { background: #f2f5fa; color: #47546b; }
.dg-btn:focus-visible,
.dg-dot:focus-visible { outline: 2px solid var(--blue, #4568f2); outline-offset: 2px; }

.dg-dots { display: flex; gap: 5px; }
.dg-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #d7dfea;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.dg-dot.is-on { background: var(--blue, #4568f2); transform: scale(1.15); }

.dg-step {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted, #6f7b91);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .dg-item { transition: none; }
  .dg-pulse-key [data-key] .dg-face-mark,
  .dg-pulse-key [data-key] > polygon:last-of-type { animation: none; }
}

@media (max-width: 600px) {
  .dg-canvas { padding: 10px 12px 2px; }
  .dg-head { padding: 12px 13px 0; }
  .dg-legend, .dg-caption { padding-left: 13px; padding-right: 13px; }
  .dg-bar { padding: 10px 12px; }
  .dg-svg { max-height: 320px; }
}
