/* CPE typography & palette --------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400;0,500;0,600;1,400&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  --cpe-black: #1a1a1a;
  --cpe-dark: #333333;
  --cpe-mid: #555555;
  --cpe-light: #999999;
  --cpe-rule: #cccccc;
  --cpe-bg: #ffffff;
  --cpe-paper: #fafaf7;

  /* Class I host palette - tuned to CPE's quiet categorical set */
  --host-bnsf: #d4a843;      /* muted gold - BNSF */
  --host-up:   #c47836;      /* burnt orange - UP */
  --host-csx:  #5b7fa5;      /* slate blue - CSX */
  --host-ns:   #8b6b8b;      /* dusty plum - NS */
  --host-cpkc: #c4786a;      /* terracotta - CPKC */
  --host-cn:   #5a8a7a;      /* teal sage - CN */
  --host-amtrak: #2d5f2d;    /* forest green - Amtrak */
  --host-public: #5a5a5a;    /* neutral grey - state/public */
  --host-shortline: #aa9466; /* tan - short line */
  --host-private: #999999;   /* light grey - private (Brightline) */
  --host-tbd: #cccccc;       /* TBD/greenfield */

  /* Step colors */
  --step-1: #c8dcc0;
  --step-2: #7aab6d;
  --step-3: #2d5f2d;

  /* Default route color (overview scene) */
  --route-default: #1a1a1a;
  --route-default-stroke: 2px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  color: var(--cpe-black);
  background: var(--cpe-paper);
  line-height: 1.55;
}

/* Masthead --------------------------------------------------------------- */

.masthead {
  background: var(--cpe-bg);
  border-bottom: 1px solid var(--cpe-rule);
  padding: 3rem 0 2.25rem;
}

.masthead-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 2rem;
}

.kicker {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cpe-light);
  margin: 0 0 0.9rem;
}

.masthead h1 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: 2.4rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.9rem;
  color: var(--cpe-black);
}

.dek {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  line-height: 1.45;
  color: var(--cpe-mid);
  margin: 0;
  max-width: 56ch;
  letter-spacing: -0.005em;
}

/* Scrollytelling layout -------------------------------------------------- */

.scrolly {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 1.4fr;
  gap: 0;
  position: relative;
  background: var(--cpe-paper);
}

.scroller {
  padding: 4rem 0 8rem;
}

.step {
  min-height: 85vh;
  display: flex;
  align-items: center;
  padding: 2rem 3rem 2rem 2rem;
}

.step-card {
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 2px solid var(--cpe-rule);
  max-width: 440px;
  margin-left: auto;
  transition: opacity 250ms ease, border-left-color 250ms ease;
  opacity: 0.4;
}

.step.is-active .step-card {
  opacity: 1;
  border-left-color: var(--cpe-black);
}

.step-card h2 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 0.85rem;
  color: var(--cpe-black);
}

.step-card p {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--cpe-dark);
  margin: 0 0 0.75rem;
}

.step-card p:last-child {
  margin-bottom: 0;
}

.step-card strong {
  font-weight: 500;
  color: var(--cpe-black);
}

.step-card em {
  font-style: italic;
}

.closing-line {
  font-family: 'Instrument Serif', Georgia, serif !important;
  font-style: italic;
  font-size: 1.2rem !important;
  color: var(--cpe-black) !important;
  margin-top: 1.4rem !important;
  padding-top: 1.1rem;
  border-top: 1px solid var(--cpe-rule);
  line-height: 1.35;
}

/* Sticky map ------------------------------------------------------------- */

.map-container {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0;
  background: var(--cpe-paper);
}

#map {
  width: 100%;
  height: 100%;
  background: #f4f4ef;
}

.leaflet-container {
  font-family: 'Instrument Sans', sans-serif !important;
  background: #f4f4ef !important;
}

/* Tone down the basemap further - Upshot maps are quiet */
.leaflet-tile-pane {
  filter: saturate(0.45) brightness(1.04) contrast(0.96);
}

.map-overlay {
  position: absolute;
  top: 2rem;
  left: 2rem;
  background: transparent;
  padding: 0;
  max-width: 360px;
  z-index: 500;
  pointer-events: none;
}

.map-kicker {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cpe-light);
  margin-bottom: 0.35rem;
}

