/* ---- Base reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #000;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  /* Side / bottom safe areas (notch handled in .app-header) */
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.hidden { display: none !important; }

/* Body uses flex-column so header + grid stack neatly */
body {
  display: flex;
  flex-direction: column;
}

/* ---- Header bar ---- */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  /* push content below the notch */
  padding-top: calc(10px + env(safe-area-inset-top));
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  z-index: 1;
}

.header-address {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: 0.01em;
}

.header-live {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #4ade80;
  text-transform: uppercase;
}

.live-dot {
  font-size: 10px;
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ---- Grid view (2x2) ---- */
.grid-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  flex: 1;           /* fill remaining space below header */
  min-height: 0;     /* allow grid to shrink inside flex */
  width: 100%;
  background: #000;
  position: relative;
}

.tile {
  position: relative;
  background: #0f172a;
  overflow: hidden;
  cursor: pointer;
  transition: transform 80ms ease-out;
}
.tile:active { transform: scale(0.98); }

.tile-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
  pointer-events: none; /* clicks fall through to .tile */
}

/* ---- Tap-to-start overlay (covers grid until first user tap) ---- */
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5;
  cursor: pointer;
  transition: opacity 250ms ease-out;
}
.start-overlay.hidden { opacity: 0; pointer-events: none; }

.start-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: #e2e8f0;
  text-align: center;
}
.start-overlay-content p {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.start-overlay-content svg {
  opacity: 0.8;
}

.tile-label {
  position: absolute;
  bottom: 8px;
  left: 10px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 6px;
  pointer-events: none;
}

/* ---- Fullscreen single-camera view ---- */
.fullscreen-view {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.fullscreen-video {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #000;
  display: block;
  object-fit: contain;
}

.fullscreen-bar {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0));
  z-index: 11;
  pointer-events: none; /* let video taps pass through */
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f1f5f9;
  pointer-events: auto;
}
.back-btn:hover { background: rgba(15, 23, 42, 0.9); }

.fullscreen-label {
  font-size: 16px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ---- Landscape phone: keep 2x2 but tighter ---- */
@media (orientation: landscape) and (max-height: 500px) {
  .tile-label { font-size: 11px; padding: 3px 8px; }
}
