/* ================= Vantage — custom layer over Tailwind ================= */

:root {
  --ink: #07080b;
  --panel: #0e1116;
  --panel2: #151a22;
  --line: #222a36;
  --line2: #2e3948;
  --accent: #d9ff3d;
  --live: #ff4d4d;
  --mute: #8a94a3;
  --dim: #5a6473;
}

html { color-scheme: dark; }
* { -webkit-tap-highlight-color: transparent; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3d4a5c; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* Atmosphere: faint grain + vignette on the page */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.028 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Topbar hairline */
.topbar { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(14,17,22,.85), rgba(7,8,11,.6)); backdrop-filter: blur(14px); }

/* Interstate-shield-ish state chip */
.state-shield {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 32px; padding: 0 6px;
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 16px; letter-spacing: .05em;
  color: var(--ink); background: var(--accent);
  border-radius: 8px 8px 12px 12px;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 3.5px var(--line2);
}

/* Buttons */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--mute);
  transition: color .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { color: #e8eaed; border-color: var(--line2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.is-on { color: var(--accent); border-color: rgba(217,255,61,.4); }

.view-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 16px;
  font-size: 13px; font-weight: 600; border-radius: 9px; color: var(--mute);
  transition: all .15s;
}
.view-btn-on { background: var(--panel2); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line2); }

.side-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 0; font-size: 12px; font-weight: 600; border-radius: 9px; color: var(--dim);
  transition: all .15s;
}
.side-tab-on { background: var(--panel2); color: #e8eaed; box-shadow: inset 0 0 0 1px var(--line); }

.road-chip {
  flex-shrink: 0; padding: 4px 10px; border-radius: 999px;
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line); color: var(--mute);
  transition: all .15s; cursor: pointer; white-space: nowrap;
}
.road-chip:hover { border-color: var(--line2); color: #e8eaed; }
.road-chip.on { background: var(--accent); border-color: var(--accent); color: var(--ink); }

/* Camera list rows */
.cam-row {
  display: flex; gap: 10px; align-items: center; padding: 8px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: border-color .15s, transform .1s;
}
.cam-row:hover { border-color: rgba(217,255,61,.35); }
.cam-row:active { transform: scale(.985); }
.cam-thumb {
  width: 72px; height: 44px; border-radius: 9px; overflow: hidden; flex-shrink: 0;
  background: var(--ink); position: relative;
}
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.cam-thumb .tag {
  position: absolute; bottom: 3px; left: 3px;
  font-family: "IBM Plex Mono", monospace; font-size: 7.5px; font-weight: 600; letter-spacing: .08em;
  padding: 1px 4px; border-radius: 4px; background: rgba(7,8,11,.85);
}
.tag-video { color: var(--accent); }
.tag-still { color: #6ea8ff; }

/* Live / status badges */
.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: "IBM Plex Mono", monospace; font-size: 9px; font-weight: 600; letter-spacing: .14em;
  color: #fff; background: rgba(255,77,77,.9); padding: 2px 7px; border-radius: 5px;
}
.live-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fff; animation: blink 1.4s infinite; }
.still-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: "IBM Plex Mono", monospace; font-size: 9px; font-weight: 600; letter-spacing: .14em;
  color: #cfe0ff; background: rgba(110,168,255,.25); padding: 2px 7px; border-radius: 5px;
}
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ================= Wall cells ================= */
.cell {
  position: relative; overflow: hidden; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: box-shadow .15s;
}
.cell.active { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.dragover { box-shadow: inset 0 0 0 2px #3ddc84; }
.cell video, .cell .cell-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cell .cell-img { opacity: 0; transition: opacity .5s; }
.cell .cell-img.ready { opacity: 1; }

/* faint scanline texture over media, very subtle */
.cell-media-fx { position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px); }

/* empty state: road-work diagonal stripes, extremely dim */
.cell-empty {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--dim);
  background:
    repeating-linear-gradient(-45deg, rgba(217,255,61,.02) 0 18px, transparent 18px 36px),
    var(--panel);
  cursor: pointer; transition: color .15s;
}
.cell-empty:hover { color: var(--mute); }
.cell-empty .plus {
  width: 34px; height: 34px; border-radius: 11px; border: 1.5px dashed var(--line2);
  display: flex; align-items: center; justify-content: center;
}

