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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f7fa;
  min-height: 100vh;
  color: #1d3557;
}

.page-body { padding: 20px; }

/* ---- Navigation bar (mirrors the rest of the site) ---- */
.main-nav {
  position: sticky; top: 0; z-index: 1000;
  background: #000;
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05) inset;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.nav-container { max-width: 1200px; margin: 0 auto; padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.nav-logo { font-size: 1.8em; font-weight: 800; text-decoration: none; color: #fff; display: flex; align-items: center; gap: 10px; transition: all 0.4s cubic-bezier(0.4,0,0.2,1); }
.nav-logo:hover { transform: translateY(-3px) scale(1.02); }
.nav-logo .logo-icon { width: 32px; height: 28px; flex-shrink: 0; }
.nav-center { display: flex; align-items: center; gap: 40px; flex: 1; justify-content: center; }
.nav-links { display: flex; gap: 32px; align-items: center; }
.nav-links a { text-decoration: none; color: #fff; font-weight: 600; font-size: 1.05em; position: relative; padding: 10px 16px; border-radius: 8px; transition: all 0.3s cubic-bezier(0.4,0,0.2,1); }
.nav-links a::after { content: ''; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); width: 0; height: 3px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 2px; transition: width 0.3s cubic-bezier(0.4,0,0.2,1); }
.nav-links a:hover { transform: translateY(-2px); }
.nav-links a:hover::after, .nav-links a.active::after { width: calc(100% - 32px); }
.nav-links a.active { background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05)); }

.hamburger-btn { display: none; flex-direction: column; justify-content: center; align-items: center; width: 44px; height: 44px; background: transparent; border: none; cursor: pointer; padding: 8px; border-radius: 8px; }
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }
.hamburger-btn span { display: block; width: 24px; height: 3px; background: rgba(255,255,255,0.9); border-radius: 2px; transition: all 0.3s ease; }
.hamburger-btn span:nth-child(1) { margin-bottom: 5px; }
.hamburger-btn span:nth-child(3) { margin-top: 5px; }
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 6px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -6px); }

