/* Rounds: one light theme, taken from the app.
 * Layout: a bedside monitor. Calm paper-white ground, one live ECG, the patient on a phone,
 * and green only where something is yours to act on. */
:root {
  color-scheme: light;

  --bg: #f5f6fb;
  --surface: #ffffff;
  --mint: #e8f6ef;          /* the app's hero mint */
  --ink: #161929;
  --muted: #5f6271;         /* app muted, darkened a touch for 4.5:1 on --bg */
  --faint: #9b9ea8;
  --ring: rgba(22, 25, 41, 0.08);
  --accent: #029957;
  --accent-deep: #017a45;   /* accent as text: 5.0:1 on --bg */
  --accent-soft: rgba(2, 153, 87, 0.1);
  --warn: #e5011a;
  --warn-soft: rgba(229, 1, 26, 0.08);
  --info: #0482c0;
  --good: #028b4f;
  --grid: rgba(229, 1, 26, 0.09); /* ECG paper */

  --display: "Schibsted Grotesk", "Hanken Grotesk", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --shadow-soft: 0 1px 2px rgba(22, 25, 41, 0.04), 0 12px 32px rgba(22, 25, 41, 0.06);
  --shadow-lift: 0 2px 4px rgba(22, 25, 41, 0.05), 0 30px 60px -12px rgba(22, 25, 41, 0.18);
  /* Spring curves and their settle times; script.js replaces these with simulated springs
   * (CSS linear()) built from SPRING. These are the fallbacks. */
  --spring-main: cubic-bezier(0.22, 1.2, 0.36, 1);
  --spring-main-dur: 900ms;
  --spring-quick: cubic-bezier(0.22, 1.4, 0.36, 1);
  --spring-quick-dur: 260ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.icon { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }

.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ── Type ─────────────────────────────────────────────── */

.eyebrow {
  font: 700 0.8125rem/1 var(--body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 1.1rem;
}

h1, h2, h3 { font-family: var(--display); text-wrap: balance; color: var(--ink); }

h1 {
  font-weight: 800;
  font-size: clamp(2.6rem, 6.4vw, 5.25rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
}
h1 em { font-style: normal; color: var(--accent); }

h2 {
  font-weight: 800;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

h3 { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; }

.lede, .section-lede {
  color: var(--muted);
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  max-width: 34rem;
  margin-top: 1.4rem;
}

/* ── Buttons ──────────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0 1.5rem;
  border: 0;
  border-radius: 999px;
  font: 700 1rem/1 var(--body);
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  /* The app's glass over a vivid gradient */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, #03b468, var(--accent) 55%, var(--accent-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 8px 22px -6px rgba(2, 153, 87, 0.55);
  transition: transform var(--spring-quick-dur) var(--spring-quick), box-shadow 220ms ease;
}
.button:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 14px 28px -8px rgba(2,153,87,.6); }
.button:active { transform: translateY(0) scale(0.98); }
.button .icon { transition: transform var(--spring-quick-dur) var(--spring-quick); }
.button:hover .icon { transform: translateX(3px); }

.button--ghost {
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-soft);
}
.button--ghost:hover { box-shadow: inset 0 0 0 1px rgba(22,25,41,.14), var(--shadow-soft); }

.button--small { min-height: 2.6rem; padding: 0 1.1rem; font-size: 0.9375rem; }

/* ── Top bar ──────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  /* Solid, not frosted: a live blur behind a sticky bar re-renders every scroll frame. */
  background: rgba(245, 246, 251, 0.97);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.topbar.is-scrolled { border-bottom-color: var(--ring); }

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font: 800 1.25rem/1 var(--display);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand__mark { width: 1.75rem; height: 1.75rem; fill: var(--accent); }
.brand--quiet { font-size: 1.05rem; }
.brand--quiet .brand__mark { width: 1.4rem; height: 1.4rem; }

.nav { display: flex; gap: 1.75rem; margin-left: auto; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: color 160ms ease;
}
.nav a:hover { color: var(--ink); }

/* ── Hero ─────────────────────────────────────────────── */

.hero {
  position: relative;
  overflow: hidden;
  padding-block: clamp(3rem, 7vw, 6rem) clamp(6.5rem, 10vw, 8.5rem);
  background: radial-gradient(60rem 30rem at 85% 10%, var(--mint), transparent 70%);
}

.hero__ecg {
  position: absolute;
  inset: auto 0 0 0;
  width: 100%;
  height: 96px;
  opacity: 0.5;
  pointer-events: none;
}

.hero__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: clamp(2.5rem, 6vw, 5rem);
}

h1 .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
h1 .line > span { display: inline-block; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.2rem; }

.hero__note {
  margin-top: 1.4rem;
  color: var(--muted);
  font: 500 0.875rem/1.4 var(--mono);
  letter-spacing: 0.01em;
}

