/* ============================================================
   台风路径 · 深海夜航式暗色气象界面
   移动端优先,桌面端自适应
   ============================================================ */

:root {
  /* 基础色板 */
  --bg-deep:    #0a1420;              /* 深海底色 */
  --glass:      rgba(13, 27, 42, .86); /* 玻璃面板 */
  --glass-lite: rgba(20, 38, 58, .72);
  --line:       rgba(120, 160, 190, .18);
  --text:       #e8f1f8;
  --text-dim:   #7d93a8;
  --accent:     #4fd8eb;              /* 雷达青 */

  /* 台风强度官方色标(中国台风网标准) */
  --lv-td:      #30d54c;  /* 热带低压 */
  --lv-ts:      #2f7bff;  /* 热带风暴 */
  --lv-sts:     #f7d038;  /* 强热带风暴 */
  --lv-ty:      #ff9c33;  /* 台风 */
  --lv-sty:     #f450d8;  /* 强台风 */
  --lv-super:   #ff3b30;  /* 超强台风 */

  --radius: 14px;
  --font-data: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

/* ---------- 地图 ---------- */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-deep);
}
.leaflet-container { font: inherit; }
.leaflet-control-attribution {
  background: rgba(10, 20, 32, .6) !important;
  color: var(--text-dim) !important;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-control-zoom { display: none; } /* 移动端手势缩放为主 */

/* 台风眼旋转图标 */
.ty-eye { position: relative; }
.ty-eye svg {
  display: block;
  animation: spin 2.4s linear infinite;
  filter: drop-shadow(0 0 6px currentColor);
}
.ty-eye::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: .5;
  animation: pulse 2s ease-out infinite;
}
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%   { transform: scale(.6); opacity: .6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* 路径点 tooltip */
.leaflet-tooltip.ty-tip {
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.5;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.leaflet-tooltip.ty-tip::before { display: none; }
.ty-tip b { font-family: var(--font-data); }
.ty-tip .tip-lv { font-weight: 600; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  pointer-events: none;
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  width: fit-content;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.topbar-title h1 { font-size: 15px; font-weight: 600; letter-spacing: .04em; }
.logo-spin { color: var(--accent); animation: spin 6s linear infinite; }
.topbar-status {
  font-size: 11px;
  color: var(--text-dim);
  border-left: 1px solid var(--line);
  padding-left: 8px;
}
.topbar-status.ok   { color: var(--lv-td); }
.topbar-status.warn { color: var(--lv-sts); }

/* 台风切换 chips */
.switcher {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: auto;
  padding-bottom: 4px;
}
.switcher::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--glass-lite);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  white-space: nowrap;
}
.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--lv-color, var(--text-dim));
  box-shadow: 0 0 6px var(--lv-color, transparent);
}
.chip.active {
  border-color: var(--accent);
  background: rgba(79, 216, 235, .14);
}
.chip:active { transform: scale(.97); }

/* ---------- 地图控制按钮 ---------- */
.map-controls {
  position: fixed;
  right: 12px;
  top: 45%;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ctl-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.ctl-btn:active { transform: scale(.94); }

/* ---------- 图例 ---------- */
.legend {
  position: fixed;
  right: 60px;
  top: 40%;
  z-index: 16;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
.legend-title { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; letter-spacing: .06em; }
.legend ul { list-style: none; }
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
}
.legend .swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.legend .swatch.line { height: 3px; border-radius: 2px; width: 18px; }
.legend-note {
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

/* ---------- 底部信息面板(bottom sheet) ---------- */
.panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 0 16px calc(var(--safe-bottom) + 10px);
  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  transform: translateY(0);
  transition: transform .28s cubic-bezier(.3,.9,.3,1);
  touch-action: none;
}
.panel.collapsed { transform: translateY(calc(100% - 118px)); }
.panel.expanded .panel-expand { display: block; }

.panel-handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: grab;
}
.panel-handle span {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.25);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.panel-name { display: flex; align-items: center; gap: 8px; }
.panel-name strong { font-size: 18px; letter-spacing: .02em; }
.panel-name em { font-style: normal; color: var(--text-dim); font-size: 12px; }
.ty-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #08131e;
  background: var(--lv-color, var(--text-dim));
}
.panel-time { font-family: var(--font-data); font-size: 11px; color: var(--text-dim); }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.stat label { display: block; font-size: 10px; color: var(--text-dim); margin-bottom: 3px; }
.stat b {
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  word-break: break-all;
  overflow-wrap: break-word;
}
.stat.burst b {
  position: relative;
  z-index: 30;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}
