/* Dimraeth wiki - chrome from this install's UI sprites. Palette from extract_theme. */
@font-face {
  font-family: "Cinzel";
  src: url("/assets/fonts/Cinzel-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Cinzel";
  src: url("/assets/fonts/Cinzel-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Philosopher";
  src: url("/assets/fonts/Philosopher-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Philosopher";
  src: url("/assets/fonts/Philosopher-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #140e0c;
  --panel: #22191b;
  --panel-2: #2a2123;
  --wood: #47311f;
  --wood-2: #5f4f3b;
  --ink: #e8dcc8;
  --muted: #b5a48c;
  --copper: #c4a574;
  --edge: #1a1418;
  --slot: #26181e;
  --pos: #7dbe6a;
  --neg: #c45a4a;
  --paper: #e4d4b8;
  --paper-ink: #2c1c14;
  --paper-muted: #6a5340;
  --btn: #d5c4a4;
  --btn-edge: #5a3c28;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Philosopher", Georgia, serif;
  font-size: 18px;
  line-height: 1.4;
  min-height: 100%;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}
img { image-rendering: auto; }
.slot img, .skill-tree img, .refx img, .inv-panel img, .search-cap, .cta {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
a { color: var(--copper); text-decoration: none; }
a:hover { color: #e8d4a8; }
.skip, .visually-hidden {
  position: absolute; left: -9999px;
}
.skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px; z-index: 9; }

#layout { min-height: 100vh; display: flex; flex-direction: column; }
#topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--edge);
  border-bottom: 2px solid var(--wood-2);
  position: sticky;
  top: 0;
  z-index: 20;
}
#brand {
  font-family: "Cinzel", serif;
  font-weight: 700;
  color: var(--copper);
  font-size: 13px;
  letter-spacing: 0.06em;
  margin-right: 12px;
  line-height: 1.15;
  white-space: nowrap;
}
#bodyrow {
  display: flex;
  flex: 1;
  align-items: flex-start;
  min-width: 0;
}
#sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 14px 10px 40px;
  background: var(--edge) url("/assets/ui/codex_sidebar_bg.png") repeat;
  background-size: 48px 48px;
  border-right: 1px solid var(--copper);
}
#sidebar .nav-group { margin: 0 0 10px; }
#sidebar .nav-group h2 {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 700;
}
#sidebar .side-link {
  display: block;
  padding: 6px 10px;
  color: var(--ink);
  font-size: 15px;
  border-left: 2px solid transparent;
}
#sidebar .side-link.selected,
#sidebar .side-link:hover {
  color: #fff8e8;
  background: url("/assets/ui/expand-menu-bg_0.png") no-repeat center;
  background-size: 100% 33px;
  border-left-color: var(--copper);
}
#searchwrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  height: 40px;
  background: var(--slot);
  border: 1px solid var(--wood);
  padding: 0 4px;
}
#searchwrap .search-cap {
  width: 14px;
  height: 28px;
  flex-shrink: 0;
  background: url("/assets/ui/search-frame.png") no-repeat;
  background-size: 228px 28px;
}
#searchwrap .search-cap.left { background-position: left center; }
#searchwrap .search-cap.right { background-position: right center; }
#searchbox {
  flex: 1;
  height: 36px;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 0 8px;
  font: inherit;
  font-size: 16px;
}
#searchbox:focus { outline: 1px solid var(--copper); }
#searchresults {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  min-width: 280px;
  max-height: 360px;
  overflow: auto;
  background: var(--panel);
  border: 2px solid var(--wood);
  display: none;
  z-index: 30;
}
#searchresults.open { display: block; }
#searchresults a {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  color: var(--ink);
}
#searchresults a:hover { background: var(--wood); }
#settingsbtn, #navtoggle {
  background: var(--btn);
  color: var(--paper-ink);
  border: 2px solid var(--btn-edge);
  font-family: "Philosopher", serif;
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
  min-height: 0;
  padding: 6px 12px;
  cursor: pointer;
}
#navtoggle { display: none; }

