/* The trip-computer world from DESIGN.md, on the web: system ground, graphite ink, hairlines,
   square fuel segments, Barlow Semi Condensed for every figure and the system sans for words.
   Amber is only ever eating; Weight Blue is only ever weight. */

@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("/fonts/BarlowSemiCondensed-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("/fonts/BarlowSemiCondensed-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --ground: #ffffff;
  --ink: #000000;
  /* Secondary ink, darker than iOS's 60% so small text clears 4.5:1 on the web. */
  --ink-2: rgba(60, 60, 67, 0.78);
  --ink-3: rgba(60, 60, 67, 0.32);
  --rule: rgba(60, 60, 67, 0.22);
  --wash: rgba(120, 120, 128, 0.1);
  --fuel: #c27400;
  --amber-ink: #a35f00;
  --weight: #2c6fd1;
  --weight-wash: rgba(44, 111, 209, 0.28);
  --on-fuel: #000000;

  --figure: "Barlow Semi Condensed", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --gutter: clamp(20px, 5vw, 48px);
  --gap-seg: 3px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #000000;
    --ink: #ffffff;
    --ink-2: rgba(235, 235, 245, 0.66);
    --ink-3: rgba(235, 235, 245, 0.3);
    --rule: rgba(235, 235, 245, 0.18);
    --wash: rgba(118, 118, 128, 0.22);
    --fuel: #ffb020;
    --amber-ink: #ffb020;
    --weight: #5b9bff;
    --weight-wash: rgba(91, 155, 255, 0.34);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--ink);
  caret-color: var(--ink);
}

::selection { background: var(--ink-3); color: var(--ink); }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-3);
}
a:hover { text-decoration-color: currentColor; }

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

h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
b { font-weight: 600; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Figures: every number on the page. */
.figure, .figure-inline, .figure-big, .dial-value, .number-unit, .peek-figure {
  font-family: var(--figure);
  font-variant-numeric: tabular-nums;
}
.figure-inline { font-weight: 600; font-size: 1.12em; letter-spacing: 0.005em; }

/* Intro */
.intro {
  padding: clamp(36px, 8vw, 88px) 0 clamp(28px, 5vw, 48px);
  max-width: 40rem;
}
h1 {
  font-size: clamp(2.1rem, 1.2rem + 4vw, 3.6rem);
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.lede {
  margin-top: 16px;
  font-size: clamp(1.06rem, 1rem + 0.4vw, 1.25rem);
  color: var(--ink-2);
  max-width: 34em;
}

/* The instrument: dials and the readout. */
.instrument {
  display: grid;
  gap: 40px;
  border-top: 1px solid var(--ink);
  padding-top: 20px;
}
@media (min-width: 900px) {
  .instrument {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(40px, 6vw, 96px);
    align-items: start;
  }
  .readout { position: sticky; top: 24px; }
}

h2 { font-size: 1.45rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h3 { font-size: 1.15rem; font-weight: 600; }

.dials { display: grid; }
.dials-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
}

.dial {
  border: 0;
  margin: 0;
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--rule);
  min-width: 0;
}
.dial:last-child { border-bottom: 0; }
fieldset.dial > legend { padding: 0; float: left; width: 100%; margin-bottom: 10px; }
fieldset.dial > legend + * { clear: both; }
.dial-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.dial-label { font-size: 1rem; font-weight: 500; }
.dial-value { font-size: 1.65rem; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.dial-note { font-size: 0.88rem; color: var(--ink-2); margin: 2px 0 10px; }
.dial .segmented-wide + .dial-note { margin-top: 10px; }

/* Sliders: a hairline track filled in ink to the value, and a square tick for a thumb,
   like the number tick on the gauge. The input is 44px tall so it's easy to grab. */
input[type="range"] {
  --pct: 50%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
input[type="range"]:focus-visible { outline-offset: 0; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) var(--pct), var(--ink-3) var(--pct));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 30px;
  margin-top: -14px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--ground);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--ink-3); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 30px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--ground);
}

