/* /wtrp/ v5.6 —— 单页研发点计算器
 * 设计语言参照 blind-thunder.wiki 的 wt-tree:游戏卡片质感(底色+顶部色条+点阵纹理),
 * 选中=色条变金+斜纹叠层;文件夹就地展开面板;
 * v5.3:名字图标=游戏符号字体 WTSymbols(自托管,与 bt 同源;名字保留原样前缀字符——
 *       无色文字级与游戏一致,弃彩色旗标)/卡片+合计加银狮/金鹰仅金币车;
 * v5.2:卡片 130px=1680 零横滚;v5.1:图上间隔;v5.0:合计=仅所选不含前置;
 * v4.9:BR 徽标;v4.8:金币区 grid;v4.7:定宽/对齐/轻面纱。
 */
/* 游戏符号字体(bt 同款:字体栈第一位,图标字符由它渲染,中文回退系统字体) */
@font-face {
  font-family: WTSymbols;
  src: url(fonts/symbols_skyquake.ttf);
  font-display: swap;
}
:root {
  --bg: #14191b;
  --panel: #1a2427;
  --panel2: #1e2b2e;
  --line: #38434d;
  --text: #e8eef2;
  --muted: #93a5b0;
  /* 卡片五态(与游戏/盲雷一致的研究区蓝灰 + 高级区金/绿 + 活动紫/市场青/礼包橙) */
  --c-res-bg: #424e5a; --c-res-border: #495a5f; --c-res-top: #6a7b82;
  --c-pre-bg: #594b20; --c-pre-bg2: #372f15; --c-pre-border: #57441e; --c-pre-top: #8b6626;
  --c-squ-bg: #3b5734; --c-squ-border: #40642c; --c-squ-top: #588537;
  --c-eve-bg: #4a3358; --c-eve-border: #5b4370; --c-eve-top: #8a5aa8;
  --c-mar-bg: #2c4a4a; --c-mar-border: #355c5c; --c-mar-top: #4a8080;
  --c-pac-bg: #5a4020; --c-pac-border: #6e4f26; --c-pac-top: #96703a;
  --sel-top: #ffd77a;
  --radius: 6px;
  --img-h: 62px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 WTSymbols, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}

