@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #060914;
  --glass: rgba(16, 22, 38, 0.72);
  --glass-border: rgba(255, 255, 255, 0.09);
  --cyan: #22e0c8;
  --amber: #ffb23a;
  --pink: #ff4fa3;
  --gold: #ffd84a;
  --text: #eef2fb;
  --text-dim: #93a0bd;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); font-family: 'Inter', -apple-system, sans-serif; overscroll-behavior: none; }
#map { position: fixed; inset: 0; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 999;
  background: radial-gradient(120% 120% at 50% 10%, #131b33 0%, #060914 70%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .6s ease, visibility .6s ease;
}
#loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#loading-inner { text-align: center; }
#loading-logo {
  font-size: 28px; font-weight: 800; letter-spacing: 4px; color: var(--text);
  margin-bottom: 22px;
}
#loading-logo span { color: var(--cyan); }
#loading-bar { width: 220px; height: 3px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; margin: 0 auto; }
#loading-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .4s ease; }
#loading-text { margin-top: 14px; font-size: 12.5px; color: var(--text-dim); letter-spacing: .3px; }

/* ---------- topbar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
#brand { display: flex; align-items: center; gap: 10px; background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); padding: 8px 14px 8px 8px; border-radius: 16px; pointer-events: auto; }
#brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--cyan), #2a6df0);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #04101a; font-size: 15px; }
#brand-title { font-size: 13.5px; font-weight: 700; color: var(--text); line-height: 1.1; }
#brand-sub { font-size: 10px; color: var(--text-dim); letter-spacing: .3px; }
#status-pill { display: flex; align-items: center; gap: 7px; background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); padding: 8px 13px; border-radius: 999px; pointer-events: auto; }
#status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: pulse-dot 2s infinite; }
#status-text { font-size: 11px; color: var(--text-dim); font-weight: 500; white-space: nowrap; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- layer dock ---------- */
#layer-dock {
  position: fixed; left: 0; right: 0; bottom: max(108px, calc(96px + env(safe-area-inset-bottom)));
  z-index: 50; display: flex; gap: 8px; padding: 0 16px; overflow-x: auto;
  scrollbar-width: none; pointer-events: none;
}
#layer-dock::-webkit-scrollbar { display: none; }
.pill {
  pointer-events: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 7px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px);
  color: var(--text-dim); font-size: 12px; font-weight: 600; padding: 9px 14px; border-radius: 999px;
  cursor: pointer; transition: all .2s ease; font-family: inherit;
}
.pill.active { color: var(--text); border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.1); }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; opacity: .45; transition: opacity .2s; }
.pill.active .pill-dot { opacity: 1; box-shadow: 0 0 6px currentColor; }

/* ---------- stats card ---------- */
#stats-card {
  position: fixed; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 50;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px);
  border-radius: 16px; padding: 12px 16px;
}
.stats-row { display: flex; align-items: baseline; gap: 7px; }
.stats-num { font-size: 22px; font-weight: 800; color: var(--cyan); }
.stats-label { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.stats-row-small { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* ---------- fly home + 2D/3D toggle + locate-me + favorites + offline buttons ---------- */
#fly-home, #toggle-2d, #locate-me, #favorites-btn, #offline-btn, #city-info-btn {
  position: fixed; right: 16px; z-index: 50;
  width: 46px; height: 46px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); color: var(--text); font-size: 19px; cursor: pointer;
}
#fly-home { bottom: max(16px, env(safe-area-inset-bottom)); }
#toggle-2d { bottom: max(70px, calc(58px + env(safe-area-inset-bottom))); font-size: 13px; font-weight: 800; }
#locate-me { bottom: max(124px, calc(112px + env(safe-area-inset-bottom))); }
#favorites-btn { bottom: max(178px, calc(166px + env(safe-area-inset-bottom))); color: var(--gold); }
#favorites-btn.active { background: rgba(255, 216, 74, .18); border-color: var(--gold); }
#offline-btn { bottom: max(232px, calc(220px + env(safe-area-inset-bottom))); }
#city-info-btn { bottom: max(286px, calc(274px + env(safe-area-inset-bottom))); color: var(--cyan); font-weight: 900; }
#offline-btn.done { color: var(--cyan); border-color: var(--cyan); }
#offline-btn.busy { font-size: 10.5px; font-weight: 800; }

.me-pin { width: 18px; height: 18px; border-radius: 50%; background: #4fa3ff; border: 3px solid rgba(255,255,255,.9);
  box-shadow: 0 0 0 6px rgba(79,163,255,.25), 0 2px 10px rgba(0,0,0,.5); }

.fav-btn {
  width: 100%; margin-top: 4px; padding: 11px; border-radius: 12px; border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.06); color: var(--text); font-weight: 700; font-size: 12.5px;
  font-family: inherit; cursor: pointer;
}
.fav-btn.active { background: rgba(255,216,74,.15); color: var(--gold); border-color: var(--gold); }

.uber-btn {
  display: block; width: 100%; margin-top: 10px; padding: 11px; border-radius: 12px;
  background: #000; color: #fff; font-weight: 700; font-size: 12.5px; text-align: center;
  text-decoration: none; font-family: inherit; box-sizing: border-box;
}

