/*
 * Milepost website styles.
 *
 * Tokens mirror the app's palette (railed/src/constants/appTheme.ts and
 * railAccents.ts): Day chrome by default, Night chrome under
 * prefers-color-scheme: dark, the same way the app's map style themes it.
 * Signal orange is kept for download buttons only, as the app keeps it for
 * primary actions. Survey blue is the hero's map-paper tint.
 */

:root {
  --paper: #F2F3F6;
  --surface: #FFFFFF;
  --raised: #F5F6F8;
  --ink: #1F2229;
  --ink-2: #5E636E;
  --ink-3: #9AA0AB;
  --divider: #E3E6EA;
  --survey: #E4F1FC;
  --survey-line: #9CCBF2;
  --track: #1A7AE6;
  --signal: #E35D0B;
  --signal-pressed: #C9520A;
  --on-signal: #FFFFFF;
  --signal-text: #C2570C;

  /* Rail accents (Day values) for the track chart's symbols. */
  --rail-red: #C9222B;
  --rail-mustard: #947B05;
  --rail-cyan: #028A9B;
  --rail-violet: #7235D0;
  --rail-green: #12805C;

  --shadow: 0 1px 2px rgb(31 34 41 / 6%), 0 12px 32px -8px rgb(31 34 41 / 18%);

  --font: "Overpass", system-ui, -apple-system, "Segoe UI", sans-serif;
  --measure: 34rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --page: 72rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15171C;
    --surface: #1E2027;
    --raised: #262931;
    --ink: #F2F3F6;
    --ink-2: #9BA1AE;
    --ink-3: #6F7584;
    --divider: #2A2D35;
    --survey: #16202C;
    --survey-line: #2C4A6B;
    --track: #69A5FE;
    --signal: #FF9F43;
    --signal-pressed: #F28C2A;
    --on-signal: #1F1406;
    --signal-text: #FFA04A;

    --rail-red: #FD736D;
    --rail-mustard: #EED059;
    --rail-cyan: #4BD6EC;
    --rail-violet: #AD8DFD;
    --rail-green: #51D39C;

    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 16px 40px -8px rgb(0 0 0 / 55%);
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

a { color: var(--track); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3 {
  margin: 0;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--ink);
  z-index: 10;
}
.skip:focus { left: 0.5rem; }

/* ─── Header ─────────────────────────────────────────────────────── */

.site-header {
  position: relative;
  z-index: 2;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.brand img { width: 2rem; height: 2rem; flex: none; }

.site-nav {
  display: flex;
  gap: clamp(0.75rem, 3vw, 1.75rem);
  font-size: 0.95rem;
  font-weight: 600;
}

.site-nav a {
  color: var(--ink-2);
  text-decoration: none;
}
.site-nav a:hover { color: var(--ink); }

@media (max-width: 34rem) {
  .site-nav .nav-optional { display: none; }
}

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

.hero {
  position: relative;
  background: var(--survey);
  overflow: hidden;
  margin-top: -4.6rem;
  padding-top: 4.6rem;
}

/* Surveyor's guides behind the phone: a centre line and two rings. */
.hero-guides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  color: var(--survey-line);
  opacity: 0.75;
}

.hero-body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: end;
  gap: clamp(2rem, 5vw, 4rem);
  padding-top: clamp(2.5rem, 7vw, 5.5rem);
}

.hero-copy { padding-bottom: clamp(3rem, 8vw, 7rem); }

.hero h1 {
  font-size: clamp(2.6rem, 6.6vw, 5.25rem);
  letter-spacing: -0.035em;
  line-height: 0.95;
}

.hero h1 span { display: block; }

.hero .lede {
  margin-top: 1.5rem;
  max-width: var(--measure);
  font-size: clamp(1.125rem, 1.8vw, 1.3rem);
  color: var(--ink-2);
}

.hero .stores { margin-top: 2.25rem; }

.hero-phone {
  justify-self: center;
  width: min(100%, 19rem);
  margin-bottom: -6rem;
}

@media (max-width: 52rem) {
  .hero-body { grid-template-columns: 1fr; }
  .hero-copy { padding-bottom: 0; }
  .hero-phone { width: min(78%, 17rem); margin-bottom: -5rem; }
}

/* ─── Track chart ─────────────────────────────────────────────────── */

