:root {
  --bg: #fdfcf9;
  --ink: #1c1e21;
  --ink-muted: #5a5f68;
  --border: #e3e0d6;
  --panel-bg: #ffffff;
  --max-width: 1100px;
  --header-bg: #1c1e21;
  --header-ink: #fdfcf9;
  --hover-dot: #f97316;
  --selected-dot: #ffd60a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

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

/* Full-screen viewport: header + map fill exactly one screen; footer sits below, reached by scrolling */
.viewport {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  flex: 0 0 auto;
  background: var(--header-bg);
  color: var(--header-ink);
}

.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  padding: 0.85rem 1.75rem;
}

.header-top h1 {
  grid-column: 2;
  justify-self: center;
  text-align: center;
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.eyebrow {
  grid-column: 1;
  justify-self: start;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: #c9a962;
}

.subtitle {
  grid-column: 3;
  justify-self: end;
  text-align: right;
  color: rgba(253, 252, 249, 0.6);
  font-size: 0.82rem;
}

@media (max-width: 700px) {
  .header-top {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .eyebrow,
  .header-top h1,
  .subtitle {
    grid-column: 1;
    justify-self: center;
    text-align: center;
  }
}

/* Legend strip: full-width, evenly divided row of line chips */
.legend {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid rgba(253, 252, 249, 0.15);
}

/* Service advisory ticker */
.advisory-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  height: 2.3rem;
  background: var(--header-bg);
  color: var(--header-ink);
  border-top: 1px solid rgba(253, 252, 249, 0.15);
  overflow: hidden;
}

.advisory-tag {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  background: #c9a962;
  color: #1c1e21;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 1rem;
  white-space: nowrap;
}

.advisory-track {
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
}

.advisory-messages {
  display: flex;
  align-items: center;
  height: 2.3rem;
  gap: 3.5rem;
  padding-left: 3.5rem;
  white-space: nowrap;
  width: max-content;
  animation: advisory-scroll 25s linear infinite;
}

.advisory-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.advisory-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}

.advisory-close {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  border-left: 1px solid rgba(253, 252, 249, 0.15);
  color: rgba(253, 252, 249, 0.7);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 1rem;
  cursor: pointer;
}

.advisory-close:hover {
  color: var(--header-ink);
  background: rgba(253, 252, 249, 0.08);
}

.advisory-bar.dismissed {
  display: none;
}

/* Scrolls continuously at a constant speed; content is duplicated so -50% loops seamlessly */
@keyframes advisory-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Map layout */
main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.map-shell {
  height: 100%;
}

.map-scroll {
  height: 100%;
  width: 100%;
  overflow: auto;
  display: flex;
  background:
    radial-gradient(circle at center, rgba(0,0,0,0.02) 0, transparent 60%),
    var(--bg);
}

#subwayMap {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 1100px;
  min-height: 640px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 0.55rem;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(253, 252, 249, 0.15);
  border-top: 3px solid var(--line-color);
  padding: 0.7rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(253, 252, 249, 0.8);
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.legend-item:last-child {
  border-right: none;
}

.legend-item:hover {
  background: rgba(253, 252, 249, 0.08);
  color: var(--header-ink);
}

.legend-item.legend-active {
  background: var(--line-color);
  color: #14161a;
}

.legend-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  border: 1.5px solid rgba(253, 252, 249, 0.5);
}

/* SVG map elements */
.line-track {
  transition: opacity 0.2s;
}

.station-dot {
  transition: r 0.15s, opacity 0.2s, fill 0.15s;
  cursor: pointer;
}

.station {
  cursor: pointer;
  transition: opacity 0.2s;
}

.station:hover .station-dot,
.station:focus .station-dot {
  r: 58;
  fill: var(--hover-dot);
}

.station:hover .station-label,
.station:focus .station-label {
  font-weight: 700;
}

/* Selected station stays yellow even while hovered (rule order breaks the tie) */
.station.selected .station-dot {
  fill: var(--selected-dot);
}

.hub-dot {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.line-bullet {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}

.hub-label,
.station-label,
.ext-label,
.bullet-label {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.bullet-label {
  font-size: 38px;
  font-weight: 700;
  pointer-events: none;
}

.hub-label {
  font-size: 61px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  fill: var(--ink);
}

.station-label {
  font-size: 48px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  fill: var(--ink);
}

.ext-label {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  fill: var(--ink-muted);
}

.has-highlight .dimmed {
  opacity: 0.15;
}

/* Detail panel */
.detail-panel {
  position: fixed;
  top: 0;
  right: -560px;
  width: min(560px, 100vw);
  height: 100vh;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0,0,0,0.08);
  padding: 3rem 2rem;
  transition: right 0.25s ease;
  z-index: 200;
  overflow-y: auto;
}

.detail-panel.open {
  right: 0;
}

.close-panel {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-muted);
}

.close-panel:hover {
  color: var(--ink);
}

.detail-placeholder {
  color: var(--ink-muted);
}

.detail-line {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.detail-title {
  font-size: 1.6rem;
  margin-bottom: 0.3rem;
}

.detail-dates {
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.detail-desc {
  color: var(--ink-muted);
  margin-bottom: 1rem;
}

.detail-link {
  display: inline-block;
  font-weight: 700;
  border-bottom: 2px solid var(--ink);
}

button.detail-link {
  background: none;
  border: none;
  border-bottom: 2px solid var(--ink);
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.detail-media {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.detail-media-item img,
.detail-media-item video {
  display: block;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.detail-media-item figcaption {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* Footer */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 2.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-title {
  margin-bottom: 1rem;
}

.contact-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.copyright {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
  .legend {
    grid-template-columns: repeat(3, 1fr);
  }

  .legend-item {
    border-right: 1px solid rgba(253, 252, 249, 0.15);
  }

  .legend-item:nth-child(3n) {
    border-right: none;
  }
}

@media (max-width: 800px) {
  .viewport {
    height: auto;
    min-height: 100vh;
  }

  main {
    min-height: 70vh;
  }

  .detail-panel {
    width: 100%;
    right: auto;
    top: auto;
    bottom: -100%;
    height: auto;
    max-height: 80vh;
    border-left: none;
    border-top: 1px solid var(--border);
    transition: bottom 0.25s ease;
  }

  .detail-panel.open {
    bottom: 0;
  }
}

@media (max-width: 520px) {
  .legend {
    grid-template-columns: repeat(2, 1fr);
  }

  .legend-item:nth-child(3n) {
    border-right: 1px solid rgba(253, 252, 249, 0.15);
  }

  .legend-item:nth-child(2n) {
    border-right: none;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --ink: #f1f2f4;
    --ink-muted: #9a9fa8;
    --border: #2a2d33;
    --panel-bg: #1b1e23;
  }

  #subwayMap .station-dot,
  #subwayMap .hub-dot {
    fill: #1b1e23;
  }
}
