@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;1,400&family=Inter:wght@300;400;500&display=swap');

/* ─── Base ─────────────────────────────────────────────── */
body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-weight: 300;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Back Button ──────────────────────────────────────── */
.journey-back-fab {
  position: absolute;
  top: var(--space-lg);
  left: var(--space-lg);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 11px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.08), transparent 58%),
    rgba(10, 9, 18, 0.88);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.journey-back-fab:hover {
  color: rgba(255, 255, 255, 0.96);
  border-color: rgba(255, 255, 255, 0.2);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.11), transparent 58%),
    rgba(12, 11, 22, 0.92);
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.38);
}

.journey-back-fab:active {
  transform: translateY(1px) scale(0.98);
}

/* ─── Map Container ────────────────────────────────────── */
.map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

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

.journey-mini-player {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 24;
  width: min(320px, calc(100vw - 2rem));
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.08), transparent 58%),
    rgba(10, 9, 18, 0.88);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.journey-mini-player__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.journey-mini-player__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}

.journey-mini-player__dot.is-live {
  background: var(--color-accent, #7c6fcd);
  box-shadow: 0 0 12px var(--color-accent, #7c6fcd);
}

.journey-mini-player__dot.is-live.is-playing {
  animation: mini-dot-pulse 1.8s ease-in-out infinite;
}

@keyframes mini-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.journey-mini-player__label {
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.56);
}

.journey-mini-player__name {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.96);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journey-mini-player__meta {
  min-height: 1.2em;
  font-size: 0.68rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.journey-mini-player__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.journey-mini-player__btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  line-height: 1;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.journey-mini-player__btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.journey-mini-player__btn:active {
  transform: scale(0.94);
}

.journey-mini-player.is-unavailable .journey-mini-player__btn {
  opacity: 0.5;
}

.journey-processing {
  position: absolute;
  top: calc(var(--space-lg) + 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.08), transparent 58%),
    rgba(10, 9, 18, 0.9);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.journey-processing[hidden] {
  display: none !important;
}

.journey-processing__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
  animation: journey-processing-pulse 1.2s ease-in-out infinite;
}

.journey-processing__text {
  white-space: nowrap;
}

@keyframes journey-processing-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ─── MapLibre overrides ───────────────────────────────── */
.maplibregl-map {
  background: #08070e;
  font-family: var(--font-body);
}

.maplibregl-ctrl-attrib {
  background: rgba(8, 7, 14, 0.75) !important;
  color: rgba(255, 255, 255, 0.25) !important;
  font-size: 0.6rem !important;
  border: none !important;
  backdrop-filter: blur(4px);
}

.maplibregl-ctrl-attrib a {
  color: rgba(255, 255, 255, 0.3) !important;
}

.maplibregl-ctrl-attrib-button {
  filter: invert(1) opacity(0.3);
}

.maplibregl-ctrl-group {
  background: rgba(12, 11, 20, 0.9) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--border-radius-sm) !important;
  box-shadow: none !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  width: 32px !important;
  height: 32px !important;
  background: transparent !important;
  border-bottom: 1px solid var(--color-border-subtle) !important;
}

.maplibregl-ctrl-group button:last-child {
  border-bottom: none !important;
}

.maplibregl-ctrl-icon {
  filter: invert(1) opacity(0.4);
  transition: opacity var(--transition-fast);
}

.maplibregl-ctrl-group button:hover .maplibregl-ctrl-icon {
  opacity: 0.8;
}

/* ─── Station Markers ──────────────────────────────────── */
.station-marker {
  position: relative;
}

.station-marker__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent, #7c6fcd);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 0 var(--color-accent, #7c6fcd);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.station-marker__dot.latest {
  width: 14px;
  height: 14px;
  animation: marker-pulse 2.5s ease-out infinite;
}

@keyframes marker-pulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 111, 205, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(124, 111, 205, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 111, 205, 0); }
}

/* ─── MapLibre Popup Overrides ─────────────────────────── */
.maplibregl-popup-content {
  background: rgba(12, 11, 22, 0.96) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--border-radius-md) !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(16px);
  color: var(--color-text-primary) !important;
  padding: 0 !important;
}

.maplibregl-popup-tip {
  border-top-color: rgba(12, 11, 22, 0.96) !important;
  border-bottom-color: rgba(12, 11, 22, 0.96) !important;
}