.chart {
  position: relative;
  background: var(--surface);
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.chart svg {
  display: block;
  width: 100%;
  height: clamp(8.5rem, 16vw, 12rem);
}

.chart .t-main,
.chart .t-siding { stroke: var(--track); }
.chart .t-tick { stroke: var(--ink-3); }
.chart .t-mp { fill: var(--ink-2); font: 600 13px var(--font); }
.chart .t-mp-major { fill: var(--ink); font-weight: 800; }
.chart .t-road { stroke: var(--ink-3); }
.chart .t-crossing { stroke: var(--rail-red); }
.chart .t-station { fill: var(--rail-green); }
.chart .t-signal { fill: var(--rail-mustard); }
.chart .t-signal-post { stroke: var(--ink-3); }
.chart .t-bridge { stroke: var(--rail-cyan); }
.chart .t-tunnel { stroke: var(--rail-violet); }
.chart .t-label { fill: var(--ink-2); font: 500 12px var(--font); }
.chart .t-target { fill: var(--signal); }
.chart .t-target-ring { stroke: var(--signal); fill: none; }
.chart .t-target-label { fill: var(--on-signal); font: 800 13px var(--font); }
.chart .t-target-pill { fill: var(--signal); }

/* One load sequence: the line draws, then the features along it appear. */
@media (prefers-reduced-motion: no-preference) {
  .chart .draw {
    stroke-dasharray: var(--len);
    stroke-dashoffset: var(--len);
    animation: draw 1.6s cubic-bezier(.6, 0, .2, 1) 0.2s forwards;
  }
  .chart .appear {
    opacity: 0;
    animation: appear 0.5s ease-out forwards;
    animation-delay: calc(0.5s + var(--at, 0) * 1.3s);
  }
  .chart .t-target-ring {
    transform-box: fill-box;
    transform-origin: center;
    animation: ping 2.4s ease-out 2.2s infinite;
  }
}

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }
@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.9; }
  70%, 100% { transform: scale(2.2); opacity: 0; }
}

/* ─── Phone frame ─────────────────────────────────────────────────── */

.phone {
  position: relative;
  border-radius: 2.6rem;
  padding: 0.55rem;
  background: #1F2229;
  box-shadow: var(--shadow), inset 0 0 0 1.5px #3A3E48;
}

.phone img {
  width: 100%;
  height: auto;
  aspect-ratio: 660 / 1434;
  border-radius: 2.1rem;
  background: var(--raised);
}

/* ─── Store buttons ───────────────────────────────────────────────── */

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.store {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 3.5rem;
  padding: 0.55rem 1.3rem 0.55rem 1rem;
  border-radius: 999px;
  background: var(--signal);
  color: var(--on-signal);
  text-decoration: none;
  line-height: 1.15;
}
.store:hover { background: var(--signal-pressed); }

.store svg { width: 1.6rem; height: 1.6rem; flex: none; fill: currentColor; }
.store small { display: block; font-size: 0.75rem; font-weight: 500; opacity: 0.9; }
.store strong { display: block; font-size: 1.1rem; font-weight: 800; }

.store.secondary {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--divider);
}
.store.secondary:hover { background: var(--raised); }

.store[aria-disabled="true"] { cursor: default; }

/* ─── Sections ────────────────────────────────────────────────────── */

.section { padding-block: clamp(3rem, 7vw, 5.5rem); }
.section.first { padding-top: clamp(5rem, 10vw, 7rem); }

.section-head { max-width: 40rem; }
.section-head h2 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
.section-head p {
  margin-top: 1rem;
  font-size: 1.15rem;
  color: var(--ink-2);
  max-width: var(--measure);
}

/* Showcase: screenshots with captions, offset like stops along a line. */
.showcase {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin-top: clamp(2.5rem, 6vw, 4rem);
  align-items: start;
}

.showcase figure { margin: 0; }
.showcase figure:nth-child(2) { margin-top: 4rem; }
.showcase figure:nth-child(3) { margin-top: 8rem; }

.showcase figcaption { margin-top: 1.5rem; }
.showcase h3 { font-size: 1.45rem; letter-spacing: -0.015em; }
.showcase figcaption p { margin-top: 0.5rem; color: var(--ink-2); }

.pro-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem 0;
  border-radius: 6px;
  background: var(--survey);
  color: var(--track);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  vertical-align: 0.3em;
}

@media (max-width: 52rem) {
  .showcase {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: min(72vw, 17rem);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    padding-bottom: 1rem;
    scrollbar-width: none;
  }
  .showcase::-webkit-scrollbar { display: none; }
  .showcase figure { scroll-snap-align: start; }
  .showcase figure:nth-child(n) { margin-top: 0; }
}

/* Offline: copy beside a grouped list that mirrors the app's Maps screen. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}

@media (max-width: 52rem) {
  .split { grid-template-columns: 1fr; }
}

.facts {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1.1rem;
  max-width: var(--measure);
}

.facts li {
  padding-left: 1.4rem;
  position: relative;
  color: var(--ink-2);
}
.facts li strong { color: var(--ink); font-weight: 600; }

.facts li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 2px solid var(--track);
}

.grouped {
  background: var(--surface);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  padding: 0.4rem 0;
}

.grouped-title {
  padding: 0.9rem 1.25rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}

.region {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1.25rem;
}
.region { position: relative; }
/* Inset hairline between rows, starting after the status dot (as in the app). */
.region + .region::before {
  content: "";
  position: absolute;
  top: 0;
  left: 3.4rem;
  right: 0;
  border-top: 1px solid var(--divider);
}

.region-dot {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  border-radius: 50%;
  background: var(--survey);
  display: grid;
  place-items: center;
}
.region-dot::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--track);
}
.region-dot.pending::after { background: var(--ink-3); }

