/* Components. Everything here composes from tokens.css and nothing else. */

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

/* ---------------------------------------------------------------- layout */

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  /* The top inset is 0 in a browser and inside Telegram, which draws its own
     header above us. It is the status bar height in the Android shell, where
     the window is edge-to-edge — without it the first card sits under the
     clock. */
  padding: calc(8px + env(safe-area-inset-top)) var(--pad) calc(var(--nav-h) + 28px);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  animation: rise var(--slow) var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.spread {
  display: flex;
  gap: 10px;
}

.grow {
  flex: 1;
  min-width: 0;
}

/* ------------------------------------------------------------------ type */

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 800;
}

h1 {
  font-size: 30px;
  line-height: 1.12;
}
h2 {
  font-size: 20px;
  line-height: 1.2;
}
h3 {
  font-size: 16px;
  font-weight: 700;
}

p {
  margin: 0;
}

.muted {
  color: var(--ink-3);
}
.small {
  font-size: 13px;
  line-height: 1.35;
}
.tiny {
  font-size: 11.5px;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.page-head {
  padding: 14px 2px 14px;
}

.track-title {
  font-size: clamp(22px, 6.4vw, 30px);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.page-head h1 {
  margin-bottom: 2px;
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: var(--pad);
}

.card.tight {
  padding: 12px 14px;
}
.card.flush {
  padding: 0;
  overflow: hidden;
}

/* The one card that carries the product's headline number. The mesh is drawn
 * with layered radial gradients rather than an image: it scales, it themes,
 * and it costs no request. */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  padding: 22px var(--pad) 20px;
  color: var(--ink-inverse);
  background:
    radial-gradient(110% 80% at 6% 4%, rgba(255, 255, 255, 0.32), transparent 52%),
    radial-gradient(95% 85% at 98% -6%, rgba(56, 214, 255, 0.72), transparent 58%),
    radial-gradient(80% 85% at 86% 112%, rgba(255, 70, 132, 0.62), transparent 58%),
    radial-gradient(70% 70% at 22% 96%, rgba(126, 58, 242, 0.75), transparent 62%),
    var(--gradient);
  box-shadow: var(--sh-accent);
}

.hero::after {
  /* A faint grain keeps a large gradient from banding on OLED phones. */
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.5) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero .eyebrow {
  color: rgba(255, 255, 255, 0.75);
}

.hero-figure {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero-num {
  font-size: 54px;
  line-height: 1;
}

.hero-sub {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13.5px;
}

/* ------------------------------------------------------------ progress ring */

.ring {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  transform: rotate(-90deg);
}
.ring circle {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}
.ring .track {
  stroke: rgba(255, 255, 255, 0.25);
}
.ring .value {
  stroke: #fff;
  transition: stroke-dashoffset var(--slow) var(--ease);
}
.ring-wrap {
  position: relative;
  display: grid;
  place-items: center;
}
.ring-label {
  position: absolute;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.chip.done {
  background: var(--done-soft);
  color: var(--done);
}
.chip.wait {
  background: var(--wait-soft);
  color: #b45309;
}
.chip.stop {
  background: var(--stop-soft);
  color: var(--stop);
}
.chip.info {
  background: var(--info-soft);
  color: #1063c4;
}
.chip.accent {
  background: var(--accent-soft);
  color: var(--accent);
}
/* For the gradient hero only: white on translucent white, which is invisible
   on any light surface. On a card or a sheet, use the default chip. */
.chip.ghost {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.chip.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 16px;
  background: var(--surface-sunken);
  color: var(--ink);
  transition: transform var(--fast) var(--ease), filter var(--fast) var(--ease);
}

.btn:active {
  transform: scale(0.975);
}

.btn.primary {
  background: var(--gradient);
  color: var(--accent-ink);
  box-shadow: var(--sh-accent);
}

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn.danger {
  background: var(--stop-soft);
  color: var(--stop);
}

.btn.block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn.sm {
  height: 38px;
  font-size: 14px;
  padding: 0 14px;
}

/* A round floating control, like the reference map buttons. */
.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  box-shadow: var(--sh-2);
}

/* ------------------------------------------------------- segmented control */

.seg {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
}

.seg button {
  flex: 1;
  height: 38px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-3);
  transition: all var(--fast) var(--ease);
}

.seg button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-1);
}

/* More options than fit across a phone. The buttons keep their own width and
   the row scrolls, rather than every label being squeezed to three letters. */
.seg.scroll {
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.seg.scroll::-webkit-scrollbar {
  display: none;
}

.seg.scroll button {
  flex: 0 0 auto;
  padding: 0 14px;
  scroll-snap-align: start;
}

/* ------------------------------------------------------------------ rows */

.rows {
  display: flex;
  flex-direction: column;
}

.rowitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  text-align: left;
  width: 100%;
}

.rowitem + .rowitem {
  border-top: 1px solid var(--line);
}

