/* ==========================================================================
   CardiSim's mark: a heart and its monitor. The first i of "cardisim" is
   dotted with a small red heart that beats, atria then ventricles; the
   second i is dotted with a green lamp that blinks once for every QRS, the
   way a monitor's does. (mark.js sets the rate, the press and the entrance.)

   brand.css draws MediSim's round lamp in .brandI's ::after and is shared,
   so it stays as it is: everything here is scoped to
   [data-product="CardiSim"]. The lamp is that same pseudo element, made
   green (and blinking). The heart is drawn on the first ı, .brandH, which
   only CardiSim's mark has. Theme-neutral like cardisim.css: tokens only,
   voices on data-theme.

   The heart is one smooth heart, opened up (Aaron, 11-29: the atria used
   to be two round bumps on top, "ventricles wearing Mickey Mouse ears").
   Its outline never moves: a shallow notch, round shoulders, a blunt apex
   that leans to the viewer's right. Inside the red muscle sit the four
   chambers: two atria over two ventricles, the left ventricle (the
   viewer's right) behind its thicker wall. A chamber squeezes when it
   fires. It comes in two cuts ("The two cuts", below): the chambers a
   deeper red that lights, or windows onto the page. Drawn once on a 100
   by 102.6 grid (scripts/cardisim-mark/ makes the paths and the icons)
   and used as masks, so every colour is a plain background colour.

   Four layers, painted in this order with no z-index:
     .brandH::before     the ring: the outline grown by the gap, in the
                         bar's own colour, parting the heart from the stem
     .brandH > i::before the muscle
     .brandH > i::after  the atria
     .brandH::after      the ventricles
   (.brandH > i is an empty box the size of the heart; every CardiSim mark
   carries it: card<span class="brandH">ı<i></i></span>s…)

   One heart per page: only the top mark (the landing's masthead, or a
   page's bar) beats on its own. The footer's heart stands still, its lamp
   lit.

   A third cut has no heart at all ("The leads cut", below): the two ı's
   are the four monitor leads, a white dot over a green stem and a black dot
   over a red one. It borrows the heart's top layer for its white dot.
   ========================================================================== */

/* Size: everything follows the ı stem's width in each voice (--x-k, below).
   The heart is 2.8 stems wide, at least 11 px so it still reads as a heart
   on the regular-weight study bars; a ring of the page's own colour (--x-g)
   parts it from the stem and from the d beside it. The heart sits on the
   stem: its apex dips under the x-height (cap height in the original
   voice) over the stem, so the ring cuts the stem's top. Whole pixels
   throughout. */