.fav-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,.06); }
.fav-row span { font-size: 13.5px; color: var(--text); font-weight: 600; }
.fav-row-btn { flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--glass-border);
  background: rgba(34,224,200,.15); color: var(--cyan); font-weight: 700; font-size: 12px; font-family: inherit; cursor: pointer; }

/* ---------- detail sheet ---------- */
#detail-sheet-backdrop {
  position: fixed; inset: 0; z-index: 59; border: 0; padding: 0;
  background: rgba(2,8,18,.34); opacity: 0; pointer-events: none;
  transition: opacity .22s ease; cursor: default;
}
#detail-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
#detail-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--glass); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--glass-border); border-radius: 22px 22px 0 0;
  transform: translateY(110%); transition: transform .32s cubic-bezier(.2,.8,.2,1);
  max-height: min(72vh, 680px); display: flex; flex-direction: column; overflow: hidden;
}
#detail-sheet.open { transform: translateY(0); }
#detail-sheet-topbar { flex: 0 0 auto; min-height: 48px; display: flex; align-items: center; justify-content: center; padding: 4px 10px 0; }
#detail-sheet-handle { width: 72px; height: 40px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: grab; }
#detail-sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.34); }
#detail-sheet-close { position: absolute; right: 12px; top: 8px; width: 36px; height: 36px; border-radius: 18px; border: 1px solid var(--glass-border); background: rgba(255,255,255,.1); color: var(--text); font: 800 23px/1 inherit; cursor: pointer; }
#detail-sheet-content { overflow-y: auto; overscroll-behavior: contain; padding: 0 20px max(22px, env(safe-area-inset-bottom)); }
.dt-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.dt-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.dt-big { font-size: 30px; font-weight: 800; }
.dt-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); padding: 6px 0; border-top: 1px solid rgba(255,255,255,.06); }
.dt-row b { color: var(--text); font-weight: 600; }
.dt-tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .3px; padding: 3px 9px; border-radius: 999px; margin-bottom: 10px; }

/* ---------- maplibre overrides ---------- */
.maplibregl-popup-content { background: var(--glass) !important; backdrop-filter: blur(16px); color: var(--text) !important;
  border-radius: 14px !important; border: 1px solid var(--glass-border); box-shadow: 0 10px 40px rgba(0,0,0,.4) !important; }
.maplibregl-popup-tip { display: none !important; }
.maplibregl-ctrl-attrib { background: transparent !important; }
.maplibregl-ctrl-attrib a { color: var(--text-dim) !important; }

.parking-pin { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #04101a; border: 2px solid rgba(255,255,255,.6); box-shadow: 0 2px 10px rgba(0,0,0,.5); cursor: pointer; }
.parking-pin.pulse::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: ring 2.2s infinite; }
@keyframes ring { 0% { opacity: .6; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.6); } }

.event-pin { width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 2px 10px rgba(0,0,0,.5); cursor: pointer; }
.highlight-pin { font-size: 22px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); cursor: pointer; }
.highlight-pin img { width: 34px; height: 34px; object-fit: contain; display: block; }
.highlight-pin.sponsored { filter: drop-shadow(0 0 6px var(--gold)) drop-shadow(0 2px 6px rgba(0,0,0,.6)); }

.transit-pin {
  width: 16px; height: 16px; border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 800; color: #04101a; border: 1.5px solid rgba(255,255,255,.85);
  box-shadow: 0 1px 6px rgba(0,0,0,.5); cursor: pointer;
  /* La transition sul movimento è gestita in JS (solo quando la posizione cambia per un vero
     aggiornamento del veicolo, mai durante pan/zoom della camera — vedi setTransitAnimated). */
}
.transit-pin.metro { border-radius: 50%; width: 18px; height: 18px; }
.transit-pin.static { width: 22px; height: 22px; border-radius: 8px; font-size: 12px; color: #fff; }

.report-pin {
  width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; background: #a06bff; border: 2px solid rgba(255,255,255,.7);
  box-shadow: 0 2px 10px rgba(160,107,255,.6); cursor: pointer;
}

.vote-btn {
  flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--glass-border);
  font-weight: 700; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.vote-btn.confirm { background: rgba(34,224,200,.15); color: var(--cyan); }
.vote-btn.refute { background: rgba(255,79,90,.15); color: #ff4f5a; }

/* Pin monumento (layer POI mondiale): emoji o icona dedicata /icons/<nome>.png */
.poi-pin { font-size: 19px; filter: drop-shadow(0 2px 5px rgba(0,0,0,.65)); cursor: pointer; line-height: 1; }
.poi-pin img { width: 26px; height: 26px; object-fit: contain; display: block; }

.link-btn {
  display: block; width: 100%; margin-top: 8px; padding: 11px; border-radius: 12px;
  background: rgba(255,255,255,.07); border: 1px solid var(--glass-border); color: var(--text);
  font-weight: 700; font-size: 12.5px; text-align: center; text-decoration: none; box-sizing: border-box;
  font-family: inherit; cursor: pointer;
}
.link-btn.ticket-disabled { opacity: .68; cursor: not-allowed; color: var(--text-dim); }
.ticket-note { margin: 6px 4px 2px; color: var(--text-dim); font-size: 11px; line-height: 1.4; text-align: center; }
