/* ============================================================
   AQI Dashboard — 概念 E:天空渐变 + 玻璃拟态 bento
   签名元素:背景天空随当前 AQI 等级变化(sky-* 类挂在 body 上)
   ============================================================ */

:root {
  --ink-1: #22303f;
  --ink-2: #46586e;
  --ink-3: #67788d;
  --accent: #177a54;
  --accent-2: #3566c2;
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-line: rgba(255, 255, 255, 0.65);
  --glass-shadow: 0 10px 34px rgba(45, 66, 90, 0.14);
  --radius: 22px;
  --radius-sm: 14px;
  --font-sans: "Inter", "Noto Sans SC", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* AQI 等级语义色(GB 3095 六级,按浅色玻璃面微调) */
  --lv-you: #2e9e5b;    --lv-you-text: #1c7a44;    --lv-you-bg: rgba(46, 158, 91, 0.14);
  --lv-liang: #d9a514;  --lv-liang-text: #8f6900;  --lv-liang-bg: rgba(217, 165, 20, 0.16);
  --lv-qing: #e8862e;   --lv-qing-text: #a75612;   --lv-qing-bg: rgba(232, 134, 46, 0.16);
  --lv-zhong: #d84c3b;  --lv-zhong-text: #a32c1f;  --lv-zhong-bg: rgba(216, 76, 59, 0.15);
  --lv-zhongd: #8e4fb8; --lv-zhongd-text: #6c2f96; --lv-zhongd-bg: rgba(142, 79, 184, 0.15);
  --lv-yan: #973b52;    --lv-yan-text: #7a2740;    --lv-yan-bg: rgba(151, 59, 82, 0.15);

  --ok: #1c7a44;
  --warn: #a75612;
  --bad: #a32c1f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--ink-1);
  min-height: 100vh;
  background: linear-gradient(180deg, #8fc3ef 0%, #bfdcf4 38%, #f6d9bc 78%, #f9e4cc 100%);
  background-attachment: fixed;
}

/* —— 天空签名:等级变奏 —— */
body.sky-you    { background: linear-gradient(180deg, #8fc3ef 0%, #bfdcf4 38%, #f6d9bc 78%, #f9e4cc 100%); background-attachment: fixed; }
body.sky-liang  { background: linear-gradient(180deg, #9dbfe0 0%, #c9d8e4 40%, #f0d3a2 80%, #f3ddb4 100%); background-attachment: fixed; }
body.sky-qing   { background: linear-gradient(180deg, #a9b6c4 0%, #ccc9bd 42%, #e6c391 80%, #e9cd9f 100%); background-attachment: fixed; }
body.sky-zhong  { background: linear-gradient(180deg, #9aa3b0 0%, #bab3a4 45%, #d5ad80 82%, #d9b489 100%); background-attachment: fixed; }
body.sky-zhongd { background: linear-gradient(180deg, #868e9c 0%, #a89f93 45%, #c09a72 82%, #c4a17c 100%); background-attachment: fixed; }
body.sky-yan    { background: linear-gradient(180deg, #767d8a 0%, #948b81 48%, #ab8763 84%, #b08e6d 100%); background-attachment: fixed; }

/* 实拍天空层:渐变打底,当前等级照片加载完成后淡入(js 控制) */
.sky-photo {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-size: cover;
  background-position: center bottom;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.sky-photo.on { opacity: 1; }
.sky-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04) 42%, rgba(255, 255, 255, 0.16));
}
@media (prefers-reduced-motion: reduce) {
  .sky-photo { transition: none; }
}
body.photo-on::before { display: none; }
/* 重度/严重的深色天空下,提高卡片不透明度保住可读性 */
body.sky-zhongd .card, body.sky-yan .card,
body.sky-zhongd .hcard, body.sky-yan .hcard { background: var(--glass-bg-strong); }

/* 云层(纯 CSS,轻量) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42% 16% at 18% 22%, rgba(255, 255, 255, 0.5), transparent 70%),
    radial-gradient(36% 13% at 74% 14%, rgba(255, 255, 255, 0.42), transparent 70%),
    radial-gradient(50% 15% at 55% 40%, rgba(255, 255, 255, 0.3), transparent 72%),
    radial-gradient(60% 20% at 30% 88%, rgba(255, 244, 228, 0.45), transparent 75%);
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
}
.topbar-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink-1);
  min-width: 0;
}
.brand-logo { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand-t1 { font-size: 16px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.brand-t2 { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.warn { color: var(--warn); border-color: rgba(167, 86, 18, 0.3); }
.pill.warn .dot { background: var(--warn); }
a.pill { text-decoration: none; transition: background 0.15s; }
a.pill:hover { background: rgba(255, 255, 255, 0.85); }
a.pill .arrow { font-weight: 600; }

/* ============ 主网格 ============ */
.dash {
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 20px 10px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  padding: 18px 20px;
  min-width: 0;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card { transition: transform 0.16s ease, box-shadow 0.16s ease; }
  .card:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(45, 66, 90, 0.18); }
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin-bottom: 12px;
}
.card-title .spacer { margin-left: auto; }
.card-title .hint { font-weight: 400; font-size: 11px; color: var(--ink-3); }

/* 区块定位 */
.card-hero { grid-column: 1 / span 4; grid-row: 1 / span 2; display: flex; flex-direction: column; }
.horizon-strip { grid-column: 5 / span 8; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.card-chart { grid-column: 5 / span 8; display: flex; flex-direction: column; }
.card-health { grid-column: 1 / span 3; }
.card-skill { grid-column: 4 / span 3; }
.card-pipe { grid-column: 7 / span 3; }
.card-region { grid-column: 10 / span 3; }

/* ============ Hero ============ */
.hero-top { display: flex; align-items: flex-start; gap: 14px; }
.hero-num {
  font-size: clamp(64px, 6.2vw, 92px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.hero-side { padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.lv-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.lv-chip.sm { padding: 3px 9px; font-size: 12px; border-radius: 8px; letter-spacing: 0.04em; }
.hero-sub { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.hero-meta { display: flex; gap: 14px; margin: 14px 0 4px; flex-wrap: wrap; }
.hero-meta .m { display: flex; flex-direction: column; gap: 2px; }
.hero-meta .m .k { font-size: 11px; line-height: 16px; color: var(--ink-3); }
.hero-meta .m .v {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  display: flex;
  align-items: baseline;
  gap: 3px;
  white-space: nowrap;
}
.hero-meta .m .v .u { font-size: 10px; font-weight: 400; color: var(--ink-3); }

/* AQI 等级色带 */
.aqi-scale { margin: 12px 0 2px; }
.aqi-scale-bar {
  position: relative;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    var(--lv-you) 0 10%, var(--lv-liang) 10% 20%, var(--lv-qing) 20% 30%,
    var(--lv-zhong) 30% 40%, var(--lv-zhongd) 40% 60%, var(--lv-yan) 60% 100%);
  opacity: 0.85;
}
.aqi-scale-marker {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink-1);
  transform: translateX(-8px);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
}
.aqi-scale-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-3); margin-top: 6px; }

/* 污染物迷你表 */
.pollutants { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; margin-top: auto; padding-top: 14px; }
.pol { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.4); }
.pol .k { font-size: 11px; color: var(--ink-2); }
.pol .k sub { font-size: 8px; }
.pol .v { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.pol.dominant { outline: 1.5px solid var(--accent); outline-offset: -1.5px; }

/* 行动建议 */
.advice { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: auto; padding-top: 16px; }
.adv { text-align: center; padding: 10px 6px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.42); }
.adv .ic { font-size: 20px; line-height: 1; }
.adv .nm { font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.adv .st { font-size: 12px; font-weight: 700; margin-top: 2px; }
.adv .st.good { color: var(--ok); }
.adv .st.warn { color: var(--warn); }
.adv .st.bad { color: var(--bad); }

/* ============ 时效卡 ============ */
.hcard {
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  min-width: 0;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .hcard { transition: transform 0.16s ease, box-shadow 0.16s ease; }
  .hcard:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(45, 66, 90, 0.18); }
}
.hcard .hz { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
.hcard .route { font-size: 10px; color: var(--ink-3); background: rgba(255, 255, 255, 0.5); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.hcard .val { font-family: var(--font-mono); font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hcard .val .pm { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.hcard .rng { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.hcard .dir-ic { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 2px auto; }
.hcard .dir-ic svg { width: 20px; height: 20px; }
.hcard .dir-word { font-size: 15px; font-weight: 700; }
.hcard .sub { font-size: 10px; color: var(--ink-3); margin-top: auto; padding-top: 4px; }

/* ============ 预测图卡 ============ */
.card-chart { padding-bottom: 10px; }
#forecastChart { width: 100%; flex: 1; min-height: 280px; }
.chart-note { font-size: 10px; color: var(--ink-3); padding: 4px 2px 2px; }

/* ============ 模型健康 ============ */
.health-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid rgba(255, 255, 255, 0.55); }
.health-row:first-of-type { border-top: none; }
.health-row .hz { font-size: 12px; font-weight: 600; width: 34px; flex: none; }
.health-row .spark { flex: 1; min-width: 0; }
.health-row .spark svg { display: block; width: 100%; height: 34px; }
.health-row .stat { text-align: right; flex: none; }
.health-row .stat .v { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.health-row .stat .k { font-size: 9px; color: var(--ink-3); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.ok { color: var(--ok); background: var(--lv-you-bg); }
.badge.warn { color: var(--warn); background: var(--lv-qing-bg); }
.badge.bad { color: var(--bad); background: var(--lv-zhong-bg); }
.health-note { font-size: 10px; color: var(--ink-3); line-height: 1.5; margin-top: 8px; }

/* ============ Skill vs 持续性 ============ */
.skill-legend { display: flex; gap: 14px; font-size: 10px; color: var(--ink-3); margin-bottom: 8px; }
.skill-legend .sw { display: inline-block; width: 10px; height: 4px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.skill-row { padding: 6px 0 7px; border-top: 1px solid rgba(255, 255, 255, 0.55); }
.skill-row:first-of-type { border-top: none; }
.skill-row .lbl { display: flex; align-items: baseline; gap: 6px; font-size: 11px; margin-bottom: 4px; }
.skill-row .lbl b { font-size: 12px; }
.skill-row .lbl .mth { color: var(--ink-3); font-size: 10px; }
.skill-row .lbl .sig { margin-left: auto; font-size: 10px; font-weight: 600; color: var(--ok); }
.skill-row .lbl .sig.no { color: var(--ink-3); font-weight: 400; }
.skill-bars { display: flex; flex-direction: column; gap: 3px; }
.sbar { display: flex; align-items: center; gap: 6px; }
.sbar .track { flex: 1; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.4); overflow: hidden; }
.sbar .fill { height: 100%; border-radius: 4px; }
.sbar.model .fill { background: var(--accent); }
.sbar.pers .fill { background: var(--accent-2); opacity: 0.75; }
.sbar .v { font-family: var(--font-mono); font-size: 10px; width: 34px; text-align: right; color: var(--ink-2); flex: none; }
.skill-foot { font-size: 10px; color: var(--ink-3); margin-top: 8px; line-height: 1.5; }

/* ============ 数据管道 ============ */
.pipe-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, 0.55); font-size: 12px; }
.pipe-row:first-of-type { border-top: none; }
.pipe-row .st { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pipe-row .st.ok { background: var(--ok); }
.pipe-row .st.warn { background: var(--warn); }
.pipe-row .st.bad { background: var(--bad); }
.pipe-row .nm { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-row .tp { color: var(--ink-3); font-size: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-row .tm { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); flex: none; }

/* ============ 区域卡 ============ */
.region-map { width: 100%; }
.region-map svg { display: block; width: 100%; height: auto; }
.region-cap { font-size: 10px; color: var(--ink-3); line-height: 1.55; margin-top: 8px; }

/* ============ 页脚 ============ */
.dash-footer {
  max-width: 1560px;
  margin: 0 auto;
  padding: 8px 20px 26px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.7;
}
.dash-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.dash-footer a:hover { text-decoration: underline; }

/* ============ 响应式 ============ */
@media (max-width: 1150px) {
  .card-hero { grid-column: 1 / -1; grid-row: auto; }
  .horizon-strip { grid-column: 1 / -1; }
  .card-chart { grid-column: 1 / -1; }
  .card-health, .card-skill, .card-pipe, .card-region { grid-column: span 6; }
}
@media (max-width: 680px) {
  .dash { padding: 12px 12px 6px; gap: 10px; }
  .topbar-inner { padding: 10px 12px; }
  .brand-t2 { display: none; }
  .topbar-right .pill.upd { display: none; }
  .horizon-strip {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .horizon-strip .hcard { flex: 0 0 128px; scroll-snap-align: start; }
  .card-health, .card-skill, .card-pipe, .card-region { grid-column: 1 / -1; }
  .pollutants { grid-template-columns: repeat(2, 1fr); }
  .advice { grid-template-columns: repeat(2, 1fr); }
  .hero-num { font-size: 64px; }
  #forecastChart { min-height: 240px; }
}
