/* Train Radar — trainradar.co
   Shared stylesheet. Dark-first "control room" look mirroring the iOS
   DesignSystem tokens (LTTColor). No external fonts, no JS. */

:root {
  /* Dark palette (primary design) */
  --bg-base: #0b0e14;
  --bg-elevated: #131821;
  --surface: #1e2531;
  --stroke: rgba(255, 255, 255, 0.1);
  --signal: #34e18b;
  --signal-dim: rgba(52, 225, 139, 0.55);
  --signal-faint: rgba(52, 225, 139, 0.12);
  --amber: #ffbd49;
  --text-primary: #f2f5f9;
  --text-secondary: #aab4c3;
  --text-muted: #6b7686;
  --rail: rgba(52, 225, 139, 0.28);
  --max-width: 68rem;
  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-base: #f2f4f6;
    --bg-elevated: #ffffff;
    --surface: #e9edf1;
    --stroke: rgba(0, 0, 0, 0.1);
    --signal: #13a35f;
    --signal-dim: rgba(19, 163, 95, 0.6);
    --signal-faint: rgba(19, 163, 95, 0.1);
    --text-primary: #10151d;
    --text-secondary: #46505e;
    --text-muted: #77818f;
    --rail: rgba(19, 163, 95, 0.35);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded",
    "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5.5vw, 3.25rem); margin: 0 0 0.5em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); margin: 2.2em 0 0.6em; }
h3 { font-size: 1.125rem; margin: 1.8em 0 0.4em; }

p { margin: 0 0 1em; }
a { color: var(--signal); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
ul { padding-left: 1.3em; margin: 0 0 1em; }
li { margin-bottom: 0.4em; }
strong { color: var(--text-primary); }
code, .mono {
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Layout ---------- */

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.narrow { max-width: 46rem; }

main { padding-bottom: 4rem; }

/* ---------- Header ---------- */

header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg-base) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand .dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 8px var(--signal-dim);
  flex: none;
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px var(--signal-dim); }
  50% { box-shadow: 0 0 12px var(--signal-dim); }
}

nav.site-nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.92rem;
}
nav.site-nav a { color: var(--text-secondary); }
nav.site-nav a:hover { color: var(--text-primary); text-decoration: none; }

/* ---------- Hero (landing) ---------- */

.hero {
  position: relative;
  padding: clamp(3rem, 8vw, 5.5rem) 0 2.5rem;
  text-align: center;
}

.hero .tagline {
  font-size: clamp(1.05rem, 2.4vw, 1.3rem);
  color: var(--text-secondary);
  max-width: 38em;
  margin: 0 auto 1.5rem;
}

.hero .store-badge {
  display: inline-block;
  margin-top: 1.1rem;
  line-height: 0;
}
.hero .store-badge img {
  display: block;
  width: 150px;
  height: 50px;
}

/* ---------- Animated rail map panel ---------- */

.railmap {
  position: relative;
  margin: 2.5rem auto 0;
  max-width: 56rem;
  border: 1px solid var(--stroke);
  border-radius: 1.25rem;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(52, 225, 139, 0.06), transparent 60%),
    var(--bg-elevated);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.railmap svg { display: block; width: 100%; height: auto; }

.railmap .rail {
  fill: none;
  stroke: var(--rail);
  stroke-width: 1.6;
  stroke-linecap: round;
}
.railmap .rail.glow {
  stroke: var(--signal-dim);
  stroke-width: 3.5;
  opacity: 0.25;
  filter: blur(3px);
}
.railmap .station {
  fill: var(--bg-elevated);
  stroke: var(--signal-dim);
  stroke-width: 1.2;
}

.railmap .train {
  fill: var(--signal);
  filter: drop-shadow(0 0 4px var(--signal-dim));
}
.railmap .train.amber {
  fill: var(--amber);
  filter: drop-shadow(0 0 4px rgba(255, 189, 73, 0.55));
}

/* Trains move along their rail with CSS motion paths.
   Paths are duplicated in each .train's offset-path below. */
