/**
 * wiki.css — wiki layout, per docs/web/spec.md's CSS contract. Implements
 * exactly the class names wikigen emits: .wiki-layout, .wiki-sidebar,
 * .wiki-content, .entity-card, .entity-grid, .stat-table, .sprite (pixelated),
 * .badge / .badge-premium / .badge-boss / .badge-guardian, .rarity-<tier>.
 * Requires site.css to be loaded first (uses its custom properties).
 */

.wiki-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  align-items: start;
}

.wiki-sidebar {
  position: sticky;
  top: 76px;
  padding: 16px;
}

/* Framed chrome parity with the landing page (site.css's .framed) — applied
 * directly to the existing `.wiki-sidebar` selector rather than requiring a
 * markup change, since wikigen's template already emits this class. */
.wiki-sidebar {
  border-style: solid;
  border-width: var(--frame-width);
  border-image-source: url('/assets/ui/ui_frame.png');
  border-image-slice: var(--frame-slice) fill;
  border-image-width: var(--frame-width);
  border-image-repeat: round;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)) padding-box;
  border-radius: 6px;
}

.wiki-sidebar h3 {
  margin: 0 0 8px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.wiki-sidebar ul {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.wiki-sidebar li {
  margin-bottom: 4px;
}

.wiki-sidebar a {
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.wiki-sidebar a:hover,
.wiki-sidebar a.active {
  color: var(--gold);
  text-decoration: none;
}

.wiki-content {
  min-width: 0;
  padding: 24px 28px;
  /* Same nine-slice chrome as .wiki-sidebar/.infobox — the content column
   * was the one flat panel left on an otherwise framed page. */
  border-style: solid;
  border-width: var(--frame-width);
  border-image-source: url('/assets/ui/ui_frame.png');
  border-image-slice: var(--frame-slice) fill;
  border-image-width: var(--frame-width);
  border-image-repeat: round;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)) padding-box;
  border-radius: 6px;
}

.wiki-content h1 {
  color: var(--gold);
  margin-top: 0;
  border-bottom: 2px solid var(--filigree);
  padding-bottom: 12px;
}

.wiki-content h2 {
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-top: 32px;
}

.wiki-content p {
  color: var(--ink-dim);
}

/* Wiki home art accent — one banner of game art so the reference home isn't
 * text-only. Framed with the same warm well + gold edge as sprite tiles. */
.wiki-hero-art {
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: center 30%;
  border: 1px solid var(--well-edge);
  border-radius: 8px;
  margin: 4px 0 20px;
  box-shadow: var(--shadow-deep);
}

@media (max-width: 640px) {
  .wiki-hero-art {
    height: 140px;
  }
}

/* ── entity grid / card (bestiary / item / class index pages) ──────────── */

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

/* Class index only: 6 cards in even fixed rows (auto-fill orphans the 6th).
 * Mobile-first single column: each card's sprite media block is a fixed
 * 256px-wide frame, so two columns cannot fit a 390px phone (646px page
 * overflow found in critic round 3). */
.entity-grid-fixed6 {
  grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
  .entity-grid-fixed6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .entity-grid-fixed6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Grid/flex items default to min-width:auto and refuse to shrink — without
 * this the infobox stat tables force horizontal page scroll on mobile. */
.entity-detail .detail-body,
.entity-detail .infobox,
.detail-grid > .entity-detail {
  min-width: 0;
}

.entity-card {
  background: linear-gradient(to bottom, var(--metal-light), var(--metal));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.entity-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.entity-card a {
  color: var(--ink);
  text-decoration: none;
  display: block;
}

.entity-card .sprite {
  margin: 0 auto 8px;
}

.entity-card .name {
  font-weight: 700;
  font-size: 0.92rem;
}

/* Card title/subtitle emitted by wikigen's entityCard() (templates.ts). */
.entity-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  margin: 2px 0;
}

.entity-card-subtitle {
  font-size: 0.82rem;
  color: var(--ink-dim);
  margin-bottom: 4px;
}

a.entity-card {
  color: var(--ink);
  text-decoration: none;
  display: block;
}

/* ── pixel-art sprite frame ─────────────────────────────────────────────
 * Reused for hero/enemy sprite crops and item icons throughout the wiki.
 * Rendering-only rule mirrors src/ui/theme.ts's texExists() fallback: if an
 * <img> src 404s, the warm well + gold edge still reads as a slot frame. */

.sprite {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-radius: 6px;
  width: 96px;
  height: 96px;
  object-fit: contain;
}

/* Spritesheet first-frame crops (wikigen sprite.ts): the wrapper span is the
 * clipping box, so IT carries the well + gold frame; the inner .sprite div
 * inside it is a bare scaled crop (its inline style zeroes the img framing
 * above — a border/margin there would scale from the top-left origin and
 * paint past the clip edge). */
.sprite-frame {
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-radius: 6px;
  vertical-align: middle;
  margin-bottom: 8px;
  max-width: 100%;
}

/* ── stat tables (class/enemy/item stat blocks) ─────────────────────────── */

.stat-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-radius: 8px;
  overflow: hidden;
  /* fixed layout lets tables actually shrink to their container on mobile
   * (auto layout refuses to go below content width and forces page scroll) */
  table-layout: fixed;
}

/* Inside an explicit scroll container (the 6-column talent lattice) keep
 * natural column widths and scroll instead of squeezing. */
.table-scroll .stat-table {
  table-layout: auto;
  min-width: 560px;
}

/* The 6-column talent lattice honors its <colgroup> percentages (Description
 * gets the room; the numeric columns stay tight) instead of letting auto
 * layout starve whichever column has the most breakable text. Still scrolls
 * below its 560px min-width on mobile. */
.talent-table {
  table-layout: fixed;
}

.stat-table th,
.stat-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(184, 146, 58, 0.2);
  color: var(--ink);
  font-size: 0.9rem;
  overflow-wrap: break-word;
}

