/* Shared medical visuals (public/js/medviz/): the 12-lead paper ECG, the
   bedside monitor panel, the swept live trace and the small still traces.
   Shapes only; see DESIGN.md §9. */

/* 12-lead paper ECG (ecg12.js: Electro Detective, the ECG ficha, SCA's home) */
.ecg { background: #FFF4F4; color: #1A1A2E; border: 2px solid var(--ink); border-radius: 10px; padding: 6px; margin: 10px 0 4px; }
.ecg .cap { font-size: 12px; font-weight: 700; color: #8A2A4E; letter-spacing: .05em; text-transform: uppercase; padding: 0 4px 4px; }
.ecg .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.ecg .grid.x5 { grid-template-columns: repeat(5, 1fr); margin-top: 6px; }
.ecg .xl { font-size: 12px; font-weight: 700; color: #8A2A4E; margin: 8px 4px 0; }
.lead { position: relative; display: block; width: 100%; padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; min-height: 0; font: inherit; }
.lead svg { display: block; width: 100%; height: auto; }
.lead .ln { position: absolute; top: 2px; left: 5px; font-size: 12px; font-weight: 700; color: #1A1A2E; background: rgba(255, 237, 238, .85); padding: 0 3px; border-radius: 3px; }
button.lead { cursor: pointer; min-height: 44px; }
button.lead[aria-pressed="true"] { border-color: #1A1A2E; background: rgba(15, 139, 108, .22); box-shadow: 2px 2px 0 #1A1A2E; }
button.lead.ok { border-color: #0F8B6C; background: rgba(15, 139, 108, .22); }
button.lead.miss { border-color: #C62839; border-style: dashed; }
button.lead.extra { border-color: #C62839; background: rgba(198, 40, 57, .16); }
@media (max-width: 480px) { .ecg { padding: 4px; } .ecg .grid { gap: 2px; } .lead .ln { font-size: 10px; top: 1px; left: 2px; } }
.monitor { background: #0B1A1E; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 6px 6px 0 var(--ink); padding: 10px 12px 8px; color: #CFF7E6; margin: 0 0 22px; }
.monitor .mhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: #7FD9B7; }
.monitor .mhead b { font-family: var(--slab); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 26px; color: #3BF0A8; line-height: 1; }
.monitor .mhead .alarm { color: #FFB347; }

/* ACLS home: the bedside monitor (same frame as SCA's). Channels share one time
   base (--upx), so each pleth pulse sits under its QRS; one color per parameter. */
.monitor .scope { margin-top: 8px; display: grid; grid-template-columns: minmax(0, 1fr) 176px; gap: 10px;
  background: #0E1729; border: 2px solid #1F3A3A; border-radius: 10px; padding: 8px; }
.monitor .chans { display: grid; gap: 6px; min-width: 0; }
.monitor .chan { position: relative; --upx: .96px; color: #35F29A; }
.monitor .chan.spo2 { color: #4FD8F5; }
.monitor .chan.resp { color: #F5D547; }
.monitor .chan .cl { position: absolute; left: 6px; top: 3px; z-index: 1; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.monitor .screen { position: relative; height: 104px; overflow: hidden; border-radius: 6px; --lw: 2.4; --glow: 1;
  background-image: linear-gradient(rgba(53,242,154,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(53,242,154,.08) 1px, transparent 1px); background-size: 14px 14px; }
.monitor .chan.spo2 .screen, .monitor .chan.resp .screen { height: 48px; --lw: 2; }
.monitor .screen .sweep { inset: 16px 0 4px; }
.monitor .chan.spo2 .sweep, .monitor .chan.resp .sweep { inset: 6px 0 2px; }
.monitor .vitals { display: grid; gap: 6px; align-content: start; }
.monitor .vit { background: #131F38; border-radius: 8px; padding: 4px 10px 6px; color: #F3EAD8; line-height: 1.1; }
.monitor .vit small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.monitor .vit b { font-family: var(--slab); font-weight: 400; font-size: 28px; font-variant-numeric: tabular-nums; }
.monitor .vit .u { font-size: 12px; margin-left: 5px; opacity: .8; }
.monitor .vit.hr { color: #35F29A; }
.monitor .vit.spo2 { color: #4FD8F5; }
.monitor .vit.resp { color: #F5D547; }
.monitor .vit.nibp b { font-size: 22px; }
.monitor .vit.temp b { font-size: 20px; }
.monitor .heart { display: inline-block; color: #FF6B7A; font-size: .7em; margin-left: 6px; vertical-align: middle; transition: transform .12s ease-out; }
.monitor .heart.on { transform: scale(1.4); transition-duration: .05s; }
@media (max-width: 600px) {
  .monitor .scope { grid-template-columns: minmax(0, 1fr); }
  .monitor .chan { --upx: .8px; }
  .monitor .screen { height: 88px; }
  .monitor .chan.spo2 .screen, .monitor .chan.resp .screen { height: 40px; }
  .monitor .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .monitor .vit.nibp { grid-column: span 2; }
  .monitor .vit b { font-size: 24px; }
}
/* Swept monitor trace (ACLS): canvas drawn by the game, head dot moved per frame */
.sweep { position: absolute; inset: 0; }
.sweep canvas { display: block; width: 100%; height: 100%; }
.sweep .head { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px 2px currentColor; will-change: transform; }
@media (prefers-reduced-motion: reduce) { .sweep .head { display: none; } }

/* Still trace for tables (traceSVG with the minitrace class) */
.minitrace { width: 150px; height: 40px; display: block; background: #0B1220; border-radius: 6px; }
.minitrace path { fill: none; stroke: #35F29A; stroke-width: 2; vector-effect: non-scaling-stroke; }

/* The eye (eye.js: Toxíndromes' pupil questions and fichas). Printed-card look:
   cream sclera with an ink outline, azul iris, ink pupil that eases to its size. */
.eye { display: inline-block; line-height: 0; }
.eye svg { display: block; max-width: 100%; height: auto; }
.eye .sclera { fill: #FFF9EE; stroke: #1A1A2E; stroke-width: 3; }
.eye .iris { fill: color-mix(in srgb, #2B59C3 22%, #FFF9EE); stroke: #2B59C3; stroke-width: 2; }
.eye .pp { fill: #1A1A2E; transition: r .52s cubic-bezier(.2, .8, .2, 1); }
@media (prefers-reduced-motion: reduce) { .eye .pp { transition: none; } }

/* Blood-loss scene (blood-loss.js; Sangrado 2.º/3.er's Código Rojo): tiles on cream paper, like
   the paper ECG, so they read the same in both themes. Tiles pop in one by one, still under
   reduced motion. */
.bl-scene { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px 12px; margin: 14px 0 6px; padding: 0; }
.bl-tile { position: relative; background: #FFF7E4; color: #1A1A2E; border: 3px solid #1A1A2E; border-radius: 10px; padding: 8px 8px 10px;
  text-align: center; box-shadow: 3px 3px 0 #1A1A2E; animation: bl-in .28s ease-out both; animation-delay: calc(var(--i, 0) * 70ms); }
.bl-art svg { width: 100%; max-width: 120px; height: auto; display: block; margin: 0 auto 4px; }
.bl-name { display: block; font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.bl-q { position: absolute; top: -12px; right: -8px; background: #B3121F; color: #fff; border: 2px solid #1A1A2E; border-radius: 999px;
  font-family: var(--slab); font-size: 16px; padding: 0 9px; }
@keyframes bl-in { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .bl-scene { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; } }
@media (prefers-reduced-motion: reduce) { .bl-tile { animation: none; } }

/* Curve chart (curve.js; Sangrado del primer trimestre's La Curva): a printed card with a
   coloured frame and hard shadow; cream paper with dark ink in both themes. */
.cv { --c: var(--panda); margin: 6px 0 22px; padding: 14px 14px 10px; background: #FFF9EE; color: #1A1A2E; border: 6px solid var(--c); border-radius: 12px;
  box-shadow: 0 0 0 3px #1A1A2E, 6px 6px 0 3px #1A1A2E; }
.cv .cv-h { display: flex; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; font-weight: 700; font-size: 15px; }
.cv .cv-h b { font-family: var(--slab); font-weight: 400; font-size: 20px; }
.cv svg { width: 100%; height: auto; display: block; margin-top: 6px; }
.cv .ax { stroke: #1A1A2E; stroke-width: 1.5; }
.cv .grid { stroke: #1A1A2E; stroke-opacity: .12; stroke-dasharray: 3 4; }
.cv .ln { fill: none; stroke: var(--c); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.cv .dot { fill: #FFF7E4; stroke: #1A1A2E; stroke-width: 2.5; }
.cv .dot.neg { fill: #1A1A2E; }
.cv text { fill: #1A1A2E; font-family: var(--sans); }
.cv .vl { font-size: 12.5px; font-weight: 700; }
.cv .xl { font-size: 11.5px; }
.cv-deltas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cv-deltas span { background: #FFF9EE; color: #1A1A2E; border: 2px solid #1A1A2E; border-radius: 6px; padding: 1px 8px; font-weight: 700; font-size: 14px; }

/* The esophagus (esophagus.js; Patología de esófago's El Endoscopio): the endoscopic view down
   the lumen and the barium swallow film. Fixed colours, like the paper ECG, so both read the
   same in light and dark themes. */
.eso { display: inline-block; line-height: 0; }
.eso svg { display: block; max-width: 100%; height: auto; }
.eso .bezel { fill: #1A1A2E; }
.eso .mucosa { fill: #F2B8AE; }
.eso .rim { fill: none; stroke: #1A1A2E; stroke-width: 4; }
.eso .fold { stroke: #D9897D; stroke-width: 3; stroke-linecap: round; fill: none; opacity: .7; }
.eso .lumen { fill: #3A1420; }
.eso .ero { fill: #FFF3E6; stroke: #C62839; stroke-width: 2.5; }
.eso .salmon { fill: #E8704A; }
.eso .tear { fill: #8E1B2A; stroke: #C62839; stroke-width: 2; }
.eso .clot { fill: #3A0D14; }
.eso .hyper { fill: #D8564C; opacity: .55; }
.eso .exu { fill: #FFF8EC; stroke: #C9B79C; stroke-width: 1.5; }
.eso .ulcer { fill: #FFF0D8; stroke: #8E1B2A; stroke-width: 4; }
.eso .necro { fill: #2B2530; stroke: #1A1A2E; stroke-width: 1.5; }
.eso .scar { fill: #F4E6DA; stroke: #D9C3B0; stroke-width: 2; }
.eso .film { fill: #1D1D24; }
.eso .spine { stroke: #3A3A46; stroke-width: 16; }
.eso .barium { fill: #F4F1EA; }
.esobox { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 10px 0 4px; }
.esobox .lbl { font-weight: 700; max-width: 22ch; }
/* Rhythm strip (ecg-strip.js: Arritmias y EKG): pink paper or a dark monitor; the
   trace can draw itself once, still under reduced motion. */
.ekgpaper { background: #FFF7E4; border: 2px solid var(--ink); border-radius: 10px; padding: 6px; margin: 8px 0 12px; overflow: hidden; }
.ekgpaper.mon { background: #0B1A1E; }
.ekgpaper .cap { font-size: 12px; font-weight: 700; color: #8A2A4E; letter-spacing: .05em; text-transform: uppercase; padding: 0 4px 2px; }
.ekgpaper.mon .cap { color: #7FD9B7; }
.ekgstrip { display: block; width: 100%; height: auto; max-width: 100%; font-family: 'Atkinson Hyperlegible', sans-serif; }
.ekgstrip.draw path.tr { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ekgdraw 1.7s linear forwards; }
@keyframes ekgdraw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .ekgstrip.draw path.tr { animation: none; stroke-dashoffset: 0; } }

/* Burn mannequin (burn-chart.js: Quemaduras' Mapa y Parkland) */
.burnfig { --skin: #F4DCC6; --burn: #C8502A; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 8px; margin-bottom: 12px; }
.burnfig svg { display: block; width: 100%; height: auto; max-height: 62vh; }
.burnfig .rg { fill: var(--skin); stroke: #1A1A2E; stroke-width: 2; }
.burnfig .rg.burn { fill: var(--burn); }
.burnfig .pct { font: 700 15px var(--body); fill: #1A1A2E; text-anchor: middle; dominant-baseline: middle; paint-order: stroke; stroke: #FFF7E4; stroke-width: 3px; }
.burnfig .lbl { font: 700 14px var(--body); fill: var(--muted); text-anchor: middle; }
.burnfig .side { font: 600 12px var(--body); fill: var(--muted); text-anchor: middle; }
.burnfig .legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 4px; font-size: 14px; }
.burnfig .legend i { display: inline-block; width: 14px; height: 14px; border: 2px solid #1A1A2E; border-radius: 4px; margin-right: 6px; vertical-align: -2px; }
.burnfig .legend .b { background: var(--burn); }
.burnfig .legend .s { background: var(--skin); }

/* Skin patch (mole.js: Cáncer de piel's Escáner ABCDE). Fixed colours, the same in both themes. */
.molefig { background: #1A1A2E; padding: 8px; border-radius: 18px; box-shadow: 0 0 0 4px #6A2C91, 6px 6px 0 4px var(--ink); max-width: 320px; width: 100%; margin: 4px auto 0; box-sizing: border-box; }
.molefig svg.skin { display: block; width: 100%; height: auto; }
.molefig .rn { font: 400 11px var(--sans); fill: #1A1A2E; }
.molefig .ru { font: 400 10px var(--sans); fill: #1A1A2E; }
.molefig .badge { font: 700 12px var(--sans); fill: #FFF9EE; }
