/* Instant ECG — instantecg.com
   Static, no JavaScript, no third-party requests. */

:root {
  color-scheme: light dark;

  --monitor: #050e1f;
  --monitor-2: #0b1c3a;
  --on-monitor: #e9f3ff;
  --on-monitor-muted: #a9bfdc;
  --trace: #7fe3ff;
  --grid-major: rgba(127, 227, 255, 0.085);
  --grid-minor: rgba(127, 227, 255, 0.035);

  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #0d1a2d;
  --muted: #4a5a70;
  --line: #dbe3ee;
  --brand: #1766c2;
  --brand-strong: #0f4f9c;
  --chip: #e8f0fa;
  --chip-text: #0f3f7a;
  --ring: 0 0 0 1px rgb(13 26 45 / 0.08);
  --elev-1: var(--ring), 0 1px 1px -0.5px rgb(13 26 45 / 0.06), 0 3px 3px -1.5px rgb(13 26 45 / 0.06), 0 10px 20px -6px rgb(13 26 45 / 0.06);
  --elev-device:
    0 0 0 0.5px rgb(13 26 45 / 0.10),
    0 4px 5.5px rgb(13 26 45 / 0.03), 0 10px 13px rgb(13 26 45 / 0.04),
    0 19px 25px rgb(13 26 45 / 0.05), 0 33px 44px rgb(13 26 45 / 0.06),
    0 62px 83px rgb(13 26 45 / 0.07);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;

  --radius: 18px;
  --maxw: 1120px;
  --gutter: clamp(16px, 4vw, 32px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1017;
    --surface: #121a25;
    --text: #e7eef8;
    --muted: #a3b2c6;
    --line: #222e3e;
    --brand: #5aa6f2;
    --brand-strong: #8cc2f7;
    --chip: #15253b;
    --chip-text: #a9dcff;
    --ring: 0 0 0 1px rgb(255 255 255 / 0.08);
    --elev-1: var(--ring), inset 0 1px 0 rgb(255 255 255 / 0.04), 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 24px -8px rgb(0 0 0 / 0.45);
    --elev-device: 0 0 0 0.5px rgb(255 255 255 / 0.10), 0 30px 60px rgb(0 0 0 / 0.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }

a {
  color: var(--brand);
  text-underline-offset: 0.18em;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    text-decoration-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}
a:hover { color: var(--brand-strong); }

:focus-visible { outline: 3px solid var(--trace); outline-offset: 3px; border-radius: 6px; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(1.75rem, 2.4vw + 1rem, 2.6rem); }
h3 { font-size: 1.15rem; letter-spacing: -0.01em; }
p { margin: 0; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

.eyebrow {
  font: 600 0.78rem/1.2 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}
.monitor .eyebrow { color: var(--trace); }

/* ---------- Monitor (dark ECG-paper) surfaces ---------- */

.monitor {
  position: relative;
  overflow: hidden;
  color: var(--on-monitor);
  background-color: var(--monitor);
  background-image:
    radial-gradient(900px 520px at 78% 8%, rgba(23, 102, 194, 0.42), transparent 62%),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 100% 100%, 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  box-shadow: inset 0 -1px 0 rgb(127 227 255 / 0.12);
}
.monitor :where(a:not(.button):not(.badge)) { color: var(--trace); }

/* ---------- Header ---------- */

.site-header { position: relative; z-index: 2; }
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--on-monitor);
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.monitor a.brand { color: var(--on-monitor); }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.site-nav { display: flex; align-items: center; gap: clamp(14px, 3vw, 28px); font-size: 0.95rem; }
.monitor .site-nav a { color: var(--on-monitor-muted); text-decoration: none; }
.monitor .site-nav a:hover, .monitor .site-nav a[aria-current="page"] { color: var(--on-monitor); }
.nav-optional { display: none; }
@media (min-width: 640px) { .nav-optional { display: inline; } }

/* ---------- Hero ---------- */

.hero { position: relative; }
.hero .wrap {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 40px;
  padding-top: clamp(24px, 6vw, 72px);
  padding-bottom: clamp(140px, 16vw, 190px);
}
@media (min-width: 900px) {
  .hero .wrap { grid-template-columns: 1.15fr 0.85fr; align-items: center; gap: 56px; }
}
.hero h1 { font-size: clamp(2.4rem, 4.2vw + 1rem, 4.1rem); margin-top: 14px; max-width: 16ch; }
.hero .lede { margin-top: 20px; max-width: 36rem; font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.2rem); color: var(--on-monitor-muted); }
.hero .lede strong { color: var(--on-monitor); font-weight: 600; }

.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; margin-top: 32px; }
.badge { display: inline-block; border-radius: 10px; }
.badge:hover { transform: translateY(-1px); box-shadow: 0 8px 24px -8px rgb(127 227 255 / 0.35); }
.badge:active, .button:active { transform: scale(0.97); }
.badge img { height: 52px; width: auto; }
.text-link { font-weight: 600; text-decoration: underline; text-decoration-color: transparent; }
.text-link:hover { text-decoration-color: currentColor; }