/* Phone */
.phone {
  will-change: transform;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  position: relative;
  margin: 0;
  transform-style: preserve-3d;
  justify-self: center;
  width: min(100%, 340px);
  padding: 9px;
  border-radius: 52px;
  background: linear-gradient(160deg, #2a2d38, #0f1117 60%, #23262f);
  box-shadow: var(--shadow-lift), inset 0 0 0 1.5px rgba(255, 255, 255, 0.08);
}

.phone__screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 640px;
  padding: 3.4rem 0.9rem 0.9rem;
  border-radius: 44px;
  background: var(--bg);
  overflow: hidden;
}

.hero__grid { perspective: 1600px; }
.phone { rotate: none; transform: perspective(1600px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)); }
.js .hero.is-in [data-hero="phone"] { transform: perspective(1600px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)); }

/* The real app, recorded: 720 × 1566, the simulator's own status bar and Dynamic Island. */
.phone__video {
  display: block;
  width: 100%;
  aspect-ratio: 720 / 1566;
  border-radius: 43px;
  background: var(--bg);
  object-fit: cover;
}
.phone--side { width: min(100%, 320px); }

.phone__play {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  min-height: 2.75rem;
  padding: 0 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 700 0.9375rem/1 var(--body);
  cursor: pointer;
}

/* ── Sections ─────────────────────────────────────────── */

.section { padding-block: clamp(4.5rem, 10vw, 8rem); }

.patient { background: var(--surface); border-block: 1px solid var(--ring); }

.patient__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: center;
}

.points { display: grid; gap: 1.6rem; margin-top: 2.6rem; }
.points li { display: flex; gap: 1rem; align-items: flex-start; }
.points__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.points p { color: var(--muted); margin-top: 0.2rem; max-width: 26rem; }

/* Door-to-diagnosis path */
.path { position: relative; margin-top: clamp(4rem, 8vw, 6rem); }
.path__line {
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  height: 80px;
  overflow: visible;
}
.path__line path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.path ol {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  padding-top: 6rem;
}
.path li { display: flex; flex-direction: column; gap: 0.2rem; }
.path li::before {
  content: "";
  width: 14px;
  height: 14px;
  margin: -3.35rem 0 2.1rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent);
}
.path b { font: 700 1.0625rem/1.2 var(--display); }
.path span { color: var(--muted); font-size: 0.9375rem; }

.topics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-top: clamp(3.5rem, 7vw, 5rem);
  padding-top: 2rem;
  border-top: 1px solid var(--ring);
}
.topics p { font-weight: 700; }
.topics ul { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.topics li {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--ring);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

/* ── Flashcards ───────────────────────────────────────── */

.cards__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr);
  gap: clamp(3rem, 7vw, 6rem);
  align-items: center;
}

.sources { display: grid; margin-top: 2.2rem; border-top: 1px solid var(--ring); }
.sources li {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1.05rem 0.25rem;
  border-bottom: 1px solid var(--ring);
}
.sources .icon { width: 1.5rem; height: 1.5rem; color: var(--accent); }
.sources b { display: block; }
.sources span { color: var(--muted); font-size: 0.9375rem; }

.deck {
  position: relative;
  width: min(100%, 400px);
  justify-self: center;
  padding-top: 28px;
  padding-bottom: 4.5rem;
  perspective: 1400px;
}

.deck__card {
  display: block;
  width: 100%;
  aspect-ratio: 10 / 11;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--ring);
  font: inherit;
  color: inherit;
  text-align: left;
}
.deck__card--back,
.deck__card--next { position: absolute; inset: 28px 0 auto 0; transform-origin: 50% 0; }
.deck__card--back { transform: translateY(-28px) scale(0.88); opacity: 0.55; }
.deck__card--next {
  transform: translateY(-14px) scale(0.94);
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font: 700 1.3rem/1.3 var(--display);
}
.deck__card--next p { color: var(--ink); opacity: 0.35; }

.deck__card--top {
  position: relative;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
  transform-style: preserve-3d;
  transition: transform var(--spring-main-dur) var(--spring-main);
}
.deck__card--top.is-flipped { transform: rotateY(180deg); }

