/* isaac-wiki-viewer · styles
 * Dark theme tokens follow personal project convention (polyboard / leaderboard).
 * Light theme via html[data-theme="light"]（顶部 🌞/🌙 按钮切换，localStorage 记忆）。
 * No external deps — pure CSS variables, no Tailwind.
 */

:root {
  color-scheme: dark;
  --bg:           #0f1218;
  --bg-elev:      #181c25;
  --border:       #2a2f3c;
  --border-soft:  #23273300;
  --text:         #e6e8ee;
  --text-muted:   #8c93a3;
  --text-dim:     #5e6577;
  --accent:       #7c5cff;
  --accent-soft:  #7c5cff22;
  --warn:         #f1b24a;

  --c-rebirth:    #7fb069;
  --c-afterbirth: #e0a458;
  --c-abplus:     #c084fc;
  --c-repentance: #f87171;

  --header-bg:    rgba(15, 18, 24, 0.85);
  --hover-bg:     #1d2230;
  --thead-bg:     #14171f;

  --radius:       10px;
  --radius-sm:    6px;
  --font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:           #f3f4f7;
  --bg-elev:      #ffffff;
  --border:       #d9dde5;
  --border-soft:  #e7eaf000;
  --text:         #262b36;
  --text-muted:   #5f6779;
  --text-dim:     #98a0af;
  --accent:       #6a4df0;
  --accent-soft:  #6a4df01a;
  --warn:         #b4700f;

  --c-rebirth:    #4f7d3a;
  --c-afterbirth: #9c6a15;
  --c-abplus:     #8040e0;
  --c-repentance: #e05555;

  --header-bg:    rgba(255, 255, 255, 0.86);
  --hover-bg:     #eef0f6;
  --thead-bg:     #edf0f5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.muted   { color: var(--text-muted); }
.small   { font-size: 12px; }
.lead    { font-size: 15px; color: var(--text-muted); margin: 0 0 8px; }

/* ───────── Header ───────── */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  white-space: nowrap;
}
.site-nav {
  margin-left: auto;
  display: flex; gap: 4px;
  align-items: center;
}
.site-nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  transition: background .12s ease, color .12s ease;
}
.site-nav a:hover { color: var(--text); background: var(--hover-bg); }
.site-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.theme-toggle {
  flex: none;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: border-color .12s ease;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ───────── Container ───────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ───────── Intro ───────── */
.intro h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: 0.5px;
}
.intro a { color: var(--accent); border-bottom: 1px dashed var(--accent); }

/* ───────── Pages Grid ───────── */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.page-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  cursor: pointer;
  position: relative;
}
.page-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--hover-bg);
}
.page-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.page-card .icon {
  font-size: 32px;
  line-height: 1;
}
.page-card .title {
  font-size: 16px;
  font-weight: 600;
}
.page-card .subtitle {
  font-size: 12px;
  color: var(--text-muted);
}
.page-card .badge {
  position: absolute; top: 12px; right: 12px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.5px;
}
.page-card .badge.disabled {
  background: var(--border);
  color: var(--text-dim);
}

/* ───────── Toolbar ───────── */
.toolbar h1 {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 16px;
}
.count-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.toolbar-row {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1; min-width: 220px;
}
.search-wrap input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s ease;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
  pointer-events: none;
}

.filter-group {
  display: flex; gap: 4px;
  flex-wrap: wrap;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.filter-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active {
  background: var(--accent);
  color: #fff;
}
.filter-btn[style*="--c"]:not(.active) {
  position: relative;
}
.filter-btn[style*="--c"]:not(.active)::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: middle;
}
.filter-btn.active::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #fff; margin-right: 6px; vertical-align: middle;
}