/* Wide generated tables (the 6-column talent lattice) scroll inside their
 * own container instead of forcing the page wide — at 390px the berserker
 * page scrolled horizontally (scrollWidth 635 vs clientWidth 390). */
.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

/* Swipe cue under wide tables that scroll on mobile. Hidden on desktop where
 * the table fits; the actual scroll cropping alone read as broken/truncated
 * content without this affordance. */
.table-scroll-hint {
  display: none;
}

@media (max-width: 820px) {
  .table-scroll-hint {
    display: block;
    margin: 4px 2px 16px;
    text-align: right;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gold);
  }
}

.stat-table th {
  background: var(--well-light);
  color: var(--gold);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-table tr:last-child td {
  border-bottom: none;
}

/* Nested stat-tables (an ability card's Targeting/Cooldown table living inside
 * an .entity-card, which itself sits in a narrow .detail-grid cell) must NOT
 * inherit the fixed 50/50 layout — at ~160px the label column would wrap
 * "Targeting" one letter per line. Size the label column to its content and
 * never break the header word. */
.entity-card .stat-table {
  table-layout: auto;
}

.entity-card .stat-table th {
  white-space: nowrap;
  width: 1%;
}

/* Same fix for the detail-page infobox: its ~250px sticky column + the shared
 * fixed 50/50 layout broke long stat labels mid-word ("RESISTAN CE",
 * "LIFESTEA L") on every enemy/boss detail page. */
.infobox .stat-table {
  table-layout: auto;
}

.infobox .stat-table th {
  white-space: nowrap;
  width: 1%;
}

/* ── badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--metal-light);
  border: 1px solid var(--border-hi);
  color: var(--ink-dim);
}

.badge-premium {
  background: linear-gradient(to bottom, var(--gold), var(--filigree));
  color: var(--bg-deep);
  border-color: var(--filigree);
}

.badge-boss {
  background: rgba(255, 45, 85, 0.15);
  border-color: var(--rarity-mythic);
  color: var(--rarity-mythic);
}

.badge-guardian {
  background: rgba(192, 97, 255, 0.15);
  border-color: var(--rarity-epic);
  color: var(--rarity-epic);
}

/* ── rarity text tints — matches src/ui/theme.ts rarityColorNum() ──────── */

.rarity-common {
  color: var(--rarity-common);
}

.rarity-uncommon {
  color: var(--rarity-uncommon);
}

.rarity-rare {
  color: var(--rarity-rare);
}

.rarity-epic {
  color: var(--rarity-epic);
}

.rarity-legendary {
  color: var(--rarity-legendary);
}

.rarity-mythic {
  color: var(--rarity-mythic);
}

.rarity-cursed {
  color: var(--rarity-cursed);
}

.rarity-divine {
  color: var(--rarity-divine);
}

/* ── entity detail layout (infobox pattern) ───────────────────────────────
 * Markup contract (emitted by wikigen once landed):
 *   <section class="entity-detail">
 *     <aside class="infobox">...</aside>
 *     <div class="detail-body">...</div>
 *   </section>
 * On >=900px the infobox pins right, prose flows in the remaining column;
 * on narrower viewports it stacks above the body. */

.entity-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 900px) {
  .entity-detail {
    grid-template-columns: 1fr 260px;
  }

  .entity-detail .infobox {
    order: 2;
  }

  .entity-detail .detail-body {
    order: 1;
    min-width: 0;
  }
}

