/* Route section — dark getfox.net shell, washi-trip accents on top */

#route-app {
  --route-vermilion: #e8623a;
  --route-moss:      #8fb374;
  --route-sora:      #5fa8d3;
  --route-plum:      #b98fc7;

  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* One card per row: countdown+stats+toggle on top, then whichever view is
   active (map/list/calendar/style) at a fixed shared height so switching
   views doesn't jump the page around, then the detail card below. */

.route-view-surface {
  height: 480px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg2);
}
.route-view-surface.is-hidden { display: none; }

@media (max-width: 760px) {
  .route-view-surface { height: 400px; }
}

/* ─── PROGRESS / COUNTDOWN + STATS + TOGGLE (top card) ─── */

/* Dashboard-style grid: countdown top-left, stats top-right, toolbar
   spanning full width underneath — explicit areas instead of flex order
   tricks, so nothing has to fight over leftover space. */
.route-progress {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 32px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "countdown stats"
    "toolbar   toolbar";
  align-items: center;
  row-gap: 20px;
  column-gap: 32px;
}

.route-progress-countdown {
  grid-area: countdown;
  display: flex;
  align-items: center;
  gap: 14px;
}

.route-progress-countdown-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.route-progress-countdown-figures {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.route-progress-caption {
  font-family: var(--jp);
  font-size: 14px;
  color: var(--route-vermilion);
  letter-spacing: 0.02em;
}

.route-progress-compact {
  font-family: 'JetBrains Mono', monospace;
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.route-progress-compact .route-progress-of { color: var(--muted); font-weight: 400; font-size: 16px; }

.route-progress-bar {
  width: 140px;
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.route-progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--route-vermilion), var(--purple));
  width: 0;
  transition: width 1s ease-out;
}

/* ─── TOOLBAR ─── */

.route-toolbar {
  grid-area: toolbar;
  display: flex;
  justify-content: flex-start;
}

.route-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  flex-shrink: 0;
}

.route-view-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.route-view-btn.is-active {
  background: var(--route-vermilion);
  color: #1a0f08;
}

.route-view-btn:not(.is-active):hover { color: var(--text); }
.route-view-btn:focus-visible { outline: 2px solid var(--route-vermilion); outline-offset: 2px; }

/* ─── MAP ─── */

.route-map-wrap {
  position: relative;
  overflow: hidden;
  /* Without this, mobile browsers try to pinch-zoom the *page* over the
     map at the same time Leaflet handles its own pinch-zoom — the two
     fight, leaving tiles torn/misaligned. Hand touch gestures here to
     Leaflet exclusively. */
  touch-action: none;
}

.route-map-wrap::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--route-vermilion), var(--purple), var(--route-sora));
  z-index: 500;
}

.route-map {
  width: 100%;
  height: 100%;
  background: var(--bg2);
}

