/* ==========================================================================
   卫戍协议 · 干员速查  —  纯 CSS，无框架，主题由 html[data-theme] 驱动
   ========================================================================== */

:root {
  --bg: #0e1014;
  --bg-soft: #13161c;
  --surface: #181c24;
  --surface-2: #1f2430;
  --border: #2a3040;
  --border-strong: #3a4356;
  --text: #e8ecf3;
  --text-dim: #a3adbe;
  --text-mute: #6c7688;
  --accent: #e0b04a;
  --accent-soft: rgba(224, 176, 74, 0.14);
  --accent-2: #5cc8c0;
  --accent-2-soft: rgba(92, 200, 192, 0.14);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --radius-lg: 14px;
  --maxw: 1280px;
  --font: "Segoe UI", -apple-system, "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
}

html[data-theme="light"] {
  --bg: #f2f4f7;
  --bg-soft: #e9ecf1;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --border: #dfe4ec;
  --border-strong: #c5cddb;
  --text: #1b2230;
  --text-dim: #55617a;
  --text-mute: #8a94a8;
  --accent: #b8862f;
  --accent-soft: rgba(184, 134, 47, 0.12);
  --accent-2: #2a9d95;
  --accent-2-soft: rgba(42, 157, 149, 0.12);
  --shadow: 0 6px 20px rgba(20, 30, 50, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(900px 420px at 12% -10%, rgba(224, 176, 74, 0.10), transparent 65%),
    radial-gradient(760px 380px at 88% 0%, rgba(92, 200, 192, 0.08), transparent 62%);
  background-repeat: no-repeat;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button { font-family: inherit; font-size: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(14, 16, 20, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
html[data-theme="light"] .topbar { background: rgba(242, 244, 247, 0.85); }

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.topbar .brand:hover { text-decoration: none; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: block;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(224, 176, 74, 0.55);
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(224, 176, 74, 0.3);
}
html[data-theme="light"] .brand-mark {
  border-color: rgba(169, 124, 34, 0.4);
  box-shadow: 0 2px 8px rgba(169, 124, 34, 0.18);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: 0.06em; }
.brand-text small { color: var(--text-mute); font-size: 11px; letter-spacing: 0.14em; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-ghost,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-icon { width: 32px; padding: 0; }
.btn-ghost:hover,
.btn-icon:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
  text-decoration: none;
}

/* ---------------------------------------------------------------- layout */

.app {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-mute);
}
.crumbs a { color: var(--text-dim); }
.crumbs .sep { color: var(--border-strong); }
.crumbs .here { color: var(--text); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-mute);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.muted { color: var(--text-mute); }

/* ---------------------------------------------------------------- home */

.hero { padding: 18px 0 24px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: 0.04em;
  font-weight: 700;
}
.hero h1 .accent { color: var(--accent); }
.hero p { margin: 0; color: var(--text-dim); max-width: 64ch; }
.hero p.season-source {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-mute);
  max-width: 72ch;
}

.season-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.season-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  min-height: 152px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--surface-2), var(--surface) 62%);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.season-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, var(--accent-soft));
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.season-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.season-card:hover::after { opacity: 1; }

.season-card.is-pending { opacity: 0.42; cursor: not-allowed; filter: grayscale(0.7); }
.season-card.is-pending:hover { transform: none; border-color: var(--border); box-shadow: none; }

.season-index { font-size: 11px; letter-spacing: 0.22em; color: var(--accent); }
.season-title { font-size: 19px; font-weight: 600; }
.season-meta { font-size: 13px; color: var(--text-mute); }
.season-cta { margin-top: auto; font-size: 13px; color: var(--accent); }

/* ------------------------------------------------------------ season view */

.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 26px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.group-head h2 { margin: 0; font-size: 17px; letter-spacing: 0.1em; font-weight: 600; }
.group-head .count { font-size: 12px; color: var(--text-mute); }
.group-head.core h2 { color: var(--accent); }
.group-head.extra h2 { color: var(--accent-2); }

.covenant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}

.cov-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s;
}
.cov-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.cov-card.extra:hover { border-color: var(--accent-2); }

.cov-icon {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(150deg, var(--surface-2), var(--bg-soft));
  border: 1px solid var(--border-strong);
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  flex: none;
}
.cov-card.extra .cov-icon { color: var(--accent-2); }
.cov-icon img { width: 100%; height: 100%; object-fit: contain; }
/* PRTS 图标是白线稿 + 透明底，套一层圆形深色底纹才看得见（同 PRTS 模板） */
.cov-icon.has-img {
  border-radius: 50%;
  border-color: rgba(224, 176, 74, 0.55);
  background: radial-gradient(circle at 50% 42%, #8a6a24 0%, #2b2418 58%, #14100b 100%);
}
.cov-card.extra .cov-icon.has-img,
.cov-hero.extra .cov-icon.has-img {
  border-color: rgba(92, 200, 192, 0.55);
  background: radial-gradient(circle at 50% 42%, #2b8f79 0%, #1c2b2b 58%, #0e1414 100%);
}

.cov-name { font-size: 14px; font-weight: 600; letter-spacing: 0.04em; text-align: center; }
.cov-need { font-size: 11px; color: var(--text-mute); }

/* ---------------------------------------------------------- covenant view */

.cov-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(140deg, var(--surface-2), var(--surface) 70%);
}
.cov-hero .cov-icon { width: 76px; height: 76px; font-size: 28px; }
.cov-hero h1 { margin: 0; font-size: 22px; letter-spacing: 0.06em; }
.cov-hero .cov-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-mute); }
/* 返回盟约列表：hero 右侧的大按钮，手机上占满一行 */
.cov-hero .cov-back {
  margin-left: auto;
  flex: none;
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  white-space: nowrap;
}
.cov-hero .cov-back:hover { color: var(--accent); border-color: var(--accent); }
.cov-hero.extra .cov-back:hover { color: var(--accent-2); border-color: var(--accent-2); }

