/* RUN DRINK – 1-bit black and white. Night is the exact inverse. */
:root {
  --bg: #ffffff;
  --ink: #000000;
  --dot: rgb(0 0 0 / 55%);
  --accent: #909090;   /* signal colour: minute hand, thermometer, scale marks, water, runner */
}
.night {
  --bg: #1f1f1f;
  --ink: #dfdfdf;
  --dot: rgb(255 255 255 / 22%);
  --accent: #939393;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
}

/* light 1-bit dither around the cards; the cards themselves are plain, for easy reading */
body {
  background-image:
    radial-gradient(var(--dot) 0.8px, transparent 1.1px),
    radial-gradient(var(--dot) 0.8px, transparent 1.1px);
  background-size: 6px 6px;
  background-position: 0 0, 3px 3px;
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* HEADER */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 2px solid var(--ink);
  padding: 8px 8px 8px 14px;
}
.top h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.mode {
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bg);
  background: var(--ink);
  border: 2px solid var(--ink);
  padding: 7px 14px;
  cursor: pointer;
}
.mode:active { opacity: 0.7; }

/* CARDS */
.card {
  background: var(--bg);
  border: 2px solid var(--ink);
  padding: 14px;
}
.card-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* SETUP: three dials + zones */
.setup { display: flex; flex-direction: column; gap: 14px; }
.setup-top { display: flex; gap: 6px; justify-content: center; }
.dial-wrap { flex: 1 1 0; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; }

.dial { position: relative; width: 100%; aspect-ratio: 1; }
.dialsvg { width: 100%; height: 100%; touch-action: none; cursor: pointer; display: block; }
.dial-track { fill: none; stroke: var(--ink); stroke-width: 4; stroke-dasharray: 3 7; opacity: 0.6; }
.dial-progress { fill: none; stroke: var(--ink); stroke-width: 6; }
.dial-knob { fill: var(--ink); cursor: grab; }
.dial-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dial-num { font-weight: 800; font-size: 30px; line-height: 1; }
.unit { font-size: 13px; font-weight: 700; margin-top: 3px; }
.dial-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}

/* ZONES */
.zones {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 2px solid var(--ink);
}
.zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 2px;
  border: none;
  border-left: 2px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.zone:first-child { border-left: none; }
.zone span { font-weight: 800; font-size: 17px; }
.zone small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.zone.active { background: var(--ink); color: var(--bg); }
.zone:active { opacity: 0.7; }

/* RESULTS */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  border: 2px solid var(--ink);
  padding: 12px 10px;
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.stat-val { font-size: 30px; font-weight: 800; line-height: 1; margin-top: 8px; }
.stat-u { font-size: 15px; font-weight: 700; margin-left: 3px; }
.stat-hi { background: var(--ink); color: var(--bg); }

/* TIMELINE */
.timeline { display: flex; flex-direction: column; }
.tl-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.tl-divider::before,
.tl-divider::after { content: ""; flex: 1; border-top: 2px dashed var(--ink); }
.tl-divider span { white-space: nowrap; }

