/* ==========================================================================
   Original illustrations for the "What is pharmacometrics?" explainer.
   Markup is generated by tools/make_viz.py (HTML + inline SVG, no raster art).
   ========================================================================== */

.pmx__pane figure.viz {
  display: flex; flex-direction: column; align-items: stretch; min-width: 0;
  padding: clamp(16px, 2.6vw, 28px);
  background:
    radial-gradient(circle at 1px 1px, rgba(91, 58, 140, .11) 1px, transparent 1.5px) 0 0 / 18px 18px,
    linear-gradient(165deg, #F7F2FD 0%, #FFF4E6 100%);
}

.viz-label { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--purple); margin-bottom: 10px; }
.viz-label--c { text-align: center; margin: 2px 0 10px; }

/* ---------- tiles (evidence / inputs) ---------- */
.viz-tiles { display: grid; grid-template-columns: repeat(5, 1fr); }
.viz-tile {
  --c: #eee; --cf: #333;
  margin: 0 4px; padding: 14px 4px 12px; display: grid; justify-items: center; align-content: start; gap: 9px;
  text-align: center; background: #fff; border-radius: 16px; box-shadow: var(--shadow-1);
  font-size: .76rem; font-weight: 600; line-height: 1.2; color: var(--ink);
}
.viz-tile__ico { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--c); color: var(--cf); }
.viz-tile__ico .ico { width: 20px; height: 20px; }

/* ---------- flow connectors ---------- */
.viz-conn { display: block; width: 100%; height: 56px; overflow: visible; }
.viz-conn path { fill: none; stroke: var(--orange); stroke-width: 2; stroke-dasharray: 4 6; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .85; animation: vflow 1.2s linear infinite; }
@keyframes vflow { to { stroke-dashoffset: -20; } }

.viz-pill { position: relative; z-index: 1; align-self: center; display: inline-flex; align-items: center; gap: 8px; margin-top: -12px; padding: 9px 18px 9px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; font-size: .88rem; box-shadow: 0 10px 20px -10px rgba(28, 21, 48, .7); }
.viz-pill .ico { color: var(--orange); width: 18px; height: 18px; }
.viz-stem { align-self: center; width: 2px; height: 22px; background: repeating-linear-gradient(var(--orange) 0 4px, transparent 4px 8px); }

/* ---------- chart card ---------- */
.viz-card { padding: 14px 16px 16px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-2); }
.viz-card__head { display: flex; align-items: center; gap: 8px; font-family: var(--f-head); font-weight: 700; font-size: .95rem; color: var(--ink); }
.viz-card__head em { font-family: var(--f-body); font-style: normal; font-weight: 400; font-size: .82rem; color: var(--muted); }
.viz-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 4px rgba(255, 131, 3, .2); }
.viz-chart { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; }

.viz-grid line { stroke: rgba(28, 21, 48, .07); }
.viz-band { fill: rgba(255, 131, 3, .14); }
.viz-ref { stroke: rgba(28, 21, 48, .35); stroke-width: 1.3; stroke-dasharray: 4 5; }
.viz-ref--ec { stroke: var(--purple); }
.viz-axis, .viz-arrowtip { stroke: rgba(28, 21, 48, .55); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.viz-dots circle { fill: #fff; stroke-width: 2.3; transform-box: fill-box; transform-origin: center; animation: vdot .5s var(--ease) backwards; animation-delay: var(--d, 0s); }
.viz-curve { fill: none; stroke: var(--orange); stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: vdraw 1.5s .2s var(--ease) backwards; }
.viz-ec { fill: #fff; stroke: var(--purple); stroke-width: 3; }
.viz-t { font-family: var(--f-body); font-size: 13px; font-weight: 600; fill: var(--ink); }
.viz-sub { font-size: 9px; }
.viz-t--ec { fill: var(--purple); }
.viz-t--ax { font-size: 12.5px; font-weight: 500; fill: var(--muted); }
@keyframes vdot { from { opacity: 0; transform: scale(.3); } }
@keyframes vdraw { from { stroke-dashoffset: 1; } }

.viz-eq { margin: 8px 0 0; padding: 9px 12px; border-radius: 12px; background: var(--orange-50); border: 1px solid var(--orange-100); font-family: var(--f-mono); font-size: .8rem; line-height: 1.5; text-align: center; color: var(--orange-700); }
.viz-eq span { color: var(--purple); font-weight: 600; }
.viz-eq sub { font-size: .75em; }

/* ---------- honeycomb ---------- */
.viz-hex { display: block; width: 100%; max-width: 400px; margin: -10px auto -12px; overflow: visible; }
.viz-halo { fill: rgba(255, 255, 255, .6); }
.viz-cell path { stroke: #fff; stroke-width: 3; }
.viz-cell text { font-family: var(--f-head); font-weight: 700; font-size: 14px; fill: var(--ink); }
.viz-core text { font-family: var(--f-head); font-weight: 700; font-size: 13px; fill: #fff; }
.viz-cell, .viz-core { transform-box: fill-box; transform-origin: center; animation: vcell .6s var(--ease) backwards; animation-delay: var(--d, 0s); }
@keyframes vcell { from { opacity: 0; transform: scale(.6); } }

/* ---------- decision cards ---------- */
.viz-dec { display: grid; grid-template-columns: repeat(4, 1fr); }
.viz-dec__c { --c: #eee; --cf: #333; margin: 0 4px; padding: 14px 8px; display: grid; justify-items: center; align-content: start; gap: 9px; text-align: center; background: #fff; border-radius: 16px; box-shadow: var(--shadow-1); }
.viz-dec__c p { font-family: var(--f-head); font-weight: 700; font-size: .82rem; line-height: 1.25; color: var(--ink); }

/* animations wait until the block scrolls into view (only when JS is running) */
.js .pmx:not(.is-in) :is(.viz-dots circle, .viz-curve, .viz-cell, .viz-core) { animation-play-state: paused; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .viz-tiles { grid-template-columns: repeat(3, 1fr); gap: 8px 0; margin-bottom: 26px; position: relative; }
  .viz-tiles::after { content: ""; position: absolute; left: 50%; bottom: -22px; width: 2px; height: 18px; background: repeating-linear-gradient(var(--orange) 0 4px, transparent 4px 8px); }
  .viz-conn { display: none; }
  .viz-pill { margin-top: 0; }
  .viz-dec { grid-template-columns: repeat(2, 1fr); gap: 8px 0; }
  .viz-t { font-size: 17px; } .viz-sub { font-size: 12px; } .viz-t--ax { font-size: 16px; }
  .viz-hex { margin-block: 0 8px; }
}
@media (prefers-reduced-motion: reduce) { .viz-conn path { animation: none; } }