.route-map-fullscreen {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 500;
  width: 34px;
  height: 34px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.route-map-fullscreen:hover { border-color: var(--route-vermilion); }
.route-map-fullscreen:focus-visible { outline: 2px solid var(--route-vermilion); outline-offset: 1px; }

.route-map-overview {
  position: absolute;
  top: 50px;
  right: 10px;
  z-index: 500;
  width: 34px;
  height: 34px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
.route-map-overview:hover { border-color: var(--route-vermilion); }
.route-map-overview:focus-visible { outline: 2px solid var(--route-vermilion); outline-offset: 1px; }

.route-map-lines-toggle {
  position: absolute;
  top: 90px;
  right: 10px;
  z-index: 500;
  width: 34px;
  height: 34px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
.route-map-lines-toggle:hover { border-color: var(--route-vermilion); }
.route-map-lines-toggle:focus-visible { outline: 2px solid var(--route-vermilion); outline-offset: 1px; }
.route-map-lines-toggle.is-off { opacity: 0.55; }

/* Prev/next stop, flanking the map itself — same idiom as the photo
   lightbox's edge arrows: big, semi-transparent, easy to hit on mobile. */
.route-map-step {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(10, 10, 20, 0.55);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.route-map-step:hover { background: rgba(10, 10, 20, 0.8); border-color: var(--route-vermilion); }
.route-map-step:focus-visible { outline: 2px solid var(--route-vermilion); outline-offset: 1px; }
.route-map-step-prev { left: 10px; }
.route-map-step-next { right: 10px; }

@media (max-width: 760px) {
  .route-map-step { width: 40px; height: 40px; font-size: 22px; }
}

/* "Simple" line mode also hides the permanent stop-name labels and
   start/finish flags so the map reads as just the shape of the route. */
.route-map.mode-simple .route-map-label,
.route-map.mode-simple .route-flag {
  display: none;
}

.route-map-wrap:fullscreen,
.route-map-wrap.is-fullscreen {
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}
.route-map-wrap:fullscreen .route-map,
.route-map-wrap.is-fullscreen .route-map {
  height: 100%;
}

.route-fox-marker {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(232, 98, 58, 0.8));
  transform-origin: center bottom;
}
@media (prefers-reduced-motion: no-preference) {
  .route-fox-marker { animation: route-fox-bob 2.4s ease-in-out infinite; }
}
@keyframes route-fox-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.route-pin {
  width: 26px; height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.route-pin span { transform: rotate(45deg); font-size: 13px; }

.leaflet-marker-icon.is-active .route-pin {
  transform: rotate(-45deg) scale(1.3);
  box-shadow: 0 0 0 3px #fff, 0 2px 10px rgba(0,0,0,0.5);
  z-index: 10;
}

.route-flag {
  position: relative;
  display: inline-block;
  transform: translate(10px, -32px);
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg2);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.route-flag-start  { border: 1px solid var(--route-moss); color: var(--route-moss); }
.route-flag-finish { border: 1px solid var(--route-vermilion); color: var(--route-vermilion); }

/* ─── COMPACT STOP LIST (List view) ─── */

.route-stop-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--route-vermilion) var(--bg3);
}
.route-stop-list::-webkit-scrollbar { width: 6px; }
.route-stop-list::-webkit-scrollbar-track { background: var(--bg3); border-radius: 3px; }
.route-stop-list::-webkit-scrollbar-thumb { background: var(--route-vermilion); border-radius: 3px; }

.route-list-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.route-list-row:hover, .route-list-row:focus-visible { border-color: var(--chip-color, var(--route-vermilion)); }
.route-list-row:focus-visible { outline: 2px solid var(--chip-color, var(--route-vermilion)); outline-offset: 1px; }
.route-list-row.is-active { border-color: var(--chip-color, var(--route-vermilion)); box-shadow: 0 0 0 1px var(--chip-color, var(--route-vermilion)); }

.route-list-icon { font-size: 15px; text-align: center; }

.route-list-name {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.route-list-jp { font-family: var(--jp); font-size: 12px; font-weight: 400; color: var(--muted); }

.route-list-dates {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.route-list-status { font-size: 13px; }

/* ─── STYLE PANEL (trip philosophy view) ─── */

.route-style-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
}

.route-style-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  flex-shrink: 0;
}

.route-style-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--route-vermilion);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.route-style-detail {
  font-family: 'Zen Maru Gothic', var(--sans);
  font-size: 14px;
  color: #b0b8d8;
  line-height: 1.5;
}

/* ─── STATS (transport-mode donut, folded into the progress card) ─── */

.route-progress-stats {
  grid-area: stats;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--muted);
}

.route-stats-donut { flex-shrink: 0; }
.route-stats-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.route-stats-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
}

.route-stats-legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.route-stats-legend-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

.route-stats-figures { display: flex; gap: 12px; flex-wrap: wrap; }
.route-stats-figures strong { color: var(--text); font-weight: 600; }
.route-stats-distance { flex-basis: 100%; color: var(--muted); }

/* ─── CALENDAR (Calendar view) ─── */

.route-calendar-row {
  padding: 12px;
  overflow-y: auto;
}

.route-calendar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.route-cal-month {
  flex: 1 1 200px;
  min-width: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.route-cal-month-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.route-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.route-cal-dow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 3px;
}

.route-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text);
  background: var(--bg2);
  border: none;
  border-radius: 3px;
  padding: 0;
  min-height: 20px;
}

.route-cal-day.is-outside {
  background: none;
  color: var(--muted);
  opacity: 0.3;
}

.route-cal-day[data-id] {
  cursor: pointer;
  background: var(--day-color);
  color: #1a0f08;
  font-weight: 600;
  transition: transform 0.1s, box-shadow 0.15s;
}

