/* ============================================================================
 * TopAi — 深色控制中心风
 * 动效原则：只动 transform / opacity / filter(≤2px blur)，零 layout 动画
 * ========================================================================== */

:root {
  --bg-0: #07090d;
  --bg-1: #0d1117;
  --bg-2: #161c26;
  --line: #1f2733;
  --text-hi: #e8edf4;
  --text-mid: #8b96a5;
  --text-low: #4d5867;
  --accent: #4fd1ff;
  --accent-dim: rgba(79, 209, 255, 0.12);
  --accent-us: #6ea8ff;
  --accent-cn: #ff6a5e;
  --gold: #f5c451;
  --warn: #d9a53f;

  --font-mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --font-ui: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --radius: 10px;
}

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

html { color-scheme: dark; }

body {
  background: var(--bg-0);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums; /* 跳动不抖布局的关键 */
}

/* ---- 背景网格点阵 ---- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(circle, #182030 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.35;
  pointer-events: none;
}

/* ============================== 入场动画 ============================== */
.anim-group {
  animation: enter 280ms var(--ease-out) both;
  animation-delay: calc(var(--g, 0) * 60ms);
}
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================== Header ============================== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 13, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: baseline; gap: 10px; }

.brand-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
  flex-shrink: 0;
}

.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.02em; }

.header-right { display: flex; align-items: center; gap: 14px; }

.last-updated {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mid);
}
.last-updated.stale { color: var(--warn); }

/* ---- 语言切换（分段） ---- */
.lang-switch {
  position: relative;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-1);
  padding: 2px;
}
.lang-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  border-radius: 999px;
  transition: color 160ms ease, transform 120ms var(--ease-out);
}
.lang-btn:active { transform: scale(0.95); }
.lang-btn.active { color: var(--bg-0); }
.lang-indicator {
  position: absolute;
  top: 2px; left: 2px;
  height: calc(100% - 4px);
  border-radius: 999px;
  background: var(--accent);
  transition: transform 180ms var(--ease-drawer), width 180ms var(--ease-drawer);
  will-change: transform;
}

/* ============================== 布局 ============================== */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
  max-width: 1680px;
  margin: 0;                 /* 左对齐：时间轴真正贴左，表格获得更多宽度 */
  padding: 24px 32px 48px;
  align-items: start;        /* 让左栏可 sticky */
}

/* ============================== 左栏时间轴（贴左 sticky 栏） ============================== */
.sidebar {
  position: sticky;
  top: 88px;                 /* 紧贴 sticky header 下方，随页滚动时固定在左侧 */
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  padding: 20px 18px 22px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.side-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-low);
  margin-bottom: 16px;
}

.timeline {
  list-style: none;
  position: relative;
  padding-left: 18px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 4px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--line);
}

.ms {
  position: relative;
  padding: 0 0 22px 10px;
}
.ms:last-child { padding-bottom: 0; }

.ms-dot {
  position: absolute;
  left: -18px; top: 5px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1.5px solid var(--text-low);
  transition: transform 120ms var(--ease-out), border-color 120ms ease;
}

.ms.hero .ms-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.ms.hero .ms-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(79, 209, 255, 0.45);
  animation: heroPulse 2.4s var(--ease-out) infinite;
}
/* 雷达式呼吸：从 dot 向外扩散并淡出 */
@keyframes heroPulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

@media (hover: hover) and (pointer: fine) {
  .ms:hover .ms-dot { transform: scale(1.15); border-color: var(--text-mid); }
  .ms:hover .ms-title { color: var(--text-hi); }
}

.ms-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  transition: color 120ms ease;
}
.ms.hero .ms-title { color: var(--text-hi); }

.ms-sub {
  font-size: 12px;
  color: var(--text-low);
  margin-top: 2px;
}

.ms-elapsed {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-low);
}
.ms-elapsed .timer {
  display: block;
  font-size: 14px;
  color: var(--accent);
  margin-top: 1px;
}
.ms.hero .ms-elapsed .timer { font-size: 16px; }

