/* Chinese Minecraft Wiki-style — Gravestone Dungeons */

:root {
  --bg: #eaecf0;
  --page: #ffffff;
  --sidebar: #f6f7f9;
  --line: #a2a9b1;
  --line-soft: #c8ccd1;
  --ink: #202122;
  --ink-2: #54595d;
  --muted: #72777d;
  --link: #0645ad;
  --link-hover: #0b0080;
  --visited: #0b0080;
  --accent: #36c;
  --header: #fff;
  --infobox-bg: #f8f9fa;
  --table-head: #eaecf0;
  --note-bg: #fdf3d0;
  --note-border: #d4a017;
  --warn-bg: #fdf2f2;
  --warn-border: #b32424;
  --easy: #2e7d32;
  --mid: #b8860b;
  --hard: #b32424;
  --hc: #6a1b9a;
  --gold: #8a6d00;
  --font: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Cascadia Code", ui-monospace, Consolas, monospace;
  --sidebar-w: 176px;
  --content-max: 960px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 3.2rem; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--visited); }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: #f8f9fa;
  padding: 0 0.25em;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
}

/* —— Top bar —— */
.wiki-header {
  background: var(--header);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.wiki-header .inner {
  max-width: calc(var(--sidebar-w) + var(--content-max) + 40px);
  margin: 0 auto;
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wiki-logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wiki-logo span { color: #54595d; font-weight: 500; font-size: 0.85rem; margin-left: 0.35rem; }
.wiki-logo:hover { text-decoration: none; }

.wiki-search {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.wiki-search input {
  width: min(220px, 36vw);
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font: inherit;
  font-size: 0.88rem;
  background: #fff;
  color: var(--ink);
}

.wiki-search button {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #f8f9fa;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ink);
}

.wiki-search button:hover { background: #eaecf0; }

.toc-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #f8f9fa;
  border-radius: 2px;
  padding: 0.28rem 0.55rem;
  font-size: 0.82rem;
  cursor: pointer;
}

/* —— Shell —— */
.wiki-shell {
  max-width: calc(var(--sidebar-w) + var(--content-max) + 40px);
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

/* —— Sidebar (MediaWiki-like) —— */
.wiki-sidebar {
  background: var(--sidebar);
  border: 1px solid var(--line-soft);
  border-right: none;
  padding: 0.75rem 0.65rem 1rem;
  position: sticky;
  top: 3.1rem;
  max-height: calc(100vh - 3.6rem);
  overflow: auto;
  font-size: 0.84rem;
}

.wiki-sidebar .sb-title {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.55rem 0 0.25rem;
  padding-left: 0.25rem;
  letter-spacing: 0.02em;
}

.wiki-sidebar .sb-title:first-child { margin-top: 0; }

.wiki-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wiki-sidebar li { margin: 0.05rem 0; }

.wiki-sidebar a {
  display: block;
  padding: 0.18rem 0.3rem;
  color: var(--link);
  border-radius: 2px;
}

.wiki-sidebar a:hover { background: #eaf3ff; text-decoration: none; }
.wiki-sidebar a.active { background: #d9e6f7; font-weight: 600; }
.wiki-sidebar a.dimmed { opacity: 0.45; }

/* —— Content —— */
.wiki-content {
  background: var(--page);
  border: 1px solid var(--line-soft);
  min-width: 0;
  padding: 1rem 1.25rem 1.5rem;
}

.breadcrumbs {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.breadcrumbs a { color: var(--link); }

/* Article header */
.article-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
}

.article-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.25;
  color: var(--ink);
}

.article-header .sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Hatnote */
.hatnote {
  font-size: 0.88rem;
  color: var(--ink-2);
  font-style: italic;
  margin: 0.4rem 0 0.75rem;
  padding-left: 1.2em;
}

/* TOC box */
.toc-box {
  display: table;
  background: var(--infobox-bg);
  border: 1px solid var(--line);
  padding: 0.55rem 0.85rem;
  margin: 0.65rem 0 1rem;
  font-size: 0.88rem;
  max-width: 320px;
}

.toc-box .toc-title {
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.25rem;
}

.toc-box ol {
  margin: 0;
  padding-left: 1.25rem;
}

.toc-box li { margin: 0.1rem 0; }

.toc-box .toc-num { color: var(--muted); margin-right: 0.25rem; }

/* Sections — wiki article blocks */
.article {
  margin: 1.25rem 0 1.75rem;
  padding-top: 0.25rem;
  scroll-margin-top: 3.5rem;
}

.article + .article {
  border-top: 1px solid var(--line-soft);
  padding-top: 0.75rem;
}

.article > h2 {
  margin: 0 0 0.55rem;
  font-size: 1.35rem;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.2rem;
  clear: both;
}

.article h3 {
  margin: 1rem 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0.15rem;
}

.article h4 {
  margin: 0.75rem 0 0.3rem;
  font-size: 0.98rem;
  font-weight: 700;
}

.article p { margin: 0.4rem 0; }

.article ul.bullets, .article ol.numbered {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.5rem;
}

.article ul.bullets li, .article ol.numbered li { margin: 0.15rem 0; }

/* Infobox — right float like MC wiki */
.infobox {
  float: right;
  width: min(280px, 100%);
  margin: 0 0 0.75rem 1rem;
  border: 1px solid var(--line);
  background: var(--infobox-bg);
  font-size: 0.84rem;
  line-height: 1.45;
}

.infobox .ib-title {
  background: var(--table-head);
  border-bottom: 1px solid var(--line);
  padding: 0.4rem 0.55rem;
  font-weight: 700;
  text-align: center;
  font-size: 0.95rem;
}

.infobox .ib-img {
  text-align: center;
  padding: 0.55rem;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
}

.infobox .ib-img img {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  max-height: 120px;
}

.infobox table {
  width: 100%;
  border-collapse: collapse;
}

.infobox td {
  padding: 0.28rem 0.5rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.infobox tr:last-child td { border-bottom: none; }

.infobox td.k {
  width: 38%;
  color: var(--muted);
  font-weight: 600;
}

.infobox td.v { color: var(--ink); }

/* Clearfix after infobox */
.clear { clear: both; }

/* Notes */
.note, .warning {
  margin: 0.65rem 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  border-left: 4px solid;
}

.note {
  background: var(--note-bg);
  border-color: var(--note-border);
}

.warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

/* Tables — wiki style */
.wiki-table-wrap { overflow-x: auto; margin: 0.5rem 0; }

table.wiki {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #fff;
}

table.wiki th,
table.wiki td {
  border: 1px solid var(--line);
  padding: 0.35rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

table.wiki th {
  background: var(--table-head);
  font-weight: 700;
}

table.wiki tr:hover td { background: #f8f9fa; }

table.wiki td.imgs img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  vertical-align: -4px;
  margin-right: 2px;
}

table.craft {
  border-collapse: collapse;
  display: inline-table;
}

table.craft td {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: #f0f0f0;
  padding: 2px;
  text-align: center;
  vertical-align: middle;
}

table.craft img {
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
}

/* Status colors */
.d-easy { color: var(--easy); font-weight: 600; }
.d-mid { color: var(--mid); font-weight: 600; }
.d-hard { color: var(--hard); font-weight: 600; }
.d-hc { color: var(--hc); font-weight: 600; }

.mc-blue { color: #5555ff; }
.mc-red { color: #aa0000; }
.mc-green { color: #00aa00; }
.mc-purple { color: #aa00aa; }
.mc-gold { color: #8a6d00; }
.mc-gray { color: var(--muted); }

/* Item rows */
.item-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.45rem 0.25rem;
  border-bottom: 1px solid var(--line-soft);
}

.item-row:last-child { border-bottom: none; }

.item-row img.pixel {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  object-fit: contain;
  background: #f0f0f0;
  border: 1px solid var(--line-soft);
}

.item-row .name { font-weight: 700; }
.item-row .desc { font-size: 0.88rem; color: var(--ink-2); }
.item-row .desc li { list-style: none; margin: 0.1rem 0; }

.icon {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  vertical-align: -3px;
  margin-right: 2px;
}

/* Mini grid */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.4rem;
  margin: 0.45rem 0;
}

.mini-item {
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 0.4rem 0.55rem;
  font-size: 0.86rem;
}

.mini-item .t { font-weight: 700; }
.mini-item .d { color: var(--muted); font-size: 0.8rem; }

/* Adv grid */
.adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.35rem;
  margin: 0.4rem 0;
}

.adv-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 0.4rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line-soft);
  font-size: 0.84rem;
  background: #fff;
}

.adv-item img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
}

.adv-item .t { font-weight: 600; }
.adv-item .d { color: var(--muted); font-size: 0.78rem; }

/* Craft row */
.craft-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.craft-row:last-child { border-bottom: none; }

.craft-row .result {
  font-weight: 700;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.craft-row .effect { flex: 1; min-width: 120px; font-size: 0.9rem; color: var(--ink-2); }

.craft-arrow { color: var(--ink-2); }

/* Spoiler details */
details.spoiler {
  margin: 0.45rem 0;
  border: 1px solid var(--line-soft);
  background: #f8f9fa;
}

details.spoiler summary {
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  font-size: 0.88rem;
  color: var(--link);
  list-style: none;
}

details.spoiler summary::before { content: "[展开] "; font-weight: 600; }
details.spoiler[open] summary::before { content: "[收起] "; }

details.spoiler .inner {
  padding: 0 0.75rem 0.65rem;
  font-size: 0.88rem;
}

/* Step list for summon */
.steps {
  counter-reset: step;
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 0.45rem 0.55rem 0.45rem 2.4rem;
  margin: 0.35rem 0;
  border: 1px solid var(--line-soft);
  background: #fff;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0.45rem;
  top: 0.45rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--table-head);
  border: 1px solid var(--line);
  text-align: center;
  line-height: 1.45rem;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink);
}

.steps li strong { display: block; margin-bottom: 0.15rem; }
.steps li .detail { font-size: 0.88rem; color: var(--ink-2); }

/* Dialogue */
.dialogue {
  margin: 0.45rem 0;
  padding: 0.55rem 0.75rem;
  background: #f8f9fa;
  border-left: 3px solid var(--line);
  font-size: 0.9rem;
}

.dialogue .who { font-weight: 700; }
.dialogue .who.morbex { color: #6f0c99; }
.dialogue .who.player { color: var(--ink-2); font-weight: 600; }
.dialogue .line { margin: 0.2rem 0; }

/* Category footer */
.categories {
  margin-top: 1.5rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--muted);
}

.categories a { margin-right: 0.35rem; }

/* Site footer */
.wiki-footer {
  max-width: calc(var(--sidebar-w) + var(--content-max) + 40px);
  margin: 0 auto;
  padding: 0.75rem 1rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* Image cards for structures */
.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.55rem;
  margin: 0.55rem 0;
}

.shot-card {
  border: 1px solid var(--line-soft);
  background: #fff;
  font-size: 0.86rem;
}

.shot-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--line-soft);
  background: #ddd;
}

.shot-card .cap { padding: 0.4rem 0.5rem; }
.shot-card .cap .t { font-weight: 700; }
.shot-card .cap .s { color: var(--muted); font-size: 0.78rem; }

/* Responsive */
@media (max-width: 800px) {
  .wiki-shell {
    grid-template-columns: 1fr;
    padding: 0.5rem 0.55rem 1.5rem;
  }

  .wiki-sidebar {
    position: relative;
    top: 0;
    max-height: none;
    border-right: 1px solid var(--line-soft);
    border-bottom: none;
  }

  .wiki-sidebar.collapsed ul { display: none; }

  .toc-toggle { display: inline-block; }

  .wiki-content { padding: 0.75rem 0.75rem 1.25rem; }

  .infobox {
    float: none;
    width: 100%;
    margin: 0 0 0.75rem;
  }

  .article-header h1 { font-size: 1.45rem; }

  .toc-box { max-width: 100%; }
}

/* Search — prevent scroll jump while filtering */
html.searching {
  scroll-behavior: auto !important;
}

body.search-lock {
  overflow-anchor: none;
}

main.wiki-content {
  overflow-anchor: auto;
}

article.article {
  overflow-anchor: auto;
}

.search-panel {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--infobox-bg);
  border-radius: 2px;
}

.search-panel .sr-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.search-panel .sr-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.search-panel .sr-clear {
  margin-left: auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px;
  padding: 0.2rem 0.55rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink);
}

.search-panel .sr-clear:hover { background: #eaecf0; }

.search-panel .sr-hint {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.search-panel .sr-list {
  margin: 0;
  padding-left: 1.4rem;
  max-height: 240px;
  overflow: auto;
  font-size: 0.92rem;
}

.search-panel .sr-list li {
  margin: 0.2rem 0;
}

.search-panel .sr-list a {
  color: var(--link);
  font-weight: 600;
}

.search-panel .sr-list .sr-snip {
  margin: 0.1rem 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.search-panel .sr-list li {
  margin: 0.25rem 0;
  padding-bottom: 0.15rem;
  border-bottom: 1px dashed var(--line-soft);
}

.search-panel .sr-list li:last-child { border-bottom: none; }

.search-empty {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  background: var(--warn-bg);
  color: var(--ink);
  font-size: 0.9rem;
}

.search-hit {
  background: #ffeaa0;
}

.hidden-by-search {
  display: none !important;
}

/* back to hub */
.back-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line-soft);
}
.back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  background: var(--link);
  color: #fff;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.back-home:hover {
  background: var(--link-hover);
  color: #fff;
  text-decoration: none;
}
.back-hub {
  font-size: 0.82rem;
  color: var(--muted);
}
.hub-logo-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
}

.hub-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
}
.hub-main { max-width: 1040px; }
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}
.hub-card {
  display: block;
  background: var(--infobox-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.95rem 1rem;
  text-decoration: none;
  color: inherit;
  min-height: 120px;
}
.hub-card:hover { border-color: var(--link); transform: translateY(-2px); text-decoration: none; color: inherit; }
.hub-title { font-weight: 700; font-size: 1.05rem; }
.hub-en { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0.45rem; }
.hub-desc { font-size: 0.86rem; color: var(--ink-2); margin: 0 0 0.5rem; }
.hub-go { color: var(--link); font-weight: 600; font-size: 0.82rem; }
.header-meta { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 0.3rem; padding: 0.2rem 0.55rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 0.75rem; }
.chip strong { color: var(--link); }

/* tables: full display on narrow/wiki content */
.wiki-content { overflow-x: hidden; }

.wiki-table-wrap {
  overflow-x: auto;
  margin: 0.65rem 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table.wiki {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  table-layout: fixed;
}

table.wiki th,
table.wiki td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

table.wiki th {
  background: var(--table-head);
  font-weight: 700;
}

table.wiki code {
  font-size: 0.72rem;
  word-break: break-all;
  white-space: normal;
  display: inline;
}

/* stacked name+id cell */
.cell-stack { display: flex; flex-direction: column; gap: 0.15rem; }
.cell-stack .id-line {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  word-break: break-all;
}


/* back to hub — force readable contrast, ignore visited purple */
.back-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line-soft);
}

a.back-home,
a.back-home:link,
a.back-home:visited,
a.back-home:hover,
a.back-home:focus,
a.back-home:active {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
  text-decoration: none !important;
  /* high contrast: near-black pill + pure white label */
  background: #1b1b1b !important;
  color: #ffffff !important;
  border: 1px solid #3a3a3a !important;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
  cursor: pointer;
}

a.back-home:hover,
a.back-home:focus {
  background: #2e2e2e !important;
  color: #ffffff !important;
  border-color: #555 !important;
}

a.back-home:active {
  background: #111111 !important;
  color: #ffffff !important;
}

.back-hub {
  font-size: 0.82rem;
  color: var(--muted);
}

.hub-logo-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
}