.shop-screen {
  background: url("/assets/ui/shop-paper.png") no-repeat top center / contain, var(--panel);
  min-height: 458px;
  padding: 48px 28px 28px;
}
.gear-screen {
  background: url("/assets/ui/Equipment-bg.png") no-repeat top center / contain, var(--panel);
  min-height: 360px;
  padding: 40px 24px 24px;
}
.craft-screen {
  background: url("/assets/ui/big-icon-frame-crafting_0.png") no-repeat top center / contain, var(--panel);
  padding: 36px 24px;
}
.screen-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 12px;
}
.screen-tabs a {
  background: url("/assets/ui/unselected-small-tab.png") no-repeat center / 100% 100%;
  padding: 6px 12px 10px;
  color: var(--ink);
  font-family: "Philosopher", serif;
  font-weight: 700;
}
.screen-tabs a.on {
  background-image: url("/assets/ui/selected-tab.png");
  color: #fff8e8;
}

#main { flex: 1; padding: 28px 40px 56px; max-width: 1200px; min-width: 0; width: 100%; }
body.map-page #main { max-width: none; padding: 8px 12px 28px; }
body.hub-home #main { max-width: none; padding: 16px 28px 48px; }
.ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: baseline;
  margin: 0 0 24px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--wood);
  font-size: 15px;
  color: var(--muted);
}
.ribbon a { font-weight: 700; }
.codex-home {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(320px, 3fr);
  gap: 32px 48px;
  align-items: start;
}
.home-copy h1 {
  max-width: 18ch;
  margin: 0 0 12px;
}
.kicker {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.portraits {
  display: flex;
  gap: 20px;
  margin: 20px 0;
}
.portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  width: 72px;
}
.portrait-frame {
  width: 56px;
  height: 56px;
  border: 6px solid transparent;
  border-image: url("/assets/ui/dark-frame_0.png") 2 fill;
  display: grid;
  place-items: center;
}
.portrait-frame img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
}
.home-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 20px;
  font-weight: 700;
}
.home-map {
  margin: 0;
}
.home-map > a {
  display: block;
  background: #0d0a0b;
  border: 3px solid var(--copper);
  box-shadow: inset 0 0 0 1px var(--edge);
}
.home-map img.map-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  image-rendering: auto;
}
.home-map figcaption {
  margin-top: 10px;
  font-weight: 700;
}
.home-map figcaption a {
  border: 0;
  background: none;
  box-shadow: none;
  display: inline;
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.hub-strip { margin: 12px 0; }
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px 8px 4px 0;
  padding: 8px 18px;
  background: var(--btn);
  color: var(--paper-ink);
  border: 2px solid var(--btn-edge);
  font-family: "Philosopher", serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  width: auto;
  height: auto;
  min-height: 0;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.cta:hover { color: var(--paper-ink); background: #e8d8b8; filter: none; }
.cta:active { transform: scale(0.98); }
.planner { margin: 8px 0 16px; }
.planner label { margin-right: 12px; }
.node.spent { outline: 2px solid var(--copper); }
table.compare td { vertical-align: top; width: 33%; }
a, .side-link, .cta, .named-card, .big-btn, .hud-tab {
  transition: color 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.crumb .sep { margin: 0 6px; color: var(--wood-2); }
h1, h2, h3 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  color: var(--copper);
  margin: 0 0 8px;
}
h1 { font-size: 28px; line-height: 1.2; letter-spacing: 0.02em; }
h2 { font-size: 20px; line-height: 1.25; margin-top: 1.4em; }
h3 { font-size: 16px; }
.lead { color: var(--muted); max-width: 65ch; }
.panel {
  background: var(--panel) url("/assets/ui/frame.png") no-repeat center / 100% 100%;
  padding: 28px 32px;
  margin: 12px 0;
}
.inv-panel {
  background: url("/assets/ui/BAG-Inventory.png") no-repeat top center / contain, var(--panel);
  min-height: 452px;
  padding: 48px 28px 28px;
}
.shop-panel {
  background: url("/assets/ui/shop-popup.png") no-repeat top center / contain, var(--panel);
  padding: 40px 24px 24px;
}
.card {
  background: var(--panel-2);
  border: 6px solid transparent;
  border-image: url("/assets/ui/dark-frame_0.png") 2 fill;
  padding: 12px 14px;
  margin: 12px 0;
}
.card h3 { font-size: 15px; margin-bottom: 8px; }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 4px 8px; border-bottom: 1px solid #311b17; }
.kv td:first-child { color: var(--muted); width: 40%; }
.kv td.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.badge {
  display: inline-block;
  background: url("/assets/ui/popup1_5.png") no-repeat center / 100% 100%;
  padding: 2px 10px;
  font-size: 12px;
  margin-right: 6px;
}

.inv-grid, .skill-grid, .build-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 4px;
}
.slot {
  width: 52px;
  height: 52px;
  background: url("/assets/ui/slot_0.png") no-repeat center / 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
}
.slot img { width: 32px; height: 32px; object-fit: contain; }
.slot:hover { filter: brightness(1.15); }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.cat-tabs a, .cat-tabs button {
  background: url("/assets/ui/unselected-small-tab.png") no-repeat center / 100% 100%;
  border: 0;
  color: var(--ink);
  padding: 6px 12px 10px;
  font-family: "Philosopher", serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-transform: none;
}
.cat-tabs a.on, .cat-tabs button.on {
  background-image: url("/assets/ui/selected-tab.png");
}
.named-grid, .btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.named-card, .big-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 41px;
  padding: 8px 14px;
  color: var(--ink);
  background: var(--panel-2);
  border: 4px solid transparent;
  border-image: url("/assets/ui/dark-frame_0.png") 2 fill;
  font-family: "Philosopher", serif;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.named-card:hover, .big-btn:hover {
  color: #fff8e8;
  filter: brightness(1.08);
}
.named-card img, .big-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}
.skill-panel[hidden] { display: none; }

