/*==============================================*\
|| TerraLoc – Live athlete marker                ||
|| css/sport-marker.css                          ||
\*==============================================*/

/* The marker an athlete gets on a map, and the preview of it in the profile
   designer. It lives in its own file because two pages draw it: the live map
   and the profile marker designer. One copy, so a change made for one cannot
   leave the preview showing something the map will not draw. */

/* ------------------------------------------------------------------
   Live athlete marker: the sport's own icon

   It was a paraglider wing for an airborne pilot, a person for a grounded
   one and a car for someone being driven, with the athlete choosing their
   wing's colours in their profile. A cyclist is not a wing.

   The icon and the colour both come from the sport registry, handed down
   with the page config, so a new sport appears here without a CSS edit.
   --tl-athlete-marker-scale is set by the zoom handler the older markers
   already use, so these scale with the map the same way.
   ------------------------------------------------------------------ */
.tl-sport-marker {
  line-height: 0;
  cursor: pointer;
}
.tl-sport-marker-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transform: scale(var(--tl-athlete-marker-scale, 1));
  will-change: transform;
  /* A disc behind the icon so a dark stroke stays legible over a satellite
     tile or a dark hillshade. currentColor is the sport's, so the ring and
     the glyph match the line the marker sits on. */
  background: var(--tl-marker-disc, rgba(255, 255, 255, 0.94));
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.tl-sport-marker-inner svg {
  width: 20px;
  height: 20px;
}
/* Stopped: still there, no longer the thing your eye goes to. */
.tl-sport-marker.is-stopped .tl-sport-marker-inner {
  opacity: 0.55;
  background: var(--tl-marker-disc-dim, rgba(255, 255, 255, 0.78));
}

/* ------------------------------------------------------------------
   THE BASEMAP DECIDES, NOT THE PAGE.

   This was keyed on @media (prefers-color-scheme: dark), the only component
   in the project reading the operating system instead of the site, and the
   two disagree constantly: an athlete whose Mac is in dark mode, reading the
   site in light mode on a light topo map, got a near-black disc with a dark
   green glyph in it. The least legible thing on the page, and nothing about
   the page was dark.

   The site's own theme is not the answer either. A marker is drawn ON the
   map, and what is behind it is the basemap, which is a separate stored
   choice: topo, terrain, satellite or dark. Three of those four are pale, so
   the disc is pale by default and only the dark basemap flips it. That is
   what the original comment on the disc was reaching for, before an OS media
   query got in the way.
   ------------------------------------------------------------------ */
[data-tl-basemap="dark"] .tl-sport-marker-inner {
  --tl-marker-disc: rgba(20, 24, 15, 0.94);
  --tl-marker-disc-dim: rgba(20, 24, 15, 0.78);
}

/* ------------------------------------------------------------------
   Sport chip: the same sport, at label size

   The athlete's "sports I do" chips on their public profile. Same icon
   as the marker, in the same registry colour, so the chip and the map
   read as the same thing.
   ------------------------------------------------------------------ */
.tl-sport-chip-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 0.3em;
  vertical-align: -2px;
}
.tl-sport-chip-icon svg {
  width: 14px;
  height: 14px;
}

/* ------------------------------------------------------------------
   The 'dot' variant: a position rather than a badge

   The activity page shows one athlete, whose sport is already named twice in
   the header, and the marker there is a playhead. A 34px disc with a glyph in
   it covers the path it is meant to be pointing at. This is the treatment
   Explore gives a track: the sport's colour, a white ring, nothing else.
   ------------------------------------------------------------------ */
.tl-sport-marker--dot .tl-sport-marker-inner {
  background: currentColor;
  border: 3px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(16, 23, 32, 0.45);
}

/* A stopped athlete keeps the ring and loses the fill, so "here" and "here,
   not moving" are one glance apart rather than two shades of the same dot. */
.tl-sport-marker--dot.is-stopped .tl-sport-marker-inner {
  background: #FFFFFF;
  border-color: currentColor;
}

/* ------------------------------------------------------------------
   The athlete's own marker: Monogram, Photo or Name tag

   Drawn by modules/athlete-marker.js, from the TerraLoc Personal Marker
   proposals chosen on 15.09.2026. The SVG carries the shapes; what is here
   is which of them shows at which zoom, the pulse, and the fonts.

   html[data-tl-marker-zoom] is set by applyAthleteMarkerZoom: a dot below
   zoom 9, the badge from there, a Name tag opening from zoom 14. The
   profile's preview sets the attribute on its own tray to show one of them.
   ------------------------------------------------------------------ */
.tl-athlete-marker {
  position: relative;
  line-height: 0;
  cursor: pointer;
}
/* On a map it is a MapLibre marker, and those are all absolute at the
   container's corner, moved by their transform. paint() rewrites className,
   which drops maplibregl-marker and its position; left relative, every
   athlete after the first sat lower by the height of those before it, away
   from the name label that belongs to it. */
.maplibregl-map .tl-athlete-marker {
  position: absolute;
  top: 0;
  left: 0;
}
.tl-athlete-marker svg {
  display: block;
  overflow: visible;
  pointer-events: none;
}
.tl-athlete-marker-scale {
  position: absolute;
  inset: 0;
  transform-origin: 30px 30px;
  transform: scale(var(--tl-athlete-scale, 1));
  filter: drop-shadow(0 1px 2px rgba(16, 23, 32, 0.4));
}
.tl-athlete-marker-scale > svg {
  position: absolute;
  left: 0;
  top: 0;
}
.tl-athlete-marker-letters {
  font-family: var(--tl-font-display, "Bricolage Grotesque", "Archivo", Helvetica, Arial, sans-serif);
  font-weight: 800;
  letter-spacing: -0.5px;
}
.tl-athlete-marker-label {
  font-family: var(--tl-font-body, "Archivo", Helvetica, Arial, sans-serif);
  font-weight: 600;
}

/* Which drawing shows. */
.tl-athlete-marker-dot,
.tl-athlete-marker-tag {
  display: none !important;
}
[data-tl-marker-zoom="far"] .tl-athlete-marker-scale {
  display: none;
}
[data-tl-marker-zoom="far"] .tl-athlete-marker-dot {
  display: block !important;
  position: absolute;
  left: 0;
  top: 0;
}
[data-tl-marker-zoom="near"] .tl-athlete-marker--tag .tl-athlete-marker-tag {
  display: block !important;
}
[data-tl-marker-zoom="near"] .tl-athlete-marker--tag .tl-athlete-marker-badge {
  display: none;
}

/* Stopped: 60%, and the notch was never drawn. */
.tl-athlete-marker.is-stopped {
  opacity: 0.6;
}

/* Live is amber, and only live: the day face, and the night one on the
   dark basemap. */
.tl-athlete-marker-pulse,
.tl-athlete-marker-livebox {
  stroke: #B77F00;
}
[data-tl-basemap="dark"] .tl-athlete-marker-pulse,
[data-tl-basemap="dark"] .tl-athlete-marker-livebox {
  stroke: #FFB300;
}
.tl-athlete-marker-livebox {
  opacity: 0.7;
}
.tl-athlete-marker-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: tl-athlete-pulse 2.2s ease-out infinite;
}
@keyframes tl-athlete-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.43); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tl-athlete-marker-pulse {
    animation: none;
    opacity: 0.35;
  }
}
