/* Lumina — nocturnal instrument.
   Deep ink night, warm lantern amber, glass panels. Mobile-first. */

:root {
  --ink: #0a0e17;
  --ink-2: #05070d;
  --panel: rgba(14, 19, 30, 0.82);
  --panel-edge: rgba(255, 198, 107, 0.16);
  --lumen: #ffc66b;
  --lumen-dim: rgba(255, 198, 107, 0.55);
  --paper: #f2ede3;
  --muted: #8b94a7;
  --bad: #ff5c5c;
  --mid: #ffb020;
  --good: #4ade80;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  --font-display: Optima, Candara, "Gill Sans", "Gill Sans MT", "Segoe UI", sans-serif;
  --font-body: "Avenir Next", Avenir, "Segoe UI", Seravek, Verdana, sans-serif;
  --font-data: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: fixed;
  inset: 0;
  background: var(--ink);
}

/* Soft night vignette over the basemap — atmosphere, not obstruction. */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, transparent 62%, rgba(4, 6, 12, 0.55) 100%);
}

/* ---------------------------------------------------------------- chrome */

.reveal {
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  animation-delay: var(--d, 0ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.brand {
  position: fixed;
  z-index: 700;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  user-select: none;
}
.brand .mark {
  width: 22px;
  height: 22px;
  color: var(--lumen);
  filter: drop-shadow(0 0 6px rgba(255, 198, 107, 0.65));
}
.brand .word {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.09em;
  color: var(--paper);
}

/* Right-edge tool stack */
.actions {
  position: fixed;
  z-index: 700;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 76px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}
.tool svg { width: 22px; height: 22px; }
.tool:active { transform: scale(0.92); }
.tool[aria-pressed="true"] {
  background: var(--lumen);
  color: var(--ink-2);
  border-color: var(--lumen);
  box-shadow: 0 0 18px rgba(255, 198, 107, 0.45), var(--shadow);
}
.tool.danger { color: #ff8a80; }
.tool:focus-visible,
.hour input:focus-visible,
.route-card:focus-visible {
  outline: 2px solid var(--lumen);
  outline-offset: 2px;
}

/* Route-mode hint pill */
.hint {
  position: fixed;
  z-index: 700;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(78vw, 340px);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--lumen);
  white-space: nowrap;
  animation: rise 0.35s ease both;
}

/* ---------------------------------------------------------------- bottom */

.bottom {
  position: fixed;
  z-index: 700;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  pointer-events: none;
}
.bottom > * { pointer-events: auto; }

/* Hour control — the track is the day itself: night → noon → night. */
.hour {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 420px);
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.hour-label {
  font-family: var(--font-data);
  font-size: 13px;
  min-width: 52px;
  text-align: center;
  color: var(--lumen);
  letter-spacing: 0.04em;
}
.hour input {
  flex: 1;
  height: 28px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
.hour input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #131c33 0%, #23325c 22%, #e8c274 50%, #23325c 78%, #131c33 100%);
}
.hour input::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #131c33 0%, #23325c 22%, #e8c274 50%, #23325c 78%, #131c33 100%);
}
.hour input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid var(--ink-2);
  background: var(--lumen);
  box-shadow: 0 0 10px rgba(255, 198, 107, 0.8);
}
.hour input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink-2);
  background: var(--lumen);
  box-shadow: 0 0 10px rgba(255, 198, 107, 0.8);
}

.credit {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
  user-select: none;
}
body.sheet-open .credit { display: none; }

/* Route cards — horizontal snap rail on phones. */
.sheet {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 2px;
  scrollbar-width: none;
  animation: rise 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.sheet::-webkit-scrollbar { display: none; }

.route-card {
  scroll-snap-align: center;
  flex: 0 0 min(84%, 300px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  min-height: 72px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  opacity: 0.75;
}
.route-card.active {
  opacity: 1;
  border-color: var(--lumen-dim);
  box-shadow: 0 0 20px rgba(255, 198, 107, 0.22), var(--shadow);
}
.rc-score {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
  min-width: 62px;
  text-align: center;
}
.rc-score small {
  display: block;
  font-family: var(--font-body);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}
.rc-body { flex: 1; min-width: 0; }
.rc-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
}
.rc-meta {
  font-family: var(--font-data);
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Tag chips (cards + popups) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.chip {
  font-size: 10.5px;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--paper);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  z-index: 900;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 118px);
  transform: translateX(-50%);
  max-width: 84vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(46, 16, 20, 0.92);
  border: 1px solid rgba(255, 92, 92, 0.35);
  color: #ffd7d2;
  font-size: 13px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rise 0.3s ease both;
}

/* ---------------------------------------------------------------- leaflet */

.leaflet-container {
  background: var(--ink);
  font-family: var(--font-body);
}
.leaflet-control-attribution {
  background: rgba(10, 14, 23, 0.75) !important;
  color: var(--muted) !important;
  font-size: 9.5px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.leaflet-control-attribution a { color: #a9b3c9 !important; }
.leaflet-control-zoom { margin-bottom: 132px !important; }
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--paper) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}
@media (pointer: coarse) {
  .leaflet-control-zoom { display: none; }
}

.lumina-pop .leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.lumina-pop .leaflet-popup-tip {
  background: rgba(14, 19, 30, 0.95);
  border: 1px solid var(--panel-edge);
}
.lumina-pop .leaflet-popup-content { margin: 14px 18px; }
.lumina-pop .leaflet-popup-close-button {
  color: var(--muted) !important;
  padding: 6px 8px 0 0 !important;
}
.pop-score {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1;
  text-shadow: 0 0 18px currentColor;
}
.pop-sub {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 5px;
}
.pop-none {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.03em;
}
.pop-none + .pop-sub { text-transform: none; letter-spacing: 0.02em; }

/* A/B pins + locate dot */
.pin {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink-2);
  border: 2px solid var(--ink-2);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.6);
}
.pin.a { background: var(--lumen); box-shadow: 0 0 16px rgba(255, 198, 107, 0.7); }
.pin.b { background: #8fb8ff; box-shadow: 0 0 16px rgba(143, 184, 255, 0.7); }
.me-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8fb8ff;
  border: 2px solid var(--ink-2);
  box-shadow: 0 0 0 0 rgba(143, 184, 255, 0.55);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  from { box-shadow: 0 0 0 0 rgba(143, 184, 255, 0.55); }
  to { box-shadow: 0 0 0 18px rgba(143, 184, 255, 0); }
}

/* ---------------------------------------------------------------- desktop */

@media (min-width: 768px) {
  .brand { top: 20px; left: 20px; padding: 10px 20px 10px 14px; }
  .brand .word { font-size: 21px; }
  .actions { right: 20px; top: 96px; }
  .bottom { padding-bottom: 18px; gap: 12px; }
  .sheet { max-width: 720px; justify-content: center; flex-wrap: wrap; overflow: visible; }
  .route-card { flex: 0 1 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .hint, .sheet, .toast { animation: none; }
  .me-dot { animation: none; }
  .tool { transition: none; }
}
