/* Palette borrowed from New York canal signage: navy boards, gold lettering,
   against a November sky and a stone-dust towpath. */
:root {
  --navy: #14304f;
  --navy-deep: #0c2038;
  --gold: #f2b705;
  --coral: #ff6b4a;
  --sky: #eef1f3;
  --stone: #d9dcd8;
  --water: #6c8d96;
  --ink: #0e1a26;
  --muted: #51606d;
  --paper: #ffffff;
  --font: "Overpass", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ol { margin: 0; }

a { color: var(--navy); }

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

/* Masthead: a canal sign board */
.mast {
  background: var(--navy);
  color: #fff;
  padding: 1.5rem 1rem 1.25rem;
  border-bottom: 6px solid var(--gold);
}
.mast h1 {
  font-size: clamp(1.75rem, 6vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  max-width: 18ch;
}
.mast p {
  margin-top: 0.6rem;
  max-width: 52ch;
  color: #d5dee8;
}

.layout { display: block; }

/* Map and profile */
.map {
  height: 52vh;
  min-height: 300px;
  background: var(--stone);
  position: relative;
  z-index: 0;
}
.map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
}
.mapboxgl-map { font-family: var(--font); }

.profile {
  background: var(--paper);
  border-bottom: 1px solid var(--stone);
  padding: 0.75rem 1rem 0.6rem;
}
.profile-plot { touch-action: pan-y; cursor: crosshair; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot text { font: 400 11px var(--font); fill: var(--muted); }
.plot text.now-txt { font-weight: 800; font-size: 10px; fill: var(--navy-deep); }
.readout { margin-top: 0.35rem; font-size: 0.875rem; color: var(--muted); min-height: 1.4em; }

/* Map markers */
.mk { width: 0; height: 0; }
.mk-stop { cursor: pointer; z-index: 2; }
.mk-now { z-index: 3; }
.mk-cursor { z-index: 4; }
.mk-cursor span {
  display: block;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--navy-deep);
}
.mk-stop span {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: var(--navy);
  color: var(--gold);
  font: 800 12px/1 var(--font);
  padding: 5px 6px 3px;
  border-radius: 3px;
  border: 2px solid #fff;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(12, 32, 56, 0.45);
}
.mk-stop.is-optional span { background: #fff; color: var(--navy); border-color: var(--navy); }
.mk-end span { background: var(--gold); color: var(--navy-deep); border-color: var(--navy-deep); }
.mk-mile span {
  display: inline-block;
  transform: translate(-50%, -50%);
  font: 600 10px/1 var(--font);
  color: var(--navy);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 3px 4px 1px;
}
.mk-now span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  padding-top: 2px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--navy-deep);
  font: 800 12px/1 var(--font);
  color: var(--navy-deep);
  animation: pulse 1.8s ease-out infinite;
}
.mk-now.r1 span { background: var(--coral); }
.mk-now.r1.is-stacked span { margin-top: -34px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(242, 183, 5, 0.7); }
  100% { box-shadow: 0 0 0 16px rgba(242, 183, 5, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .mk-now span { animation: none; }
}

/* Side column */
.side { padding: 1.5rem 1rem 0.5rem; max-width: 44rem; margin: 0 auto; }

h2 { font-size: 1.25rem; font-weight: 800; line-height: 1.2; color: var(--navy-deep); }

.plan { margin-bottom: 2rem; }
.planner { margin-top: 0.75rem; }
.planner label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.planner input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.6rem 0.4rem;
  font: 600 1.125rem var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--navy);
  border-radius: 4px;
  min-height: 44px;
}
.planner input:invalid { border-color: #b3261e; }
.start-field { max-width: 11rem; }
.runner {
  display: grid;
  grid-template-columns: 1.6rem auto minmax(0, 1fr) 4.6rem;
  gap: 0.7rem;
  align-items: center;
  margin-top: 0.6rem;
  min-height: 44px;
}
.runner-name { font-weight: 800; font-size: 1.125rem; color: var(--navy-deep); min-width: 2.8rem; padding-top: 0.15rem; }
.planner .runner input[type="range"] {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  min-height: 44px;
  accent-color: var(--navy);
}
.pace-out { font-weight: 600; text-align: right; white-space: nowrap; padding-top: 0.15rem; }
.plan .planner { margin-top: 0; }

/* Runner badges: color plus initial, so the two are never told apart by color alone */
.badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  padding-top: 0.15rem;
  border-radius: 50%;
  border: 2px solid var(--navy-deep);
  font: 800 0.8125rem/1 var(--font);
  color: var(--navy-deep);
}
.badge.r0 { background: var(--gold); }
.badge.r1 { background: var(--coral); }
.status {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem 0.65rem;
  background: var(--paper);
  border-left: 6px solid var(--gold);
  font-weight: 600;
}
.status-line { display: flex; gap: 0.55rem; align-items: flex-start; }
.status-line > span:nth-child(2) { flex: 1; }
.clear {
  flex: none;
  font: 600 0.8125rem var(--font);
  color: var(--navy);
  background: none;
  border: 0;
  padding: 0.2rem 0.1rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.status-line + .status-line { margin-top: 0.45rem; }
.status small { display: block; font-weight: 400; font-size: 0.875rem; color: var(--muted); margin-top: 0.5rem; }

/* Stop list: the towpath runs down the left edge */
.stop-list { list-style: none; padding: 0; margin-top: 1rem; }
.stop {
  position: relative;
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  column-gap: 0.9rem;
  padding-bottom: 0.5rem;
}
.stop::before {
  content: "";
  position: absolute;
  left: 1.6rem;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--water);
}
.stop:first-child::before { top: 1rem; }
.stop:last-child::before { bottom: auto; height: 1rem; }

