/* Qwazy Land — public ledger pages.
   Pixel-art pixel-precise aesthetic that mirrors the game UI but
   stays readable as a long-form doc. No JS required to read; renders
   fine in a text browser, prints clean, screenshots well. */

/* Unifont — same family the in-game UI uses. Multi-range subset:
   ASCII for Latin, latin-ext for accented Latin (covers DE/FR/ES/PT/PL/etc.),
   cyr-gr for Cyrillic + Greek, kana/han/hangul/symbols/rest for the
   wider unicode ranges. font-display:block on ASCII so the page never
   flashes a system fallback for the headlines; swap on everything else
   so the page is readable while the larger sheets stream. */
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-ascii.woff2') format('woff2');
             unicode-range: U+0020-007E; font-display: block; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-latin-ext.woff2') format('woff2');
             unicode-range: U+0080-024F, U+1E00-1EFF, U+2000-20CF, U+2070-209F; font-display: swap; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-cyr-gr.woff2') format('woff2');
             unicode-range: U+0370-058F, U+0590-05FF; font-display: swap; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-symbols.woff2') format('woff2');
             unicode-range: U+2100-2BFF; font-display: swap; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-kana.woff2') format('woff2');
             unicode-range: U+3000-303F, U+3040-309F, U+30A0-30FF, U+3100-31FF, U+FF00-FFEF; font-display: swap; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-han.woff2') format('woff2');
             unicode-range: U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF; font-display: swap; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-hangul.woff2') format('woff2');
             unicode-range: U+1100-11FF, U+3130-318F, U+A960-A97F, U+AC00-D7AF, U+D7B0-D7FF; font-display: swap; }
@font-face { font-family:'Unifont'; src:url('/fonts/unifont-rest.woff2') format('woff2');
             unicode-range: U+0600-06FF, U+0700-074F, U+0780-07BF, U+0900-097F, U+0980-09FF,
                            U+0E00-0E7F, U+0E80-0EFF, U+1700-171F, U+A000-A48F, U+FB00-FB4F,
                            U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }

:root {
  --bg:           #16181f;
  --bg-card:      rgba(20, 22, 30, 0.92);
  --border:       rgba(255, 209, 102, 0.45);
  --border-soft:  rgba(255, 255, 255, 0.10);
  --fg:           #f3f3f3;
  --fg-soft:      #b0b0b0;
  --accent:       #ffd166;
  --accent-soft:  #ffe8b8;
  --link:         #9be1ff;
  --warm:         #c89bff;
  --danger:       #ff9090;
  --code-bg:      rgba(255, 255, 255, 0.06);
  --shadow:       0 12px 36px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  /* Unifont is a pixel font with 8 px-wide ASCII glyphs at the
     native 16 px size — much narrower than a sans-serif at the same
     pt size. Body uses 32 px (= 16 × 2, integer multiple of the
     pixel grid) so each glyph is a comfortable 16 × 32 px on screen,
     close to a 16 px sans-serif in visual weight. Line-height 48 px
     stays on grid (1.5 ratio). */
  font: 32px/48px 'Unifont', ui-monospace, monospace;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); }

img { max-width: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }

/* Top bar — sticky, single row at desktop widths. Brand on the
   left, nav on the right. Stays on one row down to 720 px; below
   that the brand drops off and only the nav shows. */
.ledger-top {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 24px;
  background: rgba(11, 13, 24, 0.96);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 0 24px rgba(255, 209, 102, 0.12);
}
.ledger-top a { text-decoration: none; }
.ledger-top .brand {
  color: var(--accent); letter-spacing: 1px;
  font-size: 32px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ledger-top nav {
  display: flex; gap: 0; flex-wrap: nowrap;
  /* 16 px keeps the chrome compact even though body is 32 px —
     the accent borders + spacing carry the visual weight. */
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 1px;
}
.ledger-top nav a {
  color: var(--fg);
  padding: 8px 16px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  transition: border-color .12s ease-out, background .12s ease-out, color .12s ease-out;
}
.ledger-top nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--border);
  background: rgba(255, 209, 102, 0.06);
}
.ledger-top nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--border);
  background: rgba(255, 209, 102, 0.08);
}
.ledger-top nav a.play {
  color: var(--accent);
  border: 1px solid var(--border);
  margin-left: 8px;
  background: rgba(255, 209, 102, 0.06);
}
.ledger-top nav a.play:hover {
  background: rgba(255, 209, 102, 0.18);
}

@media (max-width: 720px) {
  .ledger-top { padding: 8px 12px; gap: 8px; }
  .ledger-top .brand { font-size: 16px; }
  .ledger-top nav a  { padding: 6px 10px; }
}
@media (max-width: 480px) {
  .ledger-top .brand { display: none; }
}