.tl-item {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 10px;
  position: relative;
  padding-bottom: 18px;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-time { font-size: 14px; font-weight: 700; text-align: right; padding-top: 1px; }
.tl-body { position: relative; padding-left: 22px; }
.tl-body::before {
  content: "";
  position: absolute;
  left: 2px; top: 3px;
  width: 12px; height: 12px;
  background: var(--ink);
}
.tl-item:not(:last-child) .tl-body::after {
  content: "";
  position: absolute;
  left: 7px; top: 15px; bottom: -18px;
  width: 2px;
  background: var(--ink);
}
.tl-item.pre .tl-body::before { background: var(--bg); box-shadow: inset 0 0 0 2px var(--ink); }
.tl-title { font-weight: 700; font-size: 16px; }
.tl-desc { font-size: 13px; margin-top: 2px; }

@media (max-width: 400px) {
  .zone small { font-size: 9.5px; letter-spacing: 0; }
}

/* ============ shared symbol: filled = from your bottle, outlined = plain water ============ */
.r-sym { display: inline-block; width: 14px; height: 14px; background: var(--ink); flex-shrink: 0; }
.r-sym.open { background: var(--bg); box-shadow: inset 0 0 0 2px var(--ink); }

/* ============ YOUR BOTTLE: a recipe, read top to bottom ============ */
.recipe { list-style: none; margin: 0; padding: 0; }
.r-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-top: 2px dotted var(--ink);
}
.r-row:first-child { border-top: none; padding-top: 0; }
.r-row .r-sym { align-self: center; }
.r-op { font-size: 20px; font-weight: 800; text-align: center; line-height: 1; }
.r-what { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.r-amt { font-size: 15px; font-weight: 700; white-space: nowrap; }
.r-amt b { font-size: 28px; font-weight: 800; }
.r-water .r-amt b { font-size: 34px; }
.r-total { border-top: 2px solid var(--ink); margin-top: 2px; }

/* ============ DURING YOUR RUN: horizontal track ============ */
.headline { margin: 0 0 22px; font-size: 18px; font-weight: 700; }
.headline b { font-size: 24px; }
.track { position: relative; height: 54px; margin: 0 14px 0 6px; }
.t-line { position: absolute; left: 0; right: 0; top: 7px; border-top: 2px solid var(--ink); }
.t-tick { position: absolute; top: 0; transform: translateX(-50%); }
.t-tick::before { content: ""; display: block; width: 2px; height: 16px; margin: 0 auto; background: var(--ink); }
.t-tick span { display: block; margin-top: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.t-start { transform: none; }
.t-start::before { margin: 0; }
.t-sip { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.t-sip .r-sym { width: 16px; height: 16px; }
.t-sip { height: 40px; }
.t-lbl { position: absolute; top: 24px; }
.t-lbl { margin-top: 8px; font-size: 13px; font-weight: 700; }

/* ============ BEFORE YOUR RUN ============ */
.pre { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pre li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.pre b { font-size: 18px; }
.note { margin: 12px 0 0; font-size: 13px; }

/* headline: the rhythm first, the amount next to it */
.headline { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.h-amt { white-space: nowrap; font-size: 16px; }
.h-amt b { font-size: 28px; }
/* the stretch before the start is dashed: it's not part of the run */
.t-pre-line { border-top-style: dashed; }
.t-line { right: auto; }
.note { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 13px; }

/* ============ v3: pixel bottle next to the recipe ============ */
.mix { display: grid; grid-template-columns: 82px 1fr; gap: 12px; align-items: center; }
.b-ink { fill: var(--ink); }
.b-label { fill: var(--bg); }
.b-text { fill: var(--ink); font-family: inherit; font-size: 13px; font-weight: 800; }
.bottle { display: flex; flex-direction: column; align-items: center; color: var(--ink); }
.bottle svg { display: block; }
.b-more { margin-top: 6px; font-size: 14px; font-weight: 800; }
.r-row { grid-template-columns: 18px 1fr auto; }

/* ============ v3: two headings above the timeline, aligned with its two parts ============ */
.t-heads { display: flex; align-items: flex-end; margin: 0 14px 12px 6px; gap: 0; }
.t-head { font-size: 13px; font-weight: 700; line-height: 1.3; }
.t-head-pre { flex: none; padding-right: 8px; }
.t-head-run { flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-left: 2px solid var(--ink); padding-left: 8px; }
.t-head-run .h-amt { font-size: 15px; }
.t-head-run .h-amt b { font-size: 26px; }
.track { height: 42px; }

/* ============ v4: pixel dials, runner ============ */
.dial-px { fill: var(--ink); }
.dial-px .dial-dot { opacity: 0.7; }
.t-head-run .h-amt b { font-size: 26px; }

/* tiny 1-bit runner that jogs along the run part of the timeline */
.runner { position: absolute; top: -26px; height: 20px; pointer-events: none; }
.runner-fig {
  position: absolute; left: 0; top: 0;
  width: 18px; height: 20px;
  color: var(--ink);
}
@keyframes run-along { from { left: 0; } to { left: calc(100% - 18px); } }
@media (prefers-reduced-motion: reduce) { .runner-fig { animation: none; } }
.track { margin-top: 30px; }

/* ============ v5 ============ */
.tap-hint { margin-top: 2px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid var(--ink); padding: 1px 5px; white-space: nowrap; }
.runner-fig svg { display: block; }

/* ============ v6: recognisable dials + pixel numbers ============ */
.dial-px .dial-mark { opacity: 1; }   

.top h1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.top .by { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: none; color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.top .by:hover { opacity: 0.7; }

/* ============ footer card + help pop-up ============ */
.foot-card { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 14px; }
.foot-card .by { font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; }
.help {
  width: 34px; height: 34px; padding: 0;
  font: inherit; font-size: 20px; font-weight: 800; line-height: 1;
  color: var(--ink); background: var(--bg); border: 2px solid var(--ink); cursor: pointer;
}
.help:active { opacity: 0.7; }

.help-dialog {
  max-width: min(420px, calc(100vw - 32px));
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  box-shadow: 6px 6px 0 var(--ink);
}
.help-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.help-dialog h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; }
.help-dialog p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.help-dialog ol { margin: 0 0 16px; padding-left: 20px; font-size: 14px; line-height: 1.45; }
.help-dialog li + li { margin-top: 10px; }
.help-dialog .kbd { display: inline-block; border: 1px solid var(--ink); padding: 0 4px; }
.help-dialog form { text-align: right; margin: 0; }

.foot-card { flex-direction: row-reverse; }

/* timeline headings: centred over their part, divider runs down to the START tick */
.t-head-pre { text-align: center; padding: 0 8px 0 0; }
.t-head-run { position: relative; border-left: 0; align-items: center; }
.t-head-run > span:first-child { flex: 1; text-align: center; }
.t-head-run::before { content: ""; position: absolute; left: -1px; top: 0; width: 2px; bottom: -42px; background: var(--ink); }
.dial-hand { fill: var(--accent); }

/* signal colour */
.dial-px .accent, .b-water { fill: var(--accent); }
.runner-fig { color: var(--accent); }
.r-amt { color: var(--ink); }
.r-total .r-amt { color: var(--accent); }
.r-total {color: var(--accent);}


/* pixel font for the whole app (never bold) – switch --pixel-font between "Pixelify Sans" and "Silkscreen" */
@font-face { font-family: "Silkscreen"; src: url("silkscreen-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("pixelify-400.woff") format("woff"); font-weight: 400; font-display: swap; }
:root { --pixel-font: "Silkscreen"; }
body, button, .b-text, .dial text { font-family: var(--pixel-font), ui-monospace, monospace; }
body *, .b-text { font-weight: 400 !important; font-synthesis: none; }
.b-text { font-size: 14px; }

/* ============ home-screen app ============ */
/* a solid strip behind the iOS status bar, so nothing slides underneath it */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top);
  background: var(--bg); z-index: 50; pointer-events: none;
}
/* opened from the home screen: one fixed screen, no rubber-band scrolling of the whole page */
@media (display-mode: standalone) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .app {
    height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    gap: 8px; padding-top: calc(env(safe-area-inset-top) + 8px); padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
  }
}