.sign {
  position: relative;
  align-self: start;
  background: var(--navy);
  color: var(--gold);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
  padding: 0.55rem 0 0.35rem;
  border-radius: 3px;
  border: 2px solid var(--paper);
}
.sign small { display: block; font-size: 0.625rem; font-weight: 600; color: #c9d4df; margin-top: 0.15rem; }
.stop.is-optional .sign { background: var(--paper); color: var(--navy); border-color: var(--navy); }
.stop.is-optional .sign small { color: var(--muted); }
.stop.is-end .sign { background: var(--gold); color: var(--navy-deep); border-color: var(--navy-deep); }
.stop.is-end .sign small { color: var(--navy-deep); }

.stop-body { background: var(--paper); padding: 0.8rem 0.9rem 0.85rem; border-radius: 4px; }
.stop.is-passed .stop-body { background: #f7f8f9; }
.stop-name {
  font: 800 1.0625rem/1.25 var(--font);
  color: var(--navy-deep);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--stone);
  text-underline-offset: 3px;
}
.stop-name:hover { text-decoration-color: var(--gold); }
.etas { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.3rem; }
.etas li { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.etas .badge { width: 1.35rem; height: 1.35rem; font-size: 0.6875rem; }
.eta.is-actual { color: #1d6b45; }
.stop-note { margin-top: 0.3rem; color: var(--muted); font-size: 0.9375rem; max-width: 60ch; }
.stop-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.9rem 0.35rem;
  font: 600 0.9375rem var(--font);
  border-radius: 4px;
  border: 2px solid var(--navy);
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--navy-deep); }
.btn.is-quiet { background: transparent; color: var(--navy); }
.btn.is-quiet:hover { background: #e2e8ee; }

.gap {
  grid-column: 2;
  padding: 0.45rem 0 0.2rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

@media (min-width: 980px) {
  body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(26rem, 1fr); align-items: start; }
  .layout { display: contents; }
  .chart { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
  .mast { grid-column: 2; grid-row: 1; padding: 2rem 2rem 1.5rem; }
  .side { grid-column: 2; grid-row: 2; padding: 2rem 2rem 0.5rem; margin: 0; max-width: 42rem; }
  .map { flex: 1; height: auto; min-height: 0; }
  .profile { padding: 0.9rem 1.5rem 0.75rem; border-bottom: 0; }
}

.stops { padding-bottom: 3rem; }

/* "Who is here?" chooser on the map */
.mapboxgl-popup-content { padding: 0.8rem 0.9rem 0.9rem; border-radius: 4px; font-family: var(--font); }
.mapboxgl-popup-close-button { font-size: 1.25rem; width: 32px; height: 32px; }
.here-pop strong { display: block; font-weight: 800; color: var(--navy-deep); margin-bottom: 0.5rem; }
.here-btns { display: flex; gap: 0.4rem; }
.here-btns .btn { padding-left: 0.7rem; padding-right: 0.7rem; white-space: nowrap; }
@media (max-width: 480px) {
  .here-btns { flex-direction: column; }
  .here-btns .btn { justify-content: center; }
}


.who { display: inline-flex; flex: none; gap: 0.2rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.btn { gap: 0.4rem; }
.btn[hidden] { display: none; }
.btn .badge { width: 1.35rem; height: 1.35rem; font-size: 0.6875rem; margin-top: -0.15rem; }

.start-row { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; }
.start-row .start-field { flex: 0 1 11rem; }
.start-row .btn { min-height: 46px; }

/* The default page is read-only: no planner, no check-in buttons. */
body[data-mode="view"] .planner,
body[data-mode="view"] .stop-actions .btn.is-quiet,
body[data-mode="view"] .clear { display: none; }
.sync { margin-top: 0.75rem; font-weight: 600; color: #b3261e; }
.sync[hidden] { display: none; }

/* What-if pace slider under an upcoming stop time */
.etas li { flex-wrap: wrap; }
.whatif { flex: 1 0 100%; display: flex; align-items: center; gap: 0.75rem; }
.whatif-range, .arrive-range, .left-range { flex: 1; min-width: 0; max-width: 22rem; min-height: 40px; margin: 0; accent-color: var(--navy); }
body[data-mode="view"] .whatif .clear { display: inline; }

.map-view {
  font: 600 0.875rem var(--font);
  min-height: 40px;
  padding: 0.45rem 0.8rem 0.3rem;
  color: var(--navy-deep);
  background: #fff;
  border: 2px solid var(--navy-deep);
  border-radius: 4px;
  cursor: pointer;
}
.map-view:hover { background: #e2e8ee; }

.stops .stop-list { margin-top: 0; }

/* Weather: the day's summary under the status box, and one line per stop */
.wx-day { margin-top: 0.75rem; font-size: 0.9375rem; color: var(--ink); max-width: 60ch; }
.wx-day[hidden], .wx[hidden] { display: none; }
.wx { margin-top: 0.45rem; font-size: 0.9375rem; color: var(--muted); }

/* Weather icons */
.wx { display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; }
.wx-part { display: inline-flex; align-items: center; gap: 0.3rem; }
.ico { flex: none; color: var(--navy); }
.plot text.wx-axis { fill: #7a3fa8; }

/* No directions to a stop both runners have already left behind. */
.stop.is-passed .dir { display: none; }
body[data-mode="view"] .stop.is-passed .stop-actions { display: none; }
.stop.is-passed .stop-note { display: none; }
.plot text.pace-lbl { font-weight: 800; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.gap .badge { width: 1.15rem; height: 1.15rem; font-size: 0.625rem; }
.gap .who { vertical-align: middle; margin-right: 0.2rem; }
.range-lbl { flex: none; width: 3.6rem; font-size: 0.8125rem; color: var(--muted); }
