/* smart-cities.css — layout for the city-district capability-tour dashboard. Brand
   tokens come from engine.css. Mirrors energy.css/factory.css's conventions (scene-hero
   section + detail-heading + the same panel/grid/kpi/actions rules) so every
   capability-tour demo shares one differentiated layout. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bq-bg);
  color: var(--bq-text);
  font-family: var(--bq-font);
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--bq-orange), var(--bq-orange-soft));
  box-shadow: 0 0 18px rgba(241, 182, 33, 0.5);
  flex: 0 0 auto;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.brand-name span { color: var(--bq-orange); }
.brand-sub { font-size: 11px; color: var(--bq-muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.clock { font-variant-numeric: tabular-nums; color: var(--bq-muted); font-size: 13px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--bq-ok);
  border: 1px solid rgba(47, 191, 113, 0.4);
  border-radius: 999px; padding: 4px 10px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bq-ok);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---- hero scene ---- */
.scene-hero-section {
  margin: 2px 0 4px;
}

/* Chapter 2's geofence-pulse (the faulty streetlight, stuck on / wasting power)
   reads amber/warning rather than the engine's default critical-red ring — an
   early, non-alarming flag suits "wasting power" better than a red intrusion-style
   alarm. Scoped to this demo's own first effect zone only (data-zone="0" as
   authored in index.html/embed's effectZones array); chapter 3's parking-lot
   geofence (zone 1) and chapter 4's air-quality zone (zone 2) keep their own
   scoped treatments below. This is a demo-side CSS override, not an engine.css edit. */
.scene-effect-zone[data-zone="0"] .scene-geofence-ring {
  border-color: var(--bq-warning);
}
.scene-effect-zone[data-zone="0"] .scene-geofence-ring {
  animation-name: scene-geofence-pulse-amber;
}
@keyframes scene-geofence-pulse-amber {
  0% { opacity: 0.9; transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.5); }
  100% { opacity: 0; transform: scale(1.08); box-shadow: 0 0 24px 6px rgba(245, 166, 35, 0); }
}

/* Chapter 3's geofence-pulse (Market Street Parking Lot filling up) — same amber,
   non-alarming treatment as zone 0 above (a filling lot is a heads-up, not a fault). */
.scene-effect-zone[data-zone="1"] .scene-geofence-ring {
  border-color: var(--bq-warning);
  animation-name: scene-geofence-pulse-amber;
}

/* ---- detail section heading ---- */
.detail-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--bq-border);
}
.detail-heading h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}
.detail-heading .panel-hint {
  font-size: 12px;
}

/* ---- KPI row ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* ---- main grid ---- */
.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-auto-rows: auto;
  gap: 12px;
}
.panel {
  background: var(--bq-panel);
  border: 1px solid var(--bq-border);
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.panel-hint { font-size: 11px; color: var(--bq-faint); }
.scope { color: var(--bq-muted); font-weight: 400; font-size: 12px; }

.panel-main { grid-column: 1; grid-row: 1; }
.panel-side { grid-column: 2; grid-row: 1; }
.panel-alerts { grid-column: 2; grid-row: 2 / span 2; display: flex; flex-direction: column; }
.panel-devices { grid-column: 1; }

.chart-lg { width: 100%; height: 260px; }
.chart-md { width: 100%; height: 150px; }
.chart-gauge { width: 100%; height: 260px; }

.alert-scroll { flex: 1 1 auto; max-height: 420px; overflow-y: auto; }
.device-scroll { max-height: 190px; overflow-y: auto; }

/* actions */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  font-family: inherit; font-size: 12px; font-weight: 600;
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--bq-border); background: var(--bq-elevated); color: var(--bq-text);
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--bq-orange); border-color: var(--bq-orange); color: var(--bq-on-accent); }
.btn-primary:hover { background: var(--bq-orange-soft); }
.btn-ghost { background: transparent; color: var(--bq-orange); border-color: var(--bq-orange); }
.btn-ghost:hover { background: rgba(241, 182, 33, 0.12); }

/* legend */
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--bq-muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---- responsive: stack cleanly, no horizontal scroll at 375px ---- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .panel-main, .panel-side, .panel-alerts, .panel-devices { grid-column: 1 !important; grid-row: auto !important; }
  .panel-alerts { grid-row: auto; }
}
@media (max-width: 560px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .chart-lg { height: 220px; }
  .chart-gauge { height: 220px; }
  /* keep long KPI labels from overflowing narrow cards */
  .bq-kpi { padding: 12px; overflow: hidden; }
  .bq-kpi .kpi-label { letter-spacing: 0.02em; font-size: 11px; }
  .bq-kpi .kpi-value-row { min-width: 0; }
  .panel-head h2 { font-size: 13px; }
}
@media (max-width: 375px) {
  .app { padding: 10px; }
  .bq-kpi .kpi-value { font-size: 20px; }
  .btn { padding: 6px 10px; }
}
