/* Cams — Natal ao vivo
   Estética escura, cinematográfica. Tokens abaixo alimentam todo o tema. */

:root {
  --bg: #0a0b0d;
  --panel: #101216;
  --panel-2: #16191f;
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-strong: rgba(255, 255, 255, 0.14);
  --text: #f2f3f5;
  --text-dim: #9aa3ad;
  --text-faint: #6b7480;
  --live: #ff3b3b;
  --live-soft: rgba(255, 59, 59, 0.16);
  --accent: #ffb454; /* âmbar discreto p/ detalhes secundários */
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.4);
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #0d0f12;
}

/* Grão sutil por cima do mapa, dando ar de filme */
#map::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 500; /* acima dos tiles, abaixo dos controles leaflets (1000) */
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ---------- Leaflet: harmonizar com o tema ---------- */
.leaflet-container { font-family: var(--font-body); }

.leaflet-control-zoom {
  border: 1px solid var(--panel-border) !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: var(--shadow-lg) !important;
}
.leaflet-control-zoom a {
  background: rgba(16, 18, 22, 0.92) !important;
  color: var(--text-dim) !important;
  border: 0 !important;
  backdrop-filter: blur(8px);
  transition: color 0.15s ease, background 0.15s ease;
}
.leaflet-control-zoom a:hover { color: var(--text) !important; background: var(--panel-2) !important; }

.leaflet-control-attribution {
  background: rgba(10, 11, 13, 0.72) !important;
  color: var(--text-faint) !important;
  backdrop-filter: blur(6px);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* Tooltip escuro dos marcadores */
.leaflet-tooltip.cam-tooltip {
  background: rgba(16, 18, 22, 0.95);
  border: 1px solid var(--panel-border-strong);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}
.leaflet-tooltip.cam-tooltip::before { display: none; }

/* ---------- Marcadores AO VIVO ---------- */
.cam-marker-wrap { background: none; border: none; }

.cam-marker {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.cam-marker-dot {
  position: relative;
  z-index: 2;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--live);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(10, 11, 13, 0.45), 0 2px 10px rgba(255, 59, 59, 0.55);
  transition: transform 0.25s var(--ease);
}

.cam-marker-pulse {
  position: absolute;
  z-index: 1;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(255, 59, 59, 0.55);
  animation: pulse 2.4s ease-out infinite;
}

.cam-marker-halo {
  position: absolute;
  z-index: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(16, 18, 22, 0.35);
  backdrop-filter: blur(2px);
  transition: transform 0.25s var(--ease), border-color 0.25s ease;
}

.cam-marker:hover .cam-marker-dot,
.leaflet-marker-icon.marker-active .cam-marker-dot { transform: scale(1.25); }

.cam-marker:hover .cam-marker-halo,
.leaflet-marker-icon.marker-active .cam-marker-halo {
  transform: scale(1.18);
  border-color: rgba(255, 59, 59, 0.6);
}

@keyframes pulse {
  0%   { transform: scale(1);    opacity: 0.7; }
  70%  { transform: scale(3.4);  opacity: 0; }
  100% { transform: scale(3.4);  opacity: 0; }
}

/* ---------- Cabeçalho ---------- */
.brand {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 14px;
  background: rgba(16, 18, 22, 0.82);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  animation: drop-in 0.7s var(--ease) both;
}

@keyframes drop-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand-block { display: flex; align-items: center; gap: 10px; }

.brand-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 12px rgba(255, 59, 59, 0.9);
  animation: blink 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.brand-text { line-height: 1.05; }

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-actions { display: flex; align-items: center; gap: 8px; }

.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--live-soft);
  border: 1px solid rgba(255, 59, 59, 0.35);
  border-radius: 999px;
  white-space: nowrap;
}

.count-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  animation: blink 1.8s ease-in-out infinite;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--panel-border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); background: rgba(255,255,255,0.04); }
.btn-ghost[aria-expanded="true"] { color: var(--accent); border-color: rgba(255, 180, 84, 0.4); }

