/* ===========================================================================
   US · the friend map: a real street map, photo pins with weather bubbles,
   a pill to jump between you, hearts along the line, and the big number.
   The map is bright in both themes, so its controls are always paper-white.
   =========================================================================== */

.tracker {
  display: grid;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: var(--pen-w, 2px) solid color-mix(in srgb, var(--pen) 70%, transparent);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.tracker .us-map {
  position: relative;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  aspect-ratio: auto;
  height: min(62vh, 560px);
  max-height: none;
  background: #d4e4ec;
}
.us-map .lf { position: absolute; inset: 0; z-index: 0; background: #d4e4ec; font: inherit; }
.us-map .leaflet-control-attribution {
  font-size: 0.6rem;
  background: rgb(255 255 255 / 0.7);
  color: #555;
  padding: 0 0.35rem;
  border-radius: 6px 0 0 0;
}
.us-map .leaflet-control-attribution a { color: #555; }

/* ---- the line between you */
.pm-line { stroke: #e0607e; stroke-opacity: 0.9; }
.pm-line.is-live { animation: march 1.1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -22; } }

/* ---- how sure your device is about where you are */
.pm-acc { fill: var(--rabbit); fill-opacity: 0.12; stroke: var(--rabbit); stroke-opacity: 0.5; }
.pm-acc.who-tuna { fill: var(--tuna); stroke: var(--tuna); }

/* ---- pins: photo on the spot, weather bubble above, city below */
.pm-icon { background: none; border: 0; }
.pm { position: absolute; left: 0; top: 0; width: 0; height: 0; color: #1d2126; }
.pm-av {
  position: absolute;
  left: -30px; top: -30px;
  width: 60px; height: 60px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff6e4;
  border: 3.5px solid #fff;
  box-shadow: 0 0 0 3px var(--who), 0 6px 14px rgb(0 0 0 / 0.35);
  cursor: pointer;
}
.pm-av img, .pill-av img, .th-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Leaflet sizes marker images to their natural size; a pin photo must fill its circle. */
.leaflet-container .leaflet-marker-pane .pm-av img { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; }
.av-emoji { font-size: 1.9rem; line-height: 1; }
.pm-bubble {
  position: absolute;
  left: 0; bottom: 42px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.22);
  font-weight: 800;
  font-size: 0.88rem;
  white-space: nowrap;
}
.pm-bubble::after {
  content: '';
  position: absolute;
  left: 50%; bottom: -5px;
  width: 11px; height: 11px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.pm-wx { display: inline-flex; align-items: center; gap: 0.2rem; }
.pm-wx .ico { color: #e8a33d; }
.pm-time { font-family: var(--mono); font-size: 0.8rem; color: #444; }
.pm-sep { width: 1px; height: 0.9em; background: #ddd; }
.pm-badge {
  position: absolute;
  left: 12px; top: 10px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid #fff;
  display: none;
  place-items: center;
  font-size: 0.7rem;
  box-shadow: 0 2px 5px rgb(0 0 0 / 0.3);
}
.pm.is-here .pm-badge { display: grid; background: #37c46a; }
.pm.is-asleep .pm-badge { display: grid; background: #7b61ff; }
.pm.is-asleep .pm-badge::after { content: '☾'; color: #fff; font-size: 0.72rem; line-height: 1; }
.pm.is-here .pm-av { animation: pm-here 2.4s ease-out infinite; }
@keyframes pm-here {
  0% { box-shadow: 0 0 0 3px var(--who), 0 0 0 3px color-mix(in srgb, var(--who) 60%, transparent), 0 6px 14px rgb(0 0 0 / 0.35); }
  100% { box-shadow: 0 0 0 3px var(--who), 0 0 0 20px color-mix(in srgb, var(--who) 0%, transparent), 0 6px 14px rgb(0 0 0 / 0.35); }
}
.pm-name {
  position: absolute;
  left: 0; top: 36px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  white-space: nowrap;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.05;
  color: #1d2126;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff;
}
.pm-name small { font-family: var(--body); font-size: 0.66rem; font-weight: 700; color: #555; }
.is-dark-map .pm-name { color: #f3eee2; text-shadow: 0 0 3px #10151c, 0 0 3px #10151c, 0 0 6px #10151c; }
.is-dark-map .pm-name small { color: #b8ae9a; }
.pm.is-hit .pm-av { animation: hit 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes hit { 35% { transform: scale(1.35) rotate(-8deg); } }

/* ---- overlay controls */
.map-ui { position: absolute; inset: 0; z-index: 500; pointer-events: none; overflow: hidden; }
.map-ui > * { pointer-events: auto; }
.map-side { position: absolute; top: 12px; right: 12px; display: grid; gap: 8px; }
.map-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #1d2126;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 3px 10px rgb(0 0 0 / 0.2);
  cursor: pointer;
}
.map-btn:active { transform: scale(0.94); }
.map-pill {
  position: absolute;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.22);
}
.pill-av {
  width: 42px; height: 42px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--who);
  background: #fff6e4;
  cursor: pointer;
}
.pill-av .av-emoji { font-size: 1.35rem; }
.pill-av[disabled] { opacity: 0.4; cursor: default; }
.pill-sep { width: 1px; height: 26px; background: #e4e4e4; }
.pill-btn {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border: 0;
  border-radius: 50%;
  background: #f1f3f4;
  color: #1d2126;
  cursor: pointer;
}
.pill-heart { background: #ffe1e8; color: #e0476b; font-size: 1.3rem; }
.pill-btn:active, .pill-av:active { transform: scale(0.92); }

/* ---- hearts in flight (positioned in pixels by the script) */
.map-heart {
  position: absolute;
  left: 0; top: 0;
  z-index: 3;
  color: #e0476b;
  font-size: 1.9rem;
  line-height: 1;
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
  pointer-events: none;
}
.map-heart.is-trail { font-size: 0.85rem; opacity: 0.85; animation: trail 0.9s ease-out forwards; }
@keyframes trail { to { opacity: 0; margin-top: -18px; } }

/* ---- the big number and the facts */
.tracker-hero {
  display: grid;
  justify-items: center;
  gap: 0.8rem;
  padding: 1.1rem 1rem 1.2rem;
  border-top: 2px dashed color-mix(in srgb, var(--pen) 25%, transparent);
  text-align: center;
}
.th-empty { margin: 0; color: var(--muted); }
.th-main { display: flex; align-items: center; gap: 1rem; }
.th-av {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  padding: 0;
  border-radius: 50%;
  overflow: visible;
  background: #fff6e4;
  border: 3px solid var(--who);
  box-shadow: 2px 4px 0 rgb(0 0 0 / 0.3);
  cursor: default;
}
.th-av > img, .th-av > .av-emoji { border-radius: 50%; overflow: hidden; }
.th-av > img { width: 100%; height: 100%; }
.th-av .av-emoji { font-size: 1.8rem; }
.th-av.is-mine { cursor: pointer; }
.th-cam {
  position: absolute;
  right: -4px; bottom: -4px;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text);
  color: var(--ground);
  border: 2px solid var(--surface);
}
.th-main > .th-av:first-child { transform: rotate(-6deg); }
.th-main > .th-av:last-child { transform: rotate(6deg); }
.th-dist { display: grid; justify-items: center; line-height: 1; }
.th-num {
  font-family: var(--display);
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, var(--tuna), var(--rabbit));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.th-unit { font-family: var(--display); font-size: 1.15rem; color: var(--muted); margin-top: 0.15rem; }
.th-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.45rem; max-width: 760px; }
.th-fact {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  font-size: 0.86rem;
}
.th-fact .ico { color: var(--muted); flex: none; }
.th-fact i { color: var(--faint); }
.th-soon { border-color: color-mix(in srgb, var(--heart) 50%, var(--line)); }
.th-soon .ico { color: var(--heart); }
.th-mi { color: var(--muted); }
.th-actions { display: grid; justify-items: center; gap: 0.3rem; }
.th-heart {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.5rem 1.3rem;
  border-radius: 16px 20px 14px 18px;
  border: 2.5px solid var(--pen);
  background: var(--heart);
  color: #2a1216;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: 3px 4px 0 var(--pen);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.th-heart:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--pen); }
.th-heart-ico { font-size: 1.2rem; animation: beat 1.3s ease-in-out infinite; }
@keyframes beat { 0%, 60%, 100% { transform: scale(1); } 20% { transform: scale(1.25); } 40% { transform: scale(0.95); } }
.th-count { font-size: 0.78rem; color: var(--faint); min-height: 1em; }

@media (max-width: 760px) {
  .tracker { border-radius: 0; border-inline: 0; margin-inline: calc(var(--gutter) * -1); }
  .tracker .us-map { height: 68dvh; margin: 0; width: 100%; border-radius: 0; }
  .map-btn { width: 42px; height: 42px; }
  .map-zin, .map-zout { display: none; } /* pinch instead */
  .pm-av { left: -27px; top: -27px; width: 54px; height: 54px; }
  .pm-bubble { bottom: 38px; font-size: 0.82rem; }
  .th-main { gap: 0.7rem; }
  .th-av { width: 48px; height: 48px; }
  .th-fact { font-size: 0.8rem; padding: 0.25rem 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pm-line.is-live, .th-heart-ico, .pm.is-here .pm-av { animation: none; }
}

/* ---- map style picker */
.map-styles {
  position: absolute;
  top: 12px; right: 64px;
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 6px;
  border-radius: 16px;
  background: #fff;
  color: #1d2126;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}
.map-styles[hidden] { display: none; }
.ms-head { margin: 0.2rem 0.5rem 0.3rem; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #888; }
.ms-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
.ms-item:hover { background: #f1f3f4; }
.ms-item.is-on { background: #fff1e0; }
.ms-item.is-on::after { content: '✓'; margin-left: auto; color: #c98a4b; }
.ms-swatch { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1.5px rgb(0 0 0 / 0.15); }