.cell-err {
  position: absolute; inset: 0; z-index: 7; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  background: rgba(7,8,11,.88); color: var(--mute); backdrop-filter: blur(4px);
}

/* cell top info bar (overlay) */
.cell-info {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: none; align-items: center; gap: 7px; padding: 6px 8px;
  background: linear-gradient(180deg, rgba(7,8,11,.85), transparent);
}
.cell-road {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 11px; letter-spacing: .06em;
  color: var(--ink); background: var(--accent); border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
}
.cell-name { font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

/* cell controls (bottom overlay) */
.cell-ctr {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 11;
  display: none; align-items: center; gap: 5px; padding: 7px 8px;
  background: linear-gradient(0deg, rgba(7,8,11,.9), transparent);
  opacity: 0; transition: opacity .2s;
}
.cell:hover .cell-ctr, .cell.show-ctr .cell-ctr { opacity: 1; }
@media (pointer: coarse) { .cell-ctr { opacity: 1; } }
.cbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(21,26,34,.9); border: 1px solid rgba(46,57,72,.6); color: #c3cad4;
  transition: all .12s; backdrop-filter: blur(4px);
}
.cbtn:hover { color: #fff; border-color: var(--line2); }
.cbtn:active { transform: scale(.9); }
.cbtn.rec-on { background: var(--live); border-color: var(--live); color: #fff; animation: recpulse 1.5s infinite; }
.cbtn.lock-on { color: var(--accent); border-color: rgba(217,255,61,.4); }
@keyframes recpulse { 0% { box-shadow: 0 0 0 0 rgba(255,77,77,.6) } 70% { box-shadow: 0 0 0 6px rgba(255,77,77,0) } 100% { box-shadow: 0 0 0 0 rgba(255,77,77,0) } }

/* still-cam refresh progress: thin sweep along the bottom */
.refresh-bar { position: absolute; bottom: 0; left: 0; height: 2px; z-index: 9; background: rgba(110,168,255,.75); width: 0%; }
.refresh-bar.running { animation: refill var(--refresh-s, 20s) linear infinite; }
@keyframes refill { from { width: 0% } to { width: 100% } }

/* hero layout spans */
.hero-layout .cell-0 { grid-column: span 3 / span 3; grid-row: span 3 / span 3; }

/* skeleton shimmer */
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.045) 50%, transparent 70%);
  animation: shim 1.8s infinite; z-index: 4;
}
@keyframes shim { from { transform: translateX(-100%) } to { transform: translateX(100%) } }
.cell.playing.shimmer::after { display: none; }

/* status dot in cell info */
.sdot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); flex-shrink: 0; }
.sdot.ok { background: #3ddc84; box-shadow: 0 0 6px rgba(61,220,132,.7); }
.sdot.wait { background: #f5a623; }
.sdot.bad { background: var(--live); }

/* ================= State picker ================= */
.sp-backdrop { backdrop-filter: blur(20px); background:
  radial-gradient(1200px 600px at 80% -10%, rgba(217,255,61,.06), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, rgba(110,168,255,.05), transparent 60%),
  rgba(7,8,11,.94); }
.sp-searchrow { background: linear-gradient(180deg, rgba(7,8,11,.95) 70%, transparent); }

.sp-stagger { opacity: 0; transform: translateY(14px); animation: rise .55s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: calc(var(--d) * 70ms); }
@keyframes rise { to { opacity: 1; transform: none } }

.state-card {
  position: relative; text-align: left; padding: 14px 14px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  transition: border-color .15s, transform .12s, background .15s;
  opacity: 0; animation: rise .4s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: calc(var(--d) * 22ms);
}
.state-card:hover { border-color: rgba(217,255,61,.4); background: var(--panel2); }
.state-card:active { transform: scale(.97); }
.state-card .abbr {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 30px; line-height: 1;
  letter-spacing: .02em; color: #e8eaed;
}
.state-card.soon { opacity: 0; }
.state-card.soon .abbr { color: var(--dim); }
.state-card.soon:hover { border-color: var(--line2); }
.state-card .meta { font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--dim); }
.state-card .cnt { color: var(--accent); }
.state-card.soon .cnt { color: var(--dim); }

/* ================= Map ================= */
.leaflet-container { font-family: Barlow, sans-serif; background: var(--ink); }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--mute) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(7,8,11,.7) !important; color: var(--dim) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--mute) !important; }