.train { offset-rotate: 0deg; }
.t1 { offset-path: path("M -40 218 C 120 210 190 150 320 148 S 560 190 700 132 S 880 60 940 66"); animation: glide 26s linear infinite; }
.t2 { offset-path: path("M 940 260 C 780 258 700 208 560 226 S 320 300 180 260 S 20 200 -40 210"); animation: glide 31s linear infinite; animation-delay: -12s; }
.t3 { offset-path: path("M -40 110 C 140 118 260 60 420 76 S 700 150 940 128"); animation: glide 23s linear infinite; animation-delay: -6s; }
.t4 { offset-path: path("M 460 340 C 470 260 430 200 470 140 S 560 40 620 -20"); animation: glide 19s linear infinite; animation-delay: -3s; }
.t5 { offset-path: path("M -40 218 C 120 210 190 150 320 148 S 560 190 700 132 S 880 60 940 66"); animation: glide 26s linear infinite; animation-delay: -14s; }
.t6 { offset-path: path("M -40 110 C 140 118 260 60 420 76 S 700 150 940 128"); animation: glide 23s linear infinite reverse; animation-delay: -11s; }

@keyframes glide {
  from { offset-distance: 0%; }
  to { offset-distance: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .train { animation: none; offset-distance: 38%; }
  .t2 { offset-distance: 62%; }
  .t3 { offset-distance: 20%; }
  .t4 { offset-distance: 55%; }
  .t5 { offset-distance: 80%; }
  .t6 { offset-distance: 47%; }
  .brand .dot { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Feature grid ---------- */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 3rem;
}

.feature {
  background: var(--bg-elevated);
  border: 1px solid var(--stroke);
  border-radius: 1rem;
  padding: 1.4rem 1.4rem 1.2rem;
  text-align: left;
}
.feature h3 {
  margin: 0.6rem 0 0.35rem;
  font-size: 1.05rem;
}
.feature p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}
.feature .icon {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.6rem;
  background: var(--signal-faint);
  color: var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.feature .icon svg { width: 1.2rem; height: 1.2rem; }
.feature .pro {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--signal-faint);
  color: var(--signal);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 0.15em;
}

/* ---------- Legal / article pages ---------- */

article.legal {
  padding-top: 2.5rem;
}
article.legal h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
article.legal .meta {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 2rem;
}
article.legal h2 { font-size: 1.3rem; }
article.legal table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 0 0 1.5em;
}
article.legal th, article.legal td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--stroke);
  vertical-align: top;
}
article.legal th { color: var(--text-secondary); font-weight: 600; }

.table-scroll { overflow-x: auto; }

.callout {
  background: var(--bg-elevated);
  border: 1px solid var(--stroke);
  border-left: 3px solid var(--signal);
  border-radius: 0.6rem;
  padding: 1rem 1.2rem;
  margin: 1.5em 0;
  font-size: 0.97rem;
}
.callout.warn { border-left-color: var(--amber); }

/* ---------- FAQ ---------- */

details.faq {
  border: 1px solid var(--stroke);
  border-radius: 0.8rem;
  background: var(--bg-elevated);
  margin-bottom: 0.8rem;
  padding: 0;
}
details.faq summary {
  cursor: pointer;
  padding: 1rem 1.2rem;
  font-weight: 600;
  list-style: none;
  position: relative;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "+";
  position: absolute;
  right: 1.2rem;
  color: var(--text-muted);
  font-weight: 400;
}
details.faq[open] summary::after { content: "\2212"; }
details.faq .answer { padding: 0 1.2rem 1.1rem; color: var(--text-secondary); }
details.faq .answer p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */

footer.site {
  border-top: 1px solid var(--stroke);
  margin-top: 3rem;
  padding: 2.5rem 0 3rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
footer.site .cols {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  justify-content: space-between;
  margin-bottom: 1.8rem;
}
footer.site nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}
footer.site a { color: var(--text-secondary); }
footer.site .attribution {
  font-size: 0.82rem;
  line-height: 1.7;
  max-width: 60em;
}

@media (max-width: 40rem) {
  nav.site-nav { display: none; }
  .hero { text-align: left; }
  .hero .tagline { margin-left: 0; }
}
