/* Top Heroes Wiki — readable column width, Traditional Chinese */
:root {
  --bg: #f7f3ea;
  --bg-card: #fffdf7;
  --ink: #1c1a16;
  --muted: #5c564c;
  --line: #d9d0bf;
  --accent: #8a6a14;
  --term-bg: rgba(232, 180, 35, 0.22);
  --link: #6b4e0e;
  --link-hover: #9a6d10;
  --header: #2a2418;
  --callout: #efe6c9;
  --max: 44rem;
  --gold: #e8b423;
  --gold-stroke: #b07a10;
  --red: #dc3b3b;
  --red-stroke: #9a1e1e;
  --white: #f7f4ff;
  --white-stroke: #8b90c8;
  font-family: "Noto Sans TC", "Source Han Sans TC", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161410;
    --bg-card: #1f1b16;
    --ink: #f3eee4;
    --muted: #b8b0a2;
    --line: #3b352b;
    --accent: #e8b423;
    --term-bg: rgba(232, 180, 35, 0.28);
    --link: #f0c14b;
    --link-hover: #ffd978;
    --header: #0f0d0a;
    --callout: #2c2718;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  font-size: 17px;
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--link-hover); }
.skip {
  position: absolute; left: -999px; top: 0;
}
.skip:focus { left: 1rem; background: var(--bg-card); padding: 0.3rem 0.6rem; }

.site-header, .site-footer { background: var(--header); color: #f7f3ea; }
.site-header .inner, .site-footer .inner, .page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem;
}
.site-header .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}
.site-title {
  color: #f7f3ea;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  font-size: 1.05rem;
}
.site-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-nav a { color: #ead9a5; text-decoration: none; }
.site-nav a.current, .site-nav a:hover { color: #fff; text-decoration: underline; }


/* Site-wide search in the header. Hidden until JS removes the hidden attribute. */
.site-search[hidden],
.site-search-results[hidden] {
  display: none !important;
}
.site-search {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
}
.site-search label {
  color: #ead9a5;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.site-search input[type="search"] {
  width: 10.5rem;
  max-width: 42vw;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 0.28rem 0.5rem;
  border: 1px solid #5a4f3a;
  border-radius: 6px;
  background: #3a3326;
  color: #f7f3ea;
}
.site-search input[type="search"]::placeholder {
  color: #cbbd9a;
}
.site-search-results {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  min-width: 16rem;
  max-width: min(22rem, 90vw);
  max-height: 18rem;
  overflow: auto;
  z-index: 30;
  background: var(--bg-card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0;
}
.site-search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-search-results a {
  display: block;
  padding: 0.35rem 0.8rem;
  color: var(--link);
  text-decoration: none;
}
.site-search-results a:hover {
  background: var(--callout);
  color: var(--link-hover);
}
.site-search-empty {
  margin: 0;
  padding: 0.35rem 0.8rem;
  color: var(--muted);
}
@media (max-width: 36rem) {
  .site-search {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .site-search input[type="search"] {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
  }
  .site-search-results {
    left: 0;
    right: 0;
    min-width: 0;
    max-width: none;
  }
}

.page { padding-bottom: 3rem; }
.entry-head h1 { font-size: 1.8rem; line-height: 1.35; margin: 0.4rem 0 0.8rem; }
.lede { color: var(--muted); margin-top: 0; }

h2 { font-size: 1.35rem; margin: 2.2rem 0 0.7rem; border-bottom: 1px solid var(--line); padding-bottom: 0.25rem; }
h3 { font-size: 1.12rem; margin: 1.6rem 0 0.5rem; }
h4 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }
section > h2:first-child { scroll-margin-top: 0.8rem; }
section, h2, h3 { scroll-margin-top: 0.8rem; }

.toc {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 1.1rem 1rem;
  margin: 1rem 0 1.5rem;
}
.toc h2 { margin: 0 0 0.4rem; font-size: 1rem; border: 0; }
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc li { margin: 0.15rem 0; }
.toc li.d1 { margin-left: 1rem; list-style: circle; }

.term {
  background: var(--term-bg);
  border-radius: 3px;
  padding: 0 0.35em;
  font-weight: 600;
}

.lead-grid {
  display: grid;
  grid-template-columns: minmax(0, 16rem) minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}
.lead-art { margin: 0; }
.lead-art figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; }
.lead-placeholder .lead-frame {
  aspect-ratio: 480 / 561;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}
.lead-placeholder-card {
  flex: 0 0 72px;
  display: inline-flex;
}
.lead-placeholder-card .lead-frame {
  width: 72px;
  aspect-ratio: 480 / 561;
  font-size: 0.68rem;
  line-height: 1.3;
  padding: 0.25rem;
  border-radius: 4px;
}
@media (max-width: 36rem) {
  .lead-grid { grid-template-columns: 1fr; }
  .lead-placeholder .lead-frame { max-width: 16rem; }
}

.props { margin: 0; }
.props .prop { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.35rem 0.8rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.props dt { color: var(--muted); font-weight: 600; }
.props dd { margin: 0; }

.table-wrap { overflow-x: auto; margin: 0.8rem 0 1.1rem; }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); font-size: 0.95rem; }
th, td { border: 1px solid var(--line); padding: 0.4rem 0.55rem; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.table-wrap td { white-space: pre-wrap; }
th { background: rgba(138, 106, 20, 0.08); font-weight: 600; }

details.skill { background: var(--bg-card); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.8rem; margin: 0.45rem 0; }
details.skill summary { cursor: pointer; font-weight: 600; }
details.skill p { margin: 0.5rem 0; }
details.skill ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }

.star-row, .star-max { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; flex-wrap: wrap; }
.star-max { gap: 8px; }
.star { display: inline-block; }
.star path { stroke-width: 1.15; stroke-linejoin: round; }
.star-gold path { fill: var(--gold); stroke: var(--gold-stroke); }
.star-red path { fill: var(--red); stroke: var(--red-stroke); }
.star-white path { fill: var(--white); stroke: var(--white-stroke); }

.callout {
  background: var(--callout);
  border-left: 4px solid var(--accent);
  padding: 0.7rem 1rem;
  border-radius: 0 6px 6px 0;
  margin: 0.8rem 0 1rem;
}
.callout p { margin: 0.35rem 0 0; }
.gear-list { display: grid; gap: 0.6rem; margin: 0.8rem 0; }
.gear-row { background: var(--bg-card); border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.8rem; }
.gear-row h3 { margin: 0 0 0.2rem; font-size: 1rem; color: var(--accent); }
.gear-row p { margin: 0; }

.cards, .hero-index { display: grid; gap: 0.8rem; margin: 1rem 0; }
.card, .hero-card {
  display: flex; gap: 0.9rem; align-items: center;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.7rem 0.9rem;
  text-decoration: none; color: inherit;
}
.card:hover, .hero-card:hover { border-color: var(--accent); }
.card strong, .hero-card h2 { display: block; margin: 0 0 0.15rem; font-size: 1.05rem; }
.card span, .hero-card .meta { color: var(--muted); font-size: 0.9rem; }

.site-footer { font-size: 0.88rem; color: #d7cbae; }
.site-footer a { color: #ead9a5; }
.site-footer .inner { padding-top: 1.2rem; padding-bottom: 1.4rem; }

ul { padding-left: 1.25rem; }
li { margin: 0.2rem 0; }

.hero-roster,
.codex-index {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.75rem;
}
.hero-roster li,
.codex-index li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.55rem;
  margin: 0;
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--line);
  break-inside: avoid;
}
.hero-roster .wiki-status,
.codex-index li {
  color: var(--muted);
}
.hero-roster .wiki-status { font-size: 0.88rem; }
#heroes > h3,
#heroes section > h3 {
  font-size: 1.12rem;
  margin: 1.4rem 0 0.35rem;
  scroll-margin-top: 0.8rem;
}
@media (max-width: 36rem) {
  .hero-roster,
  .codex-index { grid-template-columns: 1fr; }
}

