/*
 * The Kingless Wiki: the game's own interface for a reference to read. Dark oiled oak and forged iron (the kit's painted
 * pieces, client/src/art/ui, drawn as 9-slices), cream words, the label face (Marcellus) for what names things, the text
 * face (Alegreya) for reading, Cinzel for titles, as in the game's windows. The figures are the game's own (art/fonts).
 */
@font-face { font-family: "Label Figures"; font-weight: 400; font-display: swap; src: url("art/fonts/figures-label.woff2") format("woff2"); unicode-range: U+30-39; }
@font-face { font-family: "Text Figures"; font-weight: 400; font-display: swap; src: url("art/fonts/figures-text-400.woff2") format("woff2"); unicode-range: U+30-39; }
@font-face { font-family: "Text Figures"; font-weight: 700; font-display: swap; src: url("art/fonts/figures-text-700.woff2") format("woff2"); unicode-range: U+30-39; }
@font-face { font-family: "Marcellus"; font-weight: 400; font-display: swap; src: url("fonts/marcellus-400.woff2") format("woff2"); }
@font-face { font-family: "Cinzel"; font-weight: 700; font-display: swap; src: url("fonts/cinzel-700.woff2") format("woff2"); }
@font-face { font-family: "Alegreya"; font-weight: 400; font-display: swap; src: url("fonts/alegreya-400.woff2") format("woff2"); }
@font-face { font-family: "Alegreya"; font-weight: 400; font-style: italic; font-display: swap; src: url("fonts/alegreya-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Alegreya"; font-weight: 700; font-display: swap; src: url("fonts/alegreya-700.woff2") format("woff2"); }

:root {
  --font-label: "Label Figures", "Marcellus", "Palatino Linotype", "Book Antiqua", serif;
  --font-text: "Text Figures", "Alegreya", "Palatino Linotype", Georgia, serif;
  --font-title: "Label Figures", "Cinzel", "Marcellus", "Palatino Linotype", serif;
  --cream: #f2e5c6;
  --cream-dim: #c4af86;
  --ink: #0e0905;
  --gold: #e8bb5e;
  --gold-dim: #b98a3a;
  --oak: #1c130c;
  --oak-2: #261a10;
  --oak-3: #2f2115;
  --line: #4a3522;
  --good: #8fe39a;
  --bad: #ff8a6e;
  --kit-window: url("art/ui/window.webp") 52 fill / 40px stretch;
  --kit-title: url("art/ui/title.webp") 40 62 fill / 14px 22px stretch;
  --kit-plaque: url("art/ui/plaque.webp") 56 fill / 13px stretch;
  --kit-slot: url("art/ui/slot.webp") 34 fill / 8px stretch;
  --kit-button: url("art/ui/button.webp") 64 fill / 11px stretch;
  --kit-button-lit: url("art/ui/button-lit.webp") 64 fill / 11px stretch;
  --shadow: 0 1px 0 #000, 0 0 3px rgb(0 0 0 / 0.85);
  --side: 236px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: #110b07; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font: 400 17px/1.55 var(--font-text);
  background:
    radial-gradient(ellipse at 50% -10%, rgb(120 78 34 / 0.22), transparent 55%),
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0.012) 0 2px, transparent 2px 7px),
    linear-gradient(#17100a, #0f0a06);
  background-attachment: fixed;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: rgb(232 187 94 / 0.35); }

