/* Cardiac Mastery: design tokens
   Paper and grid come from ECG chart paper; red is the trace. */
:root {
  --paper: #FBF6F5;
  --surface: #FFFFFF;
  --grid-minor: rgba(214, 120, 120, 0.13);
  --grid-major: rgba(200, 70, 80, 0.24);
  --ink: #1B2130;
  --ink-soft: #5A6070;
  --rule: #E9DDDC;
  --trace: #C8102E;
  --trace-ink: #A50D25;
  --slate: #3B4A6B;
  --focus: #1F5FD1;

  --serif: ui-serif, "New York", Charter, "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;

  --tabbar-h: 58px;
  --gutter: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121620;
    --surface: #1A1F2B;
    --grid-minor: rgba(255, 110, 120, 0.07);
    --grid-major: rgba(255, 90, 105, 0.15);
    --ink: #ECEEF3;
    --ink-soft: #A3A9B7;
    --rule: #2A3040;
    --trace: #FF5266;
    --trace-ink: #FF7A8A;
    --slate: #9FB0D6;
    --focus: #7EA8FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121620; --surface: #1A1F2B;
  --grid-minor: rgba(255, 110, 120, 0.07); --grid-major: rgba(255, 90, 105, 0.15);
  --ink: #ECEEF3; --ink-soft: #A3A9B7; --rule: #2A3040;
  --trace: #FF5266; --trace-ink: #FF7A8A; --slate: #9FB0D6; --focus: #7EA8FF;
  color-scheme: dark;
}

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

/* Even line breaks: headings balance, body text avoids orphaned words. */
h1, h2, h3, .lede { text-wrap: balance; }
p, li { text-wrap: pretty; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#screen {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter)
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  outline: none;
}

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

/* ---------- Home: the rhythm strip ---------- */

.strip {
  position: relative;
  margin: 0 calc(var(--gutter) * -1);
  padding: 28px var(--gutter) 22px;
  background-color: var(--paper);
  background-image:
    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: 25px 25px, 25px 25px, 5px 5px, 5px 5px;
  background-position: -1px -1px;
  border-bottom: 1px solid var(--rule);
}

.strip h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(34px, 10vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.strip .lede {
  margin: 10px 0 0;
  max-width: 32ch;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.4;
}

.trace {
  display: block;
  width: 100%;
  height: 84px;
  margin: 18px 0 4px;
  overflow: visible;
}
.trace path {
  fill: none;
  stroke: var(--trace);
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.strip .calibration {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

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

.section { margin-top: 30px; }

.section h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
}

.section > p { margin: 0 0 14px; color: var(--ink-soft); font-size: 15px; }

.pack {
  display: grid;
  grid-template-columns: 6px 1fr;
  column-gap: 14px;
  padding: 14px 16px 14px 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
}
.pack + .pack { margin-top: 10px; }
.pack::before { content: ""; background: var(--trace); grid-row: span 3; }
.pack.locked::before { background: var(--rule); }
.pack h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.pack .meta { margin: 2px 0 0; font-size: 15px; color: var(--ink-soft); }
.pack .status { margin: 8px 0 0; font-size: 14px; color: var(--slate); }

/* ---------- Placeholder screens ---------- */

.page-head { padding-top: 18px; }
.page-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.1;
}

.empty {
  margin-top: 24px;
  padding: 22px 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.empty h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.empty p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.empty ul { margin: 12px 0 0; padding-left: 20px; color: var(--ink-soft); font-size: 15px; }
.empty li + li { margin-top: 4px; }

.build-note {
  margin-top: 36px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 6px max(8px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 4px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--rule);
  z-index: 10;
}
.tabbar a {
  flex: 1;
  max-width: 96px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 4px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
}
.tabbar svg {
  width: 25px; height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar a[aria-current="page"] { color: var(--trace-ink); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.1; }

.noscript { padding: 24px; text-align: center; }

