/* ============================================================
   India Heat Pump Atlas — CII Heat Pump Alliance
   National Installation Dashboard by CIIHPA
   Light "teal + amber" theme: a soft green-grey page, white cards,
   deep teal-ink text, teal as the primary accent with an amber
   highlight. Installed-capacity reads as a low->high scale on the
   map (teal -> amber -> red).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg:          #f1f6f4;
  --panel:       #ffffff;
  --panel-alt:   #eaf2f0;
  --line:        #d3e2de;
  --text:        #13312d;
  --text-muted:  #5b7772;
  --cool:        #0d9488;
  --warm:        #f59e0b;
  --hot:         #dc2626;
  --good:        #65a30d;
  --primary:     #0d9488;

  --shadow-sm: 0 1px 2px rgba(13,49,45,0.05), 0 1px 3px rgba(13,49,45,0.08);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cool); }

/* ---------------- Layout shell ---------------- */

/* The header is the one dark surface on an otherwise light page —
   deep CII-navy blue. */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid #05132f;
  background: linear-gradient(180deg, #082a63 0%, #041d47 100%);
  flex-wrap: wrap;
}

.app-header .brand__text h1 { color: #f4fbf9; }
.app-header .brand__tagline,
.app-header .header-status,
.app-header .header-status__note,
.app-header #last-updated { color: rgba(255,255,255,0.7); }

/* white-background logo needs a chip so it reads on the dark header */
.app-header .brand__mark {
  background: #fff;
  padding: 4px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  height: 52px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 6px;
}

.brand__org {
  margin: 0 0 1px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.brand__text h1 {
  font-family: var(--font-display);
  font-size: 1.40rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
}

.brand__tagline {
  margin: 2px 0 0;
  font-size: 0.98rem;
  color: var(--text-muted);
}

.header-partners {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #0d1f45;
  line-height: 1.2;
  background: #e8eefb;
  border: 1px solid #c3d3f2;
  border-radius: 999px;
  padding: 6px 18px;
}

.header-partners__count {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--warm);
  margin: 0 1px;
}

.header-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-status__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(101,163,13,0.7);
  animation: pulse 2s infinite;
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(101,163,13,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(101,163,13,0); }
  100% { box-shadow: 0 0 0 0 rgba(101,163,13,0); }
}

.container {
  padding: 20px 28px 48px;
  max-width: 1500px;
  margin: 0 auto;
}

/* ---------------- Filters (grouped into one card) ---------------- */

.filters-panel {
  margin-bottom: 20px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.filters select,
.filters input {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.82rem;
}

.filters select:focus,
.filters input:focus {
  outline: 2px solid var(--warm);
  outline-offset: 1px;
}

.filters label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.filters-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.btn {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.btn:hover { border-color: var(--warm); }
.btn:focus-visible { outline: 2px solid var(--warm); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }

/* Prominent primary action (Apply filters) — solid teal */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 10px 22px;
  font-size: 0.85rem;
}
.btn-primary:hover { background: #0b7c72; border-color: #0b7c72; }

/* Secondary action (Reset) — quieter, but still a full-size button */
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-muted);
  padding: 10px 20px;
  font-size: 0.85rem;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* ---------------- KPI row ---------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--kpi-tint, var(--panel));
  border: 1px solid var(--kpi-border, var(--line));
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--kpi-accent, var(--cool));
}

/* Per-box colour — each KPI owns a hue tied to the Alliance's story:
   teal = fleet size, amber = thermal energy, green = carbon avoided. */
.kpi-card--teal  { --kpi-accent:#0d9488; --kpi-tint:#e7f5f2; --kpi-border:#bfe3dc; --kpi-value:#0b7c72; }
.kpi-card--amber { --kpi-accent:#f59e0b; --kpi-tint:#fdf3e1; --kpi-border:#f3ddab; --kpi-value:#b45309; }
.kpi-card--green { --kpi-accent:#65a30d; --kpi-tint:#eef6e1; --kpi-border:#d6e8b3; --kpi-value:#4d7c0f; }

.kpi-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--kpi-value, var(--text));
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 4px;
}

.panel .panel-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 14px;
}

