/* Electrocardiopedia */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nav nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--trace); }
[hidden] { display: none !important; }

/* --- Index hero -------------------------------------------------------------- */
.atlas-hero { background: radial-gradient(800px 420px at 85% 0%, rgba(94, 234, 212, 0.12), transparent 60%), radial-gradient(700px 420px at 0% 100%, rgba(11, 79, 179, 0.25), transparent 65%), var(--night); color: var(--on-night); padding: var(--hero-top) var(--gutter) 44px; }
.atlas-hero .eyebrow { color: var(--trace); }
.atlas-hero h1 { font-size: min(var(--h1), 10vw); max-width: 16em; } /* "electrocardiography" must fit on a 320 px screen */
.atlas-hero h1 em { font-style: italic; color: var(--trace); }
.atlas-hero .lede { max-width: 40em; }
.atlas-search { display: block; margin-top: 30px; max-width: 640px; }
.atlas-search input { width: 100%; min-height: 54px; padding: 0 20px; border-radius: 999px; border: 1.5px solid var(--night-line); background: var(--night-2); color: #fff; font: inherit; }
.atlas-search input::placeholder { color: var(--on-night-muted); }
.atlas-search input:focus { border-color: var(--trace); outline: none; box-shadow: 0 0 0 4px var(--trace-soft); }
.atlas-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.atlas-chips button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--night-line); background: transparent; color: var(--on-night-muted); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.atlas-chips button:hover { color: #fff; border-color: var(--on-night-muted); }
.atlas-chips button[aria-pressed="true"] { background: var(--trace); border-color: var(--trace); color: #04231f; }
.atlas-count { margin-top: 14px; font-size: 14.5px; color: var(--on-night-muted); min-height: 1.5em; }
.chip-count { margin-left: 8px; font-family: var(--mono); font-size: 12.5px; font-weight: 600; opacity: 0.7; font-variant-numeric: tabular-nums; }
/* Topics within the chosen section: one scrollable row on phones, wrapped on wider screens. */
.atlas-groups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--night-line); }
.atlas-groups button { min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid transparent; background: var(--night-2); color: var(--on-night-muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.atlas-groups button:hover { color: #fff; border-color: var(--night-line); }
.atlas-groups button[aria-pressed="true"] { background: transparent; border-color: var(--trace); color: var(--trace); }
/* Keeps each chip's screen-reader count inside the chip (and inside the scrolling row). */
.atlas-chips button, .atlas-groups button { position: relative; }
.atlas-chips button:focus-visible, .atlas-groups button:focus-visible { outline: 2px solid var(--trace); outline-offset: 2px; }
@media (max-width: 640px) {
  .atlas-chips button { min-height: 38px; padding: 0 13px; font-size: 14.5px; }
  .atlas-groups { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter); scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - 28px), transparent); }
  .atlas-groups::-webkit-scrollbar { display: none; }
  .atlas-groups button { scroll-snap-align: start; flex: none; }
}