.map-title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 1.65rem;
  letter-spacing: -0.015em;
  color: var(--cpe-black);
  margin-bottom: 0.85rem;
  line-height: 1.15;
  text-shadow: 0 0 8px rgba(255,255,255,0.85), 0 0 4px rgba(255,255,255,0.85);
  max-width: 340px;
}

.map-legend {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--cpe-dark);
  line-height: 1.5;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(2px);
  padding: 0.7rem 0.9rem;
  display: inline-block;
  border-left: 2px solid var(--cpe-black);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.18rem 0;
}

.legend-swatch {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

.legend-count {
  color: var(--cpe-light);
  margin-left: 0.45rem;
  font-feature-settings: "tnum";
}

.map-footnote {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 300;
  font-size: 0.72rem;
  color: var(--cpe-light);
  font-style: italic;
  margin-top: 0.5rem;
  max-width: 320px;
  line-height: 1.4;
}

/* Loading state - covers the map while corridor-geometries.geojson loads. */
.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 700;
  font-family: 'Instrument Sans', sans-serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--cpe-mid);
  background: rgba(255,255,255,0.92);
  padding: 0.6rem 1rem;
  border-left: 2px solid var(--cpe-rule);
  pointer-events: none;
  opacity: 1;
  transition: opacity 200ms ease;
}
.map-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.map-footnote .dash-swatch {
  display: inline-block;
  width: 22px;
  height: 0;
  margin-right: 0.3rem;
  border-top: 1.5px dashed var(--cpe-mid);
  vertical-align: middle;
}

/* Direct labels on the map - the Upshot move */
.map-label {
  background: transparent;
  border: none;
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--cpe-black);
  text-shadow:
    -1px -1px 2px #fff, 1px -1px 2px #fff, -1px 1px 2px #fff, 1px 1px 2px #fff,
    0 0 4px rgba(255,255,255,0.9);
  white-space: nowrap;
  pointer-events: none;
  text-align: center;
}

.map-label.host-label {
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.map-label.dollar-label {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--cpe-black);
  letter-spacing: -0.01em;
}

.map-label.dollar-label .label-detail {
  display: block;
  font-family: 'Instrument Sans', sans-serif;
  font-style: normal;
  font-size: 0.7rem;
  color: var(--cpe-mid);
  letter-spacing: 0;
  margin-top: 0.1rem;
  /* Detail lines can be long; wrap within the divIcon width instead of
     overflowing (the base .map-label is nowrap for one-word host labels). */
  white-space: normal;
}

/* Leaflet tooltip overrides - quieter, more newspaper */
.leaflet-tooltip {
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--cpe-rule);
  border-radius: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.8rem;
  color: var(--cpe-dark);
  padding: 0.45rem 0.65rem;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before {
  border-top-color: var(--cpe-rule);
}

/* Scene navigation dots ------------------------------------------------- */

.scene-nav {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 600;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(2px);
  padding: 0.85rem 0.55rem;
  border-left: 2px solid var(--cpe-rule);
}

.scene-dot {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.scene-dot::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cpe-light);
  transition: width 180ms ease, height 180ms ease, background 180ms ease;
}

.scene-dot:hover::before {
  background: var(--cpe-mid);
  width: 9px;
  height: 9px;
}

.scene-dot.is-active::before {
  background: var(--cpe-black);
  width: 10px;
  height: 10px;
}

.scene-dot:focus-visible {
  outline: 2px solid var(--cpe-black);
  outline-offset: 2px;
  border-radius: 50%;
}

.scene-dot-num {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
  font-size: 0.62rem;
  color: var(--cpe-light);
  opacity: 0;
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.95);
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 150ms ease;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.scene-dot:hover .scene-dot-num,
.scene-dot:focus-visible .scene-dot-num {
  opacity: 1;
  color: var(--cpe-dark);
}

/* Keyboard hint - quietly fades in once, then dismisses */
.kbd-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--cpe-rule);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.72rem;
  color: var(--cpe-mid);
  padding: 0.45rem 0.85rem;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.kbd-hint.is-visible {
  opacity: 1;
}

.kbd-hint kbd {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  background: var(--cpe-paper);
  border: 1px solid var(--cpe-rule);
  padding: 0.05rem 0.35rem;
  margin: 0 0.1rem;
  color: var(--cpe-dark);
}

