/* Drift — hand-written CSS, no framework, no CDN, no build step.
   One light source: the lantern. One live signal: the guide. Everything else is ink
   on a night sea. Controls are pillows; surfaces are separated by tone, never by lines. */

@font-face {
  font-family: Archivo;
  src: url(fonts/archivo-400.woff2) format("woff2");
  font-weight: 400;
  font-display: block;
}

@font-face {
  font-family: Archivo;
  src: url(fonts/archivo-600.woff2) format("woff2");
  font-weight: 600;
  font-display: block;
}

:root {
  /* ink, brightest to faintest */
  --ink: #f2f7f9;
  --ink-2: #b9ccd7;
  --ink-3: #7d97a6;
  --ink-4: #55707f;

  /* ground, night to raised */
  --night: #04070f;
  --deck: #061019;
  --raise: #0d1c27;
  --raise-2: #16293a;

  /* the sea's two lights */
  --guide: #7fe9d0;
  --lantern: #ffc46b;
  --warn: #ff8b9a;

  --face: Archivo, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --pad: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--face);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

body[data-screen="voyage"] { touch-action: none; }

[hidden] { display: none !important; }

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

button {
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

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

/* ── the sea ─────────────────────────────────────────────── */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity .6s ease;
}

body[data-screen="start"] #stage,
body[data-screen="voyage"] #stage { opacity: 1; }

#app { position: fixed; inset: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ── start ───────────────────────────────────────────────── */
.screen--start {
  justify-content: space-between;
  padding-top: calc(var(--safe-t) + 16px);
  pointer-events: none;
}

.screen--start > * { pointer-events: auto; }

.masthead { padding: 0 var(--pad); }

.masthead__bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* One quiet signature, not a badge: the mark and a handle, the size of a note. */
.made {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 14px 0;
  margin: -14px 0;
  font-size: 12.5px;
  line-height: 1;
  letter-spacing: 0.005em;
  color: var(--ink-3);
  text-decoration: none;
  transition: color .15s ease;
}

.made:hover { color: var(--ink); }

.made__mark {
  width: 11px;
  height: 11px;
  flex: none;
  fill: currentColor;
}

.made-row { margin: 6px 0 0; }

.wordmark {
  margin: 0;
  font-size: clamp(3.6rem, 15.5vw, 7rem);
  font-weight: 400;
  line-height: .86;
  letter-spacing: -0.05em;
  color: var(--ink);
}

.lede {
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  color: var(--ink-2);
  max-width: 30ch;
}

/* The tray is a scrim, not a card: the sea keeps running underneath it, and the
   veil is long enough that the water fades instead of stopping. */
.tray {
  padding: 26px var(--pad) calc(var(--safe-b) + 18px);
  background: linear-gradient(
    to top,
    var(--night) 0,
    var(--night) 28%,
    rgba(4, 7, 15, .95) 46%,
    rgba(4, 7, 15, .74) 64%,
    rgba(4, 7, 15, .34) 84%,
    rgba(4, 7, 15, 0) 100%
  );
}

.tray__inner { max-width: 460px; }

.ask {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 2px;
}

.ask__q {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.ask__q--big {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.ask__v {
  flex: none;
  font-size: 34px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: .82;
  letter-spacing: -0.05em;
  color: var(--ink-4);
  transition: color .18s ease;
}

.ask__v.is-set { color: var(--guide); }

/* ── the meter: one thumb, one number ────────────────────── */
.meter__input {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  --fill: 50%;
}

.meter__input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--guide) var(--fill), #1d3040 var(--fill));
}

.meter__input::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #1d3040;
}

.meter__input::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--guide);
}

.meter__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 7px rgba(127, 233, 208, .12);
}

.meter.is-set .meter__input::-webkit-slider-thumb { background: var(--guide); }

.meter__input::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 7px rgba(127, 233, 208, .12);
}

.meter.is-set .meter__input::-moz-range-thumb { background: var(--guide); }

.meter__ends {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ── actions ─────────────────────────────────────────────── */
.cta {
  display: block;
  width: 100%;
  min-height: 54px;
  margin-top: 20px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--lantern);
  color: #241503;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.012em;
  transition: background .15s ease, transform .12s ease, color .15s ease;
}