.cov-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.panel-head h2 { margin: 0; font-size: 13px; letter-spacing: 0.16em; color: var(--text-dim); font-weight: 600; }
.panel-head .hint { font-size: 12px; color: var(--text-mute); }

.op-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  padding: 14px;
}
/* 空盟约（如「绝技」没有固定成员）时，提示占满整行 */
.op-grid > .empty {
  grid-column: 1 / -1;
  padding: 24px 16px;
  background: transparent;
}

.op-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.op-card:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-2); }
.op-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 6px 16px rgba(224, 176, 74, 0.18);
}

.op-avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(150deg, var(--surface-2), var(--bg-soft));
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-mute);
}
.op-avatar img { width: 100%; height: 100%; object-fit: cover; }

.op-name {
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.op-tier {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(10, 12, 16, 0.78);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

/* ------------------------------------------------------------ 叠层核心 */

.panel-tools { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stack-toggle { height: 26px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.stack-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.op-stack-badge { display: none; }
.op-grid.stack-view .op-card {
  transition: transform 0.15s, opacity 0.18s, filter 0.18s,
    border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
/* 没有叠层能力：压暗去色 */
.op-grid.stack-view .op-card[data-stack="none"] { opacity: 0.26; filter: grayscale(1); }
.op-grid.stack-view .op-card[data-stack="none"]:hover { opacity: 0.5; filter: grayscale(0.4); }
/* 浅色主题下压得太狠会看不见，留一点对比度 */
html[data-theme="light"] .op-grid.stack-view .op-card[data-stack="none"] { opacity: 0.42; }
/* 当前选中的卡不压暗，避免看不清选中态 */
.op-grid.stack-view .op-card[aria-pressed="true"] { opacity: 1; filter: none; }
/* 有一点叠层能力：正常显示 */
/* 叠层能力特别强：描金高亮 + 角标 */
.op-grid.stack-view .op-card[data-stack="strong"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 8px 20px rgba(224, 176, 74, 0.22);
}
.op-grid.stack-view .op-card[data-stack="strong"] .op-name {
  color: var(--accent);
  font-weight: 600;
}
.op-grid.stack-view .op-card[data-stack="strong"] .op-stack-badge {
  display: grid;
  place-items: center;
  position: absolute;
  top: 4px;
  left: 4px;
  height: 16px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--accent);
  color: #14161c;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------- detail */

.detail {
  position: sticky;
  top: 74px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.detail h2 { margin: 0 0 2px; font-size: 13px; letter-spacing: 0.16em; color: var(--text-dim); font-weight: 600; }

.detail-op { display: flex; align-items: center; gap: 12px; }
.detail-op .op-avatar { width: 64px; height: 64px; flex: none; aspect-ratio: auto; }
.detail-op .name { font-size: 18px; font-weight: 600; line-height: 1.2; }
.detail-op .meta { font-size: 12px; color: var(--text-mute); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.chip.core { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.extra { border-color: var(--accent-2); color: var(--accent-2); background: var(--accent-2-soft); }

.effect-block { display: flex; flex-direction: column; gap: 8px; }
.effect-label { font-size: 11px; letter-spacing: 0.18em; color: var(--text-mute); }
.effect-text {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.effect-text em { font-style: normal; color: var(--accent); }
.effect-text .bonus {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 2px solid var(--accent-2);
  background: var(--accent-2-soft);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* 精锐（升级后）特质 */
.trait-up {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
}
.trait-up-label {
  display: inline-block;
  margin-bottom: 2px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--accent);
}
.trait-up .effect-text { font-size: 13px; color: var(--text-dim); }

.detail-empty { color: var(--text-mute); font-size: 13px; }

@media (max-width: 980px) {
  .cov-layout { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; }
}

@media (max-width: 560px) {
  .app { padding: 18px 14px 48px; }
  .covenant-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .cov-icon { width: 52px; height: 52px; font-size: 20px; }
  .op-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; padding: 10px; }
  .cov-hero { flex-wrap: wrap; padding: 12px; gap: 12px; }
  .cov-hero .cov-icon { width: 60px; height: 60px; }
  .cov-hero .cov-back { margin-left: 0; width: 100%; height: 44px; }
  .panel-head .hint { display: none; }
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px 26px;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--text-dim); }