/* --- The bar: the wiki's name, and the search ------------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: linear-gradient(#2a1d12, #1a110a);
  border-bottom: 2px solid #050302;
  box-shadow: 0 2px 0 #3a2918, 0 6px 18px rgb(0 0 0 / 0.6);
}
.logo {
  display: inline-flex; align-items: baseline; gap: 10px;
  padding: 9px 26px 8px;
  border: 14px solid transparent; border-width: 14px 22px; border-image: var(--kit-title);
  text-decoration: none !important;
  white-space: nowrap;
}
.logo-name {
  font: 700 26px/1 var(--font-title); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--cream); text-shadow: 0 1px 0 #000, 0 0 6px rgb(0 0 0 / 0.9), 0 0 1px #6b4a1c;
}
.logo-wiki { font: 400 15px/1 var(--font-label); letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); text-shadow: var(--shadow); }
.search { position: relative; flex: 1; max-width: 560px; margin-left: auto; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 40px;
  font: 400 16px var(--font-text); color: var(--cream);
  background: #0c0805 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b98a3a' stroke-width='2.4'%3E%3Ccircle cx='10' cy='10' r='6.5'/%3E%3Cpath d='M15 15l6 6'/%3E%3C/svg%3E") 13px 50% no-repeat;
  border: 1px solid #5a4128; border-radius: 3px;
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.8), 0 1px 0 rgb(255 255 255 / 0.04);
}
.search input::placeholder { color: #8a7656; }
.search input::-webkit-search-cancel-button { filter: sepia(1) hue-rotate(-10deg); }
.found {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 30;
  margin: 0; padding: 6px; list-style: none;
  max-height: min(70vh, 560px); overflow: auto;
  background: #120c08; border: 1px solid var(--gold-dim); border-radius: 3px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.75);
}
.found li a, .found li.more { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 2px; color: var(--cream); text-decoration: none; }
.found li a .k { margin-left: auto; font: 400 13px var(--font-label); color: var(--cream-dim); }
.found li.on a, .found li a:hover { background: rgb(232 187 94 / 0.14); }
.found li.more { color: var(--cream-dim); font-style: italic; }
.found .pic { width: 30px; height: 30px; }
.menu { display: none; }

/* --- The frame: the navigation and the page -------------------------------------------------------------------- */
.frame { display: flex; gap: 22px; max-width: 1480px; margin: 0 auto; padding: 22px 22px 40px; align-items: flex-start; }
.side {
  position: sticky; top: 86px; flex: 0 0 var(--side);
  max-height: calc(100vh - 100px); overflow: auto;
  padding: 16px 12px;
  border: 40px solid transparent; border-image: var(--kit-window);
  border-width: 22px; border-image-width: 22px;
  scrollbar-width: thin; scrollbar-color: #5a4128 transparent;
}
.side ul { margin: 0; padding: 0; list-style: none; }
.side .sec > a {
  display: block; padding: 6px 8px; font: 400 16px var(--font-label); color: var(--cream); text-shadow: var(--shadow);
  border-radius: 2px;
}
.side .sec > a:hover { background: rgb(255 255 255 / 0.05); text-decoration: none; }
.side .sec.open > a { color: var(--gold); }
.side .sec ul { margin: 2px 0 8px 10px; padding-left: 8px; border-left: 1px solid var(--line); }
.side .sec ul a { display: block; padding: 3px 8px; font-size: 15px; color: var(--cream-dim); border-radius: 2px; }
.side .sec ul a:hover { color: var(--cream); text-decoration: none; background: rgb(255 255 255 / 0.04); }
.side .sec li.here > a { color: var(--gold); background: rgb(232 187 94 / 0.1); }