.route-cal-day[data-id]:hover,
.route-cal-day[data-id]:focus-visible {
  transform: scale(1.15);
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.route-cal-day[data-id]:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.route-cal-day.is-active {
  box-shadow: 0 0 0 2px var(--text);
  z-index: 3;
}

.route-cal-day.is-today { box-shadow: 0 0 0 2px #fff inset; }
.route-cal-day.is-today.is-active { box-shadow: 0 0 0 2px #fff inset, 0 0 0 4px var(--text); }

.route-cal-today-mark {
  position: absolute;
  top: -9px;
  font-size: 9px;
}

/* ─── DETAIL CARD (the one card, below everything) ─── */

.route-card {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 24px;
}

.route-card.is-updated { animation: route-card-pulse 0.5s ease-out; }
@keyframes route-card-pulse {
  0% { box-shadow: 0 0 0 2px var(--chip-color, var(--route-vermilion)); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.route-card-nav-pos {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.route-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.route-card-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.route-card-title {
  font-family: 'Shippori Mincho', var(--jp);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.route-card-en {
  display: block;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.route-card-status {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.route-card-dates {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.route-card-days { color: var(--text); }

/* Dashboard-style two-column body: day-bar/chips/notes on the left,
   activities as their own icon grid on the right — not a full-width bar
   competing with everything else for attention. */
.route-card-body {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 20px;
}
.route-card-main { min-width: 0; }

.route-card-bar {
  display: flex;
  gap: 2px;
  height: 8px;
  width: 45%;
  min-width: 140px;
  margin-bottom: 14px;
}

.route-card-bar-seg {
  flex: 1;
  height: 100%;
  min-width: 2px;
  border-radius: 1px;
  background: var(--bg3);
}
.route-card-bar-seg.is-filled { background: var(--chip-color, var(--route-vermilion)); }

.route-card-chip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.route-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mode-color, var(--chip-color));
  background: color-mix(in srgb, var(--mode-color, var(--chip-color)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--mode-color, var(--chip-color)) 40%, transparent);
  padding: 4px 10px;
  border-radius: 20px;
}

.route-card-distance {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

.route-card-desc {
  font-family: 'Zen Maru Gothic', var(--sans);
  font-size: 15px;
  color: #b0b8d8;
  line-height: 1.6;
  margin-bottom: 8px;
}
.route-card-desc:last-of-type { margin-bottom: 12px; }

.route-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.route-card-flexible {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--route-vermilion);
  letter-spacing: 0.03em;
}

.route-card-activities-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 128px;
  padding: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.route-card-activities-grid:hover, .route-card-activities-grid:focus-visible { border-color: var(--chip-color, var(--route-vermilion)); }
.route-card-activities-grid:focus-visible { outline: 2px solid var(--chip-color, var(--route-vermilion)); outline-offset: 1px; }

.route-card-activities-icons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  font-size: 17px;
  line-height: 1;
}
.route-card-activities-icons-grid span { display: flex; align-items: center; justify-content: center; }

.route-card-activities-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

/* ─── MODAL (things to do) ─── */

.route-modal[hidden] { display: none; }

.route-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.route-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 8, 0.75);
}

.route-modal-panel {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.route-modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.route-modal-close:hover, .route-modal-close:focus-visible { color: var(--text); }

.route-modal-title {
  font-family: 'Shippori Mincho', var(--jp);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  padding-right: 30px;
}

.route-modal-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.route-modal-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-family: 'Zen Maru Gothic', var(--sans);
  font-size: 15px;
  color: #b0b8d8;
  line-height: 1.5;
}

.route-modal-icon { font-size: 18px; flex-shrink: 0; }

/* ─── LEAFLET OVERRIDES ─── */

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg2); color: var(--text); }
.leaflet-container { font-family: var(--sans); background: var(--bg2); }
.leaflet-control-attribution { background: rgba(10,8,16,0.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

.route-map-label {
  background: transparent;
  border: none;
  box-shadow: none;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 0 2px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.95), 0 0 4px rgba(0,0,0,0.8);
}
.route-map-label::before { display: none; }

/* ─── RESPONSIVE ─── */

@media (max-width: 760px) {
  .route-progress {
    grid-template-columns: 1fr;
    grid-template-areas: "countdown" "stats" "toolbar";
    gap: 14px;
    padding: 16px 18px;
  }
  .route-progress-countdown { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
  .route-progress-stats { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
  .route-view-toggle { width: 100%; }
  .route-view-btn { flex: 1; }
  .route-view-btn-label { display: none; }

  .route-style-row { grid-template-columns: 1fr; gap: 4px; }

  .route-map-fullscreen { width: 38px; height: 38px; font-size: 18px; }
  .route-map-overview { top: 54px; width: 38px; height: 38px; font-size: 16px; }

  .route-cal-day { font-size: 9px; }
  .route-cal-month-label { font-size: 10px; }
  .route-cal-month { flex: 1 1 100%; }

  .route-progress-stats { flex-wrap: wrap; }
  .route-progress-compact { font-size: 18px; }

  .route-list-row { grid-template-columns: 20px 1fr auto; padding: 12px; }
  .route-list-dates { display: none; }
  .route-list-name { font-size: 13px; }

  .route-card { padding: 16px; }
  .route-card-title { font-size: 18px; }
  .route-card-body { grid-template-columns: 1fr; }
  .route-card-bar { width: 100%; }
  .route-card-activities-grid { width: 100%; flex-direction: row; justify-content: center; }

  .route-modal-panel { padding: 20px; max-height: 85vh; }
  .route-modal-title { font-size: 18px; }
}

.route-footer-link {
  max-width: 640px;
  margin: 32px auto 0;
  text-align: center;
  font-size: 14px;
}
.route-footer-link a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}
.route-footer-link a:hover {
  color: var(--purple);
}
