/* css/app.css — App layout and chrome (CIAS Module 1 scaffold) */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--ground);
  color: var(--primary);
  line-height: 1.6;
  overflow: hidden;
}

/* -- Focus styles for keyboard navigation -- */
:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* -- App grid -- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--ground-deep);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.top-bar__title {
  font-weight: 700;
  font-size: 0.88em;
  letter-spacing: -0.02em;
}

.top-bar__date {
  font-size: 0.7em;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* -- Main content area -- */
.main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* -- Map area -- */
.map-container {
  flex: 65;
  position: relative;
  background: var(--ground);
}

#map {
  width: 100%;
  height: 100%;
}

/* -- KPI strip (overlaid on map bottom) -- */
.kpi-strip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--frosted);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 1000;
}

.kpi {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.kpi:last-child { border-right: none; }

.kpi__value {
  font-family: var(--font-mono);
  font-size: 1.5em;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.kpi__label {
  font-size: 0.6em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.kpi__bar {
  width: 70%;
  margin: 4px auto 0;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-hover);
  overflow: hidden;
}

.kpi__bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease-out;
}

/* -- KPI strip overflow on narrow viewports — let cards scroll horizontally
      instead of compressing into illegible slivers. -- */
.kpi-strip {
  overflow-x: auto;
  scrollbar-width: thin;
}

.kpi { min-width: 9.5rem; }

.kpi__critical {
  margin-top: 4px;
  font-size: 0.58em;
  letter-spacing: 0.3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* -- Threshold strip (slider control, positioned above KPI strip) -- */
.threshold-strip {
  position: absolute;
  bottom: 80px;
  left: 16px;
  right: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(20, 18, 16, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  z-index: 999;
  font-size: 0.78em;
  color: var(--primary);
}

.threshold-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--secondary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-size: 0.95em;
}

.threshold-label .mono {
  color: var(--copper);
  font-size: 1.05em;
  font-variant-numeric: tabular-nums;
}

#critical-slider {
  width: 100%;
  accent-color: var(--copper);
}

/* -- Context panel -- */
.panel {
  flex: 35;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.panel__header {
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

.panel__title {
  font-weight: 700;
  font-size: 1em;
}

.panel__content {
  flex: 1;
  overflow-y: auto;
}

/* -- Utility -- */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

/* -- Tablet responsive -- */
@media (max-width: 1024px) {
  .main { flex-direction: column; }
  .map-container { flex: 1; }
  .panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 40vh; border-top: 1px solid var(--border);
    border-left: none; border-radius: var(--radius) var(--radius) 0 0;
    z-index: 150;
  }
  .kpi-strip { font-size: 0.85em; }
  .kpi__value { font-size: 1.2em; }
  .threshold-strip { bottom: 74px; left: 8px; right: 8px; font-size: 0.72em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