/* Annotation popup */
.corridor-annotation {
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--cpe-rule);
  padding: 0.6rem 0.85rem;
  font-size: 0.78rem;
  color: var(--cpe-dark);
  max-width: 240px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.corridor-annotation strong {
  display: block;
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: 0.92rem;
  color: var(--cpe-black);
  margin-bottom: 0.2rem;
}

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

.footer {
  background: var(--cpe-bg);
  border-top: 1px solid var(--cpe-rule);
  padding: 1.5rem 0;
  font-size: 0.78rem;
  color: var(--cpe-light);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-label {
  font-weight: 500;
  color: var(--cpe-mid);
}

.footer a {
  color: var(--cpe-mid);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--cpe-rule);
}
.footer a:hover {
  color: var(--cpe-black);
  text-decoration-color: var(--cpe-mid);
}

.footer-brand {
  margin-left: auto;
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  color: var(--cpe-light);
}

/* Static export mode --------------------------------------------------- */
/* Triggered by ?static=1 in the URL — hides interactive chrome so the
   screenshot is a clean editorial graphic. */
body.is-static .scene-nav,
body.is-static .kbd-hint,
body.is-static .map-loading,
body.is-static .map-kicker,
body.is-static .leaflet-control-attribution {
  display: none !important;
}
body.is-static .map-overlay {
  top: 1.5rem;
  left: 1.5rem;
}

/* Pinned tooltip ------------------------------------------------------- */
/* When the user clicks a corridor, the tooltip stays open for them to read.
   Slightly heavier styling distinguishes it from the transient hover form. */
.leaflet-tooltip.is-pinned {
  border: 1px solid var(--cpe-black);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  background: #ffffff;
  pointer-events: auto;
  padding-right: 1.7rem;
}
.leaflet-tooltip.is-pinned::after {
  content: "×";
  position: absolute;
  top: 0.15rem;
  right: 0.35rem;
  color: var(--cpe-light);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

/* Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .step-card { transition: none !important; }
  .scene-dot::before { transition: none !important; }
  .leaflet-tile-pane { transition: none !important; }
}

/* Responsive ----------------------------------------------------------- */
/* Tablet: tighten things, but keep the side-by-side layout if there is room */
@media (max-width: 1100px) {
  .scrolly { grid-template-columns: minmax(320px, 1fr) 1.3fr; }
  .map-overlay { top: 1.25rem; left: 1.25rem; max-width: 300px; }
  .map-title { font-size: 1.4rem; }
  .scene-nav { right: 0.85rem; padding: 0.6rem 0.35rem; }
  .step { padding: 1.75rem 1.75rem 1.75rem 1.5rem; }
}

/* Phone: stack vertically, map sticks to top, scroller below */
@media (max-width: 760px) {
  .masthead { padding: 2rem 0 1.5rem; }
  .masthead-inner { padding: 0 1.25rem; }
  .masthead h1 { font-size: 1.8rem; }
  .dek { font-size: 1rem; }

  .scrolly { grid-template-columns: 1fr; }
  .map-container {
    position: sticky;
    top: 0;
    height: 58vh;
    order: -1;
    border-bottom: 1px solid var(--cpe-rule);
  }
  .scroller { padding: 2rem 0 4rem; }
  .step {
    padding: 1.25rem 1.25rem 1.25rem 1.25rem;
    min-height: 65vh;
  }
  .step-card {
    margin: 0;
    max-width: 100%;
    padding-left: 1rem;
  }
  .step-card h2 { font-size: 1.45rem; }
  .step-card p { font-size: 0.96rem; }

  /* Map overlay - tighten and let it use full top width on phone */
  .map-overlay {
    top: 1rem; left: 1rem; right: 1rem;
    max-width: none;
  }
  .map-title { font-size: 1.15rem; max-width: 70%; }
  .map-legend { font-size: 0.75rem; padding: 0.55rem 0.7rem; }
  .map-footnote { font-size: 0.66rem; max-width: 240px; }

  /* Scene nav - bottom-center horizontal pill instead of right-edge column */
  .scene-nav {
    flex-direction: row;
    right: 50%;
    top: auto;
    bottom: 0.85rem;
    transform: translateX(50%);
    padding: 0.45rem 0.6rem;
    gap: 0.4rem;
    border-left: none;
    border-bottom: 2px solid var(--cpe-rule);
  }
  .scene-dot-num { display: none; }

  .footer-inner { padding: 0 1.25rem; }
  .footer-brand { margin-left: 0; }
}
