/* CTXRS — Repeater map page
   Layers on top of assets/styles.css and Leaflet's own stylesheet.
   The dark-mode tile filter lives in assets/theme.css, since it only
   applies when html[data-theme="dark"] is set. */

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.85fr);
  gap: 20px;
  align-items: start;
}

#map {
  height: 620px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--map-bg);
  z-index: 0;
}

#map .leaflet-container {
  background: var(--map-bg);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-family: inherit;
}

.map-popup strong {
  display: block;
  font-size: 1rem;
}

.popup-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* --- pins --- */

.map-pin {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: #7f96a8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.map-pin-live {
  background: #54d6a1;
}

.map-pin-active {
  transform: scale(1.35);
  box-shadow: 0 0 0 6px rgba(122, 199, 247, 0.28);
}

/* --- side list --- */

.site-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 620px;
  padding-right: 4px;
  overflow-y: auto;
}

.site-card {
  display: block;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.site-card:hover,
.site-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.site-card.is-active {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.site-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.site-card-name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.site-badge {
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-card-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-card-note {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

/* --- shared detail list (cards and popups) --- */

.site-details {
  margin: 11px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  font-size: 0.85rem;
}

.detail-row {
  display: contents;
}

.site-details dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  align-self: center;
}

.site-details dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  #map { height: 420px; }
  .site-list { max-height: none; overflow: visible; }
}

/* --- live status --- */
.map-pin-online  { background: #54d6a1; }
.map-pin-offline { background: #ef6b6b; }
.map-pin-unknown { background: #7f96a8; }
.popup-status { display: block; margin-top: 9px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
}
.status-pill .status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}
.status-online {
  border-color: rgba(84,214,161,.34);
  background: rgba(45,150,111,.14);
  color: var(--green);
}
.status-offline {
  border-color: rgba(239,107,107,.34);
  background: rgba(163,56,56,.14);
  color: var(--red);
}
.status-unknown {
  border-color: rgba(143,176,200,.28);
  background: rgba(90,120,145,.12);
  color: var(--muted);
}
.site-card-head { align-items: center; }

/* --- homepage map: shorter than the dedicated page --- */
.map-home #map { height: 440px; }
@media (max-width: 900px) { .map-home #map { height: 320px; } }

/* --- known out of service --- */
.map-pin-down { background: #e8c15c; }
.status-down {
  border-color: rgba(232,193,92,.4);
  background: rgba(150,118,40,.16);
  color: var(--amber);
}

/* --- teardrop pins ---
 * A square with three rounded corners, rotated 45deg so the square corner
 * points down. Colours still come from .map-pin-online / -offline / etc,
 * which set background. */
.map-pin {
  position: absolute;
  top: 0;
  left: 50%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border: 2px solid rgba(255, 255, 255, .92);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 3px 7px rgba(0, 0, 0, .55);
  transition: transform 140ms ease;
}

.map-pin::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
}

/* keep the rotation - a bare scale() here would flatten the teardrop */
.map-pin-active {
  transform: rotate(-45deg) scale(1.18);
  box-shadow: 0 0 0 5px rgba(122, 199, 247, .3), 0 3px 9px rgba(0, 0, 0, .6);
}
