/*
 * FormationEntry.css —— 首页「阵法」弹窗：目录 + 类型/品阶双维筛选 + 碎片解锁/升级 + 局内开关。
 *
 * 壳沿用 GeneralCodex.css 的 general-codex-shell / window / close，
 * 这里排筛选条、阵法卡（阵盘机关图压在光阵图上）、碎片进度和底部开关。
 *
 * ★ 四张阵法图都是透明底 PNG，卡片给的是暖色衬底，不要改成深色，
 *   否则抠图边缘那圈极淡的米白会显出来。
 * ★ 卡片状态（品阶 / 是否解锁）一律走 data-* 属性，**不要往 .formation-card
 *   的 class 里塞第二个词** —— verify 是按 `class="formation-card"` 数卡片的。
 */
#formation-overlay {
  --general-codex-scale: 1;
  position: fixed;
  z-index: 100018;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  background: rgba(24, 17, 12, 0.72);
  color: #3a2519;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#formation-overlay.is-visible { display: flex; }
#formation-overlay * { box-sizing: border-box; letter-spacing: 0; }

.formation-shell {
  width: 540px;
  flex: 0 0 540px;
}

.formation-window {
  width: 540px;
  height: 760px;
  max-height: 760px;
  min-height: 0;
  margin: 0 auto;
  /* 底部多留一点：知道了按钮 + 开关说明贴着羊皮纸撕边会看不清 */
  padding: 70px 26px 40px;
  display: flex;
  flex-direction: column;
  cursor: default;
}

.formation-window h2 {
  margin: 0;
  font-size: 38px;
  text-align: center;
}

.formation-count {
  margin: 2px 0 0;
  color: #8a5a3a;
  font-size: 15px;
  text-align: center;
}

.formation-legend {
  margin: 6px 0 10px;
  color: #8a5a3a;
  font-size: 15px;
  line-height: 1.35;
  text-align: center;
}

/* ---------- 筛选条 ---------- */
.formation-filters {
  flex: 0 0 auto;
  padding: 0 2px 8px;
  border-bottom: 2px solid rgba(75, 43, 29, 0.22);
}

.formation-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.formation-filter-row:last-child { margin-bottom: 0; }

.formation-filter-label {
  flex: 0 0 auto;
  width: 40px;
  color: #6d4630;
  font-size: 16px;
  font-weight: 700;
}

.formation-chip {
  padding: 3px 10px;
  border: 2px solid #4b2b1d;
  border-radius: 8px;
  background: rgba(255, 243, 201, 0.4);
  color: inherit;
  font: inherit;
  font-size: 17px;
  line-height: 1.3;
  cursor: pointer;
}

.formation-chip.is-on {
  background: #a94435;
  color: #fff3c9;
}

