﻿:root {
  --page-bg: #f2f2f2;
  --ink: #1f2630;
  --muted: #8a919e;
  --accent: #5aa6ed;
  --accent-strong: #439aea;
  --panel-bg: #0f1824;
  --panel-border: #24344b;
  --panel-text: #dde8f5;
  --panel-muted: #8ea6c7;
  --map-bg: #f0eeeb;
  --hero-dark: rgba(0, 0, 0, 0.76);
}

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

body {
  background: var(--page-bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  font-family: "Taviraj", serif;
  min-height: 100vh;
  overflow: hidden;
}

header {
  align-items: center;
  background-image:
    linear-gradient(105deg, rgba(0, 0, 0, 0.78), rgba(35, 35, 35, 0.7)),
    url("../../../images/bg.jpg");
  background-position: center;
  background-size: cover;
  border-bottom: 2px solid rgba(90, 166, 237, 0.55);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-shrink: 0;
  gap: 14px;
  min-height: 68px;
  padding: 10px 18px;
  position: relative;
  z-index: 10;
}

header::after {
  background: linear-gradient(90deg, rgba(90, 166, 237, 0.35), rgba(227, 32, 23, 0.2), transparent);
  content: "";
  inset: auto 0 0;
  height: 3px;
  position: absolute;
}

.site-mark {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-link {
  color: #fff;
  font-family: "Taviraj", serif;
  font-size: 1.25rem;
  line-height: 1.1;
  text-decoration: none;
}

.logo-link span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.75rem;
  font-weight: 300;
  margin-left: 6px;
}

.site-mark p {
  color: rgba(255, 255, 255, 0.62);
  font-family: "Taviraj", serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#status-area {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-left: auto;
}

#status-pill {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  font-family: "Taviraj", serif;
  font-size: 0.72rem;
  gap: 6px;
  padding: 5px 11px;
}

#status-led {
  background: #666;
  border-radius: 50%;
  height: 7px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  width: 7px;
}

#status-led.live {
  background: #00e676;
  box-shadow: 0 0 8px #00e676;
}

#status-led.error {
  background: #ff1744;
  box-shadow: 0 0 8px #ff1744;
}

#status-led.loading {
  animation: blink 0.8s ease-in-out infinite;
  background: #ffab40;
  box-shadow: 0 0 8px #ffab40;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

#refresh-btn,
#theme-btn,
#legend-toggle-btn,
#sidebar-close-btn {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  min-width: 34px;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  width: 34px;
}

#refresh-btn:hover,
#theme-btn:hover,
#legend-toggle-btn:hover,
#sidebar-close-btn:hover {
  background: rgba(90, 166, 237, 0.24);
  border-color: rgba(144, 198, 255, 0.58);
}

#refresh-btn:active,
#theme-btn:active,
#legend-toggle-btn:active,
#sidebar-close-btn:active {
  background: rgba(90, 166, 237, 0.35);
  transform: translateY(1px);
}

#refresh-btn svg,
#theme-btn svg,
#legend-toggle-btn svg,
#sidebar-close-btn svg {
  fill: none;
  height: 17px;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 17px;
}

#refresh-btn svg {
  height: 16px;
  width: 16px;
}

#theme-btn .icon-moon {
  display: none;
}

#legend-toggle-btn,
#sidebar-close-btn {
  display: none;
}

#sidebar-backdrop {
  display: none;
}

#theme-btn.is-dark .icon-sun {
  display: none;
}

#theme-btn.is-dark .icon-moon {
  display: block;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#map-wrap {
  background: var(--map-bg);
  cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  flex: 1;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

#map-wrap.is-panning {
  cursor: grabbing;
}

#map-container {
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
  transform: translate(0px, 0px) scale(1);
  transform-origin: 50% 50%;
  transition: transform 0.2s ease;
  will-change: transform;
}

#map-wrap.is-panning #map-container {
  transition: none;
}

#tube-map-svg {
  display: block;
  height: 100%;
  transition: filter 0.33s ease;
  width: 100%;
}