.codex-group { margin: 0 0 1.6rem; }
.codex-group > h3 {
  font-size: 1.12rem;
  margin: 1.4rem 0 0.35rem;
  scroll-margin-top: 0.8rem;
}
.codex-group .codex-index { margin-bottom: 0.2rem; }

/* Catalog tables: sticky header, denser 100-row tables, inline charts. */
.jump-nav { font-size: 0.92rem; color: var(--muted); }
.jump-nav a { margin-right: 0.45rem; }
.table-dense table { font-size: 0.88rem; }
.table-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  background-image: linear-gradient(rgba(138, 106, 20, 0.08), rgba(138, 106, 20, 0.08));
  z-index: 2;
}
.chart-block { margin: 1rem 0 1.5rem; }
.chart-block svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.chart-block figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.45rem 0 0;
  line-height: 1.65;
}


/* Catalog tables: card stack on narrow screens, sticky first column for short-cell tables. */
.table-wrap.table-sticky-col {
  overflow-x: auto;
}
.table-wrap.table-sticky-col th:first-child,
.table-wrap.table-sticky-col td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 4.8rem;
  background: var(--bg-card);
  box-shadow: 2px 0 0 var(--line);
}
.table-wrap.table-sticky-col thead th:first-child {
  z-index: 3;
  background: var(--bg-card);
  background-image: linear-gradient(rgba(138, 106, 20, 0.08), rgba(138, 106, 20, 0.08));
}