.rowitem .title {
  font-weight: 650;
  font-size: 15px;
}

.rowitem .sub {
  font-size: 12.5px;
  color: var(--ink-3);
}

.rowitem .metric {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--surface-sunken);
  flex: 0 0 auto;
}

.avatar.ring-accent {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

/* -------------------------------------------------------------- two-up stat */

.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.versus .side {
  text-align: center;
}

.versus .big {
  font-size: 32px;
  line-height: 1.05;
}

.versus .absent {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 8px 0;
}

.versus .vs {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}

.deadline-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
  color: var(--ink-3);
  background: var(--surface-sunken);
  flex: 0 0 auto;
}

.deadline-title {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  text-wrap: pretty;
}

/* ------------------------------------------------------------ queue meter */

.meter {
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  overflow: hidden;
  display: flex;
}

.meter span {
  display: block;
  height: 100%;
}
.meter .ahead {
  background: var(--line-strong);
}
.meter .you {
  background: var(--gradient);
  min-width: 6px;
}
.meter .behind {
  background: var(--accent-soft);
}

/* ------------------------------------------------------------- timeline */

.track-list {
  position: relative;
  padding-left: 30px;
}

.track-list::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}

.node {
  position: relative;
  padding: 9px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  /* A <button> centres its text by default, which turns a wrapped stage name
     into a ragged block in the middle of the timeline. */
  text-align: left;
  width: 100%;
}

.node::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--line-strong);
}

.node.done::before {
  background: var(--done);
  box-shadow: 0 0 0 2px var(--done);
}

.node.current::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 5px rgba(108, 76, 241, 0.25);
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 5px var(--accent-soft), 0 0 0 10px rgba(108, 76, 241, 0.08);
  }
}

.node.skipped::before {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--line);
}

.node.branch::before {
  background: var(--wait);
  box-shadow: 0 0 0 2px var(--wait);
}

.node .label {
  font-weight: 650;
  font-size: 15px;
}
.node.pending .label,
.node.skipped .label {
  color: var(--ink-3);
  font-weight: 550;
}

/* ------------------------------------------------------------ bottom nav */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  /* However many tabs there are: phase-3 adds one behind a feature flag, and
     a hardcoded column count silently squashes them into four. */
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}

.nav button {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 650;
  transition: color var(--fast) var(--ease);
}

.nav button[aria-current="page"] {
  color: var(--accent);
}

.nav svg {
  width: 24px;
  height: 24px;
}

/* ---------------------------------------------------------------- sheet */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 10, 20, 0.42);
  backdrop-filter: blur(2px);
  animation: fade var(--fast) var(--ease) both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px var(--pad) calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--sh-3);
  animation: slide var(--slow) var(--ease) both;
}

@keyframes slide {
  from {
    transform: translateY(14%);
    opacity: 0.6;
  }
}

.grab {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 2px auto 12px;
}

/* ------------------------------------------------------------- welcome */

.welcome {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100dvh - var(--nav-h) - 60px);
  padding-top: 10px;
}

.welcome-hero {
  flex: 1;
  justify-content: flex-end;
  min-height: 300px;
}

.welcome-title {
  font-size: clamp(30px, 8.5vw, 40px);
  line-height: 1.04;
  text-wrap: balance;
}

/* --------------------------------------------------------------- inputs */

.field {
  display: grid;
  gap: 6px;
}

.field > label {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-3);
}

.input {
  height: 50px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  width: 100%;
}

.input:focus {
  border-color: var(--accent);
  outline: none;
}

/* A grid of selectable cards — the onboarding wizard's whole vocabulary. */
.choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1.5px solid transparent;
  box-shadow: var(--sh-1);
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.choice:active {
  transform: scale(0.99);
}

.choice[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice .title {
  font-weight: 650;
  font-size: 15px;
}

.choice .sub {
  font-size: 12.5px;
  color: var(--ink-3);
}

.switch {
  width: 50px;
  height: 30px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  position: relative;
  flex: 0 0 auto;
  transition: background var(--fast) var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform var(--fast) var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

/* --------------------------------------------------------------- states */

.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-3);
}

.empty .glyph {
  font-size: 34px;
  margin-bottom: 8px;
}

.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(
    90deg,
    var(--surface-sunken) 25%,
    var(--surface-2) 37%,
    var(--surface-sunken) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -135% 0;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px);
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--sh-2);
  animation: rise var(--fast) var(--ease) both;
}

/* The line that has to be on every screen showing a requirement or a
 * statistic, and that must not be hidden in a settings page. */
.disclaimer {
  padding: 14px 4px 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-3);
  text-align: center;
}

/* A recovery code. Monospace so an l and a 1 are distinguishable when
   somebody copies it onto paper, and breakable so 43 characters fit a phone
   without a horizontal scrollbar. */
.code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  color: var(--ink);
}