.mkr { border-radius: 50%; border: 1.5px solid rgba(7,8,11,.9); box-shadow: 0 0 6px rgba(0,0,0,.5); }
.mkr-video { background: var(--accent); }
.mkr-still { background: #6ea8ff; }

.marker-cluster { background: rgba(217,255,61,.18) !important; }
.marker-cluster div {
  background: var(--panel2) !important; color: var(--accent) !important;
  font-family: "IBM Plex Mono", monospace !important; font-weight: 600 !important; font-size: 10px !important;
  border: 1px solid rgba(217,255,61,.45) !important;
}

.mp-in { animation: mpin .25s cubic-bezier(.2,.7,.2,1); }
@keyframes mpin { from { opacity: 0; transform: translate(-50%, 12px) } to { opacity: 1; transform: translate(-50%, 0) } }

/* ================= Mobile nav ================= */
.mnav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; font-size: 10px; font-weight: 600; color: var(--dim); transition: color .15s;
}
.mnav-btn.mnav-on { color: var(--accent); }

.more-item {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 14px;
  font-size: 13px; font-weight: 600; text-align: left; transition: border-color .15s;
}
.more-item:active { transform: scale(.97); }

.m-layout {
  flex: 1; padding: 10px 0; border-radius: 12px; background: var(--panel2);
  border: 1px solid var(--line); font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: 13px;
}
.m-layout:active { transform: scale(.94); }

.sheet-in { animation: sheetup .28s cubic-bezier(.2,.7,.2,1); }
@keyframes sheetup { from { transform: translateY(100%) } to { transform: none } }

.sidebar-sheet { animation: none; }
@media (max-width: 767px) {
  .sidebar-sheet.open { display: flex !important; animation: sheetup .28s cubic-bezier(.2,.7,.2,1); }
}

/* ================= Modals, toasts, misc ================= */
.modal-in { animation: modalin .25s cubic-bezier(.2,.7,.2,1); }
@keyframes modalin { from { opacity: 0; transform: scale(.95) translateY(10px) } to { opacity: 1; transform: none } }

.pro-glow { position: absolute; top: -120px; right: -120px; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(217,255,61,.14), transparent 65%); pointer-events: none; }

.sc-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px; border-bottom: 1px dashed var(--line); color: var(--mute); }
.sc-row kbd { font-family: "IBM Plex Mono", monospace; font-size: 11px; background: var(--panel2); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; padding: 2px 8px; color: #e8eaed; }

.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 9px;
  background: rgba(21,26,34,.95); border: 1px solid var(--line2); backdrop-filter: blur(10px);
  border-radius: 14px; padding: 10px 16px; font-size: 13px; font-weight: 500; color: #e8eaed;
  box-shadow: 0 12px 32px rgba(0,0,0,.5); max-width: 92vw;
  animation: toastin .3s cubic-bezier(.2,.7,.2,1);
}
.toast.leaving { opacity: 0; transform: translateY(-8px); transition: all .25s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px) scale(.96) } to { opacity: 1; transform: none } }
.toast .t-accent { color: var(--accent); }
.toast .t-warn { color: #f5a623; }
.toast .t-err { color: var(--live); }
.toast .t-ok { color: #3ddc84; }

/* Mobile: keep wall & map clear of the bottom nav */
@media (max-width: 767px) {
  #wallWrap, #mapWrap { bottom: calc(58px + env(safe-area-inset-bottom)); }
  body.tv #wallWrap { bottom: 0; }
}

/* ================= TV mode ================= */
body.tv .topbar, body.tv #sidebar, body.tv #mnav { display: none !important; }
body.tv #wallWrap { padding: 0; }
body.tv #wallGrid { gap: 2px; }
body.tv #tvBar { display: flex !important; }
.tv-bar { background: linear-gradient(0deg, rgba(7,8,11,.92), rgba(7,8,11,.55) 75%, transparent); border-top: 1px solid rgba(34,42,54,.5); backdrop-filter: blur(8px); }
.tv-ticker { display: inline-block; padding-left: 100%; animation: ticker 45s linear infinite; }
@keyframes ticker { from { transform: translateX(0) } to { transform: translateX(-100%) } }

/* video elements never show poster flash-of-white */
video { background: #000; }
video::-webkit-media-controls { display: none !important; }

/* Focus visibility for keyboard users */
:focus-visible { outline: 2px solid rgba(217,255,61,.6); outline-offset: 2px; border-radius: 8px; }