.cta:hover { background: #ffd18b; }
.cta:active { transform: scale(.985); }

.cta[disabled] {
  background: var(--raise);
  color: var(--ink-4);
  cursor: default;
}

.cta--quiet { background: var(--raise-2); color: var(--ink); }
.cta--quiet:hover { background: #1d3446; }

.row { display: flex; gap: 10px; }
.row .cta { flex: 1; }

.micro {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}

.limit {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-3);
  /* Wide enough that the limit line holds two lines on a phone; still short
     enough to stay a sane measure in the report's wide column. */
  max-width: 52ch;
}

.more { margin-top: 10px; }

.more summary {
  display: list-item;
  padding: 4px 0;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}

.more summary::marker { color: var(--guide); }

.more p {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-3);
  max-width: 46ch;
}

/* ── voyage ──────────────────────────────────────────────── */
.screen--voyage { justify-content: space-between; }

.hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 14px) var(--pad) 0;
}

.hud__clock { display: flex; flex-direction: column; gap: 3px; }

.timer {
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.hud__sub {
  font-size: 12.5px;
  line-height: 1.3;
  color: rgba(185, 204, 215, .7);
}

.hud__act { display: flex; align-items: center; gap: 12px; }

.combo {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--lantern);
}

.pill {
  min-height: 34px;
  padding: 0 15px;
  border-radius: 999px;
  background: rgba(6, 16, 25, .6);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}

.pill:hover { background: rgba(13, 28, 39, .9); color: var(--ink); }

.bottom {
  padding: 0 var(--pad) calc(var(--safe-b) + 34px);
  text-align: center;
}

.phase {
  margin: 0;
  font-size: clamp(1.75rem, 7vw, 2.25rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.035em;
  color: rgba(242, 247, 249, .94);
  transition: opacity .5s ease;
}

.hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: rgba(185, 204, 215, .58);
  transition: opacity 1.4s ease;
}

.hint.is-gone { opacity: 0; }

/* ── docks (the sheets that slide over a voyage) ─────────── */
.dock {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(var(--safe-b) + 10px);
  margin-inline: auto;
  max-width: 440px;
  padding: 20px 18px 12px;
  border-radius: 26px;
  background: var(--deck);
}

.dock__title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.dock .micro { margin-bottom: 6px; }

.text {
  display: block;
  width: 100%;
  padding: 14px 0 6px;
  font-size: 14px;
  color: var(--ink-2);
  text-align: center;
  text-decoration: underline;
  text-decoration-color: rgba(185, 204, 215, .3);
  text-underline-offset: 3px;
}

.text:hover { text-decoration-color: var(--ink-2); }

.text--dim { color: var(--ink-3); font-size: 13px; padding-top: 12px; }

/* ── report ──────────────────────────────────────────────── */
.screen--report {
  background: var(--night);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: block;
  padding: calc(var(--safe-t) + 22px) var(--pad) calc(var(--safe-b) + 30px);
}

.report { max-width: 620px; margin: 0 auto; }

