/*
 * Helsincy Mod Manager 官网 — 自动发现 / 前置体检 / 存档守护
 *
 * 这两个区块里的面板都是纯 HTML + CSS 绘制的界面模型，不是截图。
 * 里面出现的路径、文件名、状态码全部来自主仓库的真实实现，改功能时要一起改：
 *   前置规则  src-tauri/crates/hmm-games-mhw/data/mhw-prerequisites.default.json
 *   库扫描    src-tauri/crates/hmm-infra/src/game_discovery.rs
 *   存档发现  docs/SAVE_DIRECTORY_AUTO_DISCOVERY_DESIGN.md
 *   后台保障  docs/SAVE_BACKUP_BACKGROUND_AUTOMATION_DESIGN.md
 */

/* ================= 通用：开发中标记 ================= */

/* 已落地和未落地的能力必须一眼分得出来，否则就是在骗玩家。 */
.pill--wip {
  border-color: rgb(247 169 59 / 34%);
  background: rgb(247 169 59 / 7%);
  color: var(--ember);
}

.tag-wip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  border: 1px solid rgb(247 169 59 / 30%);
  border-radius: var(--r-xs);
  background: rgb(247 169 59 / 7%);
  padding: 0.15em 0.5em;
  color: var(--ember);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 0.12em;
  white-space: nowrap;
}

/* ================= 自动发现 + 前置体检 ================= */

.discover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 1.6rem);
  align-items: start;
}

@media (width <= 980px) {
  .discover {
    grid-template-columns: 1fr;
  }
}

/* 右列是两块：体检面板 + 竖排的边界说明。
   拆成一列而不是让面板拉伸，是为了跟左边的扫描链路等高，不留一大块空档。 */
.discover__col {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2vw, 1.6rem);
}

/* ---------- 扫描链路 ---------- */

.probe {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 70% at 0% 0%, rgb(36 193 240 / 9%), transparent 60%),
    linear-gradient(165deg, var(--ink-850), var(--ink-900) 62%);
  padding: clamp(1.4rem, 2.4vw, 2.1rem);
}

.probe__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.probe__head h3 {
  font-family: var(--font-display-cn);
  font-size: 1.08rem;
}

.lang-en .probe__head h3 {
  font-family: var(--font-display);
}

.chain {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding-left: 1.9rem;
}

/* 贯穿四步的冰线，尾部淡出 */
.chain::before {
  position: absolute;
  top: 0.55rem;
  bottom: 1.4rem;
  left: 6px;
  width: 1px;
  background: linear-gradient(180deg, var(--ice-400), var(--line) 70%, transparent);
  content: "";
}

.link-step {
  position: relative;
}

.link-step::before {
  position: absolute;
  top: 0.3rem;
  left: -1.9rem;
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink-950);
  border-radius: 50%;
  background: var(--ice-400);
  box-shadow: 0 0 12px rgb(36 193 240 / 55%);
  content: "";
}

.link-step--last::before {
  background: var(--jade);
  box-shadow: 0 0 14px rgb(79 224 176 / 60%);
}

.link-step__name {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  color: var(--frost-100);
  font-size: 0.95rem;
  font-weight: 500;
}

.link-step__name em {
  color: var(--frost-700);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-style: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* 真实路径片段用等宽字，跟正文明确区分开 */
.link-step code {
  display: block;
  overflow-x: auto;
  margin: 0.5rem 0 0.4rem;
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--ice-a40);
  border-radius: var(--r-xs);
  background: rgb(4 7 15 / 62%);
  padding: 0.45rem 0.7rem;
  color: var(--ice-300);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.link-step p {
  color: var(--frost-600);
  font-size: 0.82rem;
  line-height: 1.7;
}

.probe__foot {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 1.1rem;
  color: var(--frost-600);
  font-size: 0.8rem;
  line-height: 1.7;
}

.probe__foot::before {
  flex-shrink: 0;
  color: var(--ice-400);
  font-family: var(--font-mono);
  content: "⌗";
}

/* ---------- 前置体检面板 ---------- */

.preflight {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--ink-900);
  box-shadow: var(--shadow-card);
}

.preflight__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--ink-800), var(--ink-850));
  padding: 0.95rem 1.2rem;
}

