/* KeptIt — keptitapp.com
 *
 * Every value here is lifted from the app's design system rather than chosen to
 * look similar: colours from AppColor.swift, spacing and radii from
 * AppMetrics.swift, the type treatment from AppFont.swift. The point is that
 * the site and the product are the same object, not two things that rhyme.
 */

:root {
  /* Ground and ink — AppColor */
  --paper:        #FBFCF9;
  --surface:      #FFFFFF;
  --ink:          #0F1611;
  --ink-rgb:      15, 22, 17;
  --muted:        #5A6459;
  --separator:    #E0E6DC;

  /* Forest green, the brand */
  --forest:       #14532D;
  --forest-rgb:   20, 83, 45;
  /* The wordmark's second tone. #14532D against #0F1611 is ~5 points of
     luminance apart, which made "KeptIt" read as "Keptlt". */
  --mark:         #2E7D52;
  --on-accent:    #FFFFFF;

  /* Coordinate grid behind the sphere */
  --grid-rgb:     15, 22, 17;
  --grid-alpha:   0.055;

  /* Per-activity tints, matching ChallengeType.tint */
  --steps:        #14532D;
  --distance:     #0E6E8C;
  --flights:      #8A4A12;
  --sleep:        #2F3E8F;
  --workout:      #A8451C;
  --readiness:    #0F6E63;
  --recovery:     #5F3A94;
  --danger:       #B3261E;

  /* Metrics */
  --hairline: 0.5px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 26px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #0D0F0D;
    --surface:    #161916;
    --ink:        #E9EEE9;
    --ink-rgb:    233, 238, 233;
    --muted:      #96A096;
    --separator:  #242A24;

    --forest:     #3ECF8E;
    --forest-rgb: 62, 207, 142;
    --mark:       #7FD8A0;
    --on-accent:  #0D0F0D;

    --grid-rgb:   255, 255, 255;
    --grid-alpha: 0.05;

    --steps:      #3ECF8E;
    --distance:   #5CC8E8;
    --flights:    #F0A860;
    --sleep:      #93A6FF;
    --workout:    #FF9166;
    --readiness:  #46DCC4;
    --recovery:   #C78BFF;
    --danger:     #FF6B6B;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  /* SF Pro, not rounded — AppFont uses the system face at medium weights. */
  font: 400 17px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 20px 96px;          /* Metrics.Spacing.screen */
}

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

h1 {
  font-size: clamp(38px, 8vw, 56px);
  line-height: 1.04;
  letter-spacing: -1.5px;        /* bbLargeTitle tracking */
  font-weight: 500;              /* display weights lifted to .medium */
  margin: 0 0 12px;
  text-wrap: balance;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.7px;
  font-weight: 500;
  margin: 56px 0 12px;
  text-wrap: balance;
}

h3 {
  font-size: 18px;
  letter-spacing: -0.3px;
  font-weight: 500;
  margin: 32px 0 8px;
}

p { margin: 0 0 16px; }

/* bbEyebrowStyle — sentence case, not the old uppercase mono */
.eyebrow {
  font-size: 14px;
  letter-spacing: 0;
  color: var(--muted);
  margin: 0 0 8px;
}

.lede {
  font-size: 20px;
  line-height: 1.5;
  letter-spacing: -0.2px;
  color: var(--muted);
  max-width: 34rem;
}

a { color: var(--forest); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

ul { padding-left: 0; list-style: none; margin: 0 0 16px; }
li { margin: 0; }

strong { font-weight: 500; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: rgba(var(--forest-rgb), 0.09);
  padding: 2px 6px;
  border-radius: 5px;
}

/* ── Wordmark ──────────────────────────────────────────────── */

.wordmark {
  display: inline-block;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.3px;
  text-decoration: none;
  color: var(--ink);
}
.wordmark span { color: var(--mark); }

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

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0;
}
.masthead nav { display: flex; gap: 20px; font-size: 15px; }
.masthead nav a { color: var(--muted); text-decoration: none; }
.masthead nav a:hover { color: var(--ink); }

.hero {
  position: relative;
  display: grid;
  place-items: center;
  padding: 8px 0 40px;
}

/* Reserves the sphere's space in the layout. The dots themselves live on
   #field, which is fixed to the viewport so they can scatter across the whole
   page rather than staying trapped in this box. */
[data-sphere-anchor] {
  width: min(620px, 94vw);
  height: min(620px, 94vw);
  display: block;
}

#field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

/* Content sits above the dot field. Without this the dispersed dots would draw
   over the copy instead of behind it. */
main { position: relative; z-index: 1; }