.region-body { flex: 1; min-width: 0; }
.region-name { font-weight: 600; line-height: 1.3; }
.region-meta { font-size: 0.85rem; color: var(--ink-2); }

.region-action {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--signal-text);
}

/* Colour modes strip. */
.modes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-top: clamp(2rem, 5vw, 3rem);
}

.mode {
  padding: 1.1rem 1.1rem 1.25rem;
  background: var(--surface);
  border-radius: 1rem;
}

.mode-lines { display: grid; gap: 5px; margin-bottom: 1rem; }
.mode-lines span { height: 5px; border-radius: 3px; }
.mode h3 { font-size: 1.05rem; letter-spacing: -0.01em; }
.mode p { margin-top: 0.3rem; font-size: 0.9rem; color: var(--ink-2); line-height: 1.45; }

@media (max-width: 60rem) {
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 30rem) {
  .modes { grid-template-columns: 1fr; }
}

/* Free vs Pro: the app's comparison table. */
.compare {
  margin-top: clamp(2rem, 5vw, 3rem);
  background: var(--surface);
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.compare table {
  width: 100%;
  border-collapse: collapse;
}

.compare th,
.compare td {
  padding: 1rem 1.25rem;
  text-align: left;
  vertical-align: middle;
}

.compare thead th {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-2);
}
.compare thead th.pro { color: var(--signal-text); font-weight: 800; }

.compare tbody tr { border-top: 1px solid var(--divider); }
.compare tbody th { font-weight: 500; }

.compare .plan {
  width: 7.5rem;
  text-align: center;
}

.compare .yes,
.compare .no { display: inline-block; width: 1.25rem; height: 1.25rem; }
.compare .yes { color: var(--signal-text); }
.compare .free .yes { color: var(--ink-2); }
.compare .no { color: var(--ink-3); }
.compare .text { font-weight: 600; }

@media (max-width: 34rem) {
  .compare th, .compare td { padding: 0.85rem 0.6rem; }
  .compare th[scope="row"], .compare thead th:first-child { padding-left: 1rem; }
  .compare .plan { width: 4.5rem; }
  .compare .text { font-size: 0.8rem; }
}

.crews {
  margin-top: 1.5rem;
  color: var(--ink-2);
  max-width: 44rem;
}

/* Download band. */
.download {
  background: var(--survey);
  position: relative;
  overflow: hidden;
}

.download .wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: center;
}

.download h2 { font-size: clamp(2.2rem, 5.5vw, 3.8rem); }
.download p { margin-top: 0.9rem; color: var(--ink-2); max-width: var(--measure); }

.download img.app-icon {
  width: clamp(6rem, 14vw, 9rem);
  height: auto;
  border-radius: 22%;
  box-shadow: var(--shadow);
}

@media (max-width: 40rem) {
  .download .wrap { grid-template-columns: 1fr; }
  .download img.app-icon { grid-row: 1; }
}

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

.site-footer {
  padding-block: 3rem 3.5rem;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.site-footer .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem 3rem;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-weight: 600;
}
.site-footer nav a { color: var(--ink); text-decoration: none; }
.site-footer nav a:hover { text-decoration: underline; }

.site-footer .fine { max-width: 38rem; }
.site-footer .fine p + p { margin-top: 0.6rem; }
.site-footer .fine a { color: inherit; }

@media (max-width: 40rem) {
  .site-footer .wrap { grid-template-columns: 1fr; }
}

/* ─── Legal pages ─────────────────────────────────────────────────── */

.doc-head {
  background: var(--survey);
  margin-top: -4.6rem;
  padding: 7.5rem 0 3rem;
}

.doc-head .wrap { max-width: 42rem; }
.doc-head h1 { font-size: clamp(2.4rem, 6vw, 4rem); }
.doc-head p { margin-top: 0.75rem; color: var(--ink-2); }

.doc {
  max-width: 42rem;
  padding-block: 3rem 5rem;
}

.doc .summary {
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border-radius: 1rem;
  font-size: 1.05rem;
}

.doc h2 {
  margin-top: 2.75rem;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  scroll-margin-top: 1.5rem;
}

.doc h3 {
  margin-top: 1.75rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.doc p,
.doc ul { margin-top: 0.9rem; }
.doc ul { padding-left: 1.25rem; }
.doc li + li { margin-top: 0.45rem; }

.doc .caps { text-transform: none; font-size: 0.95rem; color: var(--ink-2); }

.doc .table-scroll { overflow-x: auto; margin-top: 1.1rem; }
.doc table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--surface);
  border-radius: 0.75rem;
  overflow: hidden;
}
.doc th, .doc td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--divider);
}
.doc thead th { border-top: 0; font-weight: 700; }

.doc .toc {
  margin-top: 2rem;
  padding: 0;
  list-style: none;
  columns: 2 14rem;
  column-gap: 2rem;
  font-size: 0.95rem;
}
.doc .toc li { break-inside: avoid; margin: 0 0 0.4rem; }

/* Placeholders still to fill in before launch. */
.fill {
  padding: 0 0.3em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--signal) 18%, transparent);
  color: var(--signal-text);
  font-weight: 600;
}