/* Alpha banner — mandatory across every ledger page; in-game
   surfaces use the same warning palette. */
.alpha-banner {
  background: rgba(196, 84, 60, 0.14);
  color: #ffd0c2;
  border-bottom: 2px solid #c4543c;
  padding: 8px 16px;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
}
.alpha-banner b { color: #ffe8b8; }

/* Article container — wide enough that 32 px body still gives ~70+
   chars per line (Unifont ASCII is 16 px wide at this size). */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 32px 128px;
}

article header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border-soft);
}

article h1 {
  font-size: 64px;
  line-height: 80px;
  color: var(--accent);
  margin: 0 0 16px;
  letter-spacing: 2px;
}
article header .description {
  color: var(--fg-soft);
  margin: 0;
}

article h2 {
  font-size: 48px;
  line-height: 64px;
  color: var(--accent);
  margin: 48px 0 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-soft);
  letter-spacing: 1px;
}
article h3 { font-size: 32px; line-height: 48px; color: var(--accent-soft); margin: 32px 0 12px; }
article h4 { font-size: 32px; line-height: 48px; color: var(--fg);          margin: 24px 0 8px; }

article p, article ul, article ol, article blockquote {
  margin: 0 0 24px;
}
article ul, article ol { padding-left: 48px; }
article li { margin-bottom: 8px; }
article li > p { margin: 0 0 12px; }

article blockquote {
  border-left: 3px solid var(--warm);
  padding: 6px 0 6px 12px;
  color: var(--accent-soft);
  background: rgba(200, 155, 255, 0.05);
}

article hr {
  border: 0;
  border-top: 1px dashed var(--border-soft);
  margin: 32px 0;
}

/* Anchor link icon next to every heading. Hidden until hover, so
   skim-reading stays clean. Fixed 32 px to match the body grid. */
article h1 .anchor,
article h2 .anchor,
article h3 .anchor,
article h4 .anchor {
  color: var(--fg-soft);
  margin-left: 16px;
  text-decoration: none;
  opacity: 0;
  transition: opacity .12s ease-out;
  font-size: 32px;
  vertical-align: middle;
}
article h2:hover .anchor,
article h3:hover .anchor,
article h4:hover .anchor { opacity: 1; }

/* Code: inline + fenced. Fenced has hard borders to match the rest. */
code, pre {
  font: 32px/48px 'Unifont', ui-monospace, monospace;
  background: var(--code-bg);
}
code {
  padding: 1px 5px;
  color: var(--accent-soft);
  border: 1px solid var(--border-soft);
}
pre {
  padding: 12px 14px;
  border: 2px solid var(--border-soft);
  overflow-x: auto;
  margin: 0 0 14px;
}
pre code { padding: 0; border: 0; background: transparent; color: var(--fg); }

/* Stat tables — for items + monsters. Pixel-style, two columns. */
.stat-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-table th, .stat-table td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.stat-table tr:last-child th,
.stat-table tr:last-child td { border-bottom: 0; }
.stat-table th { color: var(--accent); font-weight: normal; width: 40%; }
.stat-table td { color: var(--fg); }
.stat-table.drops th { width: 65%; }
.stat-table.drops a  { color: var(--fg); }
.stat-table.drops a:hover { color: var(--accent); }
.stat-table .ledger-icon-inline {
  display: inline-block;
  width: 24px; height: 24px;
  vertical-align: middle;
  margin-right: 8px;
  /* background-size + position now come from the inline style emitted
     server-side with slot=24 — no override needed. */
}

/* Item / monster head card — sprite + tier badge + meta strip,
   sits at the top of every per-entity page. Mirrors the in-game
   guide's card layout so the public page reads as an extension of
   the game, not a separate document. */