/* ---------- Lista de câmeras ---------- */
.cam-list {
  position: fixed;
  top: 86px;
  left: 16px;
  bottom: 16px;
  z-index: 900;
  width: 320px;
  display: flex;
  flex-direction: column;
  background: rgba(16, 18, 22, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  overflow: hidden;
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.45s var(--ease), opacity 0.3s ease;
}

.cam-list.closed {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.cam-list-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.cam-list-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cam-list-head p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.cam-list-items {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.cam-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  animation: item-in 0.5s var(--ease) both;
}

.cam-list-items li:nth-child(1) .cam-item { animation-delay: 0.05s; }
.cam-list-items li:nth-child(2) .cam-item { animation-delay: 0.08s; }
.cam-list-items li:nth-child(3) .cam-item { animation-delay: 0.11s; }
.cam-list-items li:nth-child(4) .cam-item { animation-delay: 0.14s; }
.cam-list-items li:nth-child(5) .cam-item { animation-delay: 0.17s; }
.cam-list-items li:nth-child(6) .cam-item { animation-delay: 0.20s; }
.cam-list-items li:nth-child(7) .cam-item { animation-delay: 0.23s; }
.cam-list-items li:nth-child(8) .cam-item { animation-delay: 0.26s; }
.cam-list-items li:nth-child(9) .cam-item { animation-delay: 0.29s; }
.cam-list-items li:nth-child(10) .cam-item { animation-delay: 0.32s; }

@keyframes item-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cam-item:hover { background: rgba(255, 255, 255, 0.05); }

.cam-item.active {
  background: var(--live-soft);
  border-color: rgba(255, 59, 59, 0.35);
}

.cam-item-dot {
  position: relative;
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
}
.cam-item-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 59, 59, 0.6);
  animation: pulse 2.4s ease-out infinite;
}

.cam-item-text { min-width: 0; }

.cam-item-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cam-item-area {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-item-arrow {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--text-faint);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.2s var(--ease);
}
.cam-item:hover .cam-item-arrow,
.cam-item.active .cam-item-arrow { opacity: 1; transform: translateX(0); }

/* Scrollbar discreta */
.cam-list-items::-webkit-scrollbar { width: 5px; }
.cam-list-items::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: rgba(5, 6, 8, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.scrim.visible { opacity: 1; }

/* ---------- Painel / bottom sheet da câmera ---------- */
.viewer {
  position: fixed;
  top: 86px;
  right: 16px;
  bottom: 16px;
  z-index: 950;
  width: 420px;
  display: flex;
  flex-direction: column;
  background: rgba(16, 18, 22, 0.94);
  border: 1px solid var(--panel-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  overflow: hidden;
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.45s var(--ease), opacity 0.3s ease;
}

.viewer[hidden] { display: none; }

.viewer.closing {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
}

.viewer-handle { display: none; }

.viewer-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.viewer-titles { min-width: 0; flex: 1; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fff;
  background: var(--live);
  border-radius: 5px;
}

.live-badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  animation: blink 1.4s ease-in-out infinite;
}

.viewer-area {
  display: block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

.viewer-title {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.btn-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.btn-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }

.viewer-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 59, 59, 0.06), transparent 65%),
    #000;
}

.viewer-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Skeleton enquanto o player carrega */
.viewer-embed.loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.05) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.viewer-foot {
  padding: 14px 16px 16px;
  margin-top: auto;
}

.btn-youtube {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border-strong);
  border-radius: 9px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-youtube:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.28); }
.btn-youtube svg { color: var(--live); }

.viewer-note {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-faint);
}

/* ---------- Dica ---------- */
.hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 800;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 15px;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(16, 18, 22, 0.88);
  border: 1px solid var(--panel-border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  white-space: nowrap;
  animation: hint-in 0.8s var(--ease) 0.6s both;
}

@keyframes hint-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.hint.hidden {
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s var(--ease);
}

.hint-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  flex-shrink: 0;
}
.hint-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 59, 59, 0.6);
  animation: pulse 2.4s ease-out infinite;
}

.hint-close {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--text-faint);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.hint-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 760px) {
  .brand {
    top: 10px;
    left: 10px;
    right: 10px;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px 9px 12px;
  }
  .brand-name { font-size: 17px; }
  .brand-sub { font-size: 10px; }
  .count-badge { font-size: 11px; padding: 5px 9px; }
  .btn-ghost span { display: none; }
  .btn-ghost { padding: 7px 9px; }

  .cam-list {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    transform: translateY(0);
  }
  .cam-list.closed { transform: translateY(calc(100% + 24px)); }

  .cam-list-head::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    margin: 0 auto 12px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.18);
  }

  .scrim.visible { display: block; }

  .viewer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 82vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    transform: translateY(0);
  }
  .viewer.closing { transform: translateY(calc(100% + 24px)); }

  .viewer-handle {
    display: grid;
    place-items: center;
    padding: 10px 0 2px;
  }
  .viewer-handle span {
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.18);
  }

  .hint {
    bottom: 16px;
    font-size: 12px;
    max-width: calc(100vw - 32px);
  }
}