/* 品阶 chip 未选中时给一条本阶颜色的边框，选中后整块染色 */
.formation-chip.is-rarity { padding: 3px 9px; }
.formation-chip.is-rarity.r-白 { border-color: #8d8d8d; }
.formation-chip.is-rarity.r-绿 { border-color: #2f7a46; }
.formation-chip.is-rarity.r-蓝 { border-color: #2b5c9a; }
.formation-chip.is-rarity.r-紫 { border-color: #7a3ea8; }
.formation-chip.is-rarity.r-橙 { border-color: #c45c12; }
.formation-chip.is-rarity.r-红 { border-color: #a94435; }
.formation-chip.is-rarity.r-青 { border-color: #1a9b8e; }
.formation-chip.is-rarity.r-粉 { border-color: #d4548a; }

.formation-chip.is-rarity.is-on.r-白 { background: #8d8d8d; color: #fff; }
.formation-chip.is-rarity.is-on.r-绿 { background: #2f7a46; color: #fff; }
.formation-chip.is-rarity.is-on.r-蓝 { background: #2b5c9a; color: #fff; }
.formation-chip.is-rarity.is-on.r-紫 { background: #7a3ea8; color: #fff; }
.formation-chip.is-rarity.is-on.r-橙 { background: #c45c12; color: #fff; }
.formation-chip.is-rarity.is-on.r-红 { background: #a94435; color: #fff; }
.formation-chip.is-rarity.is-on.r-青 { background: #1a9b8e; color: #fff; }
.formation-chip.is-rarity.is-on.r-粉 { background: #d4548a; color: #fff; }

/* ---------- 列表 ---------- */
.formation-list {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding: 0 2px 6px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* ---------- 阵法卡 ---------- */
.formation-card {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 7px 10px 7px 7px;
  border: 2px solid #6b4029;
  border-left-width: 7px;
  border-radius: 10px;
  background: rgba(255, 246, 222, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 243, 201, 0.5);
}

/* 左侧竖条跟品阶同色，扫一眼就能分品阶 */
.formation-card[data-rarity="白"] { border-left-color: #8d8d8d; }
.formation-card[data-rarity="绿"] { border-left-color: #2f7a46; }
.formation-card[data-rarity="蓝"] { border-left-color: #2b5c9a; }
.formation-card[data-rarity="紫"] { border-left-color: #7a3ea8; }
.formation-card[data-rarity="橙"] { border-left-color: #c45c12; }
.formation-card[data-rarity="红"] { border-left-color: #a94435; }
.formation-card[data-rarity="青"] { border-left-color: #1a9b8e; }
.formation-card[data-rarity="粉"] { border-left-color: #d4548a; }

.formation-card[data-locked="1"] {
  background: rgba(120, 100, 74, 0.16);
}

.formation-card[data-locked="1"] .formation-name {
  color: #6d5a45;
}

/* 光阵：铺在底层，虚化后当「地气/光晕」用，不让它的八角铜环抢主体 */
.formation-card-art {
  position: relative;
  flex: 0 0 86px;
  width: 86px;
  height: 86px;
  overflow: hidden;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 46%, rgba(255, 236, 190, 0.85), rgba(190, 150, 96, 0.25) 68%, rgba(120, 78, 44, 0) 100%);
}

/*
 * 列表卡片里的两张图 = 局内特效的「缩略预演」，必须和局内同一套画法
 * （用户 2026-11-10：「阵法的所有特效都改成原图 50% 透明持续旋转」
 *   → 后续修正：「阵盘不用旋转」）。
 * ★ 以前这里是 opacity .62 + blur(2.5px) + brightness/saturate 调色，
 *   局内却是另一套参数 —— 玩家在弹窗里看到的和放下后看到的不一样。
 * ★ 所以这里**不调色、不模糊**：原图 + 50%；**只有阵型图转、阵盘不转**，
 *   和 BattleFormations 的口径一一对齐（ARRAY_DPS=9≈40s 一圈 / MECH_DPS=0）。
 */
@keyframes formation-spin-cw {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.formation-card-array {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 150%;
  opacity: 0.5;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
  animation: formation-spin-cw 40s linear infinite;
}

/*
 * 机关图：压在上层，**不转**。
 * ★ 它和局内阵盘是同一张图、同一个角色（点击落点），转起来会像可抓取的旋钮；
 *   而且 40s 一圈的两张图一起转，缩略图里会看着"糊成一团"。
 */
.formation-card-mech {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  opacity: 0.5;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
}

/* 系统开了「减少动态效果」就不转（前庭敏感的用户会被持续旋转恶心到） */
@media (prefers-reduced-motion: reduce) {
  .formation-card-array {
    animation: none;
  }
}

.formation-card-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.formation-card-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.formation-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  line-height: 1.2;
}

.formation-badge {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #4b2b1d;
  background: #a94435;
  color: #fff3c9;
  font-size: 14px;
  font-style: normal;
  line-height: 1;
}

.formation-rarity {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.formation-rarity.r-白 { background: #8d8d8d; }
.formation-rarity.r-绿 { background: #2f7a46; }
.formation-rarity.r-蓝 { background: #2b5c9a; }
.formation-rarity.r-紫 { background: #7a3ea8; }
.formation-rarity.r-橙 { background: #c45c12; }
.formation-rarity.r-红 { background: #a94435; }
.formation-rarity.r-青 { background: #1a9b8e; }
.formation-rarity.r-粉 { background: #d4548a; }

/* ---------- 未解锁 / 进度 / 升级 ---------- */
.formation-lock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.formation-lock-badge {
  padding: 1px 7px;
  border: 1.5px solid #8a6a48;
  border-radius: 6px;
  background: rgba(75, 43, 29, 0.14);
  color: #7a5a3c;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.formation-lock-text {
  color: #6d4630;
  font-size: 14px;
  line-height: 1.5;
}

.formation-level {
  color: #8f4009;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
}

.formation-progress {
  position: relative;
  height: 7px;
  margin: 3px 0 1px;
  border-radius: 5px;
  background: rgba(75, 43, 29, 0.2);
  overflow: hidden;
}

.formation-progress-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #d9a441, #f0c84c);
}

.formation-upgrade {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 9px;
  border: 2px solid #8f4009;
  border-radius: 8px;
  background: #f0c84c;
  color: #4b2b1d;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}

.formation-upgrade.is-off {
  border-color: #8a6a48;
  background: rgba(160, 140, 110, 0.35);
  color: #7a5a3c;
}

/* ---------- 标签 / 效果 ---------- */
.formation-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0 2px;
}

.formation-kind,
.formation-shovel {
  padding: 1px 7px;
  border: 1.5px solid #4b2b1d;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
}

.formation-kind.kind-persist {
  background: rgba(47, 122, 70, 0.18);
  border-color: #2f7a46;
  color: #235c34;
}

.formation-kind.kind-consume {
  background: rgba(196, 92, 18, 0.16);
  border-color: #c45c12;
  color: #8f4009;
}

/*
 * 耐久型：蓝灰 + 冷色，和「消耗型橙」「常驻型绿」区分开。
 * 它强调的不是时间，而是「会不会被打坏」—— 用冷色才不会被误读成增益型。
 */
.formation-kind.kind-durable {
  background: rgba(43, 92, 154, 0.16);
  border-color: #2b5c9a;
  color: #1e4675;
}

.formation-shovel {
  background: rgba(75, 43, 29, 0.1);
  color: #6d4630;
}

.formation-fx {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin: 1px 0 0;
  color: #5a3a26;
  font-size: 13px;
  line-height: 1.35;
}

.formation-fx-tag {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1.5px solid #6b4029;
  background: rgba(255, 243, 201, 0.9);
  color: #8f4009;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.formation-desc {
  margin: 0;
  color: #5a3a26;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-all;
}

.formation-empty {
  margin: 32px 0 0;
  color: #8a5a3a;
  font-size: 18px;
  text-align: center;
}

/* ---------- 局内开关 ---------- */
.formation-auto {
  flex: 0 0 auto;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid rgba(75, 43, 29, 0.22);
}

.formation-auto-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.formation-auto-label {
  color: #4b2b1d;
  font-size: 17px;
  font-weight: 700;
}

.formation-auto-hint {
  /* ★ 必须整行独占：和标签+开关挤一行时，长句会被压成一行然后被窗口右边缘裁掉 */
  flex: 1 1 100%;
  min-width: 0;
  margin-top: 2px;
  color: #8a5a3a;
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-all;
}

.formation-switch {
  position: relative;
  flex: 0 0 auto;
  width: 62px;
  height: 30px;
  padding: 0;
  border: 2px solid #6d4630;
  border-radius: 16px;
  background: rgba(120, 100, 74, 0.5);
  cursor: pointer;
  transition: background 0.15s linear;
}

.formation-switch .formation-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fdf6e3;
  border: 1.5px solid #6d4630;
  transition: left 0.15s linear;
}

.formation-switch.is-on {
  background: #2f7a46;
  border-color: #235c34;
}

.formation-switch.is-on .formation-switch-knob {
  left: 34px;
}

/* ---------- 知道了 ---------- */
.formation-ok {
  flex: 0 0 auto;
  align-self: center;
  margin-top: 8px;
  padding: 5px 30px;
  border: 2px solid #6b4029;
  border-radius: 10px;
  background: #a94435;
  color: #fff3c9;
  font: inherit;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}