.ms-date {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-low);
  opacity: 0.7;
}

/* ============================== 焦点区 ============================== */
.focus {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 55%);
  padding: 22px 26px 26px;
  margin-bottom: 24px;
}

/* ---- 发布时间差（下） ---- */
.gap-delta {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.gap-delta-label { font-size: 13px; color: var(--text-low); letter-spacing: 0.04em; }
.gap-delta-value {
  font-size: clamp(34px, 4.6vw, 52px);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
  line-height: 1.1;
}
.gap-delta-value .unit {
  font-size: 0.5em;
  color: var(--text-mid);
  font-weight: 500;
  margin: 0 2px 0 1px;
}

/* 焦点区题词：gap-delta 下的安静注脚，服从控制中心风的克制感；30s 轮换时淡入淡出 */
.focus-epigraph {
  text-align: center;
  font-size: 12px;
  color: var(--text-low);
  letter-spacing: 0.08em;
  margin-top: 14px;
  opacity: 0.9;
  transition: opacity 160ms ease;
}

/* ---- 中美卡片 ---- */
.gap-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 14px;
}

.gap-vs {
  align-self: center;
  font-size: 18px;
  color: var(--text-low);
  line-height: 1;
}

.gap-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-1);
  padding: 14px 16px 12px;
  overflow: hidden;
}
.gap-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.gap-card-us::before { background: var(--accent-us); }
.gap-card-cn::before { background: var(--accent-cn); }

.gap-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.gap-flag { font-size: 22px; line-height: 1; }
.gap-meta { display: flex; flex-direction: column; min-width: 0; }
.gap-model {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gap-vendor { font-size: 11px; color: var(--text-low); }

/* 是否开源标记（配色复用 .tag-open / .tag-closed） */
.gap-open { margin-left: auto; align-self: center; }

.gap-card-bottom { display: flex; flex-direction: column; }
.gap-since { font-size: 11px; color: var(--text-low); }
.gap-card .timer {
  font-size: 21px;
  font-weight: 600;
  color: var(--text-hi);
  margin-top: 2px;
}
.gap-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-low);
  opacity: 0.7;
  margin-top: 4px;
}

/* ---- 计时器秒位微闪 ---- */
.timer .ss { display: inline-block; }

/* ============================== 榜单区 ============================== */
.boards-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.boards-title { font-size: 14px; font-weight: 600; color: var(--text-mid); }

.board-source {
  font-size: 12px;
  color: var(--text-low);
  text-decoration: none;
  transition: color 120ms ease;
}
.board-source:hover { color: var(--accent); }

/* ---- 分段控制器 ---- */
.seg {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-1);
  padding: 3px;
  margin-bottom: 10px;
}
.seg::-webkit-scrollbar { display: none; }

.seg-indicator {
  position: absolute;
  top: 3px; left: 0;
  height: calc(100% - 6px);
  border-radius: 6px;
  background: var(--bg-2);
  border: 1px solid #232d3d;
  transition: transform 180ms var(--ease-drawer), width 180ms var(--ease-drawer);
  will-change: transform;
}

.seg-tab {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  border: 0;
  background: none;
  color: var(--text-mid);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 160ms ease, transform 120ms var(--ease-out);
}
.seg-tab:active { transform: scale(0.97); }
.seg-tab.active { color: var(--text-hi); }
.seg-tab:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.board-desc {
  font-size: 12px;
  color: var(--text-low);
  margin-bottom: 12px;
  min-height: 1.2em;
}
.board-desc a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(79, 209, 255, 0.4);
}
.board-desc a:hover { opacity: .82; }

/* ---- 表格（固定高度内部滚动 + 固定表头 + 固定首两列） ---- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  overflow: auto;                       /* 滚轮在表格内 → 排名向下滚（表头固定） */
  max-height: calc(100vh - 340px);     /* 表格占一屏高度，超出部分内部滚动 */
  overscroll-behavior: contain;        /* 表格滚到底也不带动页面；移出表格再滚页面 */
  transition: opacity 120ms ease, filter 120ms ease;
}
.table-wrap.switching {
  opacity: 0;
  filter: blur(2px);
}