/* ── 顶栏:国家/兵种分行(用户验收:不要挤在一行) ── */
#top {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #1c2429, #161d21);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 12px; }
.brand-row { justify-content: space-between; }
.brand { font-size: 16px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.ver { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#classes { padding-top: 4px; border-top: 1px solid #232e33; }
.tabs button {
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.tabs button:hover { color: var(--text); background: #ffffff10; }
.tabs button.on { color: #fff; background: #2c3b4c; border-color: #3d5268; }
#search {
  background: #0d1215; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px 10px; width: 210px; font-size: 13px; outline: none;
}
#search:focus { border-color: #6a7b82; }

/* ── 主体 ── */
main { flex: 1; display: flex; min-height: 0; }
#tree-wrap { flex: 1; min-width: 0; min-height: 0; overflow: auto; position: relative; padding: 10px 14px 100px; }
#tree { position: relative; min-width: max-content; }
.tree-connectors {
  position: absolute; z-index: 0; top: 0; left: 0;
  display: block; overflow: visible; pointer-events: none;
}

/* 等级带:左数字标签 | 研究区(弹性拉伸) | 右区(固定宽) */
.band { position: relative; z-index: 1; display: flex; align-items: stretch; padding: 10px 0; border-bottom: 1px solid #232e33; }
.band:first-child { padding-top: 4px; }
.rank-label {
  width: 48px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #7d8f99; font-weight: 700; font-size: 16px;
  border-right: 1px solid #232e33; margin-right: 10px;
  font-family: Georgia, "Times New Roman", serif;
}
.research {
  flex: 1 1 auto; display: flex; gap: 8px;
  padding-right: 8px; border-right: 2px solid #e8edf2;
  min-width: 0;
}
/* 卡片全站定宽 130px(v5.2=1680 视口零横滚解;车名行右端放 BR;与右区一致,换国家/兵种页宽度不变);列内间距统一 10px */
.col { position: relative; z-index: 1; flex: none; width: 130px; display: flex; flex-direction: column; gap: 22px; }
/* v4.8:金币区=两列网格(宽=内容,不再按视口比例撑满——右缘大空隙消除;
   注意不能用 flex-wrap+max-content:max-content 对 flex 容器=所有卡排一行的宽度,卡会全部挤到首行溢出) */
.premium {
  position: relative; z-index: 1; flex: none; width: max-content;
  display: grid; grid-template-columns: repeat(2, 130px); gap: 10px;
  padding-left: 10px;
  align-content: start;
}
.premium .card { width: 130px; flex: none; }

/* ── 载具卡(游戏质感) ── */
.card {
  position: relative; z-index: 2; width: 100%;
  border: 1px solid var(--c-res-border);
  border-top: 2px solid var(--c-res-top);
  border-radius: var(--radius);
  background-color: var(--c-res-bg);
  box-shadow: 0 2px 3px 1px #0000001a;
  padding: 0 4px 5px;
  cursor: pointer; user-select: none;
  transition: filter .12s;
}
.card:hover { filter: brightness(1.12); }
/* 点阵纹理(自底部渐隐) */
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 5px 5px;
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 30%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0%, #000 30%, transparent 100%);
  opacity: .05;
}
.card .ph {
  height: var(--img-h); margin-top: 4px;
  padding-top: 5px; /* v5.1:图上方留间隔——statcard 车体贴图区顶缘,原显"车顶被挡" */
  background: #10161d center/cover no-repeat;
  border-radius: 4px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.card .ph img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .ph.noimg { color: #54636f; font-size: 20px; font-weight: 700; }
/* v4.9:车名行=flex(旗标+车名省略+右端 BR 徽标) */
.card .cname {
  position: relative;
  display: flex; align-items: center; gap: 3px;
  font-size: 12px; margin-top: 4px; height: 16px;
}
.card .cname .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: WTSymbols, "Microsoft YaHei", "PingFang SC", sans-serif; }
/* 战斗权重(分房):车名行最右端小徽标(数据=catalog br,即 RB 分房) */
.card .cname .br {
  flex: none; font-size: 10px; line-height: 1; font-weight: 700;
  padding: 1px 3px; border-radius: 3px;
  background: #00000059; color: #e8eef2;
}
/* 银狮购买价行(v5.3;恒渲染保卡高统一,金币/礼包车无值为空) */
.card .csl { font-size: 10px; line-height: 14px; height: 14px; color: #a8b8c2; white-space: nowrap; overflow: hidden; }
.card .crp { font-size: 12px; }
.card .crp { position: relative; font-size: 11px; color: #b8c6cf; margin-top: 1px; white-space: nowrap; }
.card .tag {
  position: absolute; top: 5px; right: 4px; z-index: 2;
  font-size: 10px; line-height: 1; padding: 2px 5px; border-radius: 3px;
  background: #000b; color: #fff;
}
/* 五态配色 */
.card.av-premium { background: var(--c-pre-bg) linear-gradient(to bottom, transparent, var(--c-pre-bg2)); border-color: var(--c-pre-border); border-top-color: var(--c-pre-top); }
.card.av-squadron { background-color: var(--c-squ-bg); border-color: var(--c-squ-border); border-top-color: var(--c-squ-top); }
.card.av-event { background-color: var(--c-eve-bg); border-color: var(--c-eve-border); border-top-color: var(--c-eve-top); }
.card.av-marketplace { background-color: var(--c-mar-bg); border-color: var(--c-mar-border); border-top-color: var(--c-mar-top); }
.card.av-pack { background-color: var(--c-pac-bg); border-color: var(--c-pac-border); border-top-color: var(--c-pac-top); }
.card.av-premium .crp, .card.av-pack .crp { color: #ffd77a; }
.card.av-squadron .crp { color: #a5e08a; }
.card.av-event .crp { color: #d0a5ea; }
.card.av-marketplace .crp { color: #8ad2cc; }
/* 选中:顶条变金 + 斜纹 + ✓ */
.card.sel { border-top-color: var(--sel-top); }
.card.sel::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,.10) 0 4px, transparent 4px 9px);
}
.card .selmark {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--sel-top); color: #3a2c00;
  font-size: 12px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
}
.card.sel .selmark { display: flex; }

/* ── 文件夹:顶层=真实卡片,背后垫同款空卡壳(游戏样式) ── */
.folder { position: relative; z-index: 1; width: 100%; cursor: pointer; user-select: none; }
/* v4.7:壳层最大下探 8px < 列间距 10px,fstack 不再加额外外边距(文件夹下列卡与邻列对齐) */
.folder .fstack { position: relative; }
.folder .fstack > .card { position: relative; z-index: 2; }
.folder .fshell {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none;
  border: 1px solid var(--c-res-border);
  border-top: 2px solid var(--c-res-top);
  border-radius: var(--radius);
  background-color: var(--c-res-bg);
  box-shadow: 0 2px 3px 1px #0000001a;
}
.folder .fshell.s1 { transform: translate(5px, 5px); }
.folder .fshell.s2 { transform: translate(10px, 8px); }
.folder .cbadge {
  position: absolute; right: 2px; bottom: 2px; z-index: 3;  /* v4.9:挪到卡片最右下角(原在名价行旁) */
  background: #000c; color: #ffd77a; font-size: 11px; line-height: 1;
  padding: 2px 6px; border-radius: 8px; border: 1px solid #6b5b23;
}
/* ── blind-thunder folding-vehicle 同款展开:absolute 浮层 + 全屏毛玻璃面纱 ── */
/* bt 面板 top:-30/padding:25 依赖其 30px 行距;我们 .col 行距 8px,
   顶衬里上限 7px(否则盖住上一张卡)。衬里公式:内容区起点 = -(top)+边框+padding。 */
.folder.open { z-index: 1000; }
.folder.open .cbadge { background: #ffd77a; color: #241a00; border-color: #b99b4e; }
.folding-panel {
  display: none;
  position: absolute;
  top: -8px; left: -13px;
  z-index: 1000;
  width: calc(100% + 26px);
  padding: 7px 12px 12px;
  background-color: var(--panel2);
  border: 1px solid var(--line);
  box-shadow: 0 0 6px 1px #0003;
}
.folder.open .folding-panel { display: block; }
.folding-panel .card + .card { margin-top: 8px; }
/* 面纱:v4.7 更轻——压暗 38% + 微模糊 2px,展开文件夹时背景文字仍可辨认 */
#veil {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(8, 12, 14, .38);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
#veil.show { opacity: 1; pointer-events: auto; }

/* ── 按钮 ── */
.btn {
  background: #2c3b4c; color: var(--text); border: 1px solid #3d5268;
  border-radius: var(--radius); padding: 3px 10px; cursor: pointer; font-size: 12px;
}
.btn:hover { background: #36485c; }

/* ── 右侧面板 ── */
#panel { width: 330px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
.p-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700;
}
#p-list { flex: 1; overflow: auto; padding: 8px; }
#p-foot { border-top: 1px solid var(--line); padding: 10px 12px; font-size: 13px; }
#p-foot .big { font-size: 18px; font-weight: 700; color: #ffd77a; }
#p-foot .big.slv { color: #c8d4dc; }
#p-foot .row { display: flex; justify-content: space-between; margin: 2px 0; }
#p-foot .note { color: var(--muted); font-size: 11px; margin-top: 4px; }

.p-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.prow { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; margin-bottom: 6px; }
.prow .top { display: flex; align-items: center; gap: 6px; }
.prow .pname { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: WTSymbols, "Microsoft YaHei", sans-serif; }
.prow .psl { font-size: 11px; color: #a8b8c2; margin-top: 2px; }
.prow .pcost { font-size: 12px; color: #ffd77a; white-space: nowrap; }
.prow .pbtns { display: flex; gap: 4px; }
.iconbtn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 4px; cursor: pointer; font-size: 11px; padding: 1px 6px;
}
.iconbtn:hover { color: var(--text); border-color: #4a5c6e; }
.prow .chain { margin-top: 5px; border-top: 1px dashed #2c3946; padding-top: 5px; }
.prow .chain .cnode { font-size: 12px; color: var(--muted); padding: 1px 0; }
.prow .chain .cnode b { color: var(--text); font-weight: 600; }
.prow .chain .subtotal { color: #ffd77a; font-weight: 700; font-size: 12px; margin-top: 3px; }

/* ── 页脚 ── */
#foot { padding: 6px 14px; font-size: 11px; color: #5c6b7a; border-top: 1px solid var(--line); background: #10161d; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #panel { width: auto; border-left: none; border-top: 1px solid var(--line); max-height: 40vh; }
}

/* 手机布局:科技树仍可横向平移,但顶部控件和等级标签不挤压可视区域 */
/* 手机端总览：保留列顺序，但把研究列排成紧凑网格，让一屏能看到更多分支。 */
@media (max-width: 600px) {
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  body { display: block; }
  #top { position: sticky; top: 0; z-index: 20; padding: 7px 8px; gap: 4px; }
  .brand-row { flex-direction: column; align-items: stretch; gap: 5px; }
  .brand { font-size: 15px; }
  #search { width: 100%; height: 30px; }
  .tabs { flex-wrap: nowrap; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; padding: 4px 8px; min-height: 28px; font-size: 12px; }
  #classes { padding-top: 3px; }

  main { display: block; min-height: 0; }
  #tree-wrap { overflow: visible; padding: 5px 6px 32px; }
  #tree { width: 100%; min-width: 0; }
  .band { display: grid; grid-template-columns: 30px minmax(0, 1fr); padding: 6px 0; }
  .band:first-child { padding-top: 3px; }
  .rank-label { grid-column: 1; grid-row: 1 / span 2; width: 30px; margin-right: 0; font-size: 12px; }
  .research {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-column: 2; grid-row: 1; gap: 14px 4px; padding-right: 4px; min-width: 0; width: auto;
    align-items: start;
  }
  .col { width: auto; min-width: 0; gap: 14px; }
  .premium {
    grid-column: 2; grid-row: 2; width: auto; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 4px; padding: 8px 4px 0; min-width: 0;
  }
  .card, .premium .card { width: 100%; min-width: 0; padding: 0 2px 3px; }
  .card .ph { height: 38px; margin-top: 2px; padding-top: 2px; }
  .card .cname { gap: 1px; font-size: 9px; margin-top: 2px; height: 13px; }
  .card .cname .br { font-size: 8px; padding: 1px 2px; }
  .card .crp { font-size: 9px; line-height: 11px; margin-top: 0; }
  .card .csl { display: none; }
  .card .tag { top: 3px; right: 2px; font-size: 8px; padding: 1px 3px; }
  .card .selmark { top: 2px; left: 2px; width: 14px; height: 14px; font-size: 9px; }
  .folder .fshell.s1 { transform: translate(3px, 3px); }
  .folder .fshell.s2 { transform: translate(6px, 5px); }
  .folder .cbadge { right: 1px; bottom: 1px; font-size: 8px; padding: 1px 3px; }
  .folding-panel { top: -6px; left: -7px; width: calc(100% + 14px); padding: 5px 6px 7px; }
  .folding-panel .card + .card { margin-top: 6px; }

  #panel { width: 100%; max-height: none; border-left: 0; border-top: 1px solid var(--line); }
  .p-head { padding: 7px 9px; }
  #p-list { max-height: 34vh; overflow: auto; padding: 6px; }
  #p-foot { padding: 7px 9px; }
  #foot { padding: 5px 8px; }
}

@media (max-width: 380px) {
  .research, .premium { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#tree-wrap::-webkit-scrollbar, #p-list::-webkit-scrollbar { width: 10px; height: 10px; }
#tree-wrap::-webkit-scrollbar-thumb, #p-list::-webkit-scrollbar-thumb { background: #2c3946; border-radius: 5px; }
#tree-wrap::-webkit-scrollbar-track, #p-list::-webkit-scrollbar-track { background: transparent; }

.hide { display: none !important; }
