:root {
  --ink: #14110e;
  --muted: #5e574e;
  --line: rgba(20, 17, 14, 0.12);
  --paper: #f2eee6;
  --asphalt: #2a2e33;
  --lane: #f0c850;
  --lane-solid: #e8b84a;
  --sidewalk: #cfc7bb;
  --bulb: #d9e4d4;
  --muni: #c8102e;
  --accent: #0d6e5c;
  --card: #fffcf7;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Newsreader", Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  background:
    radial-gradient(ellipse 70% 45% at 90% -10%, rgba(232, 184, 74, 0.28), transparent 55%),
    radial-gradient(ellipse 50% 40% at -5% 30%, rgba(13, 110, 92, 0.1), transparent 50%),
    linear-gradient(180deg, #ebe5da 0%, var(--paper) 40%, #e4ddd2 100%);
  min-height: 100vh;
}

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

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 252, 247, 0.72);
}

.eyebrow.dark { color: var(--muted); }

.hero {
  position: relative;
  padding: 1.1rem 0 3.5rem;
  color: #fffcf7;
  background:
    linear-gradient(145deg, rgba(20, 17, 14, 0.2), transparent 40%),
    linear-gradient(180deg, #1c2228 0%, #2f353c 55%, #3a4149 100%);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -30% 40%;
  height: 70%;
  background: radial-gradient(circle, rgba(232, 184, 74, 0.22), transparent 65%);
  pointer-events: none;
}

.nav {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.nav-links {
  display: flex;
  gap: 1.1rem;
  align-items: center;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #fffcf7;
  text-decoration: none;
}

.brand span {
  color: var(--lane-solid);
}

.nav-link {
  color: rgba(255, 252, 247, 0.78);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover { color: #fff; }

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2.5rem;
  align-items: center;
}

.hero h1 {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.hero h1 em {
  font-style: italic;
  color: var(--lane-solid);
}

.hero-copy {
  margin: 0 0 1.5rem;
  max-width: 34rem;
  font-size: 1.08rem;
  color: rgba(255, 252, 247, 0.82);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: var(--lane-solid);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s ease, background 0.2s ease;
}

.button:hover {
  background: #f2c85a;
  transform: translateY(-1px);
}

.hero-visual {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.bulb-gif {
  margin: 0;
  background: rgba(255, 252, 247, 0.06);
  border: 1px solid rgba(255, 252, 247, 0.12);
  border-radius: 18px;
  overflow: hidden;
}

.bulb-gif img {
  display: block;
  width: 100%;
  height: auto;
  background: #1a1f24;
}

.bulb-gif figcaption {
  padding: 0.65rem 0.85rem 0.8rem;
  font-size: 0.86rem;
  line-height: 1.35;
  color: rgba(255, 252, 247, 0.78);
}

.bulb-gif figcaption .fig-seconds {
  color: #fff;
  font-weight: 600;
}

.bulb-gif figcaption a {
  color: rgba(255, 252, 247, 0.92);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bulb-diagram,
.problem-card {
  background: rgba(255, 252, 247, 0.06);
  border: 1px solid rgba(255, 252, 247, 0.12);
  border-radius: 18px;
  padding: 1rem 1rem 1.1rem;
  backdrop-filter: blur(6px);
}

.problem-stat {
  margin: 0.35rem 0 0.75rem;
}

.problem-stat strong {
  display: block;
  font-family: var(--display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--lane-solid);
}

.problem-stat span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.diagram-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--lane-solid);
  margin-bottom: 0.65rem;
}

.street {
  position: relative;
  height: 150px;
  border-radius: 12px;
  background:
    linear-gradient(90deg, var(--sidewalk) 0 18%, transparent 18%),
    repeating-linear-gradient(
      90deg,
      #3a4047 0 28px,
      #343a41 28px 56px
    );
  overflow: hidden;
}

.sidewalk {
  position: absolute;
  inset: 0 auto 0 0;
  width: 18%;
  background: linear-gradient(180deg, #d8d0c4, #c4bcb0);
}

.bulb {
  position: absolute;
  left: 10%;
  top: 18%;
  bottom: 18%;
  width: 22%;
  border-radius: 10px 18px 18px 10px;
  background: linear-gradient(135deg, #e7efe2, #c9d8c2);
  box-shadow: inset 0 0 0 1px rgba(20, 17, 14, 0.08);
  animation: bulb-in 1.1s ease both;
}

.bus {
  position: absolute;
  left: 28%;
  top: 50%;
  transform: translateY(-50%);
  width: 78px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #e11d2e, #a50d1c);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  animation: bus-slide 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.lane-mark {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: rgba(240, 200, 80, 0.85);
  transform: translateY(-50%);
}

.lane-mark.one { right: 28%; }
.lane-mark.two { right: 18%; }
.lane-mark.three { right: 8%; }

.arrow {
  position: absolute;
  right: 1rem;
  bottom: 0.7rem;
  color: rgba(255, 252, 247, 0.7);
  font-size: 1.2rem;
  animation: pulse 2s ease-in-out infinite;
}

.diagram-note {
  margin-top: 0.75rem;
  font-size: 0.92rem;
  color: rgba(255, 252, 247, 0.78);
  line-height: 1.35;
}

@keyframes bus-slide {
  from { opacity: 0; transform: translate(-24px, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}

@keyframes bulb-in {
  from { opacity: 0; transform: scaleX(0.7); transform-origin: left center; }
  to { opacity: 1; transform: scaleX(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(4px); }
}

.section {
  padding: 3.25rem 0;
}

.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

.section-lede {
  margin: 0.65rem 0 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
}

.section-lede a { font-weight: 600; }

.problem-section {
  background: rgba(255, 252, 247, 0.55);
  border-block: 1px solid var(--line);
}

.fix-section {
  padding-bottom: 3.5rem;
}

.route-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem 1rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.route-bar label {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.route-bar select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-weight: 500;
}

.status-inline {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.problem-panel {
  padding: 1.15rem 1.25rem 1.2rem;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(200, 16, 46, 0.07), rgba(232, 184, 74, 0.12));
  border: 1px solid rgba(200, 16, 46, 0.16);
}

.problem-lead {
  margin: 0.35rem 0 0.9rem;
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.problem-lead strong {
  color: #a50d1c;
}

.problem-lead span {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.direction-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.direction-list li {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 252, 247, 0.85);
  border: 1px solid var(--line);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.direction-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.7rem;
}

.direction-list strong {
  min-width: 0;
}

.direction-gap {
  color: var(--muni);
  font-weight: 600;
  font-size: 0.88rem;
}

.direction-runs {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  color: var(--ink);
  line-height: 1.4;
}

.direction-list .vs {
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-note {
  margin: 0.85rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.panel-note[hidden] {
  display: none;
}

.section-number {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
  color: rgba(20, 17, 14, 0.2);
  line-height: 1;
}

.section-head h2,
.sources h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.calculator-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 110, 92, 0.15);
  flex-shrink: 0;
}

.controls,
.results,
.map-card,
.formula-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.controls {
  padding: 1.15rem 1.2rem 1.3rem;
}

.controls label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.controls select {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-weight: 500;
  margin-bottom: 1.1rem;
}

.range-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.range-heading.second { margin-top: 1rem; }

.range-heading output {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.simple-note {
  margin: 1rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}

.results {
  padding: 1.15rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.math-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.math-lines li {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: rgba(20, 17, 14, 0.03);
  border: 1px solid var(--line);
}

.math-lines li.math-roi {
  background:
    linear-gradient(135deg, rgba(13, 110, 92, 0.14), rgba(232, 184, 74, 0.16));
  border-color: rgba(13, 110, 92, 0.18);
}

.math-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.math-eq {
  display: grid;
  gap: 0.35rem;
}

.math-steps {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.math-steps em {
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.math-answer {
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}

.math-lines li.math-problem {
  background:
    linear-gradient(135deg, rgba(200, 16, 46, 0.08), rgba(232, 184, 74, 0.14));
  border-color: rgba(200, 16, 46, 0.16);
}

.math-problem .math-answer {
  color: #a50d1c;
}

.controls-lead {
  margin: 0.15rem 0 0.85rem !important;
  font-weight: 700;
  color: var(--ink) !important;
}

.method {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem 2rem;
  padding: 1rem 0 2.5rem;
}

.method-copy {
  grid-column: 2;
  margin: 0;
}

.method .formula-card {
  grid-column: 2;
}

.caveat {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
}

.map-card {
  padding: 1rem 1rem 0.85rem;
}

.map-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.map-heading h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
}

.legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.selected { background: var(--muni); box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.18); }
.dot.other { background: #8a847a; }

#map {
  height: min(52vh, 420px);
  border-radius: 12px;
  background: #d8d2c8;
  border: 1px solid var(--line);
}

.map-note {
  margin: 0.65rem 0 0.15rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.formula-card {
  padding: 1.1rem 1.2rem;
  display: grid;
  gap: 0.85rem;
}

.formula-card > div {
  display: grid;
  gap: 0.25rem;
}

.formula-card span {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.formula-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: rgba(20, 17, 14, 0.04);
  border: 1px solid var(--line);
}

.formula-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ranking-section {
  background: rgba(255, 252, 247, 0.55);
  border-block: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.rank-table th,
.rank-table td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.rank-table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(20, 17, 14, 0.03);
  white-space: nowrap;
}

.rank-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.rank-table tbody tr:hover {
  background: rgba(232, 184, 74, 0.12);
}

.rank-table tbody tr.is-active {
  background: rgba(13, 110, 92, 0.1);
}

.rank-table tbody tr:last-child td {
  border-bottom: 0;
}

.rank-table td:last-child {
  font-weight: 700;
  color: #a50d1c;
}

.rank-table strong {
  margin-right: 0.25rem;
}

.sources {
  padding: 2.75rem 0 3.25rem;
  background: rgba(20, 17, 14, 0.04);
  border-top: 1px solid var(--line);
}

.sources-grid {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 2rem;
  align-items: start;
}

.sources-body {
  display: grid;
  gap: 0.85rem;
}

.sources-body .formula-card {
  margin-bottom: 0.35rem;
}

.sources-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sources-body strong { color: var(--ink); }

.attribution {
  font-size: 0.82rem !important;
  opacity: 0.9;
}

footer {
  padding: 1.1rem 0 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
}

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

footer a {
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 900px) {
  .hero-grid,
  .calculator-grid,
  .sources-grid,
  .section-head {
    grid-template-columns: 1fr;
  }

  .route-bar {
    grid-template-columns: 1fr;
  }

  .nav-links { gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; }
}
