/* ============================================================
   diagram.css — shared look for the embedded research diagrams
   Tokens mirror base.css so the diagrams follow the site theme.
   ============================================================ */

:root, [data-theme="light"] {
  --page:      #FFFFFF;
  --card:      #FAF9F6;
  --stage:     #FFFFFF;
  --ink:       #2D2D2D;
  --muted:     #6B6B6B;
  --faint:     #A0A0A0;
  --line:      #DDD9D5;
  --line-soft: #ECEAE6;

  --primary:      #FF1493;
  --primary-soft: rgba(255, 20, 147, 0.12);
  --accent:       #8F89CF;
  --accent-soft:  rgba(143, 137, 207, 0.16);
  --coral:        #E8826F;
  --coral-soft:   rgba(232, 130, 111, 0.16);
  --indigo:       #5B4F9E;
  --gold:         #D4A853;
  --gold-dark:    #A9822F;
  --steel:        #8A8F98;
  --steel-dark:   #5F646C;
  --cool:         #3D8FB8;
  --cool-soft:    rgba(61, 143, 184, 0.14);
  --water:        #EAF3F8;
  --water-2:      #D7E8F1;
  --ok:           #4E9F62;
}

[data-theme="dark"] {
  --page:      #1C1C22;
  --card:      #18181D;
  --stage:     #141418;
  --ink:       #E4E4E8;
  --muted:     #9999A8;
  --faint:     #666678;
  --line:      #35353F;
  --line-soft: #26262D;

  --primary:      #FF4DB8;
  --primary-soft: rgba(255, 77, 184, 0.16);
  --accent:       #B8B4E3;
  --accent-soft:  rgba(184, 180, 227, 0.14);
  --coral:        #F0978A;
  --coral-soft:   rgba(240, 151, 138, 0.16);
  --indigo:       #8C82D6;
  --gold:         #D9B05E;
  --gold-dark:    #B08A3A;
  --steel:        #9AA0AA;
  --steel-dark:   #6C717A;
  --cool:         #6FB8DB;
  --cool-soft:    rgba(111, 184, 219, 0.14);
  --water:        #142029;
  --water-2:      #1A2C37;
  --ok:           #6FC285;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--page); }
body {
  font-family: 'General Sans', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
/* Standalone viewing gets breathing room; embedded fills the iframe */
html:not(.embedded) body { padding: 16px; max-width: 1100px; margin: 0 auto; }

.dg {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.dg-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.dg-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.dg-head p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.dg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.dg-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dg-legend i {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.dg-legend i.bar { border-radius: 2px; width: 14px; height: 4px; }

/* Panels: responsive grid of figure areas */
.dg-grid {
  display: grid;
  gap: 1px;
  background: var(--line);
}
.dg-panel {
  background: var(--stage);
  position: relative;
  min-width: 0;
}
.dg-panel svg, .dg-panel canvas { display: block; width: 100%; height: auto; }
.dg-panel-title {
  position: absolute;
  top: 8px; left: 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  pointer-events: none;
}

.dg-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.dg-controls .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.dg-readout {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dg-readout b { color: var(--ink); font-weight: 600; }

.btn {
  font: 600 12px/1 'General Sans', system-ui, sans-serif;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--stage);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .18s, background .18s, color .18s;
}
.btn:hover { border-color: var(--primary); }
.btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn:focus-visible, input[type=range]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: default; }

.slider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  flex: 1 1 260px;
  max-width: 460px;
}
.slider output { min-width: 64px; text-align: right; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--stage);
  box-shadow: 0 0 0 1px var(--primary);
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--stage);
}

/* SVG text defaults */
svg text { font-family: 'General Sans', system-ui, sans-serif; }
.t-label { font-size: 11px; font-weight: 500; fill: var(--muted); }
.t-small { font-size: 9.5px; font-weight: 500; fill: var(--faint); }
.t-strong { font-size: 12px; font-weight: 600; fill: var(--ink); }
.t-axis { font-size: 10px; font-weight: 500; fill: var(--muted); }

.dg-note {
  padding: 10px 18px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.dg-note b { color: var(--ink); font-weight: 600; }
