/* dashboard.css — styles for dashboard.html (the "data centers & the world"
 * charts dashboard). Builds on css/seo.css (shared header/footer + :root tokens).
 * Chart-card grid, KPI tiles, tabs, cited tables, the impact map, market cards. */

.dash-main { max-width: 1280px; margin: 0 auto; padding: 28px 22px 64px; }
.dash-hero h1 { max-width: 22ch; margin-bottom: 10px; }
.dash-hero .lede { margin-bottom: 6px; }
.dash-byline { font-size: 13px; color: var(--text-dim); margin: 4px 0 18px; }
.dash-byline .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: middle; box-shadow: 0 0 8px rgba(56, 232, 200, 0.7); }

.banner-warn {
  background: rgba(255, 122, 89, 0.1); border: 1px solid rgba(255, 122, 89, 0.4);
  color: #ffd9cc; padding: 12px 16px; border-radius: 12px; margin: 12px 0; font-size: 14px;
}

/* ---- Headline KPI grid ---- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin: 22px 0 8px;
}
.kpi {
  background: linear-gradient(180deg, rgba(56, 232, 200, 0.06), rgba(106, 166, 255, 0.03));
  border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 3px;
}
.kpi-v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--text);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-k { font-size: 13px; font-weight: 600; color: #c4ccde; line-height: 1.35; }
.kpi-s { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.kpi.small { background: var(--panel); padding: 14px; }
.kpi.small .kpi-v { font-size: 22px; }
.kpi.warn .kpi-v { background: linear-gradient(135deg, #ff7a7a, #ffb27a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.dash-note {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12.5px; color: var(--text-dim); line-height: 1.55;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 12px 14px; margin: 14px 0 6px;
}
.dash-note b { color: #c4ccde; }

/* ---- Tabs ---- */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 22px 0 6px;
  position: sticky; top: var(--header-h, 57px); z-index: 11;
  padding: 10px 0; background: rgba(10, 14, 26, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--panel-border);
}
.tab-btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-dim);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--panel-border); background: var(--panel);
}
.tab-btn:hover { color: var(--text); border-color: rgba(56, 232, 200, 0.4); }
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-btn.active {
  color: #04121a; border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-weight: 700;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tab-intro { font-size: 14.5px; color: #b9c2d6; max-width: 90ch; margin: 18px 0 8px; line-height: 1.6; }
.tab-intro .est { color: var(--accent); font-weight: 600; }

/* ---- Chart-card grid ---- */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 14px; }
.chart-card {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 16px 16px 12px; min-width: 0;
}
.chart-card.card-wide { grid-column: 1 / -1; }
.chart-head h3 { font-size: 15.5px; margin: 0 0 2px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.chart-sub { font-size: 12.5px; color: var(--text-dim); margin: 0 0 10px; line-height: 1.4; }
.chart-box { position: relative; height: 300px; }
.card-body { margin-top: 4px; }
.loading { font-size: 13px; color: var(--text-dim); padding: 8px 2px; }

/* ---- Citations ---- */
.cite { margin-top: 10px; padding-top: 9px; border-top: 1px dashed rgba(255, 255, 255, 0.08);
  font-size: 11.5px; color: var(--text-dim); line-height: 1.5; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.cite-tag { font-size: 9.5px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid rgba(56, 232, 200, 0.3); border-radius: 5px; padding: 1px 6px; }
.cite-body a { color: var(--accent-2); }
.cite-body a:hover { color: var(--accent); }
.cite-sep { color: rgba(255, 255, 255, 0.2); }

/* ---- Anchors (cited stat cards) ---- */
.anchor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.anchor { background: linear-gradient(180deg, rgba(74, 168, 255, 0.06), rgba(15, 20, 36, 0)); border: 1px solid var(--panel-border); border-radius: 12px; padding: 16px; }
.anchor-v { font-size: 17px; font-weight: 700; color: var(--water); line-height: 1.3; }
.anchor-k { font-size: 13px; color: #c4ccde; margin: 6px 0; line-height: 1.45; }
.anchor-src a { font-size: 12px; color: var(--accent-2); }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th { text-align: left; padding: 9px 12px; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }
.dash-table td { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: top; color: #c4ccde; }
.dash-table tr:hover td { background: rgba(255, 255, 255, 0.025); }
.dash-table .t-strong { color: var(--text); font-weight: 600; }
.dash-table .t-src { font-size: 12px; }
.dash-table .t-src a { color: var(--accent-2); }

/* ---- Impact map ---- */
.impact-map-wrap { position: relative; }
#impact-map { height: 460px; border-radius: 12px; overflow: hidden; border: 1px solid var(--panel-border); background: #0b1020; }
.map-legend-dash {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: calc(100% - 24px);
  background: rgba(10, 14, 26, 0.85); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 8px 11px; font-size: 11.5px; color: #c4ccde; backdrop-filter: blur(6px);
}
.map-legend-dash span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend-dash i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leaflet-popup-content-wrapper { background: #0f1424; color: var(--text); border: 1px solid var(--panel-border); border-radius: 12px; }
.leaflet-popup-tip { background: #0f1424; }
.pop { max-width: 240px; font-size: 13px; }
.pop-cat { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.pop-title { font-weight: 700; margin: 3px 0; color: var(--text); }
.pop-place { font-size: 12px; color: var(--text-dim); }
.pop-metric { font-size: 12.5px; margin-top: 6px; color: #c4ccde; }
.pop-src { margin-top: 7px; font-size: 12px; }
.pop-src a { color: var(--accent-2); }

/* ---- Market cards ---- */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.market-card { background: var(--bg-2); border: 1px solid var(--panel-border); border-left: 4px solid var(--slate); border-radius: 12px; padding: 14px; }
.market-move { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.market-head { font-size: 13.5px; color: var(--text); font-weight: 600; margin: 6px 0 4px; line-height: 1.4; }
.market-meta { font-size: 12px; color: var(--text-dim); }
.market-src { margin-top: 7px; font-size: 12px; }
.market-src a { color: var(--accent-2); }

/* ---- Method / sources ---- */
.method { margin-top: 36px; }
.method > summary { cursor: pointer; font-weight: 700; font-size: 16px; color: var(--text); padding: 14px 0; list-style: none; border-top: 1px solid var(--panel-border); }
.method > summary::-webkit-details-marker { display: none; }
.method > summary::after { content: "+"; float: right; color: var(--text-dim); }
.method[open] > summary::after { content: "–"; }
.method-body { font-size: 14px; color: #c4ccde; line-height: 1.65; }
.method-body h4 { color: var(--text); margin: 18px 0 6px; font-size: 14.5px; }
.method-body code { background: rgba(255, 255, 255, 0.06); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
.source-list { columns: 2; column-gap: 28px; font-size: 13px; margin-top: 8px; padding-left: 18px; }
.source-list li { margin: 4px 0; break-inside: avoid; }
.source-list a { color: var(--accent-2); }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .card-grid { grid-template-columns: 1fr; }
  .source-list { columns: 1; }
  #impact-map { height: 320px; }
  /* Dock the map legend below the map rather than floating over the markers. */
  .map-legend-dash { position: static; margin-top: 8px; max-width: none; }
}

/* Designer polish: KPI grid on big/small screens + anchored-scroll offset */
@media (min-width: 1600px) { .kpi-grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 480px) { .kpi-grid { grid-template-columns: 1fr 1fr; } .kpi-v { font-size: 22px; } }
.tab-panel { scroll-margin-top: 120px; }