/* Segmented controls: square, ruled, the chosen segment inked in. */
.segmented {
  display: inline-flex;
  border: 1px solid var(--ink-3);
}
.segmented button, .segmented label {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 500 0.94rem/1 var(--text);
  min-height: 40px;
  min-width: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 120ms linear, color 120ms linear;
}
.segmented > * + * { border-left: 1px solid var(--ink-3); }
.segmented button[aria-pressed="true"],
.segmented label:has(input:checked) {
  background: var(--ink);
  color: var(--ground);
}
.segmented button:hover:not([aria-pressed="true"]),
.segmented label:hover:not(:has(input:checked)) { background: var(--wash); }
.segmented label input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; z-index: 1; }
.segmented-wide { display: flex; }
.segmented-wide > * { flex: 1; }

/* Everyday-life choices: rows with a square marker, filled when chosen. */
.choices { display: grid; }
.choice {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 2px 14px;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}
.choice:first-child { border-top: 0; padding-top: 4px; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--ink-2);
  transform: translateY(3px);
  transition: box-shadow 120ms linear;
}
.choice:has(input:checked) .choice-mark { box-shadow: inset 0 0 0 1.5px var(--ink), inset 0 0 0 5px var(--ground), inset 0 0 0 9px var(--ink); }
.choice:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.choice-name { font-weight: 600; }
.choice-detail { grid-column: 2; font-size: 0.9rem; color: var(--ink-2); }

/* The readout. */
/* The readout opens on the same line and level as the dials' "About you". */
.readout-head { min-height: 42px; display: flex; align-items: center; padding-bottom: 8px; }
.number {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 10px;
  margin-top: 2px;
}
.number .figure {
  font-size: clamp(4.25rem, 3rem + 4vw, 4.75rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.number-unit { font-size: 1.45rem; font-weight: 500; color: var(--ink-2); }
.readout-sub { margin-top: 8px; color: var(--ink-2); }

.gauge-block { margin-top: 28px; }
/* The Fuel Gauge: one segment per 250 kcal, from nothing to what you burn today. Amber up
   to the number is what you eat; blue past it is what your body covers. */
.gauge {
  --n: 12;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: var(--gap-seg);
  height: 36px;
}
.seg {
  box-shadow: inset 0 0 0 1px var(--ink-2);
  background: linear-gradient(to right,
    var(--fuel) 0 var(--eat, 0%),
    var(--weight-wash) var(--eat, 0%) var(--body, 0%),
    transparent var(--body, 0%));
}
.gauge-tick {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
}
.gauge-ends {
  position: relative;
  height: 1.2em;
  margin-top: 8px;
  font: 500 0.94rem/1.2 var(--figure);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.gauge-ends .gauge-burn {
  position: absolute;
  top: 0;
  transform: translateX(-100%);
  white-space: nowrap;
  padding-right: 6px;
}
/* A hairline under the gauge where today's burn ends, part-way into the last segment. */
.gauge-burn-mark {
  position: absolute;
  bottom: -9px;
  width: 1px;
  height: 7px;
  background: var(--ink-2);
}
.to-beta { display: inline-flex; align-items: center; margin-top: 16px; font-weight: 600; min-height: 44px; }
.signup-needs { margin: -4px 0 12px; color: var(--ink-2); }
.chart .milestone { fill: var(--ground); stroke: var(--ink); stroke-width: 1.5; }
.legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
}
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; flex: none; }
.swatch-eat { background: var(--fuel); }
.swatch-body { background: var(--weight-wash); box-shadow: inset 0 0 0 1px var(--weight); }

.explain { margin-top: 20px; max-width: 36em; }
.caution {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 0.94rem;
  color: var(--ink-2);
}

.rows { margin: 22px 0 0; border-top: 1px solid var(--rule); }
.rows > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  min-height: 44px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.rows dt { color: var(--ink-2); }
.rows dd { margin: 0; font-size: 1.2rem; text-align: right; }

/* The route. */
.route, .beta {
  margin-top: clamp(64px, 10vw, 120px);
  border-top: 1px solid var(--ink);
  padding-top: 20px;
}
.route-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px 32px;
}
.section-lede { margin-top: 6px; color: var(--ink-2); max-width: 38em; }