/* 14-col 英靈 key-level table: freeze 陣營 + 英靈 so the name stays in view. */
.table-wrap.table-sticky-col-2 th:first-child,
.table-wrap.table-sticky-col-2 td:first-child {
  width: 3rem;
  min-width: 3rem;
  max-width: 3rem;
  box-shadow: none;
}
.table-wrap.table-sticky-col-2 th:nth-child(2),
.table-wrap.table-sticky-col-2 td:nth-child(2) {
  position: sticky;
  left: var(--sticky-col1, 3rem);
  z-index: 2;
  min-width: 8.5rem;
  background: var(--bg-card);
  box-shadow: 2px 0 0 var(--line);
}
.table-wrap.table-sticky-col-2 thead th:nth-child(2) {
  z-index: 3;
  background: var(--bg-card);
  background-image: linear-gradient(rgba(138, 106, 20, 0.08), rgba(138, 106, 20, 0.08));
}

/* Keep short-cell tables at intrinsic width so columns stay readable and horizontal scroll works. */
.table-wrap.table-sticky-col table {
  width: max-content;
  min-width: 100%;
}
.table-wrap.table-sticky-col th,
.table-wrap.table-sticky-col td {
  overflow-wrap: normal;
  white-space: nowrap;
}
.table-wrap.table-sticky-col th:last-child,
.table-wrap.table-sticky-col td:last-child {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-width: 6rem;
}

/* Card stack on narrow screens only. Do not shrink type. Do not hide columns. */
@media (max-width: 44rem) {
  .table-wrap.table-cards {
    overflow: visible;
  }
  .table-wrap.table-cards table {
    display: block;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    font-size: 1rem;
  }
  .table-wrap.table-cards thead {
    display: none;
  }
  .table-wrap.table-cards tbody {
    display: block;
  }
  .table-wrap.table-cards tr {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.75rem 0.9rem 0.35rem;
    margin: 0 0 0.85rem;
  }
  .table-wrap.table-cards td {
    display: block;
    border: 0;
    border-top: 1px solid var(--line);
    padding: 0.4rem 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    text-align: left;
  }
  .table-wrap.table-cards td.card-title {
    order: -1;
    border-top: 0;
    padding: 0 0 0.55rem;
    font-weight: 700;
    font-size: 1.08rem;
    line-height: 1.4;
  }
  .table-wrap.table-cards td.card-title::before {
    content: none;
  }
  .table-wrap.table-cards td:not(.card-title)::before {
    content: attr(data-label) "：";
    display: block;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.1rem;
  }
}


/* In-page name filter. Hidden until JS removes the hidden attribute. */
.page-filter {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 1.1rem 0.9rem;
  margin: 0.6rem 0 1.2rem;
}
.page-filter[hidden],
.page-filter-empty[hidden] {
  display: none !important;
}
.page-filter label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.page-filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  align-items: center;
}
.page-filter input[type="search"] {
  flex: 1 1 12rem;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
.page-filter button {
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.page-filter button:hover {
  color: var(--link-hover);
}
.page-filter-empty {
  color: var(--muted);
  margin: 0.55rem 0 0;
}

/* Keep filtered-out rows/cards hidden even when card/sticky rules set display. */
.table-wrap.table-cards tr[hidden],
.table-wrap.table-sticky-col tr[hidden],
.table-wrap tr[hidden],
.table-wrap[hidden],
.hero-roster > li[hidden],
main section[hidden],
main h3[hidden],
main h4[hidden] {
  display: none !important;
}

/* Static upgrade-cost calculator (progressive enhancement; no network). */
.upgrade-cost {
  margin: 1.25rem 0 1.75rem;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.upgrade-cost fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}
.upgrade-cost legend {
  font-weight: 650;
  padding: 0;
  margin: 0 0 0.65rem;
}
.upgrade-cost-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem 1rem;
}
@media (min-width: 44rem) {
  .upgrade-cost-grid {
    grid-template-columns: 1fr 1fr;
  }
  .upgrade-cost-grid .upgrade-cost-span {
    grid-column: 1 / -1;
  }
}
.upgrade-cost label {
  display: block;
  font-weight: 650;
  margin: 0 0 0.3rem;
}
.upgrade-cost select,
.upgrade-cost input[type="number"] {
  font: inherit;
  font-size: 1rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
.upgrade-cost-actions {
  margin-top: 0.9rem;
}
.upgrade-cost button {
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.upgrade-cost button:hover {
  color: var(--link-hover);
}
.upgrade-cost-result {
  margin: 0.9rem 0 0;
}
.upgrade-cost-result[hidden] {
  display: none !important;
}
.upgrade-cost-result h3,
.upgrade-cost-result h4 {
  margin: 0.7rem 0 0.35rem;
}
.upgrade-cost-result p,
.upgrade-cost-result li {
  margin: 0.25rem 0;
}
.upgrade-cost-hint {
  color: var(--muted);
  margin: 0.35rem 0 0;
}
.upgrade-cost noscript p {
  margin: 0.5rem 0 0;
}