/* The headline sits inside the sphere's scrim, which is what the scrim is for. */
.hero-copy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  padding: 0 8px;
}
.hero-copy h1 {
  margin: 0;
  /* Held inside the scrim. Wider than this and the descenders start colliding
     with the dot field, which reads as a mistake rather than as depth. */
  font-size: clamp(27px, 5.6vw, 41px);
  letter-spacing: -1.1px;
  line-height: 1.08;
  max-width: 11ch;
  justify-self: center;
}
.hero-copy .eyebrow { margin-bottom: 10px; }
.hero-copy .sub {
  margin: 14px auto 0;
  max-width: 22ch;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.page-head {
  padding: 40px 0 32px;
  border-bottom: var(--hairline) solid var(--separator);
  margin-bottom: 32px;
}
.page-head h1 { font-size: clamp(32px, 6vw, 42px); letter-spacing: -1.2px; }

/* ── Steps list ────────────────────────────────────────────── */

.steps { display: grid; gap: 2px; margin: 24px 0 0; }

.steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: var(--hairline) solid var(--separator);
}
.steps li:first-child { border-top: var(--hairline) solid var(--separator); }

.steps .n {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--muted);
  min-width: 1.5em;
}
.steps .t { letter-spacing: -0.2px; }
.steps .d { display: block; color: var(--muted); font-size: 15px; margin-top: 2px; }

/* ── Cards ─────────────────────────────────────────────────── */

.card {
  margin: 32px 0 0;
  padding: 28px;
  border: var(--hairline) solid var(--separator);
  border-radius: var(--r-xl);
  background: var(--surface);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.note {
  border-left: 2px solid var(--forest);
  padding: 4px 0 4px 16px;
  margin: 24px 0;
  color: var(--muted);
}

/* ── Tables ────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 20px 0; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td {
  text-align: left;
  padding: 12px 16px 12px 0;
  border-bottom: var(--hairline) solid var(--separator);
  vertical-align: top;
}
th { font-weight: 500; color: var(--muted); }

/* ── Forms ─────────────────────────────────────────────────── */

form { display: flex; flex-direction: column; gap: 20px; margin-top: 24px; }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }

label, legend {
  font-size: 14px;
  color: var(--muted);
  padding: 0;
}

input[type="text"], input[type="email"], input[type="password"], textarea {
  font: inherit;
  font-size: 16px;               /* below 16px iOS zooms the page on focus */
  color: var(--ink);
  background: var(--paper);
  border: var(--hairline) solid var(--separator);
  border-radius: var(--r-sm);
  padding: 13px 14px;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.6; }
textarea { resize: vertical; min-height: 130px; line-height: 1.5; }

input:focus-visible, textarea:focus-visible, button:focus-visible, .chip:focus-within {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.hint { margin: 0; font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.chip {
  --tint: var(--forest);
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  letter-spacing: -0.1px;
  color: var(--ink);
  border: var(--hairline) solid var(--separator);
  border-radius: 999px;
  padding: 9px 15px;
  cursor: pointer;
  user-select: none;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--tint); }
.chip:has(input:checked) {
  background: var(--tint);
  border-color: var(--tint);
  /* The ground colour, not white — in dark mode the tints are light and white
     text on them is unreadable. */
  color: var(--paper);
}

.chip[data-t="steps"]     { --tint: var(--steps); }
.chip[data-t="distance"]  { --tint: var(--distance); }
.chip[data-t="flights"]   { --tint: var(--flights); }
.chip[data-t="sleep"]     { --tint: var(--sleep); }
.chip[data-t="workouts"]  { --tint: var(--workout); }
.chip[data-t="readiness"] { --tint: var(--readiness); }
.chip[data-t="recovery"]  { --tint: var(--recovery); }

button {
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.2px;
  color: var(--on-accent);
  background: var(--forest);
  border: 0;
  border-radius: var(--r-lg);
  padding: 15px 22px;
  cursor: pointer;
  align-self: flex-start;
  transition: opacity 0.14s ease;
}
button:hover { opacity: 0.88; }
button:disabled { opacity: 0.5; cursor: default; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: var(--hairline) solid var(--separator);
}

.form-status { margin: 0; font-size: 15px; min-height: 1.3em; }
.form-status.ok { color: var(--forest); }
.form-status.error { color: var(--danger); }

/* Honeypot — off-screen rather than display:none, because some bots skip
   hidden fields and the point is that they fill it in. */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

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

footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: var(--hairline) solid var(--separator);
  color: var(--muted);
  font-size: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--ink); text-decoration: underline; }
footer .spacer { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Inbox ─────────────────────────────────────────────────── */

.count { font-size: 14px; color: var(--muted); letter-spacing: 0; font-weight: 400; }

.filters { display: flex; gap: 8px; margin: 0 0 4px; }

button.tiny {
  font-size: 14px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  align-self: auto;
}
/* An <a> styled as a button — the reply link opens a mail client, so it has to
   be a real link rather than a button that fakes one. */
a.button { display: inline-block; text-decoration: none; }
a.button.secondary {
  background: transparent;
  color: var(--ink);
  border: var(--hairline) solid var(--separator);
}
button.secondary.on {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--on-accent);
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.pager-label { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

tr.unread td { background: rgba(var(--forest-rgb), 0.045); }
/* The marker sits on the row rather than in a column of its own — a whole
   column carrying one dot is a lot of table for very little information. */
tr.unread td:first-child { box-shadow: inset 2px 0 0 var(--forest); }

td .sub { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }

.message-body {
  white-space: pre-wrap;
  max-width: 30rem;
  min-width: 14rem;
}

td.actions { white-space: nowrap; }
td.actions > * { margin-right: 6px; }