.hero-device { justify-self: center; width: min(240px, 64vw); }
@media (min-width: 900px) { .hero-device { justify-self: end; width: 280px; } }

/* ECG trace across the bottom of the hero.
   Three stacked copies of the same path: a dim base, a "write" layer that is
   revealed left to right once (like a monitor drawing the strip), and a bright
   pen head that travels with the writing edge. Clip and mask are measured
   against the visible width, so the sweep never runs off-screen. The sweep is
   finite (under 5 s) to satisfy WCAG 2.2.2. */
.trace {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  z-index: 0;
  height: 130px;
  pointer-events: none;
}
.trace-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trace path { fill: none; stroke: var(--trace); stroke-linecap: round; stroke-linejoin: round; }
.trace-base path { stroke-opacity: 0.16; stroke-width: 2; }
.trace-write path { stroke-opacity: 0.7; stroke-width: 2.2; }
.trace-write {
  filter: drop-shadow(0 0 4px rgb(127 227 255 / 0.45));
  clip-path: inset(0 100% 0 0);
  animation: trace-write 4.2s linear 0.3s forwards;
}
.trace-head { display: none; }
.trace-head path { stroke-width: 2.8; }
@keyframes trace-write { to { clip-path: inset(0 0 0 0); } }

@supports ((mask-image: linear-gradient(#000, #000)) or (-webkit-mask-image: linear-gradient(#000, #000))) {
  .trace-head {
    display: block;
    opacity: 0;
    filter: drop-shadow(0 0 6px rgb(127 227 255 / 0.9));
    -webkit-mask: linear-gradient(90deg, transparent, #000 92%, transparent) no-repeat;
    mask: linear-gradient(90deg, transparent, #000 92%, transparent) no-repeat;
    -webkit-mask-size: 12% 100%;
    mask-size: 12% 100%;
    -webkit-mask-position: -13.64% 0;
    mask-position: -13.64% 0;
    animation: trace-head 4.2s linear 0.3s forwards;
  }
}
@keyframes trace-head {
  0% { opacity: 1; -webkit-mask-position: -13.64% 0; mask-position: -13.64% 0; }
  94% { opacity: 1; }
  100% { opacity: 0; -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .trace-write { animation: none; clip-path: none; }
  .trace-head { display: none; }
}

/* ---------- Sections ---------- */

.section { padding: clamp(64px, 9vw, 112px) 0; }
.section + .section { padding-top: 0; }
.section-head { max-width: 44rem; margin-bottom: clamp(28px, 4vw, 44px); }
.section-head h2 { margin-top: 10px; }
.section-head p:not(.eyebrow) { margin-top: 14px; color: var(--muted); font-size: 1.1rem; }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  padding: 24px;
  border: 1px solid transparent; /* keeps an outline in forced-colors mode */
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--elev-1);
}
.card .num { font: 600 0.75rem/1 var(--mono); letter-spacing: 0.1em; color: var(--brand); }
.card h3 { margin-top: 12px; }
.card p { margin-top: 8px; color: var(--muted); }

/* Modern iPhone frame (CSS only). Sized with container units so it scales
   with whatever width it is given. Expects 19.5:9 screenshots (for example
   1206x2622 from an iPhone 17 Pro simulator). */
.iphone { container-type: inline-size; }
.iphone-frame {
  position: relative;
  padding: 1.1cqi;
  border-radius: 16.5cqi;
  background: linear-gradient(150deg, #5b6068 0%, #2a2d33 22%, #44484f 48%, #1f2227 74%, #4c5058 100%);
  box-shadow: var(--elev-device), inset 0 0 0 0.35cqi rgb(255 255 255 / 0.18);
}
.iphone-frame img {
  display: block;
  width: 100%;
  border: 2.6cqi solid #030304;
  border-radius: 15.4cqi;
  background: #000;
}
/* Dynamic Island */
.iphone-frame::after {
  content: "";
  position: absolute;
  top: 6.2cqi;
  left: 50%;
  width: 30cqi;
  height: 8.8cqi;
  translate: -50% 0;
  border-radius: 999px;
  background: #000;
  box-shadow: inset 0 0 0 0.3cqi rgb(255 255 255 / 0.04);
}
/* Side buttons: action + volume on the left, side button on the right */
.iphone-frame::before {
  content: "";
  position: absolute;
  top: 19%;
  left: -0.7cqi;
  width: 0.9cqi;
  height: 7cqi;
  border-radius: 0.5cqi 0 0 0.5cqi;
  background: #3a3e45;
  box-shadow:
    0 12cqi 0 0 #3a3e45, 0 15cqi 0 0 #3a3e45, 0 25cqi 0 0 #3a3e45, 0 28cqi 0 0 #3a3e45,
    calc(100cqi + 0.5cqi) 15cqi 0 0 #3a3e45, calc(100cqi + 0.5cqi) 20cqi 0 0 #3a3e45, calc(100cqi + 0.5cqi) 24cqi 0 0 #3a3e45;
}
@media (prefers-color-scheme: dark) {
  .iphone-frame { box-shadow: 0 0 0 0.5px rgb(255 255 255 / 0.12), inset 0 0 0 0.35cqi rgb(255 255 255 / 0.18), 0 30px 60px rgb(0 0 0 / 0.55); }
}

/* Screenshot rail */
.screens {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(200px, 1fr);
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px var(--gutter) 20px;
  margin: 0 calc(var(--gutter) * -1);
  scrollbar-width: thin;
}
.screens figure { margin: 0; scroll-snap-align: center; }
.screens figcaption { margin-top: 12px; text-align: center; font-size: 0.95rem; color: var(--muted); }
@media (min-width: 960px) { .screens { overflow: visible; margin: 0; padding: 8px 0 0; } }

/* Rhythm library */
.library { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
@media (min-width: 700px) {
  .library .wide { grid-column: span 2; }
  .library .wide ul { columns: 2; column-gap: 28px; }
  .library .wide li { break-inside: avoid; }
  .library .wide li:nth-child(6) { border-top: 0; }
}
.library .card h3 { margin-top: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.count { font: 600 0.8rem/1 var(--mono); color: var(--brand); white-space: nowrap; }
.library ul { margin: 14px 0 0; padding: 0; list-style: none; }
.library li { padding: 7px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.98rem; }
.library li:first-child { border-top: 0; }

/* Exams */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chips li {
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-text);
  font-weight: 550;
  font-size: 0.97rem;
}

/* Audience + authors */
.split { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.authors {
  display: grid;
  gap: 28px;
  align-items: center;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid transparent;
  border-radius: calc(var(--radius) + 6px);
  background: var(--surface);
  box-shadow: var(--elev-1);
}
@media (min-width: 760px) { .authors { grid-template-columns: auto 1fr; } }
.authors img { width: 112px; height: 112px; border-radius: 26px; }
.authors h2 { font-size: clamp(1.5rem, 1.6vw + 1rem, 2rem); margin-top: 8px; }
.authors p:not(.eyebrow) { margin-top: 12px; color: var(--muted); max-width: 44rem; }
.authors p strong { color: var(--text); font-weight: 600; }

/* Email signup */
.signup {
  display: grid;
  gap: 24px;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid transparent;
  border-radius: calc(var(--radius) + 6px);
  background: var(--surface);
  box-shadow: var(--elev-1);
}
@media (min-width: 860px) { .signup { grid-template-columns: 1fr 1fr; align-items: center; gap: 40px; } }
.signup h2 { font-size: clamp(1.5rem, 1.6vw + 1rem, 2rem); margin-top: 8px; }
.signup p:not(.eyebrow) { margin-top: 12px; color: var(--muted); }
.signup-form label { display: block; font-weight: 600; font-size: 0.95rem; }
.signup-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.signup-row input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.signup-row input::placeholder { color: var(--muted); opacity: 0.8; }
.signup-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.signup-row .button { min-height: 48px; border: 0; cursor: pointer; font: 600 1rem/1 var(--font); }
.signup .fine-print { font-size: 0.88rem; }

/* Closing call to action */
.closer .wrap {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 20px;
  justify-items: start;
  padding-top: clamp(56px, 8vw, 88px);
  padding-bottom: clamp(56px, 8vw, 88px);
}
@media (min-width: 760px) {
  .closer .wrap { grid-template-columns: 1fr auto; align-items: center; }
}
.closer h2 { max-width: 20ch; }
.closer p:not(.eyebrow) { margin-top: 10px; color: var(--on-monitor-muted); }

/* ---------- Support page ---------- */

.page-hero .wrap { position: relative; z-index: 1; padding-top: clamp(20px, 5vw, 56px); padding-bottom: clamp(48px, 7vw, 80px); }
.page-hero h1 { font-size: clamp(2.2rem, 3.4vw + 1rem, 3.4rem); margin-top: 12px; }
.page-hero p:not(.eyebrow) { margin-top: 16px; max-width: 40rem; color: var(--on-monitor-muted); font-size: 1.15rem; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.button:hover { background: var(--brand-strong); color: #fff; transform: translateY(-1px); }
@media (prefers-color-scheme: dark) {
  .button { color: #04101f; }
  .button:hover { color: #04101f; }
}
.monitor .button { background: var(--trace); color: #04101f; }
.monitor .button:hover { background: #b4efff; color: #04101f; box-shadow: 0 8px 24px -8px rgb(127 227 255 / 0.5); }

.support-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.support-grid .card h2 { font-size: 1.3rem; letter-spacing: -0.01em; }
.support-grid .card p { margin-top: 10px; }
.support-grid .card .button { margin-top: 18px; }
.checklist { margin: 12px 0 0; padding-left: 1.2em; color: var(--muted); }
.checklist li { margin: 4px 0; }
.notice { box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 45%, transparent), var(--elev-1); }
.mail { font-weight: 600; word-break: break-word; }

/* ---------- 404 ---------- */

.lost { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.lost main { flex: 1; display: grid; align-content: center; }
.lost .wrap { position: relative; z-index: 1; padding-top: 40px; padding-bottom: 200px; }
.lost h1 { font-size: clamp(2.2rem, 3.4vw + 1rem, 3.6rem); margin-top: 12px; }
.lost p:not(.eyebrow) { margin-top: 16px; color: var(--on-monitor-muted); max-width: 34rem; font-size: 1.1rem; }
.lost .button { margin-top: 28px; }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--line); padding: 36px 0 44px; font-size: 0.95rem; color: var(--muted); }
.site-footer .wrap { display: grid; gap: 18px; }
@media (min-width: 760px) {
  .site-footer .wrap { grid-template-columns: 1fr auto; align-items: start; }
}
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.footer-brand img { width: 28px; height: 28px; border-radius: 7px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; }
.footer-links a { color: var(--muted); text-decoration: underline; text-decoration-color: transparent; }
.footer-links a:hover { color: var(--text); text-decoration-color: currentColor; }
.disclaimer { grid-column: 1 / -1; max-width: 52rem; font-size: 0.88rem; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .badge:hover, .button:hover, .badge:active, .button:active { transform: none; }
}