.infobox {
  border-style: solid;
  border-width: var(--frame-width);
  border-image-source: url('/assets/ui/ui_frame.png');
  border-image-slice: var(--frame-slice) fill;
  border-image-width: var(--frame-width);
  border-image-repeat: round;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)) padding-box;
  border-radius: 6px;
  padding: 14px;
  position: sticky;
  top: 76px;
}

.infobox .sprite,
.infobox .sprite-frame,
.infobox img {
  display: block;
  margin: 0 auto 10px;
}

.infobox .stat-table {
  margin: 8px 0 0;
  font-size: 0.85rem;
}

/* Dense multi-column entity index (wiki pattern 7 / grid variant) */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}

/* A detail cell carrying its own infobox+body (enemy/item pages) needs the
 * whole column: at a 2-up 320px minmax the nested `1fr 260px` split left the
 * body ~160px and squeezed ability tables. Give those a wider floor. */
@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ── rarity tint on entity cards — border + subtle background wash ──────── */

.entity-card.rarity-common {
  border-color: var(--rarity-common);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(184, 192, 200, 0.08), rgba(184, 192, 200, 0.08));
}

.entity-card.rarity-uncommon {
  border-color: var(--rarity-uncommon);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(91, 214, 107, 0.1), rgba(91, 214, 107, 0.1));
}

.entity-card.rarity-rare {
  border-color: var(--rarity-rare);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(74, 163, 255, 0.1), rgba(74, 163, 255, 0.1));
}

.entity-card.rarity-epic {
  border-color: var(--rarity-epic);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(192, 97, 255, 0.12), rgba(192, 97, 255, 0.12));
}

.entity-card.rarity-legendary {
  border-color: var(--rarity-legendary);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(255, 176, 32, 0.12), rgba(255, 176, 32, 0.12));
}

.entity-card.rarity-mythic {
  border-color: var(--rarity-mythic);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(255, 45, 85, 0.14), rgba(255, 45, 85, 0.14));
}

.entity-card.rarity-cursed {
  border-color: var(--rarity-cursed);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(214, 23, 74, 0.14), rgba(214, 23, 74, 0.14));
}

.entity-card.rarity-divine {
  border-color: var(--rarity-divine);
  background: linear-gradient(to bottom, var(--metal-light), var(--metal)),
    linear-gradient(rgba(255, 244, 214, 0.16), rgba(255, 244, 214, 0.16));
}