.board-table {
  width: 100%;
  border-collapse: separate;           /* separate：sticky 单元格边框才不会丢失 */
  border-spacing: 0;
  font-size: 14px;
  min-width: 900px;
}

.board-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-low);
  background: var(--bg-2);
  padding: 11px 16px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: inset 0 -1px 0 var(--line);
}
.board-table thead th.num { text-align: right; }

.board-table tbody td {
  padding: 11px 16px;
  white-space: nowrap;
  background: var(--bg-1);
  box-shadow: inset 0 -1px 0 rgba(31, 39, 51, 0.55);
}
.board-table tbody tr { transition: background-color 90ms ease; }

/* 排名 + 模型列：横向滚动时一起钉在左侧，始终看得到排名与模型名 */
.board-table th:nth-child(1),
.board-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  padding: 11px 8px 11px 14px;
  box-shadow: inset -1px 0 0 rgba(31, 39, 51, 0.7);
}
.board-table th:nth-child(2),
.board-table td:nth-child(2) {
  position: sticky;
  left: var(--rank-w, 48px); /* 由 JS 测量排名列实际宽度后写入，与排名列严格对齐，无黑缝 */
  z-index: 2;
  width: 1%;                /* 按最宽模型名自适应列宽（不拉伸、不截断） */
  white-space: nowrap;
  box-shadow: inset -1px 0 0 rgba(31, 39, 51, 0.7);
}
/* 左上角：表头与首两列交叉处，压在最上层 */
.board-table thead th:nth-child(1),
.board-table thead th:nth-child(2) {
  z-index: 4;
  background: var(--bg-2);
}

@media (hover: hover) and (pointer: fine) {
  .board-table tbody tr:hover td { background: rgba(22, 28, 38, 0.75); }
  .board-table tbody tr:hover td:nth-child(1),
  .board-table tbody tr:hover td:nth-child(2) { background: rgba(22, 28, 38, 0.96); }
}

/* 行入场 stagger（仅前 20 行有 --d 延迟，由 JS 控制 class） */
.board-table tbody tr.row-enter {
  animation: rowEnter 160ms var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}
@keyframes rowEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rank {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-low);
  width: 44px;
}
.rank.top {
  color: var(--gold);
  font-weight: 700;
}

.cell-model {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-hi);
}
.model-tag {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  color: #7dd3fc;
  background: rgba(125, 211, 252, 0.14);
  border: 1px solid rgba(125, 211, 252, 0.32);
}
.cell-vendor { color: var(--text-mid); }
.cell-flag { font-size: 15px; }

.tag-open, .tag-closed {
  font-size: 10.5px;
  font-family: var(--font-mono);
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: 0.03em;
}
.tag-open   { color: #7ee2a8; background: rgba(126, 226, 168, 0.09); border: 1px solid rgba(126, 226, 168, 0.25); }
.tag-closed { color: var(--text-low); background: rgba(77, 88, 103, 0.1); border: 1px solid rgba(77, 88, 103, 0.35); }

.cell-score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--accent);
}

/* ============================== Footer ============================== */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 32px 32px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-low);
  max-width: 1680px;
  margin: 0;
}
.footer-sep { opacity: 0.5; }
.footer-sources a {
  color: var(--text-low);
  text-decoration: none;
  transition: color 120ms ease;
}
.footer-sources a:hover { color: var(--accent); }
.footer-sources .src-sep { margin: 0 8px; opacity: 0.45; }

/* ============================== 语言切换过渡 ============================== */
.lang-fading .layout,
.lang-fading .site-footer {
  opacity: 0.6;
  filter: blur(2px);
}
.layout, .site-footer {
  transition: opacity 160ms ease, filter 160ms ease;
}

