:root {
  /* Taken from the Heart Rate Logger icon and AppTheme. */
  --night: #18191c;
  --paper: #f4f3f0;
  --moon: #3a3b40;
  --pulse: #ff6b6b;

  --bg: var(--night);
  --ink: var(--paper);
  --quiet: #9a9ba1;
  --grid: #2b2c31;
  --line: var(--paper);
  --accent: var(--pulse);

  --measure: 38rem;
  --gutter: clamp(1rem, 5vw, 4rem);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfbfa;
    --ink: var(--night);
    --quiet: #5f6066;
    --grid: #e4e4e2;
    --line: var(--night);
    --accent: #e0484d;
    color-scheme: light;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent);
}

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

.wrap {
  padding-inline: var(--gutter);
  max-width: 76rem;
  margin-inline: auto;
}

/* Site bar */

.site-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-block: 1.5rem;
  color: var(--quiet);
  font-size: 0.9375rem;
}

.site-bar a {
  text-decoration: none;
}

.site-name {
  color: var(--ink);
  font-weight: 600;
}

/* Hero */

.hero {
  padding-top: clamp(2rem, 8vw, 6rem);
}

.app-mark {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.app-mark img {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 22.5%;
  box-shadow: 0 0 0 1px var(--grid);
}

.app-mark p {
  margin: 0;
  color: var(--quiet);
  font-size: 0.9375rem;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 11vw, 8.5rem);
  font-weight: 600;
  font-stretch: 80%;
  font-variation-settings: "wdth" 80;
  line-height: 0.9;
  letter-spacing: -0.03em;
}

.lede {
  max-width: var(--measure);
  margin: 1.5rem 0 0;
  font-size: clamp(1.1875rem, 2.2vw, 1.4375rem);
  line-height: 1.45;
}

/* Overnight trace */

.trace {
  margin: clamp(3rem, 8vw, 5rem) 0 0;
}

.trace-plot {
  position: relative;
  height: clamp(13rem, 32vw, 22rem);
}

.trace-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.trace-grid line {
  stroke: var(--grid);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.trace-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.trace-bpm {
  position: absolute;
  left: 0;
  transform: translateY(-120%);
  color: var(--quiet);
  font-size: 0.8125rem;
}

.trace-low {
  position: absolute;
  width: 0;
  height: 0;
}

.trace-low::before {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  left: -0.5rem;
  top: -0.5rem;
  border-radius: 50%;
  background: var(--accent);
}

.trace-low span {
  position: absolute;
  top: 1rem;
  left: -6rem;
  width: 12rem;
  text-align: center;
  font-size: 0.9375rem;
  line-height: 1.35;
}

.trace-hours {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  color: var(--quiet);
  font-size: 0.8125rem;
}

.trace figcaption {
  margin-top: 1.25rem;
  color: var(--quiet);
  font-size: 0.875rem;
}

@media (prefers-reduced-motion: no-preference) {
  .js .trace-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 2.8s cubic-bezier(0.45, 0, 0.2, 1) 0.3s forwards;
  }

  .js .trace-low {
    opacity: 0;
    animation: arrive 0.5s ease-out 1.9s forwards;
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes arrive {
  to {
    opacity: 1;
  }
}

/* Sections */

section {
  padding-block: clamp(4rem, 10vw, 7rem) 0;
}

h2 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 600;
  font-stretch: 85%;
  font-variation-settings: "wdth" 85;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

section > p,
.prose p,
.prose ul {
  max-width: var(--measure);
}

.features {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(0, 2fr);
  column-gap: var(--gutter);
}

.features dt,
.features dd {
  padding-block: 1.25rem;
  border-top: 1px solid var(--grid);
}

.features dt {
  font-weight: 600;
}

.features dd {
  margin: 0;
  max-width: var(--measure);
}

.features dd p {
  margin: 0;
}

.features dd p + p {
  margin-top: 0.5rem;
  color: var(--quiet);
}

@media (max-width: 40rem) {
  .features {
    grid-template-columns: 1fr;
  }

  .features dd {
    padding-top: 0.25rem;
    border-top: 0;
  }
}

.quiet {
  color: var(--quiet);
}

/* Prose pages */

.prose {
  padding-top: clamp(2rem, 8vw, 5rem);
}

.prose h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  margin-bottom: 1rem;
}

.prose h2 {
  margin-top: 3rem;
  font-size: 1.5rem;
}

.prose li + li {
  margin-top: 0.5rem;
}

/* Footer */

footer {
  margin-top: clamp(5rem, 12vw, 9rem);
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--grid);
  color: var(--quiet);
  font-size: 0.9375rem;
}

footer p {
  margin: 0;
}
