* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1a1a1a;
  background: #f7f7f5;
}

/* One-shot ride across the viewport on load (faces right). */
.motorcycle-drive {
  position: fixed;
  top: 18vh;
  left: 0;
  width: 72px;
  height: auto;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  animation: motorcycle-drive-right 2.4s ease-in forwards;
}
@keyframes motorcycle-drive-right {
  0%   { transform: translateX(-120%); opacity: 0; }
  8%   { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateX(100vw); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .motorcycle-drive { display: none; }
}

.page-header {
  padding: 10px 16px 8px;
  text-align: center;
}
.page-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  margin-bottom: 4px;
}
.page-header h1 { margin: 0; font-size: clamp(18px, 3vw, 24px); }
.progress-header { margin: 0; font-size: 13px; font-weight: 600; color: #444; }
.status-note { margin: 4px 0 0; font-size: 13px; font-style: italic; color: #0a58ff; }

/* Mechanical odometer (digit drum images) — click toggles expenses */
.odometer {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  padding: 4px 6px;
  background: #111;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.75),
    inset 0 -1px 1px rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.15);
}
.odometer:focus-visible {
  outline: 2px solid #0a58ff;
  outline-offset: 2px;
}
.odo-wheel {
  width: 28px;
  height: 36px;
  overflow: hidden;
  background: #0a0a0a;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.odo-reel {
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.odo-reel img {
  display: block;
  width: 28px;
  height: 36px;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}
.odo-unit {
  margin: 0 2px 2px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #bbb;
  text-transform: lowercase;
}
@media (prefers-reduced-motion: reduce) {
  .odo-reel { transition: none !important; }
}

/* Expenses + GPX track panel (opened via odometer click) */
.expenses-panel {
  max-width: min(720px, 100%);
  margin: 8px auto 4px;
  text-align: left;
  background: white;
  border: 1px solid #e2e2df;
  border-radius: 8px;
  padding: 10px 14px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.expenses-panel-body { font-size: 13px; }
.track-map-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e2e2df;
}
.track-map-heading {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
}
.track-map-status {
  margin: 0 0 8px;
  font-size: 12px;
  color: #666;
}
.track-map-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}
.track-play-btn,
.track-rate-btn,
.track-3d-btn {
  appearance: none;
  border: 1px solid #d0d0cb;
  background: #f7f7f4;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #222;
}
.track-play-btn:disabled,
.track-rate-btn:disabled,
.track-3d-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.track-play-btn:not(:disabled):hover,
.track-rate-btn:not(:disabled):hover,
.track-3d-btn:not(:disabled):hover {
  background: #eee;
}
.track-3d-btn {
  border-color: #0a58ff;
  color: #0a58ff;
}
.track-live {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.track-speed {
  font-size: 18px;
  font-weight: 700;
  color: #0a58ff;
}
.track-elev {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}
.track-map {
  height: 42vh;
  min-height: 260px;
  border-radius: 6px;
  overflow: hidden;
  background: #e8e8e4;
}
.expenses-empty { margin: 0; color: #999; font-style: italic; }
.expenses-category { margin: 0 0 10px; }
.expenses-category:last-of-type { margin-bottom: 6px; }
.expenses-category-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
}
.expenses-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.expenses-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  color: #444;
}
.expenses-meta { min-width: 0; }
.expenses-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.expenses-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid #e2e2df;
  font-weight: 700;
}

.map { height: 40vh; min-height: 240px; }