/* ---------------- Main grid: map | location detail ---------------- */

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

/* Short panel (only as tall as its content) that stays in view — as you
   scroll down the tall map it sticks near the top and scrolls with you.
   max-height keeps a very long sector-breakdown table scrolling inside
   its own box rather than running off-screen. */
#location-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
  #location-panel { position: static; max-height: none; }
}

/* ---------------- Key Insights (curated narrative, separate from the
   live-filtered map/KPIs above — its own tinted panel says so) -------- */

.insights-panel {
  margin-top: 18px;
  background: linear-gradient(135deg, #eaf2f0 0%, #fdf3e1 100%);
  border-color: #dde8d4;
}

/* Heading set apart from the list below it with its own rule, rather
   than just sitting flush above the first card. */
.insights-panel h2 {
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--cool);
}

.insights-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insights-list li {
  background: rgba(255,255,255,0.65);
  border-left: 4px solid var(--cool);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text);
}

.insights-list li:nth-child(1) { border-left-color: #0d9488; }
.insights-list li:nth-child(2) { border-left-color: #f59e0b; }
.insights-list li:nth-child(3) { border-left-color: #dc2626; }
.insights-list li:nth-child(4) { border-left-color: #65a30d; }
.insights-list li:nth-child(5) { border-left-color: #082a63; }

.insights-list strong {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-display);
  font-size: 0.92rem;
}

/* ---------------- Partners (logo walls) ---------------- */

.partners-panel {
  margin-top: 18px;
}

.partners-group-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 20px 0 12px;
}
.partners-group-title:first-of-type {
  margin-top: 2px;
}

.partners-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
}

.partner-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 92px;
  padding: 10px 24px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.partner-logo:hover {
  border-color: var(--cool);
  box-shadow: var(--shadow-sm);
}

.partner-logo img {
  max-height: 68px;
  max-width: 190px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sector-chips {
  margin-bottom: 12px;
}

.pullup-details summary {
  cursor: pointer;
  color: var(--cool);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ---------------- Map (ECharts, India states GeoJSON — no basemap tiles,
   so nothing outside India can ever render) ---------------- */

.map-shell {
  position: relative;
}

#india-map {
  width: 100%;
  height: 820px;
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

.map-scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(10,19,48,0.85);
  color: #fff;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 500;
  transition: opacity 0.15s ease;
}

.map-scroll-hint.is-hidden {
  opacity: 0;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* ECharts tooltip content (see buildPinCallout in dashboard.js) — the
   tooltip's own background/border comes from the `tooltip` option in JS. */
.pin-popup strong { font-family: var(--font-display); font-size: 0.95rem; }
.pin-popup__sector { color: var(--text-muted); font-size: 0.75rem; margin: 2px 0 6px; }
.pin-popup ul { list-style: none; margin: 0; padding: 0; font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.6; }

/* ---------------- Location pull-up content ---------------- */

.state-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 2px;
}

.state-region {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stat-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-list li {
  background: var(--panel-alt);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-list .stat-num {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  display: block;
}

.stat-list .stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.74rem;
  margin: 0 6px 6px 0;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 30px 10px;
  text-align: center;
}

/* ---------------- Table (sector breakdown, inside the pull-up) ---------------- */

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
}

tbody tr:hover { background: var(--panel-alt); }

footer.app-footer {
  border-top: 1px solid var(--line);
  background: linear-gradient(0deg, #ffffff 0%, #ecf4f2 100%);
  padding: 22px 28px;
  margin-top: 12px;
}

.footer-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-brand .brand__mark {
  height: 34px;
  width: auto;
}

.footer-brand__org {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.footer-brand__tagline {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.footer-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
}

@media (max-width: 640px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .footer-meta { align-items: flex-start; text-align: left; }
}

/* ---------------- Scroll-to-top button ---------------- */

.scroll-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(13,49,45,0.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, background 0.15s ease;
  z-index: 900;
}

.scroll-top:hover { background: #0b7c72; }
.scroll-top:focus-visible { outline: 2px solid var(--warm); outline-offset: 2px; }

.scroll-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