.page {
  flex: 1; min-width: 0;
  padding: 18px 26px 30px;
  border: 40px solid transparent; border-image: var(--kit-window);
}
.page > h1 {
  margin: 6px 0 4px; font: 700 32px/1.15 var(--font-title); letter-spacing: 0.02em; color: var(--cream);
  text-shadow: 0 1px 0 #000, 0 0 8px rgb(0 0 0 / 0.7);
}
.lede { margin: 0 0 16px; color: var(--cream-dim); font-style: italic; font-size: 18px; }
.crumbs { font: 400 14px var(--font-label); color: var(--cream-dim); }
.crumbs a { color: var(--cream-dim); }
.crumbs a:hover { color: var(--gold); }
.crumbs .sep { margin: 0 7px; color: var(--gold-dim); }
article { max-width: 920px; }
.has-box article { max-width: none; }
article h2 {
  clear: none; margin: 30px 0 10px; padding-bottom: 5px;
  font: 400 23px/1.2 var(--font-label); color: var(--gold); text-shadow: var(--shadow);
  border-bottom: 1px solid var(--line);
}
article h3 { margin: 22px 0 8px; font: 400 19px var(--font-label); color: var(--cream); }
article h4 { margin: 16px 0 6px; font: 400 17px var(--font-label); color: var(--cream-dim); }
article p { margin: 0 0 12px; }
article ul, article ol { margin: 0 0 14px; padding-left: 24px; }
article li { margin: 3px 0; }
article strong { color: #fff1d2; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 6px; text-align: center;
  font: 400 14px/1.5 var(--font-label); color: var(--cream);
  background: #0d0805; border: 1px solid #5a4128; border-bottom-width: 2px; border-radius: 3px;
}
.note {
  margin: 14px 0; padding: 10px 14px;
  background: rgb(232 187 94 / 0.06); border-left: 3px solid var(--gold-dim); border-radius: 2px;
  color: var(--cream); font-size: 16px;
}
.foot { padding: 18px; text-align: center; color: #7d6a4c; font: 400 13px var(--font-label); }

/* --- The infobox: a thing's numbers, on the kit's plaque ------------------------------------------------------- */
.infobox {
  float: right; clear: right; width: 310px; margin: 4px 0 18px 24px;
  padding: 10px 12px 12px;
  border: 13px solid transparent; border-image: var(--kit-plaque);
  font-size: 15.5px;
}
.infobox .box-pic { display: flex; justify-content: center; margin: 4px 0 10px; }
.infobox .box-pic .pic { width: 112px; height: 112px; }
.infobox .box-pic .pic.glyph { width: 96px; height: 96px; }
.infobox .box-title { text-align: center; font: 400 18px var(--font-label); color: var(--cream); margin-bottom: 8px; text-shadow: var(--shadow); }
.infobox table { width: 100%; border-collapse: collapse; }
.infobox th, .infobox td { padding: 4px 4px; vertical-align: top; border-top: 1px solid rgb(255 255 255 / 0.06); text-align: left; }
.infobox th { width: 42%; font: 400 14px/1.4 var(--font-label); color: var(--cream-dim); }
.infobox td { color: var(--cream); }
.infobox .box-head th { padding-top: 10px; border-top: 0; color: var(--gold); font-size: 15px; }

/* --- Pictures: an item on the slot's dark bed, a creature's mark, a glyph ------------------------------------------ */
.pic {
  display: inline-block; flex: none; width: 36px; height: 36px;
  border: 8px solid transparent; border-image: var(--kit-slot);
  background: #0b0705;
  vertical-align: middle;
}
.pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pic.mark { border: 0; border-radius: 50%; background: none; box-shadow: 0 0 0 2px #3a2816, 0 0 0 3px #000; overflow: hidden; }
.pic.mark img { object-fit: cover; }
.pic.glyph { border: 0; background: none; }
.pic.sm { width: 28px; height: 28px; border-width: 5px; }
.pic.mark.sm, .pic.glyph.sm { width: 26px; height: 26px; }
.spell-glyph {
  display: block; width: 100%; height: 100%;
  background: var(--glyph) center / contain no-repeat, var(--hue);
  background-blend-mode: hard-light;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
i.icon {
  display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -0.25em; background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat;
}
.thing { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.thing .pic { width: 30px; height: 30px; border-width: 5px; }
.thing .pic.mark, .thing .pic.glyph { width: 24px; height: 24px; }
.grade-1 { --grade: #94e35a; } .grade-2 { --grade: #e07cf0; } .grade-3 { --grade: #ff7a2e; }

/* --- Tables: the data, sortable and narrowed as you type ------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 6px 0 18px; border: 1px solid #3c2a19; border-radius: 3px; background: rgb(0 0 0 / 0.22); }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th, td { padding: 6px 10px; text-align: left; vertical-align: middle; }
thead th {
  position: sticky; top: 0;
  font: 400 14px var(--font-label); color: var(--gold); white-space: nowrap;
  background: #1e150d; border-bottom: 1px solid #4a3522;
}
tbody tr { border-top: 1px solid rgb(255 255 255 / 0.05); }
tbody tr:nth-child(even) { background: rgb(255 255 255 / 0.018); }
tbody tr:hover { background: rgb(232 187 94 / 0.06); }
td.n, th.n { text-align: right; white-space: nowrap; }
td .muted, .muted { color: var(--cream-dim); }
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th::after { content: ""; display: inline-block; width: 0.9em; margin-left: 4px; color: var(--gold-dim); }
table.sortable thead th[aria-sort="ascending"]::after { content: "▲"; font-size: 10px; }
table.sortable thead th[aria-sort="descending"]::after { content: "▼"; font-size: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.filters input, .filters select {
  height: 34px; padding: 0 10px; font: 400 15px var(--font-text); color: var(--cream);
  background: #0c0805; border: 1px solid #5a4128; border-radius: 3px;
}
.filters input { min-width: 220px; }
.filters .count { margin-left: auto; font: 400 14px var(--font-label); color: var(--cream-dim); }

/* --- Lists of things as tiles (a section's front page, a family of items) ----------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 8px 0 20px; padding: 0; list-style: none; }
.tiles li a {
  display: flex; align-items: center; gap: 10px; height: 100%; padding: 8px 10px;
  color: var(--cream); background: rgb(0 0 0 / 0.25); border: 1px solid #3c2a19; border-radius: 3px;
}
.tiles li a:hover { border-color: var(--gold-dim); background: rgb(232 187 94 / 0.07); text-decoration: none; }
.tiles li a small { display: block; color: var(--cream-dim); font-size: 13.5px; line-height: 1.3; }
.tiles .pic { width: 40px; height: 40px; }
.tiles .pic.mark, .tiles .pic.glyph { width: 34px; height: 34px; }

/* --- The front page ------------------------------------------------------------------------------------------- */
.portal { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 10px 0 24px; }
.portal a {
  display: grid; grid-template-columns: 52px 1fr; gap: 4px 14px; align-items: center;
  padding: 14px 16px; color: var(--cream);
  border: 13px solid transparent; border-image: var(--kit-plaque);
}
.portal a:hover { text-decoration: none; filter: brightness(1.12); }
.portal a .pic { grid-row: span 2; width: 52px; height: 52px; }
.portal a b { font: 400 19px var(--font-label); color: var(--gold); text-shadow: var(--shadow); }
.portal a small { color: var(--cream-dim); font-size: 14.5px; line-height: 1.35; }
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center;
  margin: 0 0 18px; padding: 16px 20px;
  background: linear-gradient(90deg, rgb(232 187 94 / 0.07), transparent 70%);
  border-left: 3px solid var(--gold-dim);
}
.hero p { margin: 0; font-size: 18px; }
.facts { display: flex; gap: 22px; flex-wrap: wrap; }
.facts span { font: 400 14px var(--font-label); color: var(--cream-dim); text-align: center; }
.facts b { display: block; font: 700 26px var(--font-text); color: var(--gold); }

/* --- Screenshots: shown when the file is there, nothing at all when it is not -------------------------------------- */
figure.shot { margin: 8px 0 18px; }
figure.shot img { display: block; max-width: 100%; height: auto; border: 2px solid #050302; box-shadow: 0 0 0 1px #4a3522, 0 6px 18px rgb(0 0 0 / 0.5); }
figure.shot figcaption { margin-top: 6px; font-size: 14.5px; color: var(--cream-dim); font-style: italic; }
.box-shot img { width: 100%; height: auto; border: 1px solid #050302; }

/* --- Words in a thing's colours: rarities, quality, a spell's school ----------------------------------------------- */
.tag { display: inline-block; padding: 0 7px; margin: 0 2px; font: 400 13px/1.7 var(--font-label); border-radius: 2px; background: rgb(255 255 255 / 0.06); color: var(--cream-dim); }
.good { color: var(--good); } .bad { color: var(--bad); }
.cols { columns: 2 260px; column-gap: 28px; }
.cols > * { break-inside: avoid; }
.see-also { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--line); }
.empty { color: var(--cream-dim); font-style: italic; }

/* --- A phone, a narrow window ---------------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .frame { padding: 12px 10px 30px; gap: 0; }
  .side {
    position: fixed; top: 64px; left: 0; bottom: 0; z-index: 25; max-height: none; width: min(320px, 86vw);
    transform: translateX(-105%); transition: transform 0.18s ease-out;
    background: #160f09; border-image: none; border: 0; border-right: 2px solid #3a2918; padding: 14px;
  }
  body.nav-open .side { transform: none; box-shadow: 10px 0 30px rgb(0 0 0 / 0.7); }
  .menu {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 40px; padding: 0 9px; background: none; border: 1px solid #5a4128; border-radius: 3px; cursor: pointer;
  }
  .menu i { display: block; height: 2px; background: var(--cream); }
  .bar { gap: 10px; padding: 8px 10px; }
  .logo { padding: 6px 12px 5px; border-width: 10px 14px; }
  .logo-name { font-size: 19px; letter-spacing: 0.1em; }
  .logo-wiki { display: none; }
  .page { padding: 4px 8px 20px; border-width: 22px; border-image-width: 22px; }
  .page > h1 { font-size: 26px; }
  .infobox { float: none; width: auto; margin: 6px 0 16px; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .portal { grid-template-columns: 1fr; }
  .filters input { min-width: 0; flex: 1; }
}
