/* =============================================================================
   map.css - kartan, markörerna, cyklistkorten och rutt-listan.
   ============================================================================= */

/* --- Kartkortet ----------------------------------------------------------- */
.map-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Verktygsraden ligger inuti kortet, ovanför kartan. */
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
}

#map {
  height: min(62vh, 540px);
  width: 100%;
  background: #eef1f4;
}
@media (min-width: 720px) {
  #map { height: 560px; }
}

/* Leaflets kontroller görs mjukare och modernare. */
.leaflet-container { font-family: var(--body); }
.leaflet-bar {
  border: none !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
}
.leaflet-bar a {
  border: none !important;
  color: var(--ink) !important;
  font-weight: 600;
}
.leaflet-bar a:first-child { border-bottom: 1px solid var(--line) !important; }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.8) !important;
  border-radius: 8px 0 0 0;
  font-size: 10px;
}
/* Rundade, mjuka popup-rutor. */
.leaflet-popup-content-wrapper {
  border-radius: 14px !important;
  box-shadow: var(--shadow-lg) !important;
}
.leaflet-popup-content { margin: 12px 14px; font-size: 0.88rem; }

/* --- Markör (byggs som HTML via L.divIcon) -------------------------------- */
.rider-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.rider-marker .pin {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 17, 21, 0.35);
}
/* Mjuk puls runt pricken så att den känns levande. */
.rider-marker .pin::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--c);
  opacity: 0.5;
  animation: ping 2.4s ease-out infinite;
}
@keyframes ping {
  0% { transform: scale(0.7); opacity: 0.55; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .rider-marker .pin::after { animation: none; opacity: 0.3; }
}

.rider-marker .label {
  margin-top: 7px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: #fff;
  color: var(--ink);
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(15, 17, 21, 0.18);
  white-space: nowrap;
}

/* Liten ring där ett spår börjar. */
.track-start {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(15, 17, 21, 0.45);
  box-shadow: 0 1px 4px rgba(15, 17, 21, 0.25);
}

/* --- Filterknappar (piller) ---------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 15px;
  min-height: 38px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.chip .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--ink));
  flex: none;
}
.chip:hover { border-color: #d3d7de; }
/* Avstängt filter blir blekt och grått. */
.chip[aria-pressed="false"] {
  opacity: 0.5;
  background: #f3f4f6;
}
.chip[aria-pressed="false"] .swatch { background: var(--muted); }

/* Streckad markering för rutt-filtret. */
.chip .dash {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--ink);
  flex: none;
}

/* --- Cyklistkort ---------------------------------------------------------- */
.rider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.rider-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.rider-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #dfe3e9;
}

/* Rund bricka med cyklistens initial i personens färg. */
.rider-card .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  background: var(--c);
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.15);
}

.rider-card .rc-name {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.rider-card .rc-time {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}
.rider-card .rc-km {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.1;
}
.rider-card .rc-km small {
  display: block;
  font-family: var(--body);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Grön prick = positionen är färsk. Grå = ett tag sedan. */
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  box-shadow: 0 0 0 3px rgba(0, 146, 70, 0.16);
}
.live-dot.stale {
  background: #b6bcc6;
  box-shadow: 0 0 0 3px rgba(182, 188, 198, 0.2);
}

/* --- Lista med planerade rutter ------------------------------------------ */
.route-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.route-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 13px 16px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
}
/* Streckad linje i listan matchar rutten på kartan. */
.route-list .line {
  width: 30px;
  height: 0;
  border-top: 3px dashed var(--c, var(--ink));
  flex: none;
}
.route-list .tag {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