@media (max-width: 820px) {
  .wiki-layout {
    grid-template-columns: 1fr;
  }

  .wiki-sidebar {
    position: static;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 12px;
    /* Grid items default to min-width:auto — without this the 700px chip
     * row stretches the whole page instead of scrolling inside the bar. */
    min-width: 0;
    max-width: 100%;
  }

  .wiki-sidebar h3 {
    display: none;
  }

  .wiki-sidebar ul {
    display: flex;
    gap: 8px;
    margin: 0;
    flex: none;
  }

  .wiki-sidebar li {
    margin: 0;
  }

  .wiki-sidebar a {
    display: inline-block;
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--well);
    border: 1px solid var(--well-edge);
    font-size: 0.82rem;
  }

  .wiki-sidebar a.active {
    background: linear-gradient(to bottom, var(--gold), var(--filigree));
    color: var(--bg-deep);
  }

  .wiki-content {
    padding: 18px;
  }

  .entity-detail .infobox {
    position: static;
  }
}

/* ── bestiary cards (enemy roster pages) ─────────────────────────────────
 * Sprite on the left, name + compact stat grid + abilities on the right — a
 * balanced monster-compendium entry, replacing the item-style infobox whose
 * tall 17-row stat table dwarfed a basic enemy's near-empty body. */

.bestiary-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 8px 0;
}

.bestiary-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  align-items: start;
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-radius: 10px;
  padding: 16px;
}

.bestiary-card.is-elite {
  border-color: var(--border-hi);
}

.bestiary-card.is-boss {
  border-color: var(--rarity-mythic);
  box-shadow: inset 0 0 0 1px rgba(255, 45, 85, 0.25);
}

/* Mid-act guardian: purple frame matching its GUARDIAN badge (badge-guardian). */
.bestiary-card.is-guardian {
  border-color: var(--rarity-epic);
  box-shadow: inset 0 0 0 1px rgba(192, 97, 255, 0.25);
}

.bestiary-media {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Center the sprite vertically against the taller info column. */
  align-self: center;
  /* A consistent box with padding + min-height so a sprite whose art runs to
   * its frame edge always has margin around it (never flush against the card),
   * and short cards don't vertically squeeze the sprite. */
  min-height: 148px;
  padding: 8px;
  box-sizing: border-box;
}

/* The enemy sprites are transparent PNGs, so drop the framed "well" box +
 * gold border and let the creature sit directly on the card — no grey tile
 * around it. */
.bestiary-media .sprite-frame {
  margin-bottom: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.bestiary-info {
  min-width: 0;
}

.bestiary-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bestiary-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
}

.bestiary-meta {
  margin: 4px 0 12px;
  color: var(--ink-dim);
  font-size: 0.84rem;
}

.bestiary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 10px;
}

@media (min-width: 1080px) {
  .bestiary-stats {
    grid-template-columns: repeat(6, 1fr);
  }
}

.statlet {
  background: var(--metal);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
}

.statlet-k {
  display: block;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
}

.statlet-v {
  display: block;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ink);
}

.bestiary-secondary {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--ink-dim);
}

/* Abilities inside a bestiary card: keep them tight, no giant margins. */
.bestiary-info h4 {
  margin: 12px 0 6px;
  color: var(--gold);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bestiary-info .entity-card {
  text-align: left;
  margin-bottom: 10px;
}

@media (max-width: 640px) {
  .bestiary-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .bestiary-media {
    justify-content: flex-start;
  }

  .bestiary-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── ability cards (abilities page + class/enemy ability blocks) ─────────
 * Media-left card matching the bestiary/item pattern: fx sprite + info. */

.ability-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 8px 0;
}

.ability-card {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 14px;
  align-items: start;
  /* Cool metal so the card reads on BOTH the metal content panel (abilities
   * page) and the warm well of a bestiary card (where abilities are nested). */
  background: linear-gradient(to bottom, var(--metal-light), var(--metal));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: left;
}

.ability-media {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* fx PNGs are transparent glow sprites — no framed grey tile behind them. */
.ability-media img.sprite {
  width: 52px;
  height: 52px;
  background: transparent;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  image-rendering: pixelated;
}

.ability-body {
  min-width: 0;
}

.ability-body h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  color: var(--ink);
}

.ability-body h3 a {
  color: var(--ink);
}

.ability-meta {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--ink-dim);
}