.deck__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.8rem;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-lift), inset 0 0 0 1px var(--ring);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.deck__answer { transform: rotateY(180deg); background: linear-gradient(180deg, #fff, var(--mint)); }

.deck__q { font: 800 clamp(1.4rem, 2.6vw, 1.75rem)/1.2 var(--display); letter-spacing: -0.02em; }
.deck__a { color: var(--muted); font-size: 1.0625rem; }
.deck__hint { margin-top: auto; color: var(--muted); font: 500 0.8125rem/1 var(--mono); }

.tag {
  align-self: flex-start;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font: 700 0.75rem/1 var(--body);
  letter-spacing: 0.02em;
}
.tag--miss { background: var(--warn-soft); color: var(--warn); }

.deck__actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}
.deck__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9375rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--ring), var(--shadow-soft);
  transition: transform var(--spring-quick-dur) var(--spring-quick), background-color 200ms ease, color 200ms ease;
}
.deck__btn--miss { color: var(--warn); }
.deck__btn--knew { color: var(--good); }
.deck__btn--knew.is-pressed { background: var(--good); color: #fff; transform: scale(1.06); }

/* The top card leaving with "Knew it", and the next one stepping up */
.deck.is-advanced .deck__card--top { transform: translateX(120%) rotate(14deg); opacity: 0; transition: transform 650ms var(--ease-out), opacity 500ms ease 150ms; }
.deck.is-advanced .deck__card--next { transform: none; transition: transform var(--spring-main-dur) var(--spring-main) 120ms; }
.deck.is-advanced .deck__card--next p { opacity: 1; transition: opacity 400ms ease 300ms; }
.deck.is-advanced .deck__card--back { transform: translateY(-14px) scale(0.94); opacity: 1; transition: transform var(--spring-main-dur) var(--spring-main) 200ms, opacity 400ms ease 200ms; }

/* ── Join ─────────────────────────────────────────────── */

.join { padding-block: 0 clamp(4rem, 8vw, 6rem); }

.join__panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  text-align: center;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(2rem, 5vw, 3.5rem) clamp(3.5rem, 6vw, 4.5rem);
  border-radius: 36px;
  background: radial-gradient(40rem 20rem at 0% 0%, #f2fbf6, transparent 70%), var(--mint);
  box-shadow: inset 0 0 0 1px rgba(2, 153, 87, 0.14);
}
.join__ecg { position: absolute; inset: auto 0 0 0; width: 100%; height: 56px; opacity: 0.28; pointer-events: none; }
.join__copy { position: relative; }
.join__copy p { margin: 0.9rem auto 0; color: var(--muted); max-width: 26rem; }


/* ── Footer ───────────────────────────────────────────── */

.footer { padding-block: 2rem 2.5rem; border-top: 1px solid var(--ring); }
.footer__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; color: var(--muted); font-size: 0.875rem; }
.footer__inner p:last-child { margin-left: auto; }

/* ── Motion: start states only apply when script is running ── */

.js [data-hero] { opacity: 0; transform: translateY(14px); }
.js h1[data-hero] { opacity: 1; transform: none; }
.js h1[data-hero] .line > span { transform: translateY(105%); }
.js [data-hero="phone"] { transform: translateY(40px) scale(0.97); }
.js .hero.is-in [data-hero] { opacity: 1; transform: none; transition: opacity 600ms ease var(--d, 0ms), transform var(--spring-main-dur) var(--spring-main) var(--d, 0ms); }
.js .hero.is-in h1[data-hero] .line > span { transform: none; transition: transform 900ms var(--ease-out) var(--d, 0ms); }


.js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 700ms ease, transform 900ms var(--ease-out); transition-delay: var(--d, 0ms); }
.js [data-reveal].is-in { opacity: 1; transform: none; }


.js [data-path] .path__line path { stroke-dasharray: var(--len, 1400); stroke-dashoffset: var(--len, 1400); transition: stroke-dashoffset 1600ms var(--ease-out); }
.js [data-path].is-in .path__line path { stroke-dashoffset: 0; }
.js [data-path] li { opacity: 0; transform: translateY(10px); transition: opacity 500ms ease, transform var(--spring-main-dur) var(--spring-main); transition-delay: var(--d, 0ms); }
.js [data-path].is-in li { opacity: 1; transform: none; }

.js [data-deck] { opacity: 0; transform: translateY(30px) rotate(-3deg); transition: opacity 700ms ease, transform var(--spring-main-dur) var(--spring-main); }
.js [data-deck].is-in { opacity: 1; transform: none; }

/* Safety net: the start states above hide content until script.js reveals it. script.js adds
 * .ready once it has set everything up; if it never gets there (blocked, failed to load, threw),
 * this reveals the page after 2s instead of leaving it blank. */
@keyframes reveal-fallback { to { opacity: 1; transform: none; stroke-dashoffset: 0; } }
.js:not(.ready) :is([data-hero], h1[data-hero] .line > span, [data-reveal], [data-path] li, [data-path] .path__line path, [data-deck]) {
  animation: reveal-fallback 400ms ease 2s forwards;
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 960px) {
  .hero__grid, .patient__grid, .cards__grid, .join__panel { grid-template-columns: minmax(0, 1fr); }
  .cards__copy { order: -1; }
  .path ol { grid-template-columns: minmax(0, 1fr); gap: 1.4rem; padding-top: 0; padding-left: 2.2rem; border-left: 2.5px solid var(--accent); }
  .path li::before { position: absolute; margin: 0.25rem 0 0 -2.95rem; }
  .path li { position: relative; }
  .path__line { display: none; }
}

@media (max-width: 640px) {
  .nav { display: none; }
  .topbar .button--small { margin-left: auto; }
  .phone__screen { height: 580px; }
  .footer__inner p:last-child { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* The case-path line has no reveal to snap to, so it rests fully drawn. */
  .js [data-path] .path__line path { stroke-dashoffset: 0 !important; }
  /* The fallback animation is off here, so without script.js show the final state at once. */
  .js:not(.ready) :is([data-hero], h1[data-hero] .line > span, [data-reveal], [data-path] li, [data-deck]) { opacity: 1; transform: none; }
}

[hidden] { display: none !important; }