.preflight__bar h4 {
  color: var(--frost-050);
  font-size: 0.92rem;
  font-weight: 600;
}

.preflight__bar .pill {
  margin-left: auto;
}

.pf-list {
  display: flex;
  flex-direction: column;
}

.pf {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 0.3rem 0.85rem;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  padding: 1rem 1.2rem;
  transition: background var(--dur);
}

.pf:hover {
  background: var(--ink-850);
}

/* 状态图标：CSS 画的对勾 / 感叹 / 叉，避免为三个符号引一套图标 */
.pf__state {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid currentcolor;
  border-radius: 50%;
  color: var(--frost-700);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.pf--ok .pf__state {
  color: var(--jade);
  background: rgb(79 224 176 / 10%);
}

.pf--ok .pf__state::after {
  content: "✓";
}

.pf--unverified .pf__state {
  color: var(--ice-400);
  background: var(--ice-a08);
}

.pf--unverified .pf__state::after {
  content: "?";
}

.pf--warn .pf__state {
  color: var(--ember);
  background: rgb(247 169 59 / 10%);
}

.pf--warn .pf__state::after {
  content: "!";
}

.pf--miss .pf__state {
  color: var(--coral);
  background: rgb(255 122 107 / 10%);
}

.pf--miss .pf__state::after {
  content: "×";
  font-size: 0.85rem;
}

.pf__name {
  color: var(--frost-100);
  font-size: 0.92rem;
  font-weight: 500;
}

.pf__badge {
  border-radius: var(--r-xs);
  padding: 0.2em 0.55em;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.pf--ok .pf__badge {
  background: rgb(79 224 176 / 12%);
  color: var(--jade);
}

.pf--unverified .pf__badge {
  background: var(--ice-a08);
  color: var(--ice-400);
}

.pf--warn .pf__badge {
  background: rgb(247 169 59 / 12%);
  color: var(--ember);
}

.pf--miss .pf__badge {
  background: rgb(255 122 107 / 12%);
  color: var(--coral);
}

.pf__detail {
  grid-column: 2 / -1;
  color: var(--frost-600);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

/* 路径用等宽字，结论句回到正文字体——Chakra Petch 没有中文字形，
   中文落到 fallback 上间距会很散。 */
.pf__detail b {
  display: inline-block;
  margin-top: 0.35rem;
  color: var(--frost-300);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
}

.preflight__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 1rem 1.2rem;
}

.preflight__foot span {
  color: var(--frost-600);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

/* 必须限定直接子元素：每个环节里还嵌着 zh/en 两个 span，
   用裸的 `span + span` 会连内层的英文 span 也加上箭头。 */
.preflight__foot > span + span::before {
  margin-right: 0.5rem;
  color: var(--ice-500);
  content: "→";
}

/* ================= 存档守护 ================= */

.guardian {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 1.6rem);
  align-items: start;
}

@media (width <= 980px) {
  .guardian {
    grid-template-columns: 1fr;
  }
}

.gpanel {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: linear-gradient(165deg, var(--ink-850), var(--ink-900) 60%);
  padding: clamp(1.4rem, 2.4vw, 2rem);
}

.gpanel__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
}

.gpanel__head h3 {
  font-family: var(--font-display-cn);
  font-size: 1.08rem;
}

.lang-en .gpanel__head h3 {
  font-family: var(--font-display);
}

.gpanel > p {
  color: var(--frost-500);
  font-size: 0.88rem;
  line-height: 1.75;
}

/* ---------- 多 Steam 账号候选确认 ---------- */

.accounts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgb(4 7 15 / 55%);
  padding: 0.85rem;
}

.accounts__hint {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.15rem 0.2rem 0.35rem;
  color: var(--frost-500);
  font-size: 0.78rem;
}

.acct {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--ink-850);
  padding: 0.7rem 0.85rem;
  transition: border-color var(--dur), background var(--dur);
}

.acct:hover {
  border-color: var(--ice-a24);
  background: var(--ink-800);
}

/* 推荐项 = 最近修改的那个候选；后端给标记，但仍然要用户点一下 */
.acct--rec {
  border-color: var(--ice-a24);
  background: linear-gradient(100deg, rgb(36 193 240 / 10%), var(--ink-850) 55%);
}