.maplibregl-popup-close-button {
  color: var(--color-text-muted) !important;
  font-size: 1.1rem !important;
  padding: 6px 10px !important;
  line-height: 1 !important;
  right: 2px !important;
  top: 2px !important;
}

.maplibregl-popup-close-button:hover {
  background: transparent !important;
  color: var(--color-text-secondary) !important;
}

.station-popup {
  padding: var(--space-md) var(--space-lg);
  min-width: 200px;
}

.station-popup__name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.station-popup__location {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.station-popup__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border-subtle);
  padding-top: var(--space-sm);
}

.station-popup__meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  opacity: 0.7;
}

/* ─── History Panel ────────────────────────────────────── */
.history-panel {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(480px, calc(100vw - 2rem));
}

.history-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm) 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
  touch-action: pan-x;
}

.history-scroll::-webkit-scrollbar {
  display: none;
}

.history-scrollbar {
  margin-top: 2px;
  padding: 0 2px;
  pointer-events: auto;
}

.history-scrollbar[hidden] {
  display: none;
}

.history-scrollbar__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  margin: 0;
  cursor: ew-resize;
}

.history-scrollbar__slider:focus-visible {
  outline: none;
}

.history-scrollbar__slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.history-scrollbar__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 10px;
  border-radius: 999px;
  margin-top: -4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.1));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.history-scrollbar__slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.history-scrollbar__slider::-moz-range-thumb {
  width: 44px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.history-scrollbar__slider:focus-visible::-webkit-slider-thumb {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.22);
}

.history-scrollbar__slider:focus-visible::-moz-range-thumb {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.22);
}

.history-card {
  flex: 0 0 180px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: rgba(12, 11, 22, 0.88);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  padding: var(--space-sm) var(--space-md);
  backdrop-filter: blur(16px);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  width: 180px;
  max-width: 180px;
  overflow: hidden;
  touch-action: pan-x;
}

.history-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(20, 18, 35, 0.95);
}

.history-card__step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.history-card__step-text {
  min-width: 0;
  white-space: nowrap;
}

.history-card__step-person {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.history-card__step-person-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.22));
}

.history-card__name {
  display: block;
  width: 100%;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card__location {
  display: -webkit-box;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 1px;
  min-height: calc(1.35em * 2);
  max-height: calc(1.35em * 2);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  margin-top: auto;
  padding-top: var(--space-xs);
}

.history-card__accent {
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background: var(--card-color, #7c6fcd);
  flex: 0 0 auto;
}

.history-card__play-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text-secondary);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.58rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card__play-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

.history-card__play-btn.is-playing {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text-primary);
}

.history-card__play-btn.is-busy {
  cursor: progress;
  opacity: 0.85;
}

.history-card__play-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.history-card__play-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.18);
  outline-offset: 1px;
}

/* ─── Empty State ──────────────────────────────────────── */
.empty-journey[aria-hidden="true"] {
  display: none;
}

.empty-journey {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 20;
  padding: var(--space-xl);
  pointer-events: none;
  background: rgba(8, 7, 14, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.empty-journey__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  opacity: 0.85;
}

.empty-journey__text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  max-width: 280px;
  line-height: 1.7;
}

.empty-journey__cta {
  display: inline-block;
  margin-top: var(--space-lg);
  padding: 10px 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  pointer-events: all;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.empty-journey__cta:hover {
  color: var(--color-text-secondary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ─── Connection line SVG ──────────────────────────────── */
.journey-path {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 6 4;
  animation: dash-flow 20s linear infinite;
}

@keyframes dash-flow {
  to { stroke-dashoffset: -100; }
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  .journey-mini-player {
    top: auto;
    right: var(--space-md);
    left: var(--space-md);
    bottom: calc(var(--space-md) + 102px);
    width: auto;
  }

  .journey-back-fab {
    top: var(--space-md);
    left: var(--space-md);
  }

  .journey-processing {
    top: calc(var(--space-md) + 48px);
    max-width: calc(100vw - (var(--space-md) * 2));
  }

  .journey-processing__text {
    max-width: calc(100vw - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .history-panel {
    bottom: var(--space-md);
  }

  .history-card {
    flex-basis: 164px;
    width: 164px;
    max-width: 164px;
  }
}