.inspect {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--panel);
  border: 6px solid transparent;
  border-image: url("/assets/ui/dark-frame_0.png") 2 fill;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.inspect .icon-diamond {
  width: 105px;
  height: 108px;
  flex-shrink: 0;
  background: url("/assets/ui/Big_Frame.png") no-repeat center;
  background-size: 105px 108px;
  display: grid;
  place-items: center;
  image-rendering: pixelated;
}
.inspect .icon img, .inspect-icon { width: 56px; height: 56px; object-fit: contain; }
.ings { list-style: none; padding: 0; }
.ings li { display: flex; gap: 8px; align-items: center; margin: 4px 0; }

.refx {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
}
.refx img { width: 18px; height: 18px; object-fit: contain; }

.map-screen {
  background: var(--edge);
  border: 2px solid var(--wood);
  padding: 8px;
}
.map-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.map-tabs button {
  font-family: "Philosopher", serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  background: url("/assets/ui/unselected-small-tab.png") no-repeat center / 100% 100%;
  border: 0;
  padding: 8px 16px 12px;
  cursor: pointer;
}
.map-tabs button.on, .map-tabs button:hover {
  background-image: url("/assets/ui/selected-tab.png");
  color: #fff8e8;
}
.map-board { display: none; }
.map-board.on { display: flex; justify-content: center; }
.map-viewport {
  overflow: auto;
  max-height: min(78vh, 1100px);
  background: #0d0a0b;
  max-width: 100%;
}
.map-inner { position: relative; display: inline-block; max-width: 100%; }
.map-board img.map-art {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(76vh, 1050px);
  image-rendering: auto;
}
.map-hot {
  position: absolute;
  display: block;
  border: 1px solid transparent;
  color: transparent;
  overflow: hidden;
}
.map-hot span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(25, 18, 21, 0.82);
  color: var(--ink);
  font-size: 12px;
  padding: 2px 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.map-hot:hover, .map-hot:focus {
  border-color: var(--copper);
  background: rgba(196, 165, 116, 0.12);
}
.map-hot:hover span, .map-hot:focus span { opacity: 1; }
.region-scene { margin: 16px 0; }
.region-scene img { max-width: 100%; height: auto; border: 2px solid var(--wood); }