#train-overlay {
  height: 100%;
  inset: 0;
  pointer-events: none;
  position: absolute;
  width: 100%;
}

#train-overlay svg {
  height: 100%;
  overflow: visible;
  width: 100%;
}

#map-controls {
  align-items: center;
  backdrop-filter: blur(8px);
  background: rgba(8, 16, 28, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  display: inline-flex;
  gap: 6px;
  left: 12px;
  padding: 6px;
  position: absolute;
  top: 12px;
  z-index: 20;
}

#map-controls button {
  align-items: center;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-family: "Oswald", sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  height: 30px;
  justify-content: center;
  min-width: 30px;
  padding: 0 10px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

#map-controls button:hover {
  background: rgba(90, 166, 237, 0.24);
  border-color: rgba(144, 198, 255, 0.58);
}

#zoom-reset-btn {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#zoom-level {
  color: rgba(255, 255, 255, 0.9);
  font-family: "Oswald", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  min-width: 42px;
  text-align: center;
}

#sidebar {
  background:
    linear-gradient(165deg, rgba(9, 15, 24, 0.95), rgba(13, 24, 37, 0.95)),
    url("../../../images/bg.jpg");
  background-position: center;
  background-size: cover;
  border-left: 1px solid var(--panel-border);
  color: var(--panel-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 270px;
}

#sidebar-header {
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  color: var(--panel-muted);
  display: flex;
  font-family: "Oswald", sans-serif;
  font-size: 0.78rem;
  justify-content: space-between;
  letter-spacing: 0.14em;
  padding: 14px 15px 10px;
  text-transform: uppercase;
}

#legend {
  flex: 1;
  overflow-y: auto;
}

#legend::-webkit-scrollbar {
  width: 4px;
}

#legend::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 20px;
}

.leg-item {
  align-items: center;
  border-bottom: 1px solid rgba(142, 166, 199, 0.14);
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  transition: background-color 0.33s ease, box-shadow 0.33s ease, opacity 0.33s ease;
  user-select: none;
}

.leg-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.leg-item.focused {
  background: rgba(90, 166, 237, 0.14);
  box-shadow: inset 0 0 0 1px rgba(90, 166, 237, 0.35);
}

.leg-item.defocused {
  opacity: 0.5;
}

.leg-swatch {
  border-radius: 3px;
  flex-shrink: 0;
  height: 5px;
  width: 22px;
}

.leg-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.leg-name {
  color: var(--panel-text);
  font-size: 0.79rem;
  line-height: 1.1;
}

.leg-status {
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  line-height: 1.05;
  opacity: 0.95;
  text-transform: capitalize;
}

.leg-status.unknown {
  color: #9ab0ca;
}

.leg-status.good {
  color: #79e6b1;
}

.leg-status.warn {
  color: #ffd480;
}

.leg-status.bad {
  color: #ff9f9f;
}

.leg-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 11px;
  color: var(--panel-muted);
  font-size: 0.64rem;
  min-width: 24px;
  padding: 2px 6px;
  text-align: center;
}

.leg-badge.active {
  background: rgba(0, 200, 100, 0.15);
  border-color: rgba(0, 200, 100, 0.35);
  color: #6cffbe;
}

#sidebar-foot {
  border-top: 1px solid var(--panel-border);
  color: var(--panel-muted);
  font-size: 0.67rem;
  line-height: 1.8;
  padding: 10px 12px;
}

#last-updated {
  color: #90c6ff;
}

#tooltip {
  backdrop-filter: blur(10px);
  background: rgba(9, 16, 29, 0.96);
  border: 1px solid #2d4563;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  font-size: 0.74rem;
  max-width: 220px;
  opacity: 0;
  padding: 10px 13px;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.12s;
  z-index: 999;
}

#tooltip.show {
  opacity: 1;
}

#tt-line {
  font-family: "Oswald", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 3px;
}

#tt-vehicle {
  color: var(--panel-muted);
  font-size: 0.68rem;
  margin-bottom: 2px;
}

