/* Home page — fixed viewport, scroll only district list */

.home-app {
  height: calc(100vh - var(--chrome-h));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.home-hero {
  background: var(--fao-blue-light);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  flex-shrink: 0;
}

.home-hero-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.home-hero h1 { font-size: 1.05rem; font-weight: 700; color: var(--fao-blue-dark); }
.home-hero p { font-size: 0.78rem; color: var(--text-secondary); }

.home-alert-badges { display: flex; gap: 8px; flex-wrap: wrap; }

.alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.alert-pill.severe { background: rgba(200,64,64,0.1); color: var(--prelim-red); border: 1px solid rgba(200,64,64,0.3); }

.home-layout {
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 24px 14px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  overflow: hidden;
}

.home-map-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.home-map-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--panel-bg);
  z-index: 2;
}

.home-map-header h2 { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.home-map-header .period { font-size: 0.76rem; color: var(--text-secondary); }

.home-map-body {
  flex: 1;
  position: relative;
  min-height: 0;
}

#home-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.home-map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 400;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.7rem;
  box-shadow: var(--shadow-sm);
}

.home-map-legend strong {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.home-map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.home-map-legend .legend-swatch {
  display: inline-block;
  width: 14px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.home-map-cta {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 400;
}

.home-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.assessment-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.assessment-card h3 { font-size: 0.82rem; font-weight: 700; color: var(--fao-blue-dark); margin-bottom: 6px; }
.assessment-card p { font-size: 0.74rem; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.45; }

.stat-pills { display: flex; flex-direction: column; gap: 6px; }

.stat-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.stat-pill .sp-label { font-size: 0.72rem; font-weight: 600; }
.stat-pill .sp-value { font-size: 1.15rem; font-weight: 700; }
.stat-pill.extreme { background: rgba(123,0,0,0.06); border-color: var(--cdi-extreme); }
.stat-pill.extreme .sp-value { color: var(--cdi-extreme); }
.stat-pill.severe-total { background: rgba(200,64,64,0.06); }
.stat-pill.severe-total .sp-value { color: var(--cdi-severe); }
.stat-pill.improving { background: rgba(0,160,0,0.06); }
.stat-pill.improving .sp-value { color: var(--cdi-normal); }

.district-stress-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.district-stress-card h3 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fao-blue-dark);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.stress-list {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.stress-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.stress-item.is-open { background: var(--fao-blue-light); margin: 0 -6px; padding: 8px 6px; border-radius: 4px; }
.stress-item:last-child { border-bottom: none; }

.stress-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.65rem;
}
.stress-map-link {
  color: var(--fao-blue);
  font-weight: 600;
  text-decoration: none;
}
.stress-map-link:hover { text-decoration: underline; }
.stress-detail-panel { margin-top: 6px; }

.stress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.stress-name-row { display: flex; align-items: center; gap: 8px; }

.stress-rank {
  width: 18px; height: 18px;
  background: var(--fao-blue-light);
  color: var(--fao-blue-dark);
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stress-name { font-size: 0.76rem; font-weight: 600; }
.stress-value { font-size: 0.76rem; font-weight: 700; }

.stress-bar {
  height: 8px;
  background: #e8e8e8;
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  margin-bottom: 2px;
}
.stress-bar-seg { height: 100%; }

.stress-meta { font-size: 0.65rem; color: var(--text-muted); }

@media (max-width: 1000px) {
  .home-app { height: auto; overflow: visible; }
  .home-layout { grid-template-columns: 1fr; overflow: visible; }
  .home-map-card { min-height: 380px; height: auto; }
  .district-stress-card { max-height: 360px; }
}

@media (max-width: 600px) {
  .home-layout { padding: 10px 12px; }
  .home-map-card { min-height: 320px; }
}