/* ───────── Table ───────── */
.table-wrap {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--bg-elev);
}
.items-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}
.items-table tbody tr {
  /* hash 定位行落在 sticky 顶栏(~56px)之下,避免被压住 */
  scroll-margin-top: 56px;
}
.items-table thead th {
  position: sticky; top: 0;
  background: var(--thead-bg);
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.items-table thead th[data-type="int"] { width: 80px; text-align: right; }
.items-table thead th[data-type="icon"] { width: 48px; text-align: center; }
.items-table thead th[data-type="dlc"] { width: 100px; text-align: center; }
.items-table thead th:hover { color: var(--accent); }
.items-table thead th.sort-asc::after  { content: " ▲"; font-size: 9px; }
.items-table thead th.sort-desc::after { content: " ▼"; font-size: 9px; }

.items-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.items-table tbody tr:hover { background: var(--hover-bg); }
.items-table tbody td.col-id { text-align: right; color: var(--text-muted); font-family: var(--font-mono); }
.items-table tbody td.col-icon { text-align: center; padding: 4px 6px; }
.items-table tbody td.col-dlc { text-align: center; }

.icon-sprite {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto;
  background-image: url('icons/collectibles.png');
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
/* 饰品页用独立 sprite 图（坐标同样镜像自 wiki 渲染 CSS） */
.icon-sprite.icon-trinket {
  background-image: url('icons/trinkets.png');
}
/* 胶囊/卡牌/符文（卡牌页混用 cards + runes 两张图，按行内 icon_class 切换） */
.icon-sprite.icon-pill {
  background-image: url('icons/pills.png');
}
.icon-sprite.icon-card {
  background-image: url('icons/cards.png');
}
.icon-sprite.icon-rune {
  background-image: url('icons/runes.png');
  /* wiki 端同样做 1/8 缩放（2304×256 → 288×32），坐标在其缩放空间内 */
  background-size: 288px 32px;
}
.icon-sprite.icon-empty {
  background: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  line-height: 32px;
  text-align: center;
}

.dlc-chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.dlc-chip.rebirth         { background: #7fb06922; color: var(--c-rebirth); }
.dlc-chip.afterbirth      { background: #e0a45822; color: var(--c-afterbirth); }
.dlc-chip.afterbirth_plus { background: #c084fc22; color: var(--c-abplus); }
.dlc-chip.repentance      { background: #f8717122; color: var(--c-repentance); }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

/* ───────── Back to top ───────── */
.back-top {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 20;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease, border-color .12s ease, color .12s ease;
}
.back-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.back-top:hover { border-color: var(--accent); color: var(--accent); }

/* ───────── Footer ───────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  margin-top: 40px;
}
.site-footer a { color: var(--accent); }

/* ───────── Responsive ───────── */
/* 折叠屏竖屏 / 小平板（含 w800×h900） */
@media (max-width: 860px) {
  .container { padding: 18px; }
  .search-wrap { min-width: 200px; }
  .intro h1 { font-size: 24px; }
}

/* 手机 */
@media (max-width: 640px) {
  .header-inner { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 14px; }
  .brand .brand-sub { display: none; }
  /* nav 容器横滚（6 个链接在小屏塞不下；保留 flex-wrap nowrap 让 brand 不被压扁） */
  .site-nav {
    margin-left: auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 70vw;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a {
    padding: 6px 8px;
    font-size: 12px;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .container { padding: 14px; }
  .intro h1 { font-size: 21px; }
  .toolbar h1 { font-size: 19px; gap: 8px; }
  .pages-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .page-card { padding: 14px; }
  /* 窄屏隐藏旧中文译名列（信息次要，横向空间让给前四列） */
  .items-table th:nth-child(5),
  .items-table td:nth-child(5) { display: none; }
  .items-table tbody td { padding: 7px 8px; }
  .items-table thead th { padding: 9px 8px; }
  .back-top { right: 14px; bottom: 14px; }
}

/* ───────── Console page (console.html) ───────── */
.console-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}
.console-toc {
  position: sticky;
  top: 72px;
  align-self: start;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.console-toc h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
  padding: 0 6px;
}
.console-toc ol {
  list-style: none;
  margin: 0; padding: 0;
  counter-reset: csec;
}
.console-toc ol li {
  counter-increment: csec;
  position: relative;
}
.console-toc a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px 6px 24px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
  line-height: 1.4;
}
.console-toc a::before {
  content: counter(csec, decimal-leading-zero);
  position: absolute;
  left: 6px; top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  font-feature-settings: "tnum";
}
.console-toc a:hover { color: var(--text); background: var(--hover-bg); }
.console-toc a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.console-content {
  min-width: 0;
}
.console-section {
  scroll-margin-top: 76px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.console-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  letter-spacing: 0.3px;
}
.console-section h2 .sec-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.5px;
}
.console-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 8px;
  padding: 0 0 0 0;
}
.console-section h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 14px 0 8px;
}
.console-section .lead { margin-bottom: 14px; }
.console-section p { margin: 0 0 10px; }
.console-section ul, .console-section ol { margin: 0 0 12px; padding-left: 22px; }
.console-section li { margin-bottom: 4px; }
.console-section li::marker { color: var(--text-dim); }

/* callout boxes */
.console-callout {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid;
}
.console-callout .callout-label {
  font-weight: 600;
  margin-right: 6px;
}
.console-callout.info {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.console-callout.warn {
  background: rgba(241, 178, 74, 0.10);
  border-color: var(--warn);
  color: var(--text);
}
.console-callout.danger {
  background: rgba(248, 113, 113, 0.10);
  border-color: #f87171;
  color: var(--text);
}
:root[data-theme="light"] .console-callout.danger {
  background: #f8717114;
}

/* prerequisites steps */
.console-steps {
  list-style: none;
  margin: 0; padding: 0;
  counter-reset: cstep;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.console-steps li {
  counter-increment: cstep;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 40px;
  position: relative;
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}
.console-steps li .small { display: block; margin-top: 4px; }
.console-steps li::before {
  content: counter(cstep);
  position: absolute;
  left: 12px; top: 12px;
  width: 20px; height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
}

/* TOP 15 featured grid */
.console-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.console-top-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .12s ease, transform .12s ease;
}
.console-top-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.console-top-card .top-rank {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.5px;
  font-weight: 700;
}

/* code chip with copy */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  color: var(--text);
  user-select: all;
  transition: border-color .12s ease, background .12s ease;
  white-space: nowrap;
  vertical-align: baseline;
}
.code-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.code-chip::after {
  content: "⧉";
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 2px;
  transition: color .12s ease;
}
.code-chip:hover::after { color: var(--accent); }
.code-chip.copied {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.10);
}
:root[data-theme="light"] .code-chip.copied {
  background: #4ade8018;
}
.code-chip.copied::after {
  content: "✓";
  color: #4ade80;
}

/* console command tables (reuse .items-table structure for consistency) */
.cmd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0 6px;
  table-layout: fixed;
}

/* 步骤卡内 chip 允许断字（路径 chip 在桌面 2 列布局下也会溢出右边界） */
.console-steps .code-chip {
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
}
/* 让 .cmd-table 自动横滚收纳(无需改 HTML,每个 cmd-table 都能横滚) */
.cmd-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0 6px;
}
.cmd-table-wrap .cmd-table { margin: 0; }
.cmd-table th, .cmd-table td {
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.cmd-table th {
  background: var(--thead-bg);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.cmd-table tbody tr:hover { background: var(--hover-bg); }
.cmd-table td.cmd { white-space: nowrap; }
.cmd-table td.cmd .code-chip { font-size: 12.5px; }
.cmd-table td.note { color: var(--text-muted); font-size: 12.5px; }
.cmd-table .pair-block {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 18px;
  align-items: baseline;
}
.cmd-table .pair-block .pair-cmd { white-space: nowrap; }
.cmd-table .pair-block .pair-desc { color: var(--text-muted); font-size: 12.5px; }

/* code block (multi-line) */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  overflow-x: auto;
  margin: 8px 0;
  white-space: pre;
  position: relative;
}
.code-block::after {
  content: "copy";
  position: absolute;
  top: 6px; right: 10px;
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 1px;
  cursor: pointer;
}
.code-block:hover::after { color: var(--accent); }

/* wiki link badge (red text -> link) */
.wiki-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
}
.wiki-link:hover { color: var(--text); text-decoration-style: solid; }