.ledger-card.head {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 20px;
  margin: 0 0 24px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.ledger-card.head .ledger-icon {
  /* Size + background math now come from the inline style emitted
     server-side with slot=80 — no override needed. */
  width: 80px; height: 80px;
  flex-shrink: 0;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.ledger-card.head .ledger-portrait-wrap {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  min-width: 100px; min-height: 100px;
}
.ledger-card.head .ledger-portrait { display: block; }
.ledger-card.head .ledger-info { flex: 1; min-width: 0; }
.ledger-card.head .badges {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px;
}
.ledger-card.head .meta { color: var(--fg-soft); font-size: 16px; }
.ledger-card.head .desc { color: var(--fg); margin: 8px 0 0; }

/* Tier badges — colour ramp matches the in-game gear-tier palette. */
.tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid currentColor;
  font-size: 16px;
  letter-spacing: 1px;
}
.tier-1 { color: #c4a060; }
.tier-2 { color: #d8d8d8; }
.tier-3 { color: #84e89d; }
.tier-4 { color: #9be1ff; }
.tier-5 { color: #ffd166; }
.tier-6 { color: #c89bff; }
.tier-7 { color: #ff9bb0; }
.tier-8 { color: #ff7a40; }
.tier-9, .tier-10 { color: #ff5050; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg-soft);
  font-size: 16px;
  letter-spacing: 0.5px;
}
.tag.flying  { color: #9be1ff; border-color: #9be1ff; }
.tag.dungeon { color: #c89bff; border-color: #c89bff; }

/* Bestiary / items index — grid of mini-cards, each with sprite + name. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 16px 0 32px;
}
.card-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 12px 8px 10px;
  min-height: 168px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--border-soft);
  color: var(--fg);
  text-decoration: none;
  text-align: center;
  overflow: hidden;
  transition: border-color .12s ease-out, background .12s ease-out, transform .12s ease-out;
}
.card-tile:hover {
  border-color: var(--border);
  background: rgba(255, 209, 102, 0.06);
  transform: translateY(-2px);
}
.card-tile .tier-badge {
  position: absolute; top: 4px; right: 4px;
}
/* Sprite area inside the card. Both sprite types take their
   intrinsic size from the inline style (server-emitted to match
   the slot pitch — 56 px for items, per-monster integer scale
   for monsters). flex: 0 0 auto so the column doesn't stretch
   the box vertically — that bug duplicated the atlas Y-position
   and rendered the cell below the intended one stacked under it. */
.card-tile .ledger-icon,
.card-tile .ledger-portrait {
  margin: 0 auto 12px;
  flex: 0 0 auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.card-tile.item .ledger-icon {
  width: 56px; height: 56px;
}
.card-tile .card-name {
  color: var(--accent);
  font-size: 16px;
  letter-spacing: 0.5px;
  word-break: break-word;
}

/* Spawn list — clean unordered list with monospace coords. */
.spawns {
  list-style: none;
  padding: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
}
.spawns li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg);
}
.spawns li:last-child { border-bottom: 0; }
.spawns li strong { color: var(--accent); }

/* "Note:" line under section headings. */
.note { color: var(--fg-soft); font-style: italic; font-size: 16px; }

/* TOC on the index page — grid of section cards. */
.toc {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 24px 0;
}
.toc a {
  display: block;
  padding: 12px 14px;
  border: 2px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--fg);
  text-decoration: none;
  transition: border-color .12s ease-out, transform .12s ease-out;
}
.toc a:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}
.toc a .title { color: var(--accent); display: block; font-size: 16px; }
.toc a .desc  { color: var(--fg-soft); font-size: 16px; margin-top: 4px; }

/* Item / monster grid — used inside the bestiary + items index pages. */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.entry-grid a {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  color: var(--fg);
  text-decoration: none;
}
.entry-grid a:hover { border-color: var(--border); background: rgba(255, 209, 102, 0.06); }
.entry-grid a .meta { color: var(--fg-soft); font-size: 16px; display: block; }

/* Footer — same on every page. Compact 16 px so the meta stays
   chrome-weight, not body-weight. */
footer.ledger-foot {
  border-top: 2px solid var(--border-soft);
  padding: 32px 24px;
  margin-top: 64px;
  color: var(--fg-soft);
  font-size: 16px;
  line-height: 24px;
  text-align: center;
}
footer.ledger-foot .links {
  margin-top: 16px;
  display: flex; justify-content: center; gap: 24px; flex-wrap: wrap;
}
footer.ledger-foot a { color: var(--link); }

/* Sectioned per-page nav — prev / next at the article foot. */
.page-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 48px; padding-top: 16px;
  border-top: 1px dashed var(--border-soft);
}
.page-nav a {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  text-decoration: none;
  color: var(--fg);
}
.page-nav a:hover { border-color: var(--border); }
.page-nav .label { color: var(--fg-soft); font-size: 16px; display: block; }
.page-nav .title { color: var(--accent); }
.page-nav .next { text-align: right; }

/* Responsive — one column under 600 px, slightly tighter type. */
@media (max-width: 600px) {
  article h1 { font-size: 32px; }
  main       { padding: 16px 12px 64px; }
  .ledger-top .brand { font-size: 16px; }
  .ledger-top nav    { font-size: 16px; }
}

/* Print: drop the dark theme, keep readable typography. */
@media print {
  html, body { background: #fff; color: #000; }
  .ledger-top, footer.ledger-foot, .page-nav, .alpha-banner { display: none; }
  article h1, article h2, article h3, article h4 { color: #000; }
  a { color: #06c; text-decoration: underline; }
  pre, code { background: #f4f4f4; color: #000; border-color: #ccc; }
  .stat-table { border-color: #888; box-shadow: none; }
  .stat-table th { color: #444; }
}