/* --- Index grid -------------------------------------------------------------- */
.atlas-list { padding: 48px var(--gutter) 96px; }
.asection { scroll-margin-top: 88px; }
/* Space between visible sections only, so a filtered view starts right under the hero. */
.asection:not([hidden]) ~ .asection:not([hidden]) { margin-top: 64px; }
.asection > h2 { font-size: clamp(28px, 3vw, 36px); padding-bottom: 12px; border-bottom: 2px solid var(--ink); display: flex; align-items: baseline; gap: 14px; }
.asection > h2 small { font-family: var(--mono); font-size: 15px; color: var(--muted); font-weight: 600; }
.agroup { margin-top: 30px; }
.agroup > h3 { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--blue); margin-bottom: 12px; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.acard { display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 16px; text-decoration: none; scroll-margin-top: 96px; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.acard:hover { transform: translateY(-3px); border-color: var(--blue); box-shadow: 0 16px 34px rgba(16, 29, 46, 0.12); }
.acard-strip { display: block; width: 100%; height: 92px; border-radius: 12px; background: #fff9f5; margin-bottom: 6px; }
.acard-group, .acard-name, .acard-summary { padding: 0 6px; }
.acard-group { font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.acard-name { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.2; }
.acard-summary { font-size: 14.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* --- Article ----------------------------------------------------------------- */
.art { padding-bottom: 96px; }
.art-crumbs { padding: 22px var(--gutter) 0; font-size: 14.5px; color: var(--on-night-muted); background: var(--night); }
.art-crumbs a { color: var(--on-night); text-decoration: none; }
.art-crumbs a:hover { text-decoration: underline; }
.art-head { background: var(--night); color: var(--on-night); padding: 26px var(--gutter) 120px; }
.art-head .eyebrow { color: var(--trace); }
.art-head h1 { font-size: var(--h1); max-width: 18em; }
.art-head h1:focus { outline: none; }
.art-short { margin-top: 8px; font-size: 19px; color: var(--trace); font-weight: 600; }
.art-head .lede { max-width: 44em; }
.art-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }

.art-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px 32px; padding: 0 var(--gutter); margin-top: -92px; align-items: start; }
.art-col { display: grid; gap: 20px; align-content: start; min-width: 0; }
.art-monitor, .art-heart { background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 44px rgba(16, 29, 46, 0.14); overflow: hidden; }
.art-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.art-panel-note { color: var(--muted); font-size: 13px; }
.art-spacer { flex: 1; }
.art-dot { width: 9px; height: 9px; border-radius: 50%; background: #0f9d8a; box-shadow: 0 0 0 4px rgba(15, 157, 138, 0.16); }
.art-btn { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums; }
.art-btn:hover { border-color: var(--blue); }
.art-btn[aria-pressed="true"] { border-color: var(--blue); color: var(--blue-deep); background: #eaf2ff; }
.art-monitor-paper { background: #fffaf6; position: relative; }
.art-caliper-layer { position: absolute; inset: 0; width: 100%; pointer-events: none; touch-action: none; }
.art-caliper-layer.on { pointer-events: auto; cursor: ew-resize; touch-action: none; }
.art-caliper-layer:focus-visible { outline: 3px solid #f4b740; outline-offset: -3px; }
.art-panel-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #fbf9f6; }
.art-segs { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: #efe9df; }
.art-seg { min-height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; font: inherit; font-size: 13.5px; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap; }
.art-seg:hover { color: var(--ink); }
.art-seg[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 29, 46, 0.16); }
.art-readout { margin: 0; font-size: 13.5px; font-weight: 650; color: var(--blue-deep); font-variant-numeric: tabular-nums; }
.art-monitor-canvas { display: block; width: 100%; }
.art-heart-view { padding: 4px 8px 8px; }
/* Until the heart view loads, hold its square stage and caption row, so the
   facts below it do not jump when it arrives. */
.art-heart-view:empty::before { content: ""; display: block; width: 100%; max-width: 640px; aspect-ratio: 1; margin: 0 auto 49px; }
@media (max-width: 640px) { .art-heart-view:empty::before { margin-bottom: 46px; } }

.art-main { padding: 18px 4px 0; }
.art-main section + section { margin-top: 32px; }
.art-main h2 { font-size: 28px; margin-bottom: 10px; }
.art-main p { font-size: 18px; line-height: 1.65; }
.art-main .aside-block h3 { font-family: var(--serif); font-size: 28px; font-weight: 600; text-transform: none; letter-spacing: -0.015em; color: var(--ink); }
.art-main .aside-block li { font-size: 17px; }
.art-aside { display: grid; gap: 18px; align-content: start; }
.aside-block { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.art-main .aside-block { background: none; border: 0; padding: 0; margin-top: 32px; }
.aside-block h3 { margin: 0 0 10px; font-family: var(--sans); font-size: 12.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.aside-block ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 15.5px; }
.aside-block a { color: var(--blue); }
.art-criteria { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0; font-size: 15.5px; }
.art-criteria dt, .art-criteria dd { margin: 0; padding: 9px 0; border-top: 1px solid var(--line); }
.art-criteria dt { color: var(--muted); font-weight: 600; padding-right: 14px; }
.art-criteria dd { font-weight: 600; }

.art-cells { margin: 56px var(--gutter) 0; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
.art-cells-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; justify-content: space-between; }
.art-cells-head h2 { font-family: var(--serif); font-size: 28px; color: var(--ink); }
.art-cells-head p:not(.eyebrow) { color: #55657a; max-width: 40em; margin-top: 6px; }
.art-cells-view:not(:empty) { margin-top: 18px; }
.btn-small { min-height: 40px; padding: 0 16px; font-size: 14.5px; }
.btn-line { border-color: var(--line); background: #fff; color: var(--ink); }
.btn-line:hover { border-color: var(--blue); }

.art-related { padding: 56px var(--gutter) 0; }
.art-related h2 { font-size: 28px; margin-bottom: 16px; }
.art-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 48px var(--gutter) 0; }
.art-pager a { display: grid; gap: 2px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; text-decoration: none; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.art-pager a:hover { border-color: var(--blue); }
.art-pager small { font-family: var(--sans); font-size: 12.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.art-next { text-align: right; }

/* Lab components inside the article (scoped so they cannot touch the site). */
.lab-scope .seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.lab-scope .seg > button { min-height: 34px; padding: 4px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 650; font-size: 14px; white-space: nowrap; cursor: pointer; }
.lab-scope .seg > button[aria-pressed="true"] { background: var(--surface); color: var(--primary-strong); box-shadow: 0 1px 2px rgba(8, 54, 120, 0.18), 0 0 0 1px var(--line); }
.lab-scope .chip-btn { min-height: 36px; padding: 4px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-weight: 650; font-size: 14px; cursor: pointer; }
.lab-scope .chip-btn[aria-pressed="true"] { color: var(--primary-strong); border-color: var(--primary); background: var(--primary-soft); }
.art-chest-view { padding: 12px; }
.art-heart-seg > button { font-size: 13.5px; }
.lab-scope .h3-seg > button { flex: 1 1 auto; padding-inline: 8px; font-size: 13px; }
.lab-scope .ap-root { display: grid; gap: 8px; }
.lab-scope .ap-seg { display: flex; flex-wrap: wrap; }
.lab-scope .ap-seg > button { flex: 1 1 auto; padding-inline: 8px; font-size: 13px; }
.lab-scope .ap-canvas { display: block; width: 100%; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.lab-scope .ap-caption { margin: 0; font-size: 15px; line-height: 1.5; min-height: 4.5em; color: var(--ink); }
.lab-scope .ap-caption strong { color: var(--primary-strong); }
.lab-scope .ap-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lab-scope .ap-play { display: inline-flex; align-items: center; gap: 6px; color: var(--primary-strong); border-color: var(--primary); }
.lab-scope .ap-play svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.lab-scope .ap-speed { min-width: 92px; font-variant-numeric: tabular-nums; }
.lab-scope .ap-tip { margin: 0; font-size: 12.5px; color: var(--muted); flex: 1 1 140px; }

@media (max-width: 980px) {
  /* One column: tracing, then the heart, then the reading, then the facts. */
  .art-layout { display: flex; flex-direction: column; }
  .art-col { display: contents; }
  .art-monitor { order: 1; }
  .art-heart { order: 2; width: 100%; max-width: 620px; align-self: center; }
  .art-main { order: 3; }
  .art-aside { order: 4; }
}
@media (max-width: 640px) {
  .agrid { grid-template-columns: minmax(0, 1fr); }
  .art-head { padding-bottom: 104px; }
  .art-layout { padding: 0 12px; }
  .art-panel-head { flex-wrap: wrap; row-gap: 8px; }
  .art-monitor .art-spacer { flex-basis: 100%; height: 0; }
  .art-monitor .art-panel-head .art-btn { flex: 1 1 0; min-width: 0; padding-inline: 8px; }
  .art-segs { display: flex; width: 100%; }
  .art-seg { flex: 1 1 auto; padding-inline: 8px; }
  .art-pager { grid-template-columns: minmax(0, 1fr); }
  .art-next { text-align: left; }
  .art-cells { margin-left: 12px; margin-right: 12px; padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { .acard { transition: none; } .acard:hover { transform: none; } }

/* Pre-rendered article (scripts/build-atlas.mjs): what crawlers and readers
   without JavaScript see before atlas.js adds the live views. */
.art-static { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px 32px; padding: 40px var(--gutter) 0; align-items: start; }
.art-static .art-main { padding-top: 0; }
@media (max-width: 980px) { .art-static { grid-template-columns: minmax(0, 1fr); } }
.art-head:has(+ .art-static) { padding-bottom: 56px; }

/* Byline, tracing still, FAQ and related links (scripts/build-atlas.mjs). */
.art-byline { margin-top: 14px; font-size: 14.5px; color: var(--on-night-muted); }
.art-byline time { color: var(--on-night); }
.art-still { margin: 0 0 32px; }
.art-still-img { display: block; width: 100%; height: auto; border-radius: 16px; border: 1px solid var(--line); background: #fff9f5; }
.art-still figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }
.art-monitor-paper { isolation: isolate; }
.art-monitor-paper .art-monitor-still { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; object-position: left center; border: 0; border-radius: 0; pointer-events: none; }
.art-faq { padding: 56px var(--gutter) 0; }
.art-faq h2 { font-size: 28px; margin-bottom: 8px; }
.art-faq-item { max-width: 52em; padding: 18px 0; border-top: 1px solid var(--line); }
.art-faq-item:last-child { border-bottom: 1px solid var(--line); }
.art-faq-item h3 { font-size: 20px; line-height: 1.3; }
.art-faq-item p { margin: 8px 0 0; font-size: 17px; line-height: 1.6; }
.art-related-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.art-related-list a { display: grid; gap: 2px; height: 100%; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-decoration: none; font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.25; }
.art-related-list a:hover { border-color: var(--blue); }
.art-related-list span { font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 640px) { .art-related-list { grid-template-columns: minmax(0, 1fr); } }
@media print { .art-faq { break-inside: avoid; } .art-monitor-still { display: none; } }

.art-compare { display: inline-flex; align-items: center; min-height: 24px; margin-left: 4px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; text-decoration: none; color: var(--blue); vertical-align: 1px; }
.art-compare:hover { border-color: var(--blue); background: #eef4ff; }
.atlas-compare-cta { margin-top: 10px; font-size: 15px; color: var(--on-night-muted); }
.atlas-compare-cta a { color: var(--trace); font-weight: 650; }

.art-actions { align-items: center; }
@media print { .nav, .foot, .art-actions, .art-pager, .art-related, .art-cells, .art-panel-head, .art-panel-sub { display: none !important; } .art-head { color: #000; background: none; padding-bottom: 0; } .art-layout { margin-top: 0; } }

/* Hold what sits below the script-built index until it is built, so it does not jump. */
@media (scripting: enabled) {
  #atlas-chips:empty ~ .atlas-compare-cta { visibility: hidden; }
  body:has(#atlas-chips:empty) .foot { visibility: hidden; }
}
.art-head h1 { overflow-wrap: break-word; hyphens: auto; }