/* responsive: stack TOC on top + hide labels */
@media (max-width: 860px) {
  .console-layout { grid-template-columns: 1fr; }
  .console-toc {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .console-toc ol {
    columns: 2;
    column-gap: 16px;
  }
  .console-toc a { break-inside: avoid; }
}
@media (max-width: 640px) {
  .console-section { padding: 16px 14px; }
  .console-section h2 { font-size: 16px; }
  .console-top-grid { grid-template-columns: 1fr; }
  .console-toc ol { columns: 1; }
  /* 命令表窄屏强制触发 .cmd-table-wrap 横滚（table-layout: fixed 已全局,这里设 min-width） */
  .cmd-table-wrap .cmd-table {
    min-width: 520px;
    font-size: 12.5px;
  }
  .cmd-table th, .cmd-table td {
    padding: 6px 8px;
    word-wrap: break-word;
    word-break: break-word;  /* 中文长串允许字符间断行 */
  }
  /* 窄屏允许 chip 内部换行（避免 nowrap 撑爆 td.cmd 让描述列被挤窄） */
  .cmd-table td.cmd .code-chip {
    white-space: normal;
    word-break: break-all;
    line-height: 1.4;
  }
  /* 步骤卡窄屏改 1 列（4 列在 393px 下每列 ~85px 塞不下 chip + 文字） */
  .console-steps {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .console-steps li {
    padding: 10px 12px 10px 38px;
    font-size: 12.5px;
  }
  .console-steps li::before {
    left: 10px; top: 10px;
    width: 18px; height: 18px;
    font-size: 10px;
  }
  /* chip 路径在窄屏允许断字（如「文档\My Games\...」无空格） */
  .console-steps .code-chip {
    word-break: break-all;
    white-space: normal;
    line-height: 1.4;
  }
  /* callout 窄屏 padding 调小 */
  .console-callout { padding: 10px 12px; font-size: 12.5px; }
}
