/* CalKit website. Tokens follow the app (lib/presentation/theme/):
   black ground, white for anything tappable, one hue per macro and domain,
   Geist for words, Barlow Condensed for numbers. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ground: #000;
  --surface: #141416;
  --raised: #1e1e21;
  --hairline: rgb(255 255 255 / 0.08);
  --hairline-strong: rgb(255 255 255 / 0.16);
  --text: #fff;
  --text-2: #a1a1aa;
  --text-3: #8b8b90;

  --protein: #f472b6;
  --carbs: #facc15;
  --fat: #38bdf8;
  --activity: #e87722;
  --sleep: #818cf8;
  --recovery: #2dd4bf;
  --heart: #ff5a6e;
  --biology: #c084fc;

  --words: "Geist", ui-sans-serif, system-ui, sans-serif;
  --numbers: "Barlow Condensed", "Arial Narrow", sans-serif;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 72px;
  --s9: 112px;

  --page: min(1120px, 100% - 2 * var(--s5));
  --measure: 66ch;

  color-scheme: dark;
}

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

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

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

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: var(--s4);
  top: -100px;
  padding: var(--s2) var(--s4);
  background: var(--text);
  color: var(--ground);
  z-index: 10;
}
.skip:focus {
  top: var(--s4);
}

.wrap {
  width: var(--page);
  margin-inline: auto;
}

/* Header and footer ------------------------------------------------------ */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding-block: var(--s5);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.mark img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.masthead nav {
  display: flex;
  align-items: center;
  gap: var(--s5);
  font-size: 0.9375rem;
  color: var(--text-2);
}
.masthead nav a {
  text-decoration: none;
}
.masthead nav a:hover {
  color: var(--text);
}

.footer {
  margin-top: var(--s9);
  border-top: 1px solid var(--hairline);
  padding-block: var(--s7) var(--s8);
  color: var(--text-3);
  font-size: 0.875rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(2, 1fr);
  gap: var(--s6);
}
.footer h2 {
  margin: 0 0 var(--s3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
}
.footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s2);
}
.footer a {
  text-decoration: none;
}
.footer a:hover {
  color: var(--text);
  text-decoration: underline;
}
.footer p {
  margin: 0 0 var(--s2);
  max-width: 44ch;
}

/* Buttons ----------------------------------------------------------------- */

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}

.button {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
  padding: var(--s2) var(--s5);
  border-radius: 14px;
  background: var(--text);
  color: var(--ground);
  text-decoration: none;
  line-height: 1.15;
}
.button small {
  font-size: 0.6875rem;
  font-weight: 500;
  opacity: 0.7;
}
.button strong {
  font-size: 1.0625rem;
  font-weight: 600;
}
.button.ghost {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--hairline-strong);
}
.button:hover {
  filter: brightness(0.9);
}

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

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: var(--s8);
  align-items: end;
  padding-block: var(--s8) var(--s7);
}

.hero h1 {
  margin: 0 0 var(--s5);
  font-size: clamp(2.75rem, 6.2vw, 5rem);
  line-height: 0.98;
  font-weight: 650;
  letter-spacing: -0.045em;
  max-width: 11ch;
}

.lede {
  margin: 0 0 var(--s6);
  max-width: 42ch;
  font-size: 1.1875rem;
  line-height: 1.5;
  color: var(--text-2);
}

/* The estimate: what the app returns for one photo. */
.estimate {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 28px;
  padding: var(--s6);
}
.estimate-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  margin: 0 0 var(--s4);
  font-size: 1rem;
  font-weight: 600;
}
.estimate-title span {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-3);
}
.items {
  list-style: none;
  margin: 0 0 var(--s5);
  padding: 0;
}
.items li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--s4);
  align-items: baseline;
  padding-block: var(--s3);
  border-bottom: 1px solid var(--hairline);
  color: var(--text-2);
}
.items .qty,
.items .kcal {
  font-family: var(--numbers);
  font-weight: 600;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}
.items .qty {
  color: var(--text-3);
}
.items .kcal {
  color: var(--text);
  min-width: 3.2ch;
  text-align: right;
}
.total {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
}
.total b {
  font-family: var(--numbers);
  font-weight: 700;
  font-size: clamp(4.5rem, 9vw, 6.5rem);
  line-height: 0.85;
  letter-spacing: -0.01em;
}
.total span {
  color: var(--text-2);
}