.ability-meta strong {
  color: var(--gold);
  font-weight: 700;
}

.ability-flavor {
  margin: 0 0 8px;
  font-style: italic;
  color: var(--ink-dim);
  font-size: 0.88rem;
}

.ability-effects {
  margin: 0;
  padding-left: 18px;
}

.ability-effects li {
  color: var(--ink);
  font-size: 0.88rem;
  margin-bottom: 3px;
}

.ability-usedby {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 8px;
  font-size: 0.84rem;
}

.ability-usedby p {
  margin: 2px 0 0;
  line-height: 1.6;
}

.ability-usedby-label,
.ability-usedby-empty {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 800;
}

@media (max-width: 640px) {
  .ability-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .ability-media {
    justify-content: flex-start;
  }
}

/* ── item cards (rarity pages) ───────────────────────────────────────────
 * Same balanced layout as bestiary cards: floating icon + info, with
 * sign-coloured stat pills so a cursed item's downside reads red. */

.item-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin: 8px 0;
}

/* Below the 2-up threshold collapse to one column — a 360px min track would
 * otherwise overflow a ~340px-wide phone content column (horizontal scroll). */
@media (max-width: 760px) {
  .item-list {
    grid-template-columns: 1fr;
  }
}

.item-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  align-items: start;
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 14px;
}

/* Rarity accent on the left edge (name + badge already carry the rarity tint). */
.item-card.rarity-common { border-left-color: var(--rarity-common); }
.item-card.rarity-uncommon { border-left-color: var(--rarity-uncommon); }
.item-card.rarity-rare { border-left-color: var(--rarity-rare); }
.item-card.rarity-epic { border-left-color: var(--rarity-epic); }
.item-card.rarity-legendary { border-left-color: var(--rarity-legendary); }
.item-card.rarity-mythic { border-left-color: var(--rarity-mythic); }
.item-card.rarity-cursed { border-left-color: var(--rarity-cursed); }
.item-card.rarity-divine { border-left-color: var(--rarity-divine); }

.item-media {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

/* Icons are transparent PNGs — no framed grey tile, they sit on the card. */
.item-media img.sprite {
  width: 64px;
  height: 64px;
  background: transparent;
  border: 0;
  object-fit: contain;
  image-rendering: pixelated;
}

.item-info {
  min-width: 0;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.item-meta {
  margin: 4px 0 8px;
  color: var(--ink-dim);
  font-size: 0.82rem;
  text-transform: capitalize;
}

.item-weapon {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.84rem;
  font-weight: 700;
}

.item-flavor {
  margin: 0 0 10px;
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.86rem;
}

.item-set {
  margin: 8px 0 0;
  font-size: 0.84rem;
}

/* Cursed "blood pact" stat-conversion line (ItemBase.curseConvert), e.g.
 * "Sacrifices 35% of Max HP -> +7% as Magic" — tinted like a cost, not a stat pill. */
.item-curse-convert {
  margin: 6px 0 0;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--bad);
}

/* Sign-coloured stat modifier pills (shared: item stats + affixes). */
.stat-mods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}

.stat-mods-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin: 6px 0 3px;
}

.stat-mod {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--metal);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.stat-mod-k {
  color: var(--ink-dim);
}