:root[data-product="CardiSim"] .brandH {
  position: relative; display: inline;
  --x-t: max(var(--x-min, 3px), round(nearest, var(--x-k, .185em), 1px));
  --x-g: max(1px, round(nearest, calc(var(--x-t) * .22), 1px));
  --x-w: max(11px, round(nearest, calc(var(--x-t) * 2.8), 1px));
  --x-h: round(nearest, calc(var(--x-w) * 1.026), 1px);
  --x-dip: round(nearest, calc(var(--x-t) * .5), 1px);
  /* The stem's centre falls under the middle of the heart, just left of the apex. */
  --x-l: calc(50% - var(--x-w) * .5 + var(--x-dx, 0em));
  --x-b: calc(var(--x-xh, .49em) + var(--base-off, .208em) - var(--x-dip));
  /* The chambers' colours: deep red at rest, light as they fire, between
     as the ventricles hold. --x-fill is how much of that red they carry:
     all of it in the section cut, none in the open cut, where a chamber is
     a window onto the bar behind (--x-win). The same goes for the unlit
     grey and the blue of the entrance's lamp test. */
  --x-win: var(--x-bg, var(--chassis));
  --x-dark: color-mix(in oklab, color-mix(in oklab, var(--pilot) 72%, #000) var(--x-fill, 100%), var(--x-win));
  --x-lit: color-mix(in oklab, color-mix(in oklab, var(--pilot) 46%, #fff) var(--x-fill, 100%), var(--x-win));
  --x-mid: color-mix(in oklab, color-mix(in oklab, var(--pilot) 78%, #fff) var(--x-fill, 100%), var(--x-win));
  --x-unlit: color-mix(in oklab, color-mix(in oklab, var(--rule-2) 80%, #000) var(--x-fill, 100%), var(--x-win));
  --x-test: color-mix(in oklab, color-mix(in oklab, var(--led-blue) 72%, #000) var(--x-fill, 100%), var(--x-win));
  /* The muscle's own flare with the QRS: none in the section cut (--x-hold
     100%), where the chambers carry the beat. */
  --x-flare: color-mix(in oklab, var(--pilot) var(--x-hold, 100%), #fff);
  /* The leads cut ("The leads cut", below). --x-leads is empty in that cut
     and unset in the two heart cuts, so each value here holds only in the
     leads cut, and every use of one falls back to the heart's own. The
     white dot stands where an ı's dot goes, the size of the second ı's. */
  --x-hide: var(--x-leads) none;
  --x-pw: var(--x-leads) max(4px, round(nearest, .215em, 1px));
  --x-pl: var(--x-leads) calc(50% - var(--x-pw) / 2 + var(--x-dx, 0em));
  --x-pb: var(--x-leads) calc(.672em - var(--x-pw) / 2 + var(--base-off, .208em));
  --x-pc: var(--x-leads) var(--cap);
  --x-pring: var(--x-leads) inset 0 0 0 max(1px, round(nearest, .021em, 1px)) var(--x-ink, var(--ink));
  --x-pround: var(--x-leads) 50%;
  --x-po: var(--x-leads) 50% 50%;
  --x-p-beat: var(--x-leads) csxBeatLeadP;
  --x-p-lamp: var(--x-leads) csxLampLeadP;
  --x-h-lamp: var(--x-leads) csxLampGrass;
  --x-grass: var(--x-leads) var(--led-green);
  color: var(--x-grass, currentColor);
}
:root[data-product="CardiSim"] .brandH::before,
:root[data-product="CardiSim"] .brandH::after,
:root[data-product="CardiSim"] .brandH > i,
:root[data-product="CardiSim"] .brandH > i::before,
:root[data-product="CardiSim"] .brandH > i::after {
  content: ""; position: absolute; pointer-events: none; display: block;
  -webkit-mask: center / 100% 100% no-repeat; mask: center / 100% 100% no-repeat;
}
/* The heart's box: the empty <i>, and the ventricles' own copy of it (in
   the leads cut that copy is the white dot, and nothing else is drawn). */
:root[data-product="CardiSim"] .brandH > i {
  width: var(--x-w); height: var(--x-h); left: var(--x-l); bottom: var(--x-b);
}
:root[data-product="CardiSim"] .brandH::after {
  width: var(--x-pw, var(--x-w)); height: var(--x-pw, var(--x-h));
  left: var(--x-pl, var(--x-l)); bottom: var(--x-pb, var(--x-b));
  border-radius: var(--x-pround, 0); box-shadow: var(--x-pring, none);
}
:root[data-product="CardiSim"] .brandH::before,
:root[data-product="CardiSim"] .brandH > i { display: var(--x-hide, block); }
:root[data-product="CardiSim"] .brandH > i::before,
:root[data-product="CardiSim"] .brandH > i::after { inset: 0; }
/* The ring: the outline grown by the gap, in the page's colour, under the
   red and over the letters. */
:root[data-product="CardiSim"] .brandH::before {
  width: calc(var(--x-w) + var(--x-g) * 2); height: calc(var(--x-h) + var(--x-g) * 2);
  left: calc(var(--x-l) - var(--x-g)); bottom: calc(var(--x-b) - var(--x-g));
  background-color: var(--x-bg, var(--chassis));
  -webkit-mask-image: var(--x-ol); mask-image: var(--x-ol);
}
/* The muscle. */
:root[data-product="CardiSim"] .brandH > i::before {
  background-color: var(--pilot);
  -webkit-mask-image: var(--x-ol); mask-image: var(--x-ol);
}
/* The chambers. Each pair squeezes about the middle of the pair, so the
   walls between them hold and the outer walls thicken. */
:root[data-product="CardiSim"] .brandH > i::after {
  background-color: var(--x-dark); transform-origin: 50% 22.5%;
  -webkit-mask-image: var(--x-at); mask-image: var(--x-at);
}
:root[data-product="CardiSim"] .brandH::after {
  background-color: var(--x-pc, var(--x-dark)); transform-origin: var(--x-po, 49.6% 60%);
  -webkit-mask-image: var(--x-v); mask-image: var(--x-v);
}
/* The drawing (viewBox 0 0 100 102.6): the outline, and each cut's two
   atria and two ventricles (scripts/cardisim-mark/build.js writes these). */
:root[data-product="CardiSim"] {
  --x-ol: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 102.6'><path d='M22.4 0.3L20 0.8L18.4 1.3L16.4 2L15.2 2.5L13.6 3.3L11.6 4.5L10 5.7L8.8 6.8L7.2 8.4L6 9.8L4.2 12.4L3.4 14L2.6 15.6L1.8 17.6L1.2 19.6L0.5 22.8L0.2 25.2L0 27.2L0 30L0.1 32L0.2 34L0.6 36.8L1.5 40.8L2.3 43.6L3 45.6L4.5 49.2L5.6 51.6L6.8 53.7L9.2 57.5L10.4 59.3L12.8 62.4L16.8 67.2L19.6 70.3L22.8 73.6L28.1 78.8L34 84.1L52.8 100.3L54 101.2L54.7 101.6L55.6 102L56.8 102.4L58 102.5L59.2 102.6L60.4 102.4L61.6 102.1L62.8 101.6L63.6 101.2L64.8 100.3L66 99.1L73.6 89.2L77.6 83.9L81.7 78L87 70L89.9 65.2L92.3 60.8L94.3 56.4L96.1 52L97.6 47.2L98.5 43.6L99.4 38.8L99.8 34L100 31.2L99.9 28.4L99.7 25.2L99.3 22.8L98.8 20.4L97.7 16.8L96.8 14.8L95.8 12.8L94.3 10.4L93 8.8L92 7.6L90.8 6.5L89.1 5.2L87.2 3.9L84.8 2.7L82.8 2L80 1.3L78.4 1.1L76.4 1L74.4 1L72 1.2L68.4 1.6L66 2.1L63.6 2.8L60 4.1L57.6 5.3L55.6 6.5L54.1 7.6L50.9 10.4L50.4 10.6L50 10.6L49.6 10.5L49.2 10.2L46.8 7.6L45.6 6.5L43.9 5.2L41.2 3.5L39.2 2.5L37.6 1.9L34.4 0.9L32.8 0.5L30.8 0.2L28.8 0L26.4 0L23.6 0.2Z'/></svg>");
  --x-at-section: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 102.6'><path d='M23.6 8.8L21.6 9.2L19.6 9.8L18 10.6L16.4 11.6L15.2 12.5L13.6 14L12.6 15.2L11.5 16.8L10.5 18.8L9.9 20.4L9.4 22L8.9 24L8.7 26L8.5 28L8.6 31.2L8.8 33.6L9 34.4L9.4 35.2L10.4 36.3L10.9 36.8L11.6 37.2L12.8 37.6L14 37.7L30 37L42 36.5L42.8 36.3L43.6 35.9L44.1 35.6L44.8 34.9L45.2 34.4L45.6 33.6L46 32L46 20.8L45.9 20L45.5 18.8L45 18L44.4 17.3L43.2 16.2L41.5 14.4L40.4 13.3L39.2 12.3L38 11.5L36.8 10.8L34.4 9.8L32.8 9.2L30.8 8.8L28.4 8.5L27.2 8.5L24.4 8.7ZM74 9.6L70.4 9.9L68 10.4L65.6 11.1L63.3 12L61.7 12.8L60.4 13.6L59.2 14.4L55.6 17.6L54.9 18.4L54.4 19.2L54.1 20L54 20.8L54 30.8L54 31.6L54.2 32.4L54.5 33.2L55 34L55.6 34.6L56.8 35.4L57.6 35.7L58.4 35.9L70.8 35.4L86.4 34.8L88 34.5L89.2 34L90.2 33.2L91 32L91.3 31.2L91.4 30.4L91.4 28.8L91.3 26.4L91 24.4L90.3 21.6L89.3 18.8L88.5 17.2L87.5 15.6L86.6 14.4L85.5 13.2L84 12L82.4 11L80.8 10.3L78.8 9.7L77.6 9.6L76 9.5Z'/></svg>");
  --x-v-section: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 102.6'><path d='M34 44.4L20.4 44.9L19.2 45.1L18.4 45.4L17.6 45.9L17 46.4L16.4 47.1L16.1 47.6L15.8 48.4L15.7 49.2L15.7 50L15.8 50.8L16.1 51.6L17.4 53.6L19.8 56.8L23.2 60.9L26.4 64.4L29.2 67.3L33.2 71.2L37.2 74.9L42.4 79.5L43.2 80L44.4 80.4L45.2 80.5L46 80.4L47.2 80L47.9 79.6L48.4 79.1L49 78.4L49.4 77.6L49.7 76.4L49.8 75.2L47.2 48.4L46.9 47.2L46.2 46L45.6 45.3L44.8 44.8L44.4 44.5L43.6 44.2L42.4 44ZM74 42.8L59.2 43.4L58 43.8L56.8 44.6L56 45.6L55.4 46.8L55.3 47.6L55.3 48.8L57.8 75.2L58 76L58.5 77.2L59 78L60 78.8L60.8 79.2L61.6 79.4L62.8 79.4L63.9 79.2L64.7 78.8L65.3 78.4L66 77.7L69.3 73.2L76.4 62.5L78.6 58.8L80.7 54.8L82.4 51.2L83.2 49.2L83.5 48.4L83.6 47.6L83.6 46.8L83.3 45.6L82.6 44.4L82.3 44L81.6 43.4L80.4 42.9L79.2 42.6Z'/></svg>");
  --x-at-open: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 102.6'><path d='M24.4 11.2L22.4 11.6L20.8 12.1L19.2 12.8L18 13.5L16.8 14.4L15.6 15.5L14.5 16.8L13.7 18L12.9 19.6L12.2 21.2L11.9 22.4L11.4 24.4L11.1 26.4L11 28L11 30.4L11.1 32L11.3 32.8L11.8 34L12.4 34.7L12.8 35.1L14 35.9L15.2 36.3L16.4 36.3L30.8 35.7L40.8 35.3L42 34.9L42.8 34.4L43.3 34L43.7 33.6L44.2 32.8L44.5 32L44.7 30.8L44.7 23.2L44.7 22.4L44.5 21.6L44 20.4L43.3 19.6L41.6 18.1L38.8 15.2L37.2 14L36 13.2L34.8 12.6L33.6 12.1L32 11.6L30.8 11.3L29.2 11.1L27.6 11ZM71.2 12.3L68.8 12.8L66.8 13.3L64.8 14.1L63.2 14.8L61.6 15.8L60.8 16.4L58.5 18.4L57 19.6L56.4 20.2L56 20.8L55.6 21.5L55.3 22.8L55.2 30L55.6 31.6L56 32.3L56.3 32.8L57.2 33.6L58 34.1L58.8 34.4L60 34.6L72.8 34.1L84.4 33.6L85.2 33.4L86 33.1L86.8 32.7L87.6 32.1L88 31.6L88.5 30.8L88.8 30L88.9 29.2L88.8 27.2L88.5 24.8L88.1 22.8L87.4 20.8L86.8 19.3L86 17.8L85 16.4L84 15.2L83 14.4L82.4 13.9L81.2 13.2L80 12.7L78.4 12.2L77.2 12.1L75.2 12L72.8 12.1Z'/></svg>");
  --x-v-open: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 102.6'><path d='M35.2 45.6L24 46L22.8 46.3L22 46.7L21.2 47.3L20.8 47.7L20.2 48.4L19.7 49.6L19.5 50.4L19.5 51.2L19.8 52.4L20.4 53.4L23 56.8L25.4 59.6L28.3 62.8L31 65.6L36.8 71.1L40 74.1L40.8 74.7L42 75.2L42.8 75.4L43.6 75.4L44.8 75.1L45.6 74.8L46.4 74.3L47.1 73.6L47.6 72.8L47.9 72L48 71.2L48 70L46 49.6L45.9 48.8L45.5 48L45 47.2L44.4 46.5L43.6 46L42.4 45.5L41.2 45.3ZM75.2 44L61.6 44.5L60.4 44.6L59.2 45L58.3 45.6L57.5 46.4L57.2 46.9L56.9 47.6L56.6 48.4L56.6 49.6L58.7 71.2L59.1 72.4L59.6 73.2L60 73.6L60.4 74L61.2 74.5L62.4 74.9L63.2 75L64 74.9L65.2 74.5L66 74L66.4 73.6L67.2 72.7L73.2 63.8L75.6 60L78.1 55.6L78.9 54L80.6 50.4L80.8 49.2L80.8 48L80.4 46.8L79.9 46L78.8 44.9L77.6 44.2L76.4 44Z'/></svg>");
  --x-at: var(--x-at-section); --x-v: var(--x-v-section); --x-dot: currentColor;
}
/* ── The cuts. An admin picks which one everyone sees (/admin/settings,
   src/cardisim/settings.ts); the server writes it on <html> as data-mark.
   A cut is only a handful of inherited values, so the nearest data-mark
   wins and the settings page can show them side by side.
     section  the chambers a deeper red, lighting as they fire (the default);
              the second ı's dot is ink, like the letters (--x-dot)
     open     the chambers windows onto the page, behind heavier walls;
              the muscle flares with the QRS instead; the second ı's dot
              is the green monitor lamp
     leads    no heart: the two ı's are the monitor's leads (below) ───── */
:root[data-product="CardiSim"][data-mark="open"],
:root[data-product="CardiSim"] [data-mark="open"] {
  --x-at: var(--x-at-open); --x-v: var(--x-v-open); --x-leads: initial;
  --x-fill: 0%; --x-hold: 80%; --x-m-beat: csxBeatM; --x-dot: initial;
}
:root[data-product="CardiSim"] [data-mark="section"] {
  --x-at: var(--x-at-section); --x-v: var(--x-v-section); --x-leads: initial;
  --x-fill: 100%; --x-hold: 100%; --x-m-beat: none; --x-dot: currentColor;
}
/* ── The leads cut (Aaron, 11-29: "a totally new logo from a completely
   different direction"; he green-lit this one). The word's two ı's are the
   four limb leads, standing where you put them when you face a patient:
   the patient's right on your left, white over green ("clouds over
   grass"), then black over red ("smoke over fire"). So the first ı is a
   white dot, ringed in ink, over a green stem, and the second a black dot
   over a red stem; the stems are the letters themselves, coloured.
   It beats along lead II, white to red: the white dot swells as the beat
   starts up there (csxBeatLeadP, where the atria fire), then the red stem
   flares as it lands (csxBeatLeadQ, with the QRS). Green is the ground and
   never moves. One switch, --x-leads, turns the cut on: .brandH and
   .brandI work everything else out from it. ──────────────────────────── */
:root[data-product="CardiSim"][data-mark="leads"],
:root[data-product="CardiSim"] [data-mark="leads"] {
  --x-leads: ; --x-at: none; --x-v: none; --x-m-beat: none; --x-dot: var(--ink);
}

/* ── The dot on the second ı: brand.css's round lamp. On the open heart
   it is a green monitor lamp: lit when nothing moves (a footer, reduced
   motion) and, on a beating mark, dim between beats and lit for each QRS:
   on as the ventricles fire, down again as they let go. On the section
   heart it is a plain dot in the letters' own ink (Aaron, 11-29: "make the
   green dot black like the text"), and so it never changes: the cut sets
   --x-dot, and both lamp colours take it. ──────────────────────────────── */
:root[data-product="CardiSim"] .brandI {
  --x-lamp: var(--x-dot, var(--led-green));
  --x-lamp-off: var(--x-dot, color-mix(in oklab, var(--led-green) 58%, var(--ink)));
  --pilot: var(--x-lamp);
  /* The leads cut: this ı's stem is the red lead, and its dot is ink, the
     size of the white one beside it (see .brandH for how these switch). */
  --x-fire: var(--x-leads) var(--led-red);
  --x-fire-lit: var(--x-leads) color-mix(in oklab, var(--led-red) 60%, #fff);
  --x-id: var(--x-leads) max(4px, round(nearest, .215em, 1px));
  --x-q-beat: var(--x-leads) csxBeatLeadQ;
  --x-i-lamp: var(--x-leads) csxLampFire;
  color: var(--x-fire, currentColor);
}
:root[data-product="CardiSim"] .brandI::after {
  --led-d: var(--x-id, max(4px, .215em)); --led-y: .672em;
  left: calc(50% - var(--led-d) / 2 + var(--x-dx, 0em));
  display: block; border-radius: 50%;
  box-shadow: inset 0 0 0 max(1px, .016em) color-mix(in oklab, var(--ink) 26%, transparent);
}
@keyframes csxBeatLamp {
  0%, 15.9% { background: var(--x-lamp-off); }
  16%, 34% { background: var(--x-lamp); animation-timing-function: ease-in; }
  46%, 100% { background: var(--x-lamp-off); }
}

/* Phones: MediSim's shared study bar drops its mark under 720 px; CardiSim
   keeps it (Aaron, 10-30), and a long crumb gives way with an ellipsis. */
@media (max-width: 720px) {
  :root[data-product="CardiSim"] #studyBar .brand { display: block; flex: none; }
  :root[data-product="CardiSim"] #studyBar .studyCrumb { flex: 1 1 0; padding-left: 12px; border-left: 1px solid var(--rule); }
  :root[data-product="CardiSim"][data-theme="runsheet"] #studyBar .studyCrumb { border-left-color: var(--rule-2); }
  :root[data-product="CardiSim"] #studyBar .studyCrumb .legend { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  :root[data-product="CardiSim"] #studyBar .grow { display: none; }
}

/* mark.js nudges the word by under a pixel (--x-snap) so the heart's box
   lands on the pixel grid and paints exactly where it was laid out. */
:root[data-product="CardiSim"] .brandMark:not(.brandLive) { position: relative; left: var(--x-snap, 0px); }

/* The stem's width (--x-k) in each voice, and the centring nudge (--x-dx)
   that puts the box's anchor on the stem's centre. Both were measured from
   the font's ink (Archivo at 800 px, Aaron 10-30: "perfectly centered").
   The ı's ink sits centred in its advance, so the only offset is the mark's
   letter-spacing, which the browser adds after the glyph and so inside
   .brandH's box: the nudge is minus half of it.
   Keep each --x-dx at -(that context's letter-spacing) / 2.
     faceplate  800, 125%: stem .185em   mast ls -.04, bar -.035, foot -.03
     original   800, 125%, cap I: stem .2025em, ls .01 everywhere
     run sheet  900, 62%: stem .1625em   mast ls -.025, bar and foot -.01
     study and Heart Lab bars, faceplate and original: 400, 125%, stem
                .0988em, no letter-spacing (run sheet's bars are its 900). */
:root[data-product="CardiSim"] :is(.csMast, .csMarkShow) :is(.brandH, .brandI) { --x-dx: .02em; }
:root[data-product="CardiSim"] .csBar :is(.brandH, .brandI) { --x-dx: .0175em; }
:root[data-product="CardiSim"] .csFoot :is(.brandH, .brandI) { --x-dx: .015em; }

/* Run sheet: condensed black. */
:root[data-product="CardiSim"][data-theme="runsheet"] :is(.brandH, .brandI) { --x-k: .1625em; --x-xh: .52em; --x-dx: .005em; }
:root[data-product="CardiSim"][data-theme="runsheet"] .csMast :is(.brandH, .brandI) { --x-dx: .0125em; }

/* Original: UPPERCASE, so the heart sits on the cap I (brand.css hides
   the lamp in this voice for MediSim; CardiSim shows it, as above). */
:root[data-product="CardiSim"][data-theme="original"] :is(.brandH, .brandI) { --x-k: .2025em; --x-xh: .69em; --x-dx: -.005em; }

/* The study bar over the quiz and the other modes (MediSim's shared bar)
   and the Heart Lab's bar set the word in the regular weight in these two
   voices: the stem there is 1.5 px at 15 px, so the gap is a single pixel
   and the heart keeps its 10 px floor. */
:root[data-product="CardiSim"]:not([data-theme="runsheet"]) :is(#studyBar, .hlBar) :is(.brandH, .brandI) { --x-k: .0988em; --x-xh: .525em; --x-min: 2px; --x-dx: 0em; --x-bg: var(--plate); }
/* The course's bar sets the word bold, on the plate in every voice. */
:root[data-product="CardiSim"] .cmBar :is(.brandH, .brandI) { --x-bg: var(--plate); }

/* The heart stands above the mark's tight line box, so the masthead's mark
   makes room for it: a little at the top of a wide page, more on a phone,
   where the doors sit right above the mark. */
:root[data-product="CardiSim"] .csMast h1.brand { padding-top: .04em; }
:root[data-product="CardiSim"][data-theme="original"] .csMast h1.brand { padding-top: .2em; }
@media (max-width: 720px) {
  :root[data-product="CardiSim"] .csMast h1.brand { padding-top: .2em; }
  :root[data-product="CardiSim"][data-theme="original"] .csMast h1.brand { padding-top: .36em; }
}

/* ── The heartbeat: 1000 ms at rest (60/min), in the heart's own order
   (Aaron, 11-09: "atria firing appropriately and before the ventricles").
   The atria fire first: they light and squeeze (8%), then let go. A pause,
   as at the AV node. At 15% the ventricles fire: they light and squeeze,
   shorter more than narrower, until 32%, hold to 40% and relax by 60%;
   the atria fill a little as they do (to 36%). The chambers rest deep red
   between beats. Transform and colour only; the outline, the muscle and
   the ring never move. The lamp on the second ı runs csxBeatLamp on the
   same clock: lit with the QRS. ───────────────────────────────────────── */
@keyframes csxBeatA {
  0% { transform: scale(1); background-color: var(--x-dark); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  6% { background-color: var(--x-lit); }
  8% { transform: scale(.86); animation-timing-function: cubic-bezier(.45, 0, .35, 1); }
  18% { background-color: var(--x-lit); }
  20% { transform: scale(1); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  26% { background-color: var(--x-dark); }
  36% { transform: scale(1.04); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  58% { transform: scale(1); }
  100% { transform: scale(1); background-color: var(--x-dark); }
}
/* The open cut's muscle: a flare with the QRS (the section cut names no
   animation here, so its muscle is never repainted). */
@keyframes csxBeatM {
  0%, 15% { background-color: var(--pilot); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  19%, 34% { background-color: var(--x-flare); animation-timing-function: cubic-bezier(.4, 0, .3, 1); }
  60%, 100% { background-color: var(--pilot); }
}
/* The leads cut's beat, on the same clock: the white lead with the atria,
   the red stem with the QRS. */
@keyframes csxBeatLeadP {
  0%, 2% { transform: scale(1); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  8% { transform: scale(1.26); animation-timing-function: cubic-bezier(.45, 0, .35, 1); }
  20%, 100% { transform: scale(1); }
}
@keyframes csxBeatLeadQ {
  0%, 15% { color: var(--x-fire); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  19%, 32% { color: var(--x-fire-lit); animation-timing-function: cubic-bezier(.4, 0, .3, 1); }
  48%, 100% { color: var(--x-fire); }
}
@keyframes csxBeatV {
  0%, 15% { transform: scale(1); background-color: var(--x-dark); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  19% { background-color: var(--x-lit); }
  32% { transform: scale(.88, .84); }
  34% { background-color: var(--x-lit); }
  40% { transform: scale(.88, .84); animation-timing-function: cubic-bezier(.4, 0, .3, 1); }
  44% { background-color: var(--x-mid); }
  60% { transform: scale(1); }
  64% { background-color: var(--x-dark); }
  100% { transform: scale(1); background-color: var(--x-dark); }
}
:root[data-product="CardiSim"] .csMast .brandMark:not(.brandLive) .brandH > i::after,
:root[data-product="CardiSim"] :is(.csBar, .csMarkShow) .brandH > i::after { animation: csxBeatA 1000ms linear infinite; }
:root[data-product="CardiSim"] .csMast .brandMark:not(.brandLive) .brandH::after,
:root[data-product="CardiSim"] :is(.csBar, .csMarkShow) .brandH::after { animation: var(--x-p-beat, csxBeatV) 1000ms linear infinite; }
:root[data-product="CardiSim"] .csMast .brandMark:not(.brandLive) .brandI,
:root[data-product="CardiSim"] :is(.csBar, .csMarkShow) .brandI { animation: var(--x-q-beat, none) 1000ms linear infinite; }
:root[data-product="CardiSim"] .csMast .brandMark:not(.brandLive) .brandH > i::before,
:root[data-product="CardiSim"] :is(.csBar, .csMarkShow) .brandH > i::before { animation: var(--x-m-beat, none) 1000ms linear infinite; }
:root[data-product="CardiSim"] .csMast .brandMark:not(.brandLive) .brandI::after,
:root[data-product="CardiSim"] :is(.csBar, .csMarkShow) .brandI::after {
  animation: csxBeatLamp 1000ms linear infinite;
}
/* A still heart (a footer's) beats once when pressed (mark.js). */
:root[data-product="CardiSim"] .brand.is-beat .brandH > i::after { animation: csxBeatA 1000ms linear; }
:root[data-product="CardiSim"] .brand.is-beat .brandH::after { animation: var(--x-p-beat, csxBeatV) 1000ms linear; }
:root[data-product="CardiSim"] .brand.is-beat .brandI { animation: var(--x-q-beat, none) 1000ms linear; }
:root[data-product="CardiSim"] .brand.is-beat .brandH > i::before { animation: var(--x-m-beat, none) 1000ms linear; }
:root[data-product="CardiSim"] .brand.is-beat .brandI::after { animation: csxBeatLamp 1000ms linear; }
/* Asleep: the tab is hidden or the mark is off screen (mark.js). */
:root[data-product="CardiSim"] .brand.is-asleep .brandH > i::before,
:root[data-product="CardiSim"] .brand.is-asleep .brandH > i::after,
:root[data-product="CardiSim"] .brand.is-asleep .brandH::after,
:root[data-product="CardiSim"] .brand.is-asleep .brandI,
:root[data-product="CardiSim"] .brand.is-asleep .brandI::after { animation-play-state: paused; }
/* ── Driven: the home console plays a rhythm, and the mark performs it
   (mark.js, on `cardisim:mark` events; home.js sends them from the strip's
   own beats). The mark's own clock stops: the atria fire on each P, and on
   each QRS the lamp lights and the ventricles squeeze, unless the rhythm
   has no pulse to give (the lamp still blinks: electricity with no beat).
   Fibrillation is a quiver, with no beat in it. The leads cut is all
   electricity: the white dot swells on each P and the red stem flares on
   every QRS, pulse or none. ───────────────────────────────────────────── */
:root[data-product="CardiSim"] .brand.is-driven .brandH > i::before,
:root[data-product="CardiSim"] .brand.is-driven .brandH > i::after,
:root[data-product="CardiSim"] .brand.is-driven .brandH::after,
:root[data-product="CardiSim"] .brand.is-driven .brandI,
:root[data-product="CardiSim"] .brand.is-driven .brandI::after { animation: none; }
:root[data-product="CardiSim"] .brand.is-driven .brandI::after { background: var(--x-lamp-off); }
:root[data-product="CardiSim"] .brand.is-driven[data-fib] .brandH > i::after { animation: csxFibA 190ms steps(1) infinite; }
:root[data-product="CardiSim"] .brand.is-driven[data-fib="v"] .brandH::after { animation: csxFibV 230ms steps(1) infinite; }
@keyframes csxFibA { 0% { transform: scale(1); } 25% { transform: scale(.9); } 50% { transform: scale(1.04); } 75% { transform: scale(.95); } }
@keyframes csxFibV { 0% { transform: scale(1); } 25% { transform: scale(.94, 1.03); } 50% { transform: scale(1.03, .94); } 75% { transform: scale(.97, .98); } }
/* CardiSim answers a committed answer with a beat (mark.js), not brand.js's
   90 ms off-blink. */
:root[data-product="CardiSim"] .brand.is-blink .brandI::after { visibility: visible; }

/* ── Entrance: the landing's lamp test, as a heart. brand.js runs it on the
   live copy for 1720 ms. Here the unlit heart is grey, blue for 120 ms,
   then red at 1500 ms, and the red is the start of the first beat: the
   atria fire, then the ventricles, and the still mark takes the beat over
   where the copy leaves it, 220 ms in (mark.js re-phases it, and sends
   the echo along the rule, at the same moment). ─────────────────────────── */
:root[data-product="CardiSim"] .brandLive .brandH > i::before { animation: csxLampM 1720ms linear both; }
:root[data-product="CardiSim"] .brandLive .brandH > i::after { animation: csxLampA 1720ms linear both; }
:root[data-product="CardiSim"] .brandLive .brandH::after { animation: var(--x-p-lamp, csxLampV) 1720ms linear both; }
/* The leads cut's lamp test: a plain ink word with two unlit dots, blue for
   the same 120 ms, then the leads come on with their first beat. */
:root[data-product="CardiSim"] .brandLive .brandH { animation: var(--x-h-lamp, none) 1720ms linear both; }
:root[data-product="CardiSim"] .brandLive .brandI { animation: var(--x-i-lamp, none) 1720ms linear both; }
@keyframes csxLampLeadP {
  0%, 80.2% { transform: scale(1); background-color: transparent; box-shadow: inset 0 0 0 max(1px, .012em) var(--rule-2); }
  80.3%, 87.1% { background-color: var(--led-blue); box-shadow: inset 0 0 0 0 transparent; }
  87.2% { transform: scale(1); background-color: var(--x-pc); box-shadow: var(--x-pring); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  91.85% { transform: scale(1.26); animation-timing-function: cubic-bezier(.45, 0, .35, 1); }
  98.83%, 100% { transform: scale(1); background-color: var(--x-pc); box-shadow: var(--x-pring); }
}
@keyframes csxLampGrass {
  0%, 80.2% { color: var(--ink); }
  80.3%, 87.1% { color: var(--led-blue); }
  87.2%, 100% { color: var(--x-grass); }
}
@keyframes csxLampFire {
  0%, 80.2% { color: var(--ink); }
  80.3%, 87.1% { color: var(--led-blue); }
  87.2%, 95.92% { color: var(--x-fire); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  98.25%, 100% { color: var(--x-fire-lit); }
}
@keyframes csxLampM {
  0%, 80.2% { background-color: var(--rule-2); }
  80.3%, 87.1% { background-color: var(--led-blue); }
  87.2%, 100% { background-color: var(--pilot); }
}
@keyframes csxLampA {
  0%, 80.2% { transform: scale(1); background-color: var(--x-unlit); }
  80.3%, 87.1% { background-color: var(--x-test); }
  87.2% { transform: scale(1); background-color: var(--x-dark); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  90.69% { background-color: var(--x-lit); }
  91.85% { transform: scale(.86); animation-timing-function: cubic-bezier(.45, 0, .35, 1); }
  97.67% { background-color: var(--x-lit); }
  98.83% { transform: scale(1); }
  100% { transform: scale(1.002); background-color: color-mix(in oklab, var(--x-lit), var(--x-dark)); }
}
@keyframes csxLampV {
  0%, 80.2% { transform: scale(1); background-color: var(--x-unlit); }
  80.3%, 87.1% { background-color: var(--x-test); }
  87.2%, 95.92% { transform: scale(1); background-color: var(--x-dark); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  98.25% { background-color: var(--x-lit); }
  100% { transform: scale(.94, .92); background-color: var(--x-lit); }
}

/* ── The echo: one PQRST complex leaves from under the heart and runs out
   along the rule (mark.js: the entrance's first beat, and a press on a bar
   mark). Ink on a chassis knockout, so the rule itself seems to deflect. It
   stays inside the rule's own floor (the padding under the mark), never up
   into the letters or the byline. Transform and opacity only. ────────── */
:root[data-product="CardiSim"] .csBar { position: relative; }
.csxEcho {
  position: absolute; left: 0; z-index: 2; pointer-events: none; overflow: visible;
  bottom: calc(-1 * var(--x-rule, 2px)); color: var(--ink);
}
.csxEcho .k { fill: var(--chassis); }
.csxEcho path {
  fill: none; stroke: currentColor; stroke-width: var(--x-rule, 2px);
  stroke-linejoin: round; stroke-linecap: butt;
}

@media (prefers-reduced-motion: reduce) {
  :root[data-product="CardiSim"] .brandH,
  :root[data-product="CardiSim"] .brandI,
  :root[data-product="CardiSim"] .brandH::after,
  :root[data-product="CardiSim"] .brandH > i::before,
  :root[data-product="CardiSim"] .brandH > i::after,
  :root[data-product="CardiSim"] .brandI::after { animation: none !important; }
  .csxEcho { display: none; }
}
@media (forced-colors: active) {
  /* brand.css paints the lamp CanvasText (forced-color-adjust: none); the
     masks keep it a heart: CanvasText muscle, Canvas chambers, on a ring of
     Canvas. The lamp test's grey and blue would vanish into the system
     palette, so the copy stays as it is. */
  :root[data-product="CardiSim"] .brandLive .brandH::after,
  :root[data-product="CardiSim"] .brandLive .brandH > i::before,
  :root[data-product="CardiSim"] .brandLive .brandH > i::after { animation-name: none; }
  :root[data-product="CardiSim"] .brandH::before,
  :root[data-product="CardiSim"] .brandH::after,
  :root[data-product="CardiSim"] .brandH > i::before,
  :root[data-product="CardiSim"] .brandH > i::after { forced-color-adjust: none; }
  :root[data-product="CardiSim"] .brandH { --pilot: CanvasText; --x-bg: Canvas; --x-dark: Canvas; --x-lit: Canvas; --x-mid: Canvas; --x-flare: CanvasText; --x-ink: CanvasText; }
  /* The leads cut: a Canvas dot in a CanvasText ring; the system colours the stems. */
  :root[data-product="CardiSim"] .brandH::after { background-color: Canvas; }
  :root[data-product="CardiSim"] .brandLive :is(.brandH, .brandI) { animation-name: none; }
  .csxEcho .k { fill: Canvas; }
  .csxEcho path { stroke: CanvasText; }
}
