/* ============================================================
   MATADOR FIRE SENTRY — Wildfire Risk Report Design
   Dark theme with red/orange gradient-bordered cards
   ============================================================ */

:root {
  --bg: #111111;
  --bg-card: #1A1A1A;
  --border-subtle: #2A2A2A;
  --text: #F5F5F5;
  --text-secondary: #B0B0B0;
  --text-muted: #707070;
  --red: #E53935;
  --orange: #FB8C00;
  --amber: #FFB300;
  --yellow: #FDD835;
  --green: #43A047;
  --blue: #42A5F5;
  --gradient-risk: linear-gradient(90deg, #43A047 0%, #FDD835 33%, #FB8C00 66%, #E53935 100%);
  --gradient-border: linear-gradient(135deg, #E53935, #FB8C00);
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 16px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* === Alert Banner === */
.alert-banner {
  background: linear-gradient(90deg, #B71C1C, #E53935);
  color: #fff;
  text-align: center;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  animation: pulse 2s ease-in-out infinite;
}
.alert-banner.hidden { display: none; }
.alert-content { display: flex; align-items: center; justify-content: center; gap: 10px; }
.alert-icon { font-size: 20px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }

/* === Page Wrapper === */
.page-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* === Header === */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  width: 48px !important;
  height: 48px !important;
  max-width: 48px !important;
  max-height: 48px !important;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(229, 57, 53, 0.3));
}
.brand-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.header-info {
  flex: 1;
  text-align: right;
}
.header-title {
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
}
.header-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.header-dot { margin: 0 4px; }
.header-status { display: flex; align-items: center; }
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.06);
  font-size: 11px;
  font-weight: 600;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-badge.online .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-badge.stale .status-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.status-badge.offline .status-dot { background: var(--red); }

/* === Risk Card (main hero) === */
.risk-card {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
.risk-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius);
  padding: 2px;
  background: var(--gradient-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.risk-card.risk-low::before { background: linear-gradient(135deg, #43A047, #66BB6A); }
.risk-card.risk-mod::before { background: linear-gradient(135deg, #FFB300, #FB8C00); }
.risk-card.risk-high::before { background: linear-gradient(135deg, #FB8C00, #E53935); }
.risk-card.risk-extreme::before { background: linear-gradient(135deg, #E53935, #B71C1C); }

.risk-heading {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
  margin-bottom: 16px;
}
.risk-word { text-transform: lowercase; }
.risk-word.low { color: var(--green); }
.risk-word.mod { color: var(--amber); }
.risk-word.high { color: var(--orange); }
.risk-word.extreme { color: var(--red); }

/* Score badge */
.risk-score-row {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.risk-score-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
}
.risk-score-badge.low    { background: rgba(67,160,71,0.2); color: var(--green); }
.risk-score-badge.mod    { background: rgba(255,179,0,0.2); color: var(--amber); }
.risk-score-badge.high   { background: rgba(251,140,0,0.2); color: var(--orange); }
.risk-score-badge.extreme { background: rgba(229,57,53,0.2); color: var(--red); }
.risk-score-icon { font-size: 14px; }

/* Risk gradient bar */
.risk-gradient-bar {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: var(--gradient-risk);
  margin: 0 9px 20px;
}
.risk-gradient-divider {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 16px;
  background: rgba(255,255,255,0.5);
  transform: translateX(-50%);
  border-radius: 1px;
}
.risk-gradient-marker {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
  transform: translate(-50%, -50%);
  transition: left 0.8s ease;
  left: 0%;
}

/* Risk level icons row */
.risk-levels-row {
  position: relative;
  height: 80px;
  margin: 0 9px 24px;
}
.risk-level-item {
  text-align: center;
}
.risk-level-icon { font-size: 24px; margin-bottom: 4px; }
.risk-level-name { font-size: 13px; font-weight: 700; }
.risk-level-range { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.risk-level-item.low .risk-level-name { color: var(--green); }
.risk-level-item.moderate .risk-level-name { color: var(--amber); }
.risk-level-item.high .risk-level-name { color: var(--orange); }
.risk-level-item.extreme .risk-level-name { color: var(--red); }

/* Report Summary */
.report-summary {
  border-top: 1px solid var(--border-subtle);
  padding-top: 18px;
}
.summary-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}
.summary-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* === Section Headings === */
.section-heading {
  font-size: 18px;
  font-weight: 800;
  font-style: italic;
  margin-bottom: 16px;
}

/* === Sensor Grid === */
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.sensor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s;
}
.sensor-card:hover { border-color: #3A3A3A; }
.sensor-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 0;
}
.sensor-icon { font-size: 16px; }
.sensor-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  flex: 1;
}
.sensor-tag {
  font-family: var(--mono);
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all 0.3s ease;
}
.sensor-tag.live {
  background: rgba(67,160,71,0.15);
  color: var(--green);
  border: 1px solid rgba(67,160,71,0.3);
}
.sensor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px;
}
.sensor-row.three { grid-template-columns: 1fr 1fr 1fr; }
.sensor-metric { text-align: center; }
.sensor-metric.solo { padding: 16px; text-align: center; }
.sensor-metric.primary .sensor-value { color: var(--orange); font-size: 34px; }
.sensor-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}
.sensor-unit { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sensor-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; font-weight: 600; }

/* Rain widget */
.rain-since {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: var(--mono);
}
.rain-reset-btn {
  margin-top: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.rain-reset-btn:hover {
  background: rgba(229,57,53,0.15);
  color: var(--red);
  border-color: var(--red);
}

/* Sensor context blocks */
.sensor-context {
  padding: 8px 16px 4px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 8px;
}
.sensor-context-sm {
  padding: 6px 16px 4px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 6px;
}
.sensor-context-label {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
}
.sensor-context-explain {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.gas-context {
  flex: 1;
  text-align: left;
  padding-left: 12px;
}
.gas-quality {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
}
.gas-explain {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Indicator strip */
.sensor-indicator {
  height: 3px;
  background: var(--border-subtle);
  transition: background 0.5s;
}
.sensor-indicator.ok    { background: var(--green); }
.sensor-indicator.warn  { background: var(--amber); }
.sensor-indicator.alert { background: var(--orange); }
.sensor-indicator.crit  { background: var(--red); box-shadow: 0 0 10px rgba(229,57,53,0.4); }

/* AQI badges */
.aqi-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}
.aqi-badge.good    { background: rgba(67,160,71,0.15); color: var(--green); }
.aqi-badge.moderate { background: rgba(255,179,0,0.15); color: var(--amber); }
.aqi-badge.unhealthy { background: rgba(251,140,0,0.15); color: var(--orange); }
.aqi-badge.hazardous { background: rgba(229,57,53,0.15); color: var(--red); }

/* === Wind Compass === */
.sensor-body-wind {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
}
.compass {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.compass-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border-subtle);
  border-radius: 50%;
}
.compass-dir {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.compass-dir.n { top: 6px; left: 50%; transform: translateX(-50%); color: var(--red); }
.compass-dir.s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.compass-dir.e { right: 8px; top: 50%; transform: translateY(-50%); }
.compass-dir.w { left: 8px; top: 50%; transform: translateY(-50%); }
.compass-needle {
  position: absolute;
  top: 50%; left: 50%;
  width: 3px; height: 40px;
  background: linear-gradient(to top, var(--red), var(--orange));
  transform-origin: bottom center;
  transform: translate(-50%, -100%) rotate(0deg);
  border-radius: 2px;
  transition: transform 0.8s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 6px rgba(229,57,53,0.4);
}
.compass-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: var(--bg-card);
  border-radius: 50%;
  width: 56px; height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
}
.wind-val { font-size: 16px !important; }
.compass-center .sensor-unit { font-size: 9px; }
.wind-text { text-align: center; flex: 1; }
.wind-cardinal { font-size: 22px; font-weight: 900; letter-spacing: 2px; }
.wind-degrees { font-family: var(--mono); font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* === External Data Cards === */
.external-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.ext-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s;
}
.ext-card:hover { border-color: #3A3A3A; }
.ext-card.alert-active { border-color: var(--red); box-shadow: 0 0 12px rgba(229,57,53,0.15); }
.ext-card.alert-clear { border-color: var(--green); }
.ext-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 0;
}
.ext-icon { font-size: 16px; }
.ext-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  flex: 1;
}
.ext-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}
.ext-badge.green { background: rgba(67,160,71,0.15); color: var(--green); }
.ext-badge.red { background: rgba(229,57,53,0.15); color: var(--red); }
.ext-badge.amber { background: rgba(255,179,0,0.15); color: var(--amber); }
.ext-badge.orange { background: rgba(251,140,0,0.15); color: var(--orange); }
.ext-card-body { padding: 16px; }
.ext-muted { font-size: 13px; color: var(--text-muted); }

/* Alert detail */
.alert-detail { margin-bottom: 12px; }
.alert-detail:last-child { margin-bottom: 0; }
.alert-headline {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 4px;
}
.alert-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Drought bar */
.drought-county {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-family: var(--mono);
}
.drought-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--border-subtle);
  margin-bottom: 8px;
}
.drought-bar-seg { height: 100%; transition: width 0.5s ease; min-width: 0; }
.drought-bar-seg.d0 { background: #8bc34a; }
.drought-bar-seg.d1 { background: #f9c80e; }
.drought-bar-seg.d2 { background: #cc7400; }
.drought-bar-seg.d3 { background: #ff7066; }
.drought-bar-seg.d4 { background: #ed1b30; }
.drought-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.drought-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.drought-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Wind forecast metrics */
.wind-forecast-row {
  display: flex;
  gap: 24px;
  align-items: center;
}
.wind-forecast-metric { text-align: center; }
.wind-forecast-val {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}
.wind-forecast-unit { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.wind-forecast-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; font-weight: 600; }

/* === 7-Day Forecast Row === */
.forecast-row {
  display: flex;
  gap: 6px;
  margin-bottom: 32px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
  padding-bottom: 4px;
}
.fc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px 8px;
  min-width: 90px;
  flex: 1 0 90px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.3s;
}
.fc-card:hover { border-color: #3A3A3A; }
.fc-day {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.06);
  width: 100%;
  padding: 4px 0;
  border-radius: 6px;
}
.fc-temp {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.fc-icon {
  line-height: 1;
}
.fc-icon-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  object-position: center top;
  border-radius: 10px;
  clip-path: inset(2px 2px 8px 2px round 10px);
  mix-blend-mode: lighten;
  background: var(--bg-card);
}
.fc-precip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--blue);
  min-height: 16px;
}
.fc-wind {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.fc-wind-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* === Range Tabs === */
.range-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
  width: fit-content;
}
.range-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.range-tab:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.range-tab.active { background: var(--red); color: #fff; }

/* === Charts === */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.chart-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.chart-card canvas {
  width: 100% !important;
  height: 170px !important;
}

/* === Footer === */
footer {
  text-align: center;
  padding: 20px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* === Responsive === */
@media (max-width: 768px) {
  .page-wrapper { padding: 16px 12px; }
  header { flex-direction: column; text-align: center; }
  .header-info { text-align: center; }
  .risk-card { padding: 20px 16px; }
  .risk-heading { font-size: 18px; }
  .sensor-grid { grid-template-columns: 1fr !important; }
  .sensor-value { font-size: 24px; }
  .sensor-body-wind { flex-direction: column; }
  .charts-grid { grid-template-columns: 1fr !important; }
  .external-grid { grid-template-columns: 1fr !important; }
  .forecast-row { flex-wrap: nowrap; overflow-x: auto; }
  .fc-card { min-width: 80px; flex: 0 0 80px; }
  .fc-temp { font-size: 22px; }
  .fc-icon-img { width: 36px; height: 36px; }
  .wind-forecast-row { gap: 16px; }
  .wind-forecast-val { font-size: 22px; }
}