.stat-mod-v {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-mod.mod-pos .stat-mod-v {
  color: var(--good);
}

.stat-mod.mod-neg {
  border-color: rgba(255, 107, 107, 0.4);
}

.stat-mod.mod-neg .stat-mod-v {
  color: var(--bad);
}

@media (max-width: 640px) {
  .item-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .item-media {
    justify-content: flex-start;
  }
}

/* ── anchor "jump to" nav (dense enemy-roster pages) ────────────────────── */

.anchor-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0 20px;
  padding: 12px 14px;
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-radius: 8px;
}

.anchor-nav-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 800;
}

.anchor-nav a {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--metal-light);
  border: 1px solid var(--border-hi);
  color: var(--ink);
  font-size: 0.8rem;
}

.anchor-nav a:hover {
  border-color: var(--gold);
  text-decoration: none;
}

/* ── status effects page ────────────────────────────────────────────────
 * The Status Effects page (wikigen statuses.ts): one card per effect with a
 * large medallion icon beside its numbers + "applied by" list. */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin: 16px 0 8px;
}

.status-effect {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: start;
  background: var(--well);
  border: 1px solid var(--well-edge);
  border-radius: 8px;
  padding: 14px;
}

.status-effect-media {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.status-effect-body {
  min-width: 0;
}

.status-effect-body h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 1rem;
}

.status-effect-body h4 {
  margin: 12px 0 4px;
  color: var(--gold);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-effect .stat-table {
  margin: 8px 0 0;
  background: var(--metal);
  font-size: 0.84rem;
}

.status-effect code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.status-sources {
  font-size: 0.86rem;
  line-height: 1.6;
}

/* Coloured letter-pip fallback when a status has no medallion PNG (e.g. the
 * f100 enrage). Mirrors the game's STATUS_BADGE fallback. */
.status-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-weight: 800;
  /* Match the dark-medallion frame family of the real icon PNGs so a
   * PNG-less status (e.g. the f100 enrage) reads as a stylized placeholder,
   * not a broken image. The kind sets the glyph colour + a matching glow. */
  color: var(--gold);
  background:
    radial-gradient(circle at 50% 32%, var(--metal-light), var(--metal-dark));
  border: 1px solid var(--well-edge);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55);
}

.status-pip-dot { color: var(--good); }
.status-pip-hot { color: var(--good); }
.status-pip-buff { color: var(--rarity-rare); }
.status-pip-debuff { color: var(--rarity-epic); }
.status-pip-stun { color: var(--gold); }
.status-pip-antiheal { color: var(--rarity-epic); }
.status-pip-enrage {
  color: var(--rarity-mythic);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 8px rgba(255, 45, 85, 0.4);
}

/* ── inline "Inflicts:" chip rows on enemy / class pages ────────────────── */

.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.status-chips-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 800;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: var(--metal-light);
  border: 1px solid var(--border-hi);
  color: var(--ink);
  font-size: 0.8rem;
  text-decoration: none;
}

.status-chip:hover {
  border-color: var(--gold);
  text-decoration: none;
}

.status-chip .sprite,
.status-chip img,
.status-chip .status-pip {
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 5px;
}

.status-chip .status-pip {
  font-size: 0.6rem;
}

/* ── boss mechanic notes (enemy detail) ─────────────────────────────────── */

.boss-mechanics {
  margin: 6px 0 12px;
  padding-left: 18px;
}

.boss-mechanics li {
  color: var(--ink-dim);
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.boss-mechanics strong {
  color: var(--rarity-mythic);
}

/* Stats glossary: wide "what it does" description column reads as prose. */
.stat-glossary th {
  width: 34%;
  color: var(--ink);
  background: var(--well-light);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
}

.stat-glossary td {
  color: var(--ink-dim);
}

/* Break the stat name only at spaces (not mid-word), so labels like
 * "On-Kill Heal (Retribution)" wrap cleanly instead of "(Retribut-ion)". */
.stat-glossary th {
  overflow-wrap: normal;
  word-break: normal;
}

@media (max-width: 480px) {
  .stat-glossary th {
    width: 42%;
  }
}