.mobile-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #000; border-top: 1px solid rgba(255,255,255,0.1); box-shadow: 0 12px 32px rgba(0,0,0,0.4); padding: 12px 0; }
.mobile-nav.show { display: block; }
.mobile-nav a { display: block; padding: 14px 24px; text-decoration: none; color: rgba(255,255,255,0.9); font-weight: 600; font-size: 1.1em; border-left: 4px solid transparent; }
.mobile-nav a:hover { background: linear-gradient(90deg, rgba(255,255,255,0.1), transparent); color: #fff; border-left-color: rgba(255,255,255,0.8); }
.mobile-nav a.active { border-left-color: #667eea; background: rgba(255,255,255,0.06); }

@media (max-width: 768px) {
  .nav-container { padding: 12px 16px; gap: 8px; }
  .nav-logo { font-size: 1.3em; gap: 6px; }
  .nav-center { display: none; }
  .hamburger-btn { display: flex; }
}

/* ---- Page container ---- */
.container { max-width: 1200px; width: 100%; margin: 20px auto; background: rgba(255,255,255,0.95); border-radius: 24px; padding: 32px 36px; box-shadow: 0 30px 60px -12px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.5) inset; }
.back-link { display: inline-block; margin-bottom: 16px; color: #667eea; text-decoration: none; font-size: 0.95em; font-weight: 600; }
.back-link:hover { color: #764ba2; text-decoration: underline; }

.line-header { border-radius: 16px; padding: 24px 28px; margin-bottom: 20px; background: linear-gradient(135deg, #00AFAD 0%, #007e7c 100%); color: #fff; box-shadow: 0 8px 24px rgba(0,175,173,0.25); }
.line-header h1 { font-size: 1.9em; font-weight: 800; margin-bottom: 6px; }
.line-header p { opacity: 0.95; font-size: 1.02em; }

/* ---- Live status ribbon ---- */
.status-ribbon { display: inline-block; margin-bottom: 18px; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 0.92em; background: #eef2f7; color: #475569; }
.status-ribbon.good { background: #dcfce7; color: #166534; }
.status-ribbon.disrupted { background: #fef3c7; color: #92400e; }
.status-ribbon.unknown { background: #eef2f7; color: #64748b; }

/* ---- Controls ---- */
.map-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.search-box input { width: 100%; padding: 11px 16px; border: 2px solid #e2e8f0; border-radius: 12px; font-size: 1em; outline: none; transition: border-color 0.2s; }
.search-box input:focus { border-color: #00AFAD; }
.search-results { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.12); z-index: 20; overflow: hidden; }
.search-results.open { display: block; }
.search-item { display: block; width: 100%; text-align: left; padding: 11px 16px; background: none; border: none; font-size: 0.98em; cursor: pointer; color: #1d3557; }
.search-item:hover { background: #f0fdfc; }

.branch-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 2px solid #e2e8f0; background: #fff; font-size: 0.88em; font-weight: 600; color: #475569; cursor: pointer; transition: all 0.15s; }
.chip:hover { border-color: #00AFAD; color: #00807e; }
.chip.active { background: #00AFAD; border-color: #00AFAD; color: #fff; }

.zoom-controls { display: flex; gap: 6px; margin-left: auto; }
.zoom-controls button { width: 40px; height: 40px; border-radius: 10px; border: 2px solid #e2e8f0; background: #fff; font-size: 1.2em; font-weight: 700; color: #475569; cursor: pointer; line-height: 1; }
.zoom-controls button:hover { border-color: #00AFAD; color: #00807e; }

/* ---- Map canvas ---- */
.map-stage { position: relative; }
.route-map {
  position: relative;
  width: 100%;
  height: 620px;
  overflow: hidden;
  border: 1px solid #e8edf3;
  border-radius: 16px;
  background: #fbfdff;
  touch-action: none;          /* we handle pan/zoom ourselves */
  cursor: grab;
}
.route-map:active { cursor: grabbing; }
.dlr-svg { display: block; width: 100%; height: 100%; }

.track { fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.2s; }

.station-dot { fill: #fff; stroke: var(--line, #00AFAD); stroke-width: 3; cursor: pointer; transition: opacity 0.2s, r 0.1s; outline: none; }
.station-dot.interchange { stroke-width: 3.5; }
.station-dot.terminus { stroke-width: 4; }
.station-dot:hover, .station-dot:focus { r: 9; }
.station-dot.selected { fill: var(--line, #00AFAD); }

.station-label { font-size: 13px; font-weight: 600; fill: #1d3557; cursor: pointer; pointer-events: auto; -webkit-user-select: none; user-select: none; }
.station-label:hover { fill: #00807e; }
.station-label.selected { fill: #00807e; font-weight: 800; }

/* Branch filter dimming */
.dlr-svg.has-filter .track { opacity: 0.12; }
.dlr-svg.has-filter .track.on-route { opacity: 1; }
.dlr-svg.has-filter .station-dot { opacity: 0.18; }
.dlr-svg.has-filter .station-label { opacity: 0.18; }
.dlr-svg.has-filter .station-dot.on-route,
.dlr-svg.has-filter .station-label.on-route { opacity: 1; }

/* ---- Station detail panel ---- */
.station-panel { position: fixed; top: 0; right: 0; width: 360px; max-width: 90vw; height: 100vh; background: #fff; box-shadow: -12px 0 40px rgba(0,0,0,0.18); transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); z-index: 1100; padding: 24px; overflow-y: auto; }
.station-panel.open { transform: translateX(0); }
.sp-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: none; background: #f1f5f9; font-size: 1.3em; cursor: pointer; color: #475569; }
.sp-close:hover { background: #e2e8f0; }
#sp-name { font-size: 1.5em; font-weight: 800; padding-right: 40px; margin-bottom: 4px; }
#sp-meta { color: #64748b; font-weight: 600; font-size: 0.92em; margin-bottom: 16px; }
.station-panel h4 { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.06em; color: #94a3b8; margin: 18px 0 8px; }
#sp-blurb { font-size: 0.96em; line-height: 1.5; color: #334155; background: #f0fdfc; border-left: 3px solid #00AFAD; padding: 12px 14px; border-radius: 8px; margin-bottom: 4px; }
#sp-interchanges ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
#sp-interchanges li { background: #eef2f7; border-radius: 8px; padding: 5px 10px; font-size: 0.85em; font-weight: 600; color: #475569; }

.dep-list { list-style: none; }
.dep-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.dep-dest { font-weight: 600; font-size: 0.95em; }
.dep-time { font-weight: 800; color: #00807e; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.dep-loading, .dep-error, .dep-none, .dep-foot { font-size: 0.88em; color: #94a3b8; padding: 6px 0; }
.dep-error { color: #b45309; }
.dep-foot { margin-top: 8px; }

.sp-cta { display: inline-block; margin-top: 18px; padding: 10px 18px; background: #00AFAD; color: #fff; text-decoration: none; border-radius: 10px; font-weight: 700; font-size: 0.92em; }
.sp-cta:hover { background: #007e7c; }

/* ---- Prose / SEO sections ---- */
.map-note { font-size: 0.86em; color: #94a3b8; margin: 14px 2px 0; }
.seo-section { margin-top: 36px; }
.seo-section h2 { font-size: 1.4em; font-weight: 800; margin-bottom: 12px; }
.seo-section p { line-height: 1.65; margin-bottom: 14px; color: #334155; }
.station-guide { margin-top: 28px; }
.station-guide h3 { font-size: 1.05em; font-weight: 800; margin: 18px 0 4px; }
.station-guide p { line-height: 1.6; color: #334155; }
.pdf-line { font-size: 0.9em; color: #64748b; margin-top: 22px; }
.pdf-line a { color: #00807e; }

.cta-card { margin-top: 32px; background: linear-gradient(135deg, #00AFAD 0%, #007e7c 100%); color: #fff; border-radius: 16px; padding: 28px 32px; }
.cta-card h2 { font-size: 1.3em; margin-bottom: 8px; }
.cta-card p { opacity: 0.95; margin-bottom: 16px; }
.cta-btn { display: inline-block; background: #fff; color: #007e7c; padding: 12px 24px; border-radius: 12px; font-weight: 700; text-decoration: none; }

.error { padding: 40px; text-align: center; color: #b45309; font-weight: 600; }

@media (max-width: 768px) {
  .container { padding: 18px 14px; border-radius: 16px; }
  .line-header h1 { font-size: 1.5em; }
  .map-controls { gap: 10px; }
  .search-box { max-width: none; }
  .zoom-controls { margin-left: 0; }
  .route-map { height: 70vh; max-height: 560px; }

  /* Detail panel becomes a bottom sheet on phones */
  .station-panel {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; max-width: 100%; height: auto; max-height: 80vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.22);
  }
  .station-panel.open { transform: translateY(0); }
}
