/* ===========================================================
   GroundTruth — Design System
   Crisis intelligence built on verified human reports.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap');

:root {
  /* Surfaces — calibrated charcoal hierarchy */
  --bg: #0A0A0B;
  --bg-elevated: #111114;
  --surface: #16161A;
  --surface-2: #1C1C22;
  --surface-3: #24242B;
  --border: #2A2A33;
  --border-strong: #3A3A45;

  /* Text */
  --text: #FAFAF9;
  --text-muted: #A1A1AA;
  --text-faint: #6B6B73;

  /* Accent — singular warm amber for action/attention */
  --accent: #F5A524;
  --accent-dim: rgba(245, 165, 36, 0.12);
  --accent-glow: rgba(245, 165, 36, 0.18);

  /* Functional */
  --verify: #34D399;
  --verify-dim: rgba(52, 211, 153, 0.12);
  --danger: #F87171;
  --danger-dim: rgba(248, 113, 113, 0.12);
  --info: #60A5FA;
  --info-dim: rgba(96, 165, 250, 0.12);

  /* Damage grade chroma — EMS-98 mapped */
  --d1: #84CC16;  /* G1 negligible */
  --d2: #FACC15;  /* G2 moderate */
  --d3: #FB923C;  /* G3 substantial */
  --d4: #F87171;  /* G4 very heavy */
  --d5: #B91C1C;  /* G5 destruction */

  /* Type */
  --font-sans: 'Geist', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', monospace;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-2xl: 32px;

  /* Shadows — diffusion */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 20px 48px -16px rgba(0, 0, 0, 0.7);
  --shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

::selection {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ===========================================================
   Scrollbar
   =========================================================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ===========================================================
   Typography
   =========================================================== */
.font-mono { font-family: var(--font-mono); }
.font-sans { font-family: var(--font-sans); }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.display {
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.98;
}

.h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

p {
  margin: 0;
  color: var(--text-muted);
}

/* ===========================================================
   Buttons
   =========================================================== */
.btn {
  --bg-btn: var(--surface-2);
  --color-btn: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  background: var(--bg-btn);
  color: var(--color-btn);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s var(--ease-out);
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(0.5px) scale(0.98);
}

.btn-primary {
  --bg-btn: var(--accent);
  --color-btn: #1A1208;
  border-color: transparent;
  box-shadow: var(--shadow-inner), 0 8px 20px -8px var(--accent-glow);
}

.btn-primary:hover {
  --bg-btn: #FFB73D;
  border-color: transparent;
}

.btn-ghost {
  --bg-btn: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  --bg-btn: var(--surface);
  border-color: var(--border);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

.btn-lg {
  height: 48px;
  padding: 0 22px;
  font-size: 15px;
}

/* ===========================================================
   Cards / Surfaces
   =========================================================== */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-inner);
}

.surface-flat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* ===========================================================
   Pills / Chips / Tags
   =========================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chip-verify {
  background: var(--verify-dim);
  border-color: rgba(52, 211, 153, 0.22);
  color: var(--verify);
}

.chip-warn {
  background: var(--accent-dim);
  border-color: rgba(245, 165, 36, 0.22);
  color: var(--accent);
}

.chip-danger {
  background: var(--danger-dim);
  border-color: rgba(248, 113, 113, 0.22);
  color: var(--danger);
}

.chip-info {
  background: var(--info-dim);
  border-color: rgba(96, 165, 250, 0.22);
  color: var(--info);
}

/* Damage chips */
.chip-g1 { background: rgba(132, 204, 22, 0.1); color: var(--d1); border-color: rgba(132, 204, 22, 0.22); }
.chip-g2 { background: rgba(250, 204, 21, 0.1); color: var(--d2); border-color: rgba(250, 204, 21, 0.22); }
.chip-g3 { background: rgba(251, 146, 60, 0.1); color: var(--d3); border-color: rgba(251, 146, 60, 0.22); }
.chip-g4 { background: rgba(248, 113, 113, 0.1); color: var(--d4); border-color: rgba(248, 113, 113, 0.22); }
.chip-g5 { background: rgba(185, 28, 28, 0.15); color: #FCA5A5; border-color: rgba(185, 28, 28, 0.3); }

/* ===========================================================
   Pulse / Status
   =========================================================== */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--verify);
  position: relative;
  flex-shrink: 0;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background: var(--verify);
  opacity: 0.4;
  animation: pulse 2s var(--ease-out) infinite;
}

.pulse-dot.warn { background: var(--accent); }
.pulse-dot.warn::after { background: var(--accent); }
.pulse-dot.danger { background: var(--danger); }
.pulse-dot.danger::after { background: var(--danger); }

@keyframes pulse {
  0%   { transform: scale(0.7); opacity: 0.6; }
  70%  { transform: scale(2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ===========================================================
   Form inputs
   =========================================================== */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.field-help {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea,
select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s var(--ease-out), background 0.18s var(--ease-out);
}

textarea {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  min-height: 96px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background: var(--surface);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

/* ===========================================================
   Layout helpers
   =========================================================== */
.container-x {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.divider-v {
  width: 1px;
  align-self: stretch;
  background: var(--border);
}

/* ===========================================================
   Map — Leaflet overrides
   =========================================================== */
.leaflet-container {
  background: #0F0F12 !important;
  font-family: var(--font-sans) !important;
}

.leaflet-tile {
  filter: brightness(0.6) saturate(0.7) contrast(1.05) hue-rotate(180deg) invert(0.92);
}

.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-family: var(--font-mono) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
}

.leaflet-control-attribution {
  background: rgba(10, 10, 11, 0.7) !important;
  color: var(--text-faint) !important;
  font-size: 10px !important;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a {
  color: var(--text-muted) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

/* ===========================================================
   Animations
   =========================================================== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.shimmer {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-2) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 8px rgba(245, 165, 36, 0); }
}

.fadein {
  animation: fadeUp 0.5s var(--ease-out) backwards;
}

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

/* ===========================================================
   Grid background utility
   =========================================================== */
.grid-bg {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
}

/* ===========================================================
   Noise overlay (fixed, pointer-events none)
   =========================================================== */
.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===========================================================
   Logo lockup
   =========================================================== */
.logo-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo-mark svg { flex-shrink: 0; }

/* ===========================================================
   Utility
   =========================================================== */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.accent { color: var(--accent); }
.verify { color: var(--verify); }
.danger { color: var(--danger); }
.info { color: var(--info); }

.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* RTL support */
[dir="rtl"] .reverse-rtl { flex-direction: row-reverse; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