/* The macro strip: the meal's split in grams, full page width. */
.strip {
  display: flex;
  gap: 3px;
  height: 14px;
  margin-top: var(--s7);
}
.strip span {
  border-radius: 3px;
  transform-origin: left center;
  animation: grow 900ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.strip .p {
  flex: 38;
  background: var(--protein);
}
.strip .c {
  flex: 62;
  background: var(--carbs);
  animation-delay: 120ms;
}
.strip .f {
  flex: 22;
  background: var(--fat);
  animation-delay: 240ms;
}
.strip-legend {
  display: flex;
  gap: 3px;
  margin-top: var(--s3);
  font-size: 0.875rem;
  color: var(--text-2);
}
.strip-legend > * {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
}
.strip-legend b {
  font-family: var(--numbers);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--text);
}
.strip-legend .p {
  flex: 38;
}
.strip-legend .c {
  flex: 62;
}
.strip-legend .f {
  flex: 22;
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

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

.section {
  padding-top: var(--s9);
}
.section > h2 {
  margin: 0 0 var(--s4);
  font-size: clamp(1.875rem, 3.6vw, 2.75rem);
  line-height: 1.08;
  font-weight: 620;
  letter-spacing: -0.035em;
  max-width: 20ch;
}
.section > p {
  margin: 0 0 var(--s7);
  max-width: 54ch;
  color: var(--text-2);
  font-size: 1.0625rem;
}

/* Ways to log: a plain list of the four entry points. */
.ways {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--hairline-strong);
}
.ways li {
  padding: var(--s5) var(--s5) 0 0;
}
.ways li + li {
  padding-left: var(--s5);
  border-left: 1px solid var(--hairline);
}
.ways h3 {
  margin: 0 0 var(--s2);
  font-size: 1.0625rem;
  font-weight: 600;
}
.ways p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.9375rem;
}

/* Scores: what health data turns into, each in its domain hue. */
.scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s4);
}
.score {
  padding: var(--s5);
  background: var(--surface);
  border-radius: 20px;
}
.score dt {
  font-size: 0.9375rem;
  color: var(--text-2);
}
.score dd {
  margin: var(--s2) 0 0;
  font-family: var(--numbers);
  font-weight: 700;
  font-size: 3.5rem;
  line-height: 1;
  color: var(--hue);
}
.score.recovery {
  --hue: var(--recovery);
}
.score.sleep {
  --hue: var(--sleep);
}
.score.activity {
  --hue: var(--activity);
}
.score.heart {
  --hue: var(--heart);
}
.score dd small {
  font-family: var(--words);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-3);
  margin-left: var(--s1);
}
.sources {
  margin-top: var(--s5);
  color: var(--text-3);
  font-size: 0.9375rem;
}

/* Biology: one blood marker against its range. */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s8);
  align-items: center;
}
.split h2 {
  margin: 0 0 var(--s4);
  font-size: clamp(1.875rem, 3.6vw, 2.75rem);
  line-height: 1.08;
  font-weight: 620;
  letter-spacing: -0.035em;
}
.split p {
  margin: 0;
  color: var(--text-2);
  font-size: 1.0625rem;
  max-width: 46ch;
}
.age {
  padding: var(--s6);
  border-radius: 28px;
  border: 1px solid var(--hairline);
  background: var(--surface);
}
.age-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
}
.age-row + .age-row {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--hairline);
}
.age-row span {
  color: var(--text-2);
}
.age-row b {
  font-family: var(--numbers);
  font-weight: 700;
  font-size: 2.75rem;
  line-height: 1;
}
.age-row .bio {
  color: var(--biology);
}
.footnote {
  margin-top: var(--s4);
  font-size: 0.8125rem;
  color: var(--text-3);
}

/* Privacy: where each kind of data lives. */
.places {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s6);
}
.places h3 {
  margin: 0 0 var(--s2);
  padding-top: var(--s4);
  border-top: 2px solid var(--line);
  font-size: 1.0625rem;
  font-weight: 600;
}
.places p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.9375rem;
}
.places .phone {
  --line: var(--text);
}
.places .server {
  --line: var(--text-2);
}
.places .passing {
  --line: var(--hairline-strong);
}
.more {
  margin-top: var(--s6);
}