.report__wordmark {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.report__kicker {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.big {
  margin: 40px 0 0;
  font-size: clamp(4.4rem, 21vw, 6.6rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: .84;
  letter-spacing: -0.055em;
  color: var(--ink);
}

.big[data-tone="good"] { color: var(--guide); }
.big[data-tone="bad"] { color: var(--warn); }

.big__label {
  margin: 16px 0 0;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 28ch;
}

.big__label--lead {
  margin-top: 38px;
  max-width: 22ch;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.chart { margin-top: 30px; }
.chart__svg { display: block; width: 100%; height: auto; }

.chart__key {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.stats { margin: 42px 0 0; }

.stats__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
}

.stats dt { font-size: 15px; color: var(--ink-3); }

.stats dd {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.report .cta { margin-top: 34px; }

.quiet {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
  margin-top: 18px;
}

.quiet .text { width: auto; text-align: left; padding: 12px 0; }

/* ── page screens (gate, refer, install, recovery) ───────── */
.screen--page {
  background: var(--night);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: block;
  padding: calc(var(--safe-t) + 34px) var(--pad) calc(var(--safe-b) + 34px);
}

.page { max-width: 520px; margin: 0 auto; }

.page__title {
  margin: 0 0 16px;
  font-size: clamp(2.1rem, 8.4vw, 3.1rem);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -0.045em;
  max-width: 15ch;
}

.screen--page .lede { margin-top: 0; max-width: 34ch; }
.screen--page .lede + .lede { margin-top: 14px; }

/* ── the gate ────────────────────────────────────────────── */
.gate { margin: 34px 0 4px; }
.gate__row { margin-bottom: 26px; }
.gate__row:last-child { margin-bottom: 0; }

.gate__q {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.008em;
  color: var(--ink);
  max-width: 32ch;
}

.gate__choices {
  display: inline-grid;
  grid-template-columns: repeat(2, 104px);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--deck);
}

.choice {
  min-height: 44px;
  border-radius: 999px;
  color: var(--ink-3);
  font-size: 15px;
  font-weight: 600;
  transition: background .14s ease, color .14s ease;
}

.choice:hover { color: var(--ink-2); background: rgba(255, 255, 255, .04); }

.choice.is-on {
  background: var(--ink);
  color: var(--night);
}

.steps {
  margin: 26px 0 0;
  padding-left: 20px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 32ch;
}

.steps li { margin-bottom: 10px; padding-left: 4px; }
.steps strong { color: var(--ink); font-weight: 600; }
.steps li::marker { color: var(--guide); }

/* ── toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 22px);
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(88vw, 420px);
  padding: 13px 18px;
  border-radius: 999px;
  background: var(--raise-2);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  background: var(--night);
  color: var(--ink-2);
}

/* ── wider screens ───────────────────────────────────────── */
.screen--voyage.is-done .hud,
.screen--voyage.is-done .bottom { opacity: 0; transition: opacity .4s ease; }

@media (min-width: 700px) {
  :root { --pad: 32px; }

  .screen--start { padding-top: calc(var(--safe-t) + 28px); }
  .wordmark { font-size: clamp(5rem, 9.2vw, 8.5rem); }
  .lede { font-size: 18px; margin-top: 20px; max-width: 32ch; }

  /* Wide screens have a corner to sit in, so the veil only needs to cover the
     corner: the sea stays visible to the right of the controls. */
  .tray {
    padding-top: 120px;
    padding-bottom: 34px;
    background:
      linear-gradient(to top, rgba(4, 7, 15, .94) 0, rgba(4, 7, 15, .82) 34%, rgba(4, 7, 15, 0) 78%),
      linear-gradient(to right, rgba(4, 7, 15, .9) 0, rgba(4, 7, 15, .55) 34%, rgba(4, 7, 15, 0) 52%);
  }

  .tray__inner { max-width: 470px; }

  .timer { font-size: 24px; }
  .hud { padding-top: calc(var(--safe-t) + 22px); }

  .dock { left: 32px; right: auto; margin-inline: 0; }
  .bottom { padding-bottom: calc(var(--safe-b) + 46px); }

  .screen--page, .screen--report { padding-top: calc(var(--safe-t) + 48px); }
}

/* On a wide screen the report becomes two columns: the number and the plain
   rows on the left, the week itself on the right, and the action stays in view. */
@media (min-width: 1000px) {
  .report {
    max-width: 1040px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "head  head"
      "big   chart"
      "label chart"
      "stats chart"
      "cta   chart"
      "quiet quiet"
      "limit limit";
    column-gap: 88px;
    align-items: start;
  }

  .report__head { grid-area: head; }
  .big { grid-area: big; margin-top: 32px; }
  .big__label { grid-area: label; }
  .chart { grid-area: chart; margin-top: 34px; }
  .stats { grid-area: stats; margin-top: 30px; }
  .report .cta { grid-area: cta; margin-top: 26px; justify-self: start; width: 320px; }
  .quiet { grid-area: quiet; }
  .limit { grid-area: limit; }
}

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