/* Componenti del Registro posizioni (mappa, cursore del tempo, cronologia).
   Riusabili: tutto sta sotto le classi rp-* e le variabili --rp-*.
   Palette di Live Feedback, chiara e scura. */

:root {
  --rp-bg: #f1eee6;
  --rp-surface: #fbf9f3;
  --rp-card: #ffffff;
  --rp-ink: #172e34;
  --rp-muted: #5b6f73;
  --rp-faint: #8a9a9c;
  --rp-line: #e4dfd3;
  --rp-fill: rgba(23, 46, 52, 0.06);
  --rp-accent: #b2471a;
  --rp-on-accent: #ffffff;
  --rp-moving: #1f8a5b;
  --rp-stopped: #c0841a;
  --rp-stale: #9aa5a7;
  --rp-casing: #ffffff;
  --rp-shadow: 0 1px 2px rgba(23, 46, 52, 0.06), 0 8px 28px rgba(23, 46, 52, 0.10);
  --rp-tiles: saturate(0.62) sepia(0.10) brightness(1.02);
}
@media (prefers-color-scheme: dark) {
  :root {
    --rp-bg: #0e1618;
    --rp-surface: #152024;
    --rp-card: #1a282c;
    --rp-ink: #edf1ec;
    --rp-muted: #a3b4b5;
    --rp-faint: #71858a;
    --rp-line: #26373b;
    --rp-fill: rgba(237, 241, 236, 0.07);
    --rp-accent: #e27d4c;
    --rp-on-accent: #1a0d06;
    --rp-moving: #4cc38a;
    --rp-stopped: #e3aa4a;
    --rp-stale: #6c7e82;
    --rp-casing: #0e1618;
    --rp-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.45);
    --rp-tiles: invert(1) hue-rotate(180deg) brightness(0.86) contrast(0.9) saturate(0.45);
  }
}

/* ---------- mappa ---------- */
.leaflet-container { background: var(--rp-bg); font: inherit; }
.leaflet-tile-pane .leaflet-tile { filter: var(--rp-tiles); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--rp-surface) 80%, transparent) !important; color: var(--rp-muted); font-size: 10px; border-radius: 6px 0 0 0; }
.leaflet-control-attribution a { color: var(--rp-muted); }
.leaflet-bar a { background: var(--rp-card); color: var(--rp-ink); border-color: var(--rp-line); }
.leaflet-tooltip { background: var(--rp-card); color: var(--rp-ink); border: 0; box-shadow: var(--rp-shadow); border-radius: 8px; font-size: 13px; }
.leaflet-tooltip-top::before { border-top-color: var(--rp-card); }
.rp-pin-wrap, .rp-stop-wrap { background: none; border: 0; }

.rp-pin { position: relative; width: 40px; height: 40px; display: grid; place-items: center; transition: opacity .2s; }
.rp-pin-face {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rp-team); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
}
.rp-pin-badge { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid #fff; background: var(--rp-moving); }
.rp-stopped .rp-pin-badge { background: var(--rp-stopped); }
.rp-stale .rp-pin-badge { background: var(--rp-stale); }
.rp-stale .rp-pin-face { filter: grayscale(1); opacity: .75; }
.rp-selected .rp-pin-face { transform: scale(1.14); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rp-team) 30%, transparent), 0 3px 10px rgba(0, 0, 0, .3); }
.rp-dim { opacity: .38; }

.rp-track-casing { stroke: var(--rp-casing); }
.rp-stop {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rp-card); color: var(--rp-ink); font-weight: 800; font-size: 13px;
  border: 3px solid var(--rp-stopped); box-shadow: 0 2px 6px rgba(0, 0, 0, .25); cursor: pointer;
}

/* ---------- cursore del tempo ---------- */
.rp-scrub { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; }
.rp-play {
  width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--rp-ink); color: var(--rp-bg);
}
.rp-play svg { width: 22px; height: 22px; fill: currentColor; }
.rp-play .rp-i-pause, .rp-play.rp-on .rp-i-play { display: none; }
.rp-play.rp-on .rp-i-pause { display: inline; }
.rp-scrub-main { position: relative; padding-top: 4px; }
.rp-scrub-track { position: relative; height: 12px; border-radius: 99px; background: var(--rp-line); overflow: hidden; }
.rp-scrub-move { position: absolute; top: 0; bottom: 0; background: var(--rp-team); }
.rp-scrub-stop { position: absolute; top: 0; bottom: 0; background: var(--rp-stopped); }
.rp-scrub-rest { position: absolute; top: 0; bottom: 0; right: 0; left: 100%; background: color-mix(in srgb, var(--rp-card) 68%, transparent); }
.rp-scrub-range {
  position: absolute; left: 0; right: 0; top: -9px; width: 100%; height: 32px; margin: 0; background: none;
  -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: none;
}
.rp-scrub-range::-webkit-slider-runnable-track { height: 32px; background: none; }
.rp-scrub-range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: 3px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 3px 8px rgba(0,0,0,.25); }
.rp-scrub-range::-moz-range-track { background: none; }
.rp-scrub-range::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.rp-scrub-times { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-size: 13px; color: var(--rp-muted); font-variant-numeric: tabular-nums; }
.rp-scrub-now { font-size: 15px; color: var(--rp-ink); font-weight: 700; }

/* ---------- cronologia ---------- */
.rp-tl { list-style: none; margin: 0; padding: 0; }
.rp-tl-stop {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; text-align: left;
  padding: 12px 12px; border: 0; border-radius: 14px; background: var(--rp-card); color: var(--rp-ink); font: inherit; cursor: pointer;
  box-shadow: 0 0 0 1px var(--rp-line);
}
.rp-tl-stop:active { transform: scale(.99); }
.rp-tl-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; border: 3px solid var(--rp-stopped); }
.rp-tl-body { min-width: 0; display: grid; gap: 2px; }
.rp-tl-place { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-tl-when { font-size: 14px; color: var(--rp-muted); font-variant-numeric: tabular-nums; }
.rp-tl-dur { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.rp-tl-move { position: relative; display: flex; align-items: center; gap: 14px; min-height: 40px; padding-left: 26px; color: var(--rp-muted); font-size: 14px; }
.rp-tl-rail { position: absolute; left: 26px; top: 4px; bottom: 4px; border-left: 3px dotted color-mix(in srgb, var(--rp-muted) 55%, transparent); }
.rp-tl-text { padding-left: 20px; font-variant-numeric: tabular-nums; }
.rp-tl-now { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 650; font-size: 15px; }
.rp-tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rp-moving); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rp-moving) 22%, transparent); }
.rp-tl-now.rp-stopped .rp-tl-dot { background: var(--rp-stopped); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rp-stopped) 22%, transparent); }
.rp-tl-now.rp-stale .rp-tl-dot { background: var(--rp-stale); box-shadow: none; }
.rp-empty { color: var(--rp-muted); font-size: 15px; margin: 8px 2px; }

@media (prefers-reduced-motion: reduce) {
  .rp-pin { transition: none; }
}