#tt-toward {
  color: #9fc8ff;
  font-size: 0.73rem;
  margin-bottom: 2px;
}

#tt-time {
  color: #90f1b3;
  font-size: 0.67rem;
}

@keyframes trainPulse {
  0%,
  100% {
    r: 12;
  }

  50% {
    r: 14;
  }
}

@keyframes glowPulse {
  0%,
  100% {
    opacity: 0.22;
    r: 18;
  }

  50% {
    opacity: 0.07;
    r: 24;
  }
}

.t-dot {
  animation: trainPulse 1.8s ease-in-out infinite;
}

.t-glow {
  animation: glowPulse 1.8s ease-in-out infinite;
}

.t-label {
  dominant-baseline: central;
  fill: #fff;
  font-family: "Oswald", sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
  paint-order: stroke fill;
  pointer-events: none;
  stroke: rgba(0, 0, 0, 0.65);
  stroke-width: 2.5px;
  text-anchor: middle;
}

.train-dot {
  transition: opacity 0.33s ease;
}

body.focus-mode #tube-map-svg {
  filter: grayscale(1) saturate(0.06) brightness(0.14) contrast(1.02);
}

body.focus-mode .train-dot {
  opacity: 0.08;
}

body.focus-mode .train-dot.is-focused {
  opacity: 1;
}

body.dark-mode {
  background: #11161d;
}

body.dark-mode #map-wrap {
  background: #141a23;
}

body.dark-mode #tube-map-svg {
  filter: invert(1) hue-rotate(180deg) brightness(0.82) saturate(1.3);
}

body.dark-mode.focus-mode #tube-map-svg {
  filter: invert(1) hue-rotate(180deg) grayscale(1) saturate(0.06) brightness(0.3) contrast(1.06);
}

body.dark-mode .t-dot,
body.dark-mode .t-arrow {
  stroke: #151b28 !important;
}

@media screen and (max-width: 980px) {
  body {
    overflow: hidden;
  }

  header {
    align-items: flex-start;
    border-bottom-width: 1px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 45;
  }

  #status-area {
    justify-content: flex-end;
    margin-left: 0;
    width: 100%;
  }

  #status-pill {
    margin-right: auto;
  }

  .layout {
    overflow: hidden;
  }

  #map-wrap {
    min-height: calc(100vh - 92px);
  }

  #legend-toggle-btn {
    display: inline-flex;
  }

  #sidebar-backdrop {
    background: rgba(0, 0, 0, 0.45);
    display: block;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity 0.33s ease;
    z-index: 34;
  }

  body.sidebar-open #sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  #sidebar {
    border: 1px solid var(--panel-border);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    bottom: 0;
    left: 0;
    max-height: 56vh;
    position: fixed;
    right: 0;
    transform: translateY(calc(100% + 10px));
    transition: transform 0.33s ease;
    width: 100%;
    z-index: 40;
  }

  body.sidebar-open #sidebar {
    transform: translateY(0);
  }

  #sidebar-close-btn {
    display: inline-flex;
    height: 30px;
    min-width: 30px;
    width: 30px;
  }

  #map-controls {
    top: 10px;
  }
}

@media screen and (max-width: 640px) {
  .logo-link {
    font-size: 1.05rem;
  }

  .logo-link span {
    font-size: 0.67rem;
  }

  .site-mark p {
    font-size: 0.64rem;
  }

  #status-pill {
    font-size: 0.67rem;
  }

  #refresh-btn,
  #theme-btn,
  #legend-toggle-btn {
    height: 32px;
    min-width: 32px;
    width: 32px;
  }

  #map-wrap {
    min-height: calc(100vh - 106px);
  }

  #map-controls {
    gap: 4px;
    left: 8px;
    padding: 5px;
    top: 8px;
  }

  #map-controls button {
    height: 28px;
    min-width: 28px;
    padding: 0 8px;
  }

  #zoom-level {
    font-size: 0.64rem;
    min-width: 38px;
  }
}