/* ============================== 响应式 ============================== */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 18px 16px 32px;
    gap: 18px;
  }

  /* 左栏 → 焦点区下方横向卡片带（撤销 sticky 左栏） */
  .sidebar {
    order: 2;
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }
  .main-col { order: 1; }

  .table-wrap { max-height: 72vh; }

  .timeline {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 4px 2px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .timeline::before { display: none; }

  .ms {
    flex: 0 0 220px;
    scroll-snap-align: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-1);
    padding: 12px 14px;
  }
  .ms-dot { display: none; }

  .site-header { padding: 12px 16px; }

  .focus { padding: 18px 16px 20px; }

  .gap-cards { grid-template-columns: 1fr; }
  .gap-vs { justify-self: center; padding: 2px 0; }
}

/* ============================== 响应式：手机端表格卡片化（≤600px） ============================== */
@media (max-width: 600px) {
  /* 取消表格内部滚动，交还页面自然滚动 */
  .table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
    border-radius: 0;
  }

  .board-table {
    min-width: 0;            /* 解除桌面端 900px 最小宽度 */
    border: 0;
    display: block;
  }
  .board-table thead { display: none; }   /* 列名改由每张卡片的 data-label 呈现 */

  .board-table tbody,
  .board-table tr,
  .board-table td { display: block; width: auto; }

  /* 每行 = 一张卡片 */
  .board-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-1);
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  /* 解除桌面端 sticky 首两列 / 阴影，避免卡片里残留定位与黑缝 */
  .board-table th:nth-child(1),
  .board-table td:nth-child(1),
  .board-table th:nth-child(2),
  .board-table td:nth-child(2) {
    position: static !important;
    left: auto !important;
    box-shadow: none !important;
    background: transparent;
  }

  /* 排名 + 模型名 → 卡片标题行（同行左对齐） */
  .board-table td.rank,
  .board-table td.cell-model {
    display: inline-block;
    width: auto;
    padding: 0;
    border: 0;
  }
  .board-table td.rank::before,
  .board-table td.cell-model::before { content: none; }
  .board-table td.rank {
    color: var(--text-mid);
    font-family: var(--font-mono);
    font-weight: 700;
    margin-right: 8px;
  }
  .board-table td.rank.top { color: var(--gold); }
  .board-table td.cell-model { font-size: 15px; }

  /* 标题行与数据行之间的分隔（vendor 是标题后的第一个 flex 行） */
  .board-table td.cell-vendor {
    border-top: 1px solid var(--line);
    margin-top: 6px;
    padding-top: 10px;
  }

  /* 其余字段：标签 : 值 两端对齐 */
  .board-table td.cell-vendor,
  .board-table td.cell-flag,
  .board-table td.cell-score,
  .board-table td.cell-open {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: 0;
    white-space: normal;
  }
  .board-table td.cell-vendor::before,
  .board-table td.cell-flag::before,
  .board-table td.cell-score::before,
  .board-table td.cell-open::before {
    content: attr(data-label);
    color: var(--text-low);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  .board-table td.cell-score { color: var(--accent); }
}

/* ============================== 响应式：超小屏（≤480px） ============================== */
@media (max-width: 480px) {
  .site-header { padding: 10px 14px; gap: 10px; }
  .brand-name { font-size: 15px; }
  .header-right { gap: 8px; }
  .last-updated { font-size: 11px; }
  .boards-head { flex-wrap: wrap; gap: 4px 12px; }
  .focus { padding: 16px 14px 18px; }
  .gap-delta-value { font-size: clamp(30px, 9vw, 44px); }
}

/* ============================== 无障碍：减少动效 ============================== */
@media (prefers-reduced-motion: reduce) {
  .anim-group { animation: none; }
  .board-table tbody tr.row-enter { animation: rowEnter 160ms ease both; animation-delay: 0ms !important; }
  @keyframes rowEnter {
    from { opacity: 0; transform: none; }
    to   { opacity: 1; transform: none; }
  }
  .seg-indicator, .lang-indicator { transition: none; }
  .ms.hero .ms-dot::after { animation: none; }
}