/* 头像用 CSS 渐变绘制：CSP 的 img-src 是 'self' data:，不能外链 Steam 头像 */
.acct__avatar {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--av, linear-gradient(140deg, var(--ink-700), var(--ink-850)));
  color: var(--frost-050);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
}

.acct__avatar--unknown {
  color: var(--frost-700);
}

.acct__meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.acct__meta b {
  color: var(--frost-100);
  font-size: 0.88rem;
  font-weight: 500;
}

.acct__meta b.is-muted {
  color: var(--frost-600);
  font-style: italic;
}

.acct__meta span {
  color: var(--frost-600);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.acct__pick {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--ice-a08);
  padding: 0.32em 0.7em;
  color: var(--frost-300);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.acct--rec .acct__pick {
  border-color: var(--ice-a40);
  background: var(--ice-a14);
  color: var(--ice-300);
}

.acct__rec {
  flex-shrink: 0;
  border-radius: var(--r-xs);
  background: rgb(79 224 176 / 12%);
  padding: 0.2em 0.5em;
  color: var(--jade);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

@media (width <= 460px) {
  .acct__pick {
    display: none;
  }
}

/* ---------- 备份节奏 ---------- */

.rhythm {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.beat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--ink-900);
  padding: 0.75rem 0.9rem;
}

.beat__clock {
  grid-row: span 2;
  align-self: center;
  min-width: 4.6em;
  color: var(--ice-300);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.beat--hold .beat__clock {
  color: var(--ember);
}

.beat b {
  color: var(--frost-100);
  font-size: 0.85rem;
  font-weight: 500;
}

.beat span {
  color: var(--frost-600);
  font-size: 0.76rem;
  line-height: 1.6;
}

/* ---------- 后台保障状态机 ---------- */

.states {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.states code {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xs);
  background: rgb(4 7 15 / 55%);
  padding: 0.28em 0.6em;
  color: var(--frost-700);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.02em;
}

.states code.is-good {
  border-color: rgb(79 224 176 / 34%);
  background: rgb(79 224 176 / 8%);
  color: var(--jade);
}

.states code.is-wait {
  border-color: var(--ice-a24);
  background: var(--ice-a08);
  color: var(--ice-300);
}

/* ---------- 退出保护对话框 ---------- */

.exitguard {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.2rem;
  align-items: center;
  border: 1px solid rgb(247 169 59 / 26%);
  border-radius: var(--r-lg);
  background:
    radial-gradient(90% 140% at 0% 50%, rgb(247 169 59 / 8%), transparent 60%),
    var(--ink-900);
  padding: clamp(1.2rem, 2.2vw, 1.8rem);
}

@media (width <= 760px) {
  .exitguard {
    grid-template-columns: 1fr;
  }
}

.exitguard__title {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.5rem;
  color: var(--frost-050);
  font-size: 0.98rem;
  font-weight: 600;
}

.exitguard__title svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--ember);
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.exitguard p {
  max-width: 58ch;
  color: var(--frost-500);
  font-size: 0.86rem;
  line-height: 1.75;
}

.exitguard__acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.exitguard__acts span {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.5em 0.9em;
  color: var(--frost-500);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* 默认焦点落在“留在托盘”上——危险退出不能是顺手就点到的那个 */
.exitguard__acts span.is-default {
  border-color: var(--ice-a40);
  background: var(--ice-a14);
  box-shadow: 0 0 0 3px rgb(36 193 240 / 10%);
  color: var(--frost-050);
  font-weight: 500;
}

/* ---------- 隐私边界条 ---------- */

.boundary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 1px;
  margin-top: clamp(1rem, 2vw, 1.6rem);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--line-soft);
  overflow: hidden;
}

/* 放进右列时改成竖排，并交出 margin——间距由 .discover__col 的 gap 统一给 */
.boundary--stack {
  grid-template-columns: 1fr;
  margin-top: 0;
}

.boundary > div {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--ink-900);
  padding: 1.15rem 1.3rem;
}

.boundary b {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--frost-100);
  font-size: 0.86rem;
  font-weight: 500;
}

.boundary b::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ice-500);
  box-shadow: 0 0 8px var(--ice-500);
  content: "";
}

.boundary p {
  color: var(--frost-600);
  font-size: 0.8rem;
  line-height: 1.7;
}