/* App shell: stop list on top (mobile) / left sidebar (desktop). */
.app-shell { display: flex; flex-direction: column; }
.sidebar { background: white; border-bottom: 1px solid #e2e2df; }
.sidebar-title {
  margin: 0;
  padding: 12px 16px 6px;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
}

.main-content {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "header"
    "map"
    "detail"
    "weather";
}
.page-header { grid-area: header; }
.map { grid-area: map; }
.stop-detail-section { grid-area: detail; padding: 12px 16px; }
.weather-section {
  grid-area: weather;
  padding: 10px 16px 16px;
  border-top: 1px solid #e2e2df;
  background: #fafaf8;
}
.error { color: #b3261e; font-style: italic; }

@media (min-width: 720px) {
  .app-shell { flex-direction: row; align-items: stretch; min-height: 100vh; }
  .sidebar {
    flex: 0 0 240px;
    border-bottom: 0;
    border-right: 1px solid #e2e2df;
    overflow-y: auto;
  }
  .main-content { flex: 1; }
}

/* Map + media side by side; weather spans both columns underneath. */
@media (min-width: 1000px) {
  .main-content {
    grid-template-columns: 1fr 1.15fr;
    grid-template-areas:
      "header header"
      "map detail"
      "weather weather";
    align-items: stretch;
  }
  .map {
    height: auto;
    min-height: 420px;
    border-right: 1px solid #e2e2df;
  }
  .stop-detail-section {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    min-height: 420px;
  }
  .stop-detail-media {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .stop-detail-media .media-gallery,
  .stop-detail-media > p {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .stop-detail-media .media-slider-wrap {
    flex: 1;
    min-height: 0;
  }
  .media-slider,
  .media-stage {
    height: 100%;
    min-height: 320px;
  }
  .media-slider img, .media-slider video,
  .media-stage img, .media-stage video {
    max-height: none;
    height: 100%;
    min-height: 320px;
    object-fit: contain;
  }
}

.marker-reached { filter: grayscale(0.4) opacity(0.7); }
.marker-current { filter: none; }
.marker-upcoming { filter: grayscale(0.8) opacity(0.5); }

.fuel-flags-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.fuel-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f7f7f5;
  border: 1px solid #e2e2df;
  border-radius: 999px;
  padding: 1px 6px 1px 3px;
}
.fuel-flag {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 2px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.fuel-flag.current { border-color: #0a58ff; }
.fuel-price {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  cursor: pointer;
}
.fuel-price:disabled { cursor: default; }
.fuel-reveal {
  font-size: 11px;
  color: #444;
  white-space: nowrap;
}

.accordion-toggle {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid #f0f0ee;
  padding: 8px 4px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.accordion-toggle:disabled { cursor: default; color: #999; }
.accordion-toggle::after { content: "▾"; float: right; color: #999; }
.accordion-toggle[aria-expanded="true"]::after { content: "▴"; }
.accordion-toggle.current { font-weight: 700; color: #0a58ff; }

.accordion-detail { padding: 6px 4px 12px; border-bottom: 1px solid #f0f0ee; }
.weather-day { margin-top: 10px; }
.weather-day:first-child { margin-top: 0; }
.weather-day h4 { margin: 0 0 4px; font-size: 13px; color: #666; text-transform: uppercase; letter-spacing: 0.03em; }
.weather-hours {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.weather-hours span {
  background: #f2f2ef;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.media-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.media-slider-wrap { position: relative; margin-top: 6px; flex: 1; min-height: 0; }
.media-stage {
  width: 100%;
  min-height: 220px;
  border-radius: 8px;
  background: #000;
  overflow: hidden;
}
.media-stage img,
.media-stage video {
  display: block;
  width: 100%;
  max-height: 420px;
  height: auto;
  object-fit: contain;
  background: #000;
}
.media-slider-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  border: 0;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  z-index: 1;
}
.media-slider-nav.prev { left: 6px; }
.media-slider-nav.next { right: 6px; }
.media-thumbs {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 100%;
  padding: 2px 0 4px;
}
@media (max-width: 719px) {
  .media-thumbs { grid-template-columns: repeat(6, 1fr); }
}
.media-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  background: #111;
  cursor: pointer;
  opacity: 0.72;
}
.media-thumb img,
.media-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.media-thumb-badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 9px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.media-thumb:hover { opacity: 0.92; }
.media-thumb.is-active {
  opacity: 1;
  border-color: #0a58ff;
}
.media-thumb:focus-visible {
  outline: 2px solid #0a58ff;
  outline-offset: 2px;
}
.media-empty { color: #999; font-style: italic; padding: 6px 4px 12px; }

/* Stop list (sidebar) */
#stops-list-container {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
@media (max-width: 719px) {
  #stops-list-container { max-height: 260px; }
}
@media (min-width: 720px) {
  #stops-list-container { max-height: none; }
}
.stops-list-item {
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid #f0f0ee;
  padding: 10px 16px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.stops-list-item.current { font-weight: 600; }
.stops-list-item.active {
  font-weight: 700;
  color: #0a58ff;
  background: #eef3ff;
}

/* Stop detail pane */
.stop-detail-section h3 { margin: 0 0 8px; font-size: 17px; }

/* Experimental 3D track overlay (Cesium) */
body.track-3d-open { overflow: hidden; }
.track-3d-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: #0b0d10;
}
.track-3d-chrome {
  flex: 0 0 auto;
  padding: 10px 14px 8px;
  background: rgba(12, 14, 18, 0.92);
  color: #eee;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.track-3d-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
.track-3d-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.track-3d-controls .track-live { margin-left: auto; }
.track-3d-controls .track-speed { color: #7eb0ff; }
.track-3d-controls .track-elev { color: #ccc; }
.track-3d-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #fff;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
}
.track-3d-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: #888;
}
.track-3d-canvas {
  flex: 1;
  min-height: 0;
  position: relative;
}
.track-3d-canvas .cesium-viewer,
.track-3d-canvas .cesium-viewer-cesiumWidgetContainer,
.track-3d-canvas .cesium-widget,
.track-3d-canvas .cesium-widget canvas {
  width: 100% !important;
  height: 100% !important;
}