.closing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s5);
  margin-top: var(--s9);
  padding: var(--s7);
  border-radius: 28px;
  background: var(--surface);
}
.closing h2 {
  margin: 0 0 var(--s2);
  font-size: 1.75rem;
  font-weight: 620;
  letter-spacing: -0.03em;
}
.closing p {
  margin: 0;
  color: var(--text-2);
  max-width: 52ch;
}

/* Legal documents --------------------------------------------------------- */

.doc {
  display: grid;
  grid-template-columns: 220px minmax(0, var(--measure));
  gap: var(--s8);
  padding-top: var(--s7);
}
.doc-nav {
  position: sticky;
  top: var(--s5);
  align-self: start;
  font-size: 0.875rem;
}
.doc-nav h2 {
  margin: 0 0 var(--s3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-3);
}
.doc-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s2);
}
.doc-nav a {
  color: var(--text-2);
  text-decoration: none;
}
.doc-nav a:hover,
.doc-nav a[aria-current="page"] {
  color: var(--text);
}

.doc article h1 {
  margin: 0 0 var(--s3);
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  line-height: 1.02;
  font-weight: 650;
  letter-spacing: -0.04em;
}
.meta {
  margin: 0 0 var(--s7);
  color: var(--text-3);
  font-size: 0.9375rem;
}
.summary {
  margin: 0 0 var(--s7);
  padding: var(--s5) var(--s5) var(--s5) var(--s5);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-2);
}
.summary h2 {
  margin: 0 0 var(--s3) !important;
  padding: 0 !important;
  border: 0 !important;
  font-size: 1rem !important;
  color: var(--text);
}
.summary ul {
  margin: 0;
  padding-left: 1.2em;
}
.doc article h2 {
  margin: var(--s7) 0 var(--s3);
  padding-top: var(--s5);
  border-top: 1px solid var(--hairline);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  scroll-margin-top: var(--s5);
}
.doc article h3 {
  margin: var(--s5) 0 var(--s2);
  font-size: 1.0625rem;
  font-weight: 600;
}
.doc article p,
.doc article li {
  color: #d4d4d8;
}
.doc article ul,
.doc article ol {
  padding-left: 1.3em;
}
.doc article li + li {
  margin-top: var(--s2);
}
.doc article strong {
  color: var(--text);
  font-weight: 600;
}

.table {
  overflow-x: auto;
  margin: var(--s4) 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
th,
td {
  text-align: left;
  vertical-align: top;
  padding: var(--s3) var(--s4) var(--s3) 0;
  border-bottom: 1px solid var(--hairline);
  color: #d4d4d8;
}
th {
  font-weight: 500;
  color: var(--text-2);
  border-bottom-color: var(--hairline-strong);
}

/* Details still to be filled in before publishing. */
.fill {
  background: rgb(250 204 21 / 0.16);
  color: var(--carbs);
  padding: 0 0.25em;
  border-radius: 4px;
}

.notfound {
  padding-block: var(--s9);
}
.notfound h1 {
  margin: 0 0 var(--s4);
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
.notfound p {
  color: var(--text-2);
  max-width: 44ch;
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 900px) {
  .hero,
  .split,
  .doc {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s7);
  }
  .hero {
    padding-top: var(--s6);
  }
  .ways {
    grid-template-columns: 1fr 1fr;
  }
  .ways li:nth-child(3) {
    border-left: 0;
    padding-left: 0;
  }
  .ways li {
    padding-bottom: var(--s5);
  }
  .scores {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .places {
    grid-template-columns: 1fr;
    gap: var(--s5);
  }
  .doc-nav {
    position: static;
  }
  .doc-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2) var(--s4);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-grid > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .masthead nav .hide-small {
    display: none;
  }
  .estimate,
  .closing {
    padding: var(--s5);
  }
  .ways {
    grid-template-columns: 1fr;
  }
  .ways li + li {
    border-left: 0;
    padding-left: 0;
  }
  .strip-legend {
    font-size: 0.75rem;
  }
  .strip-legend b {
    font-size: 1.125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .strip span {
    animation: none;
  }
}