.skill-tree .node {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  color: var(--ink);
}
.skill-tree .node span { display: none; }
.skill-tree .node img { width: 32px; height: 32px; }

#dstip, #drtip {
  position: fixed;
  z-index: 50;
  max-width: 280px;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--copper);
  padding: 8px 10px;
  pointer-events: none;
  font-size: 13px;
  box-shadow: 0 4px 12px #000;
}
#drtip img { width: 32px; height: 32px; float: left; margin-right: 8px; }

html.dr-mode-late [data-spoiler="late"],
html.dr-mode-story [data-spoiler="story"],
html.dr-mode-unreleased [data-spoiler="unreleased"] {
  filter: blur(8px);
  user-select: none;
}
html.dr-mode-late [data-spoiler="late"]::after,
html.dr-mode-story [data-spoiler="story"]::after,
html.dr-mode-unreleased [data-spoiler="unreleased"]::after {
  content: "Covered";
}

#settings {
  position: fixed;
  right: 12px;
  top: 56px;
  background: var(--panel);
  border: 2px solid var(--wood);
  padding: 12px;
  z-index: 40;
}
#settings label { display: block; margin: 6px 0; }

footer {
  padding: 16px 20px 32px;
  color: var(--muted);
  font-size: 13px;
  border-top: 2px solid var(--wood);
  background: var(--edge);
}
code { color: var(--copper); }

.filters { margin: 8px 0; }
.filters input {
  background: var(--slot);
  border: 1px solid var(--wood);
  color: var(--ink);
  padding: 4px 8px;
}
.chip {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 2px 8px;
  border: 1px solid var(--wood);
  cursor: pointer;
  font-size: 12px;
}
.chip.on { background: var(--wood); color: #fff; }
.tablewrap { overflow-x: auto; }
table.db { width: 100%; border-collapse: collapse; }
table.db th, table.db td { padding: 6px 8px; border-bottom: 1px solid #311b17; text-align: left; }
table.db th { font-family: "Cinzel", serif; color: var(--copper); cursor: pointer; }

@media (max-width: 720px) {
  #navtoggle { display: inline-block; }
  #sidebar {
    display: none;
    position: fixed;
    z-index: 25;
    top: 0;
    left: 0;
    height: 100%;
    width: min(280px, 88vw);
  }
  #sidebar.open { display: block; }
  #brand { white-space: normal; }
  #searchwrap { min-width: 120px; flex: 1; max-width: none; }
  .inv-panel, .panel { background-size: cover; padding: 20px 12px; }
  .inspect { flex-direction: column; }
  .cta { width: auto; max-width: none; }
  .codex-home { grid-template-columns: 1fr; }
  .home-copy h1 { max-width: none; }
}

body.paper-main #main {
  background-color: var(--paper);
  background-image: url("/assets/ui/paper-dialoguechoices.png");
  background-repeat: repeat;
  color: var(--paper-ink);
  max-width: 46rem;
}
body.paper-main #main h1,
body.paper-main #main h2,
body.paper-main #main h3 {
  color: #6b4428;
}
body.paper-main #main .lead,
body.paper-main #main .muted,
body.paper-main #main .crumb {
  color: var(--paper-muted);
}
body.paper-main #main a { color: #6b4428; }
body.paper-main #main a:hover { color: #3a2418; }
body.paper-main #main .card {
  background: rgba(255, 250, 240, 0.55);
  color: var(--paper-ink);
}
body.paper-main #main .kv td:first-child { color: var(--paper-muted); }
body.paper-main #main table.db th { color: #6b4428; }
body.paper-main #main table.db th,
body.paper-main #main table.db td,
body.paper-main #main .kv td {
  border-bottom-color: #c4b08a;
}
body.paper-main #main .cta {
  background: var(--btn);
  color: var(--paper-ink);
}
