/* RiskCheck — visual system per docs/DESIGN.md.
   Dark analytical interface: charcoal / blue-black foundation, electric-blue
   brand accent, restrained semantic risk colors, thin borders, compact
   analytical panels. Not neon, not cyberpunk, not a government portal. */

:root {
  --background: #0b1118;
  --surface-1: #111922;
  --surface-2: #16212c;
  --surface-3: #1b2733;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #f3f6f8;
  --text-secondary: #9ca8b4;
  --text-muted: #697682;

  --accent: #2f73ff;
  --accent-hover: #4a86ff;

  /* Semantic risk colors — data colors, not branding. Used for small status
     text, icons, percentile markers, small bars only. Never flood a panel. */
  --risk-verylow: #4c9be6;   /* Very Low -> blue */
  --risk-low: #35b37e;       /* Relatively Low -> green */
  --risk-moderate: #d9a534;  /* Relatively Moderate -> amber */
  --risk-high: #e07a3c;      /* Relatively High -> orange */
  --risk-veryhigh: #dc5b5b;  /* Very High -> red */
  --risk-none: var(--text-muted);

  --radius: 8px;
  --radius-sm: 6px;
  --maxw: 1080px;

  --font: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  /* Faint topographic / map-line texture behind everything — technical
     annotation, not decoration (DESIGN.md "Geography as visual identity"). */
  background-image:
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(255, 255, 255, 0.012) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(255, 255, 255, 0.012) 39px 40px);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.tabular { font-variant-numeric: tabular-nums; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 24, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 58px;
}
.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
}
.brand .dot { color: var(--accent); }
.site-header nav {
  margin-left: auto;
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- hero / homepage ---------- */
.hero {
  padding: 88px 0 72px;
  text-align: center;
}
.hero h1 {
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  font-weight: 600;
}
.hero h1 .accent { color: var(--accent); }
.hero p.lead {
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 32px;
  font-size: 16px;
}

.search {
  display: flex;
  gap: 10px;
  max-width: 620px;
  margin: 0 auto;
  align-items: stretch; /* button matches the input's height */
}
.search-field {
  position: relative;
  flex: 1;
  display: flex; /* let the input fill the field's stretched height */
}
.search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
}

/* address typeahead dropdown */
.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  text-align: left;
  max-height: 280px;
  overflow-y: auto;
}
.suggest li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest li[aria-selected="true"],
.suggest li:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}
.suggest li .pin {
  color: var(--text-muted);
  margin-right: 8px;
  font-size: 12px;
}
.search button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0 22px;
  min-height: 49px; /* fallback so it never collapses shorter than the input */
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.search button:hover { background: var(--accent-hover); }
.search button:disabled { opacity: 0.55; cursor: default; }

.hero .sub {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.hero-points {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 72px;
  text-align: left;
}
.hero-points .pt {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface-1);
}
.hero-points .pt h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}
.hero-points .pt p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- report ---------- */
.report { padding: 32px 0 64px; }

.report-head { margin-bottom: 24px; }
.report-head h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.report-head .geo {
  color: var(--text-secondary);
  font-size: 13px;
}
.report-head .geo .tabular { color: var(--text-muted); }

.label {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  font-weight: 600;
}

/* summary metric row */
.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  padding: 12px 14px;
}
.metric .label { display: block; margin-bottom: 6px; }
.metric .value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.metric .value.tabular { font-size: 18px; }

/* panels */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  padding: 20px;
  margin-bottom: 20px;
}
.panel > .label { display: block; margin-bottom: 16px; }

.panel-split {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
}
.panel-split .why h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}
.panel-split .why p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* risk profile bars */
.hazbar {
  display: grid;
  grid-template-columns: 130px 1fr 46px 96px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}
.hazbar + .hazbar { border-top: 1px solid var(--border); }
.hazbar .hname { font-size: 13px; color: var(--text-secondary); }
.hazbar .rail {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
}
.hazbar .rail .fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 3px;
}
.hazbar .hscore {
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hazbar .hrating {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: right;
  font-weight: 600;
}

.scale-row {
  display: grid;
  grid-template-columns: 130px 1fr 46px 96px;
  gap: 12px;
  margin-top: 8px;
}
.scale-row .scale {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* real-world context cards */
.context-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.ctx {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 14px;
}
.ctx .label { display: block; margin-bottom: 8px; }
.ctx .big {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.ctx .meta { font-size: 12px; color: var(--text-secondary); }
.ctx .precision {
  margin-top: 10px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* all hazards table */
.haz-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.haz-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
}
.haz-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.haz-table .rating-cell {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.haz-table .pctl-rail {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  position: relative;
  min-width: 120px;
}
.haz-table .pctl-rail .marker {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 9px;
  background: var(--accent);
}
.haz-table tr.not-applicable td { color: var(--text-muted); }

/* honesty / framing block */
.framing {
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  padding: 14px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}
.data-warn {
  border-left-color: var(--risk-moderate);
}

.source-footer {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* loading */
.loading {
  padding: 64px 0;
  text-align: center;
  color: var(--text-secondary);
}
.loading .stages {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 13px;
  margin-top: 12px;
}
.loading .stages span { color: var(--text-muted); }
.loading .stages span.done { color: var(--text-secondary); }

.error-box {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  padding: 18px;
  color: var(--text-secondary);
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .hero { padding: 56px 0 40px; }
  .hero h1 { font-size: 30px; }
  .search { flex-direction: column; }
  .search button { padding: 12px; }
  .hero-points { grid-template-columns: 1fr; margin-top: 44px; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .panel-split { grid-template-columns: 1fr; }
  .context-grid { grid-template-columns: 1fr; }
  .hazbar { grid-template-columns: 92px 1fr 38px; }
  .hazbar .hrating { display: none; }
  .scale-row { grid-template-columns: 92px 1fr 38px; }
}