.chart { margin: 28px 0 0; }
.chart svg { display: block; width: 100%; height: clamp(220px, 32vw, 340px); overflow: visible; }
.chart text { font-family: var(--figure); font-variant-numeric: tabular-nums; fill: var(--ink-2); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .goal { stroke: var(--ink); stroke-opacity: 0.7; stroke-dasharray: 3 3; }
.chart .goal-label { fill: var(--ink); font-weight: 600; }
.chart .path { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .start { fill: var(--weight); }
.chart .end { fill: var(--ink); }
.chart .end-label { fill: var(--ink); font-weight: 600; }

.horizon {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0 0;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.horizon dt { color: var(--ink-2); font-size: 0.94rem; }
.horizon dd { margin: 2px 0 0; }
.figure-big { font-size: clamp(2rem, 1.6rem + 1.8vw, 2.75rem); font-weight: 600; line-height: 1; }

.route h3 { margin-top: 40px; }
.milestones {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.milestones th {
  text-align: left;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.milestones td { padding: 12px 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.milestones th:not(:first-child), .milestones td:not(:first-child) { text-align: right; padding-left: 12px; }
.milestones .figure-inline { font-size: 1.15rem; }
.milestones .when-date { display: block; font-size: 0.85rem; color: var(--ink-2); }

.route-none { margin-top: 24px; font-size: 1.1rem; }

.method { margin-top: 36px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.method summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.method summary::-webkit-details-marker { display: none; }
.method summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms var(--ease);
}
.method[open] summary::before { transform: rotate(45deg); }
.method p { color: var(--ink-2); max-width: 40em; margin-bottom: 14px; }

/* The beta. */
.how {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
  counter-reset: how;
}
@media (min-width: 900px) {
  .how { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
}
.how li {
  padding: 14px 0 18px;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  max-width: 30em;
}
.how b { display: block; color: var(--ink); font-size: 1.06rem; margin-bottom: 4px; }

.signup { margin-top: 40px; max-width: 34rem; }
.signup-label { display: block; font-size: 1.15rem; font-weight: 600; margin-bottom: 12px; }
.signup-row { display: flex; gap: 10px; flex-wrap: wrap; }
.signup input[type="email"] {
  flex: 1 1 16rem;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--ink-2);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 1.06rem var(--text);
}
.signup input[type="email"]::placeholder { color: var(--ink-2); opacity: 1; }
.signup input[type="email"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.signup input[aria-invalid="true"] { border-color: var(--ink); border-width: 2px; }
.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 9999px;
  background: var(--ink);
  color: var(--ground);
  font: 600 1.06rem var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: filter 120ms linear;
}
.button-primary:hover { filter: contrast(0.85); }
.button-primary:active { filter: contrast(0.7); }
.button-primary:disabled { opacity: 0.55; cursor: progress; }
.signup-error { margin-top: 10px; font-weight: 600; }
.signup-note { margin-top: 12px; font-size: 0.88rem; color: var(--ink-2); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.done { margin-top: 40px; max-width: 34rem; outline: none; }
.done-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.done-text { margin: 8px 0 20px; color: var(--ink-2); }

/* The number, following your thumb on a phone while the readout is out of view. */
.peek {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--ground);
  border-top: 1px solid var(--ink);
  transform: translateY(105%);
  transition: transform 260ms var(--ease);
}
.peek.is-shown { transform: none; }
.peek-label { font-weight: 500; color: var(--ink-2); }
.peek-figure { font-size: 2rem; font-weight: 600; line-height: 1; }
.peek-unit { font-size: 1rem; font-weight: 500; color: var(--ink-2); }
@media (min-width: 900px) { .peek { display: none; } }

.foot {
  max-width: 1180px;
  margin: clamp(64px, 10vw, 120px) auto 0;
  padding: 20px var(--gutter) calc(32px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: 0.88rem;
  color: var(--ink-2);
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

/* Privacy and other plain pages. */
.prose { max-width: 44rem; padding-top: clamp(28px, 6vw, 64px); }
.prose .back { font-size: 0.94rem; margin-bottom: 28px; }
.prose h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 2.8rem); }
.prose h2 { margin: 36px 0 8px; font-size: 1.15rem; }
.prose p + p { margin-top: 12px; }
.prose .updated { margin-top: 40px; font-size: 0.88rem; color: var(--ink-2); }