.stat.burst {
  background: var(--glass);
  z-index: 30;
}
.stat u { text-decoration: none; font-size: 10px; color: var(--text-dim); margin-left: 2px; }

/* 展开区:历史路径列表 */
.panel-expand {
  display: none;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.track-title { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.track-title small { font-size: 10px; opacity: .7; }
.track-list {
  list-style: none;
  max-height: 34vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.track-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  font-size: 12px;
  cursor: pointer;
}
.track-list li:active { background: rgba(255,255,255,.05); }
.track-list .t-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.track-list .t-time { font-family: var(--font-data); color: var(--text-dim); width: 92px; flex: 0 0 auto; }
.track-list .t-lv { flex: 1; }
.track-list .t-val { font-family: var(--font-data); color: var(--text-dim); }
.track-list li.current { background: rgba(79,216,235,.08); border-radius: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(140px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 40;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 12px;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

/* ---------- 桌面端适配 ---------- */
@media (min-width: 768px) {
  body { font-size: 15px; }

  .topbar { padding: 16px 20px 0; }
  .switcher { max-width: 60vw; }

  /* 桌面端:面板收窄靠左,像仪表卡片 */
  .panel {
    left: 20px;
    right: auto;
    bottom: 20px;
    width: 400px;
    border-radius: 18px;
    border: 1px solid var(--line);
    padding-bottom: 14px;
  }
  .panel.collapsed { transform: translateY(calc(100% - 118px + 20px)); }
  .track-list { max-height: 30vh; }

  .map-controls { right: 20px; top: auto; bottom: 40px; }
  .legend { right: 72px; top: auto; bottom: 40px; }
  .ctl-btn:hover, .chip:hover { border-color: var(--accent); }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  .ty-eye svg, .logo-spin { animation-duration: 20s; }
  .ty-eye::after { animation: none; opacity: .4; transform: scale(1.1); }
  .panel { transition: none; }
}

/* ============================================================
   v2 新增:中文底图深色滤镜 / 信息卡 popup / 标签页 /
           强度曲线 / 资讯卡片 / 顶部渐变遮罩
   ============================================================ */

/* 高德浅色中文瓦片 → 深色化滤镜(与整体暗色风格融合) */
.tile-dark {
  filter: invert(1) hue-rotate(200deg) saturate(.55) brightness(.92) contrast(.92);
}

/* 顶部渐变遮罩,提升 chips 在地图上的可读性 */
.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 130px;
  background: linear-gradient(to bottom, rgba(8, 16, 26, .78), transparent);
  pointer-events: none;
  z-index: -1;
}

/* ---------- 当前位置信息卡(Leaflet popup 主题化) ---------- */
.ty-popup .leaflet-popup-content-wrapper {
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
.ty-popup .leaflet-popup-content { margin: 12px 14px; line-height: 1.6; }
.ty-popup .leaflet-popup-tip {
  background: var(--glass);
  border: 1px solid var(--line);
}
.ty-popup .leaflet-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 18px !important;
  padding: 6px 8px 0 0 !important;
}

.pp-card { font-size: 12.5px; }
.pp-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  padding-bottom: 7px;
  margin-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.pp-row {
  display: flex;
  gap: 6px;
  padding: 2.5px 0;
}
.pp-row label {
  flex: 0 0 62px;
  color: var(--accent);
  font-weight: 600;
}
.pp-row span { flex: 1; min-width: 0; }

/* ---------- 展开区:强度曲线 ---------- */
.sparkline { margin-bottom: 10px; }
.sparkline svg {
  display: block;
  width: 100%;
  height: 48px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.spark-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.spark-range { font-family: var(--font-data); }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.tab {
  flex: 1;
  padding: 7px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.tab.active {
  color: var(--accent);
  border-color: rgba(79, 216, 235, .5);
  background: rgba(79, 216, 235, .1);
  font-weight: 600;
}

/* ---------- 资讯卡片 ---------- */
.news-list {
  list-style: none;
  max-height: 34vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.news-hint, .news-empty {
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 2px 0;
}
.news-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .2s, background .2s;
}
.news-card:active { background: rgba(79,216,235,.08); }
.news-icon { font-size: 18px; flex: 0 0 auto; }
.news-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.news-title {
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.news-meta { font-size: 10.5px; color: var(--text-dim); }
.news-arrow { color: var(--text-dim); font-size: 18px; flex: 0 0 auto; }

@media (min-width: 768px) {
  .news-card:hover { border-color: var(--accent); }
  .news-list, .track-list { max-height: 30vh; }
}
