/* Coronary anatomy view and cine-angiogram view (ui/coronary.mjs).
   Colours come from tokens.css; the few view-specific values live here. */
:root {
  --cor-shade: #3a0d0c;
  --cor-lumen-art: #6a1220;
  --cor-lumen-ven: #1a2a5c;
  --cor-fat-hi: #fff1cf;
  --cor-fat-lo: #d8b877;
  --cor-vessel-hi: #ffb8a2;
  --cor-dusk: #b9b3dc;
  --cor-thrombus-edge: #1e0610;
  --cor-thrombus-hi: #c0707c;
  --cor-art-hi: color-mix(in srgb, var(--vessel-art) 62%, #ffe3d6);
  --cor-art-lo: color-mix(in srgb, var(--vessel-art) 78%, #4a0d18);
  --cor-ven-hi: color-mix(in srgb, var(--vessel-ven) 62%, #e6f0ff);
  --cor-ven-lo: color-mix(in srgb, var(--vessel-ven) 76%, #10214a);
  --cor-atr-hi: color-mix(in srgb, var(--myo-light) 78%, #c98a6a);
  --cor-atr-lo: color-mix(in srgb, var(--myo-deep) 86%, #5a2a3a);
  --cor-outline: color-mix(in srgb, var(--myo-deep) 70%, #3a1420);
  --cor-fat: #f6dfae;
  --cor-vessel: #d8362c;
  --cor-vessel-edge: #6e1512;
  --cor-vessel-dead: #c9bcc4;
  --cor-vessel-dead-edge: #8d7f8a;
  --cor-flow: #ffe0d2;
  --cor-ghost: #b3221c;
  --cor-thrombus: #4a1220;
  --cor-plaque: #f0cf78;
  --cor-plaque-edge: #a67c1c;
  --cor-stent: #f4f8fc;
  --cor-stent-edge: #33475c;
  --cor-struct-ink: rgba(255, 255, 255, 0.88);
  --cor-halo: var(--surface);
  --cor-ang-bezel: #0a0d10;
  --cor-ang-ink: #e9f0f4;
  --cor-ang-mark: #ffd166;
  --cor-ang-ghost: #f4fbff;
}

:root[data-theme="dark"] {
  --cor-shade: #3a0d0c;
  --cor-lumen-art: #4a0c16;
  --cor-lumen-ven: #0c1838;
  --cor-fat-hi: #ecd6a2;
  --cor-fat-lo: #a8884e;
  --cor-vessel-hi: #ffb8a2;
  --cor-dusk: #9f97cf;
  --cor-thrombus-edge: #12040a;
  --cor-thrombus-hi: #b05868;
  --cor-art-hi: color-mix(in srgb, var(--vessel-art) 70%, #ffd9cc);
  --cor-art-lo: color-mix(in srgb, var(--vessel-art) 62%, #2a0710);
  --cor-ven-hi: color-mix(in srgb, var(--vessel-ven) 70%, #dbe8ff);
  --cor-ven-lo: color-mix(in srgb, var(--vessel-ven) 62%, #091533);
  --cor-atr-hi: color-mix(in srgb, var(--myo-light) 72%, #a8684e);
  --cor-atr-lo: color-mix(in srgb, var(--myo-deep) 80%, #2e1220);
  --cor-outline: #4a1c28;
  --cor-fat: #d9bd84;
  --cor-vessel: #d8362c;
  --cor-vessel-edge: #6e1512;
  --cor-vessel-dead: #8f8494;
  --cor-vessel-dead-edge: #4c4454;
  --cor-flow: #ffe0d2;
  --cor-ghost: #b3221c;
  --cor-thrombus: #2c0a14;
  --cor-plaque: #e8c56a;
  --cor-plaque-edge: #7a5a12;
  --cor-stent: #f4f8fc;
  --cor-stent-edge: #0e1a28;
  --cor-struct-ink: rgba(255, 255, 255, 0.86);
  --cor-ang-bezel: #020406;
}

.cor-view {
  container: cor-view / inline-size;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  color: var(--ink);
  font-family: var(--font);
}

.cor-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  background:
    radial-gradient(120% 90% at 50% 38%, var(--surface) 0%, var(--surface-2) 100%);
  overflow: hidden;
}

.cor-view--angio .cor-stage {
  background: var(--cor-ang-bezel);
  border-color: color-mix(in srgb, var(--line) 60%, #000);
  padding: 6px;
}

.cor-svg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

/* ---------- caption ---------- */
.cor-caption { display: flex; flex-direction: column; gap: 8px; }
.cor-cap-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cor-cap-title { font-size: 1rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.005em; }

.cor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--ok);
  background: var(--ok-soft, transparent);
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  transition: color 0.25s, background-color 0.25s;
}
.cor-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.cor-view[data-state="occluded"] .cor-chip { color: var(--danger); background: var(--danger-soft, transparent); }
.cor-view[data-state="restoring"] .cor-chip { color: var(--warn, var(--accent)); background: color-mix(in srgb, var(--warn, var(--accent)) 14%, transparent); }
.cor-view[data-state="restoring"] .cor-chip::before { animation: cor-blink 1.1s ease-in-out infinite; }
@keyframes cor-blink { 50% { opacity: 0.25; } }

.cor-facts { display: grid; gap: 4px 0; margin: 0; }
.cor-facts[hidden] { display: none; }
.cor-fact { display: grid; grid-template-columns: minmax(104px, 34%) 1fr; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 0.86rem; line-height: 1.4; }
.cor-fact dt { color: var(--muted); }
.cor-fact dd { margin: 0; font-weight: 550; }
.cor-note { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.cor-view--angio .cor-note { color: var(--ink); }

/* ---------- anatomy: heart picture ---------- */
.cor-ground { fill: var(--ink); opacity: 0.16; }
.cor-photo { pointer-events: none; }
.cor-alpha-mask { mask-type: alpha; }
:root[data-theme="dark"] .cor-photo { filter: brightness(0.9) saturate(0.96); }

/* ---------- anatomy: territory ---------- */
.cor-terr-dusk { fill: var(--cor-dusk); mix-blend-mode: multiply; }
.cor-terr-dusk--rim { fill: none; stroke: var(--cor-dusk); stroke-linecap: round; }
.cor-terr-mott { mix-blend-mode: multiply; stroke-linecap: round; }
.cor-terr-tint { fill: var(--ischemia); }
.cor-terr-tint--rim { fill: none; stroke: var(--ischemia); stroke-linecap: round; }
.cor-terr-edge { fill: none; stroke: var(--ischemia); stroke-width: 5; }
.cor-terr-edge--rim { stroke-linecap: round; stroke-opacity: 0.5; }

/* ---------- anatomy: vessels ---------- */
.cor-v-shadow { fill: var(--cor-shade); opacity: 0.4; }
.cor-v-edge { fill: var(--cor-vessel-edge); stroke: var(--cor-vessel-edge); stroke-width: 1.5; stroke-linejoin: round; }
.cor-v-body { fill: var(--cor-vessel); }
.cor-v-hi { fill: none; stroke: var(--cor-vessel-hi); stroke-linecap: round; opacity: 0.6; }
.cor-v-dead { fill: none; stroke: var(--cor-vessel-dead-edge); stroke-linecap: butt; }
.cor-v-dead-core { fill: none; stroke: var(--cor-vessel-dead); stroke-linecap: butt; }
.cor-ostium { fill: var(--cor-lumen-art); stroke: var(--cor-vessel-edge); stroke-width: 1.4; }
.cor-ostium--ghost { fill: none; stroke: var(--cor-ghost); stroke-dasharray: 2.5 2; opacity: 0.85; }
.cor-ghost { fill: none; stroke: var(--cor-ghost); stroke-linecap: round; stroke-dasharray: 5.5 4; opacity: 0.8; }
.cor-ghost--dead { stroke: var(--cor-vessel-dead-edge); opacity: 0.85; }
.cor-flow { fill: none; stroke: var(--cor-flow); stroke-linecap: round; stroke-opacity: 0.9; }
.cor-flow--ghost { stroke-opacity: 0.5; }

.cor-lesion-pulse { fill: none; stroke: var(--block); stroke-width: 2.2; }
.cor-thrombus-body { fill: var(--cor-thrombus); stroke: var(--cor-thrombus-edge); stroke-width: 0.7; stroke-linejoin: round; }
.cor-thrombus-lobe { fill: none; stroke: var(--cor-thrombus-edge); stroke-width: 0.55; stroke-linecap: round; opacity: 0.9; }
.cor-thrombus-hi { fill: var(--cor-thrombus-hi); opacity: 0.55; }
.cor-plaque path { fill: var(--cor-plaque); stroke: var(--cor-plaque-edge); stroke-width: 0.9; stroke-linejoin: round; }
.cor-stent-under { fill: none; stroke: var(--cor-stent-edge); stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.cor-stent { fill: none; stroke: var(--cor-stent); stroke-width: 0.8; stroke-linejoin: round; stroke-linecap: round; }

/* ---------- anatomy: inset (posterior picture, 640-px units) ---------- */
.cor-inset-box { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.cor-inset-title { font: 650 10.5px var(--font); fill: var(--muted); letter-spacing: 0.01em; }
.cor-inset-v-edge { fill: none; stroke: var(--cor-vessel-edge); stroke-width: 14; stroke-linecap: round; }
.cor-inset-v { fill: none; stroke: var(--cor-vessel); stroke-width: 8.5; stroke-linecap: round; }
.cor-inset-v-edge.cor-inset-v--thin { stroke-width: 10; }
.cor-inset-v.cor-inset-v--thin { stroke-width: 5.5; }
.cor-inset-v--dead { stroke: var(--cor-vessel-dead); }
.cor-inset-dot { fill: var(--cor-thrombus); stroke: var(--block); stroke-width: 8; }

/* ---------- anatomy: labels ---------- */
.cor-view[data-labels="off"] .cor-labels,
.cor-view[data-labels="off"] .cor-ang-labels,
.cor-view[data-labels="off"] .cor-ang-note { display: none; }

.cor-lbl { font: 650 13px var(--font); fill: var(--ink); paint-order: stroke; stroke: var(--cor-halo); stroke-width: 3.5px; stroke-linejoin: round; }
.cor-lbl--terr { fill: var(--ischemia); font-weight: 700; font-size: 12px; }
.cor-lbl-struct { font: 650 10.5px var(--font); fill: var(--cor-struct-ink); letter-spacing: 0.03em; paint-order: stroke; stroke: rgba(40, 10, 14, 0.5); stroke-width: 2.4px; stroke-linejoin: round; }
.cor-leader { fill: none; stroke: var(--muted); stroke-width: 1; stroke-opacity: 0.85; }
.cor-leader--terr { stroke: var(--ischemia); stroke-dasharray: 3 2.5; }
.cor-leader-dot { fill: var(--surface); stroke: var(--muted); stroke-width: 1; }
.cor-call-lead { fill: none; stroke: var(--block); stroke-width: 1.6; stroke-linecap: round; filter: drop-shadow(0 0 0.8px var(--surface)) drop-shadow(0 0 0.8px var(--surface)); }
.cor-call-box { fill: var(--block); stroke: var(--surface); stroke-width: 1.4; }
.cor-call-text { font: 700 11.5px var(--font); fill: var(--surface); }
.cor-view[data-state="restoring"] .cor-call-box { fill: var(--warn, var(--accent)); }
.cor-view[data-state="restoring"] .cor-call-lead { stroke: var(--warn, var(--accent)); }
.cor-view[data-state="restored"] .cor-call-box { fill: var(--ok); }
.cor-view[data-state="restored"] .cor-call-lead { stroke: var(--ok); }

/* ---------- angiogram ---------- */
.cor-ang-bezel { fill: var(--cor-ang-bezel); }
.cor-ang-f0 { stop-color: #b3b8bb; }
.cor-ang-f1 { stop-color: #949a9e; }
.cor-ang-f2 { stop-color: #6b7175; }
.cor-ang-heart { fill: #23282c; opacity: 0.22; }
.cor-ang-ribs path { fill: none; stroke: #20252a; stroke-width: 15; opacity: 0.1; }
.cor-ang-spine rect { fill: #1d2226; opacity: 0.15; }
.cor-ang-pedicle { fill: #14181b; opacity: 0.16; }
.cor-ang-diaphragm { fill: #14181b; opacity: 0.5; }
.cor-ang-lung { fill: #dfe4e7; opacity: 0.16; }
.cor-ang-grain { opacity: 0.9; pointer-events: none; }
.cor-ang-ring { fill: none; stroke: #2a3036; stroke-width: 1.5; }

.cor-ang-cath { fill: none; stroke: #2b3034; stroke-width: 5.4; stroke-linecap: round; opacity: 0.78; }
.cor-ang-cath-lumen { fill: none; stroke: #848a8e; stroke-width: 2.4; stroke-linecap: round; opacity: 0.75; }
.cor-ang-cath-dye { fill: none; stroke: #101315; stroke-width: 2.6; stroke-linecap: round; }
.cor-ang-dyepath { fill: none; stroke: #0f1214; stroke-linecap: butt; }
.cor-ang-puff, .cor-ang-stain { fill: #0f1214; }
.cor-ang-ghost { fill: none; stroke: var(--cor-ang-ghost); stroke-width: 1.1; stroke-dasharray: 4 3.2; stroke-linecap: round; opacity: 0.82; }
.cor-ang-terr { fill: var(--cor-ang-mark); fill-opacity: 0.07; stroke: var(--cor-ang-mark); stroke-width: 1.3; stroke-dasharray: 2 5; stroke-linecap: round; stroke-opacity: 0.7; }
.cor-ang-wire { fill: none; stroke: #15191c; stroke-width: 0.9; stroke-linecap: round; stroke-linejoin: round; }
.cor-ang-wire--tip { stroke-width: 2; }
.cor-ang-balloon { fill: #1a1e21; fill-opacity: 0.5; stroke: #101315; stroke-width: 0.9; }
.cor-ang-marker { fill: #050607; }
.cor-ang-stent { fill: none; stroke: #0b0d0f; stroke-width: 0.7; stroke-opacity: 0.6; stroke-linejoin: round; }

.cor-ang-lbl { font: 650 12px var(--font); fill: var(--cor-ang-ink); paint-order: stroke; stroke: rgba(8, 10, 12, 0.72); stroke-width: 3px; stroke-linejoin: round; }
.cor-ang-note { font: 650 11.5px var(--font); fill: var(--cor-ang-ghost); paint-order: stroke; stroke: rgba(8, 10, 12, 0.78); stroke-width: 3px; stroke-linejoin: round; }
.cor-ang-mark-line { fill: none; stroke: var(--cor-ang-mark); stroke-width: 2; stroke-linecap: round; }
.cor-ang-mark-head { fill: var(--cor-ang-mark); stroke: var(--cor-ang-mark); stroke-width: 1; stroke-linejoin: round; }
.cor-ang-mark-text { font: 750 12.5px var(--font); fill: var(--cor-ang-mark); paint-order: stroke; stroke: rgba(8, 10, 12, 0.82); stroke-width: 3.2px; stroke-linejoin: round; }
.cor-view[data-state="restored"] .cor-ang-mark-text { fill: #9be7b8; }
.cor-view[data-state="restored"] .cor-ang-mark-line { stroke: #9be7b8; }
.cor-view[data-state="restored"] .cor-ang-mark-head { fill: #9be7b8; stroke: #9be7b8; }
.cor-ang-overlay text { font: 600 11px var(--mono); fill: #c9d6dd; letter-spacing: 0.04em; }

/* Small containers: keep SVG lettering legible when the art scales down. */
@container cor-view (max-width: 420px) {
  .cor-lbl { font-size: 14.5px; }
  .cor-lbl--terr { font-size: 12.5px; }
  .cor-call-text { font-size: 12.5px; }
  .cor-ang-lbl, .cor-ang-note { font-size: 13.5px; }
  .cor-ang-mark-text { font-size: 14px; }
  .cor-ang-overlay text { font-size: 12.5px; }
  .cor-inset-title { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .cor-chip { transition: none; }
  .cor-view[data-state="restoring"] .cor-chip::before { animation: none; }
}
