/*
 * The wiki's look. The page is the jar's and is put back on every upgrade; a server's own
 * colours go in custom.css beside it, which is loaded after this and never written over.
 *
 * All of it is in one cascade layer, and custom.css is in none, so anything an owner writes
 * there wins outright - a plain ":root { --bg: ... }" beats the dark-mode block below without
 * having to out-score its selector, which is the whole of what a theme file should need.
 */

@layer page {

:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --panel-2: #efe9dd;
  --ink: #23201b;
  --muted: #6d665a;
  --line: #d9d1c1;
  --accent: #3f7a3a;
  --accent-soft: #e2eedc;
  --tip-bg: #100010;
  --tip-edge: #2a0a5a;
  --tip-edge-2: #1c0640;
  --radius: 10px;
  --gutter: 24px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --panel: #1d2024;
    --panel-2: #262a30;
    --ink: #ece8df;
    --muted: #a39d91;
    --line: #353a41;
    --accent: #7cbf6e;
    --accent-soft: #24331f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --panel: #1d2024;
  --panel-2: #262a30;
  --ink: #ece8df;
  --muted: #a39d91;
  --line: #353a41;
  --accent: #7cbf6e;
  --accent-soft: #24331f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--panel-2); padding: 0.05em 0.35em; border-radius: 4px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute;
  left: 8px;
  top: -40px;
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 6px;
  z-index: 10;
}
.skip:focus { top: 8px; }

/* ------------------------------------------------------------------ header */

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--gutter) 12px;
}

.brand { display: flex; gap: 12px; align-items: center; min-width: 0; text-decoration: none; }
.mark { width: 34px; height: 34px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.brand .title { display: block; font: 600 1.3rem/1.2 var(--serif); }
.brand .tagline { display: block; color: var(--muted); font-size: 0.88rem; }

.search {
  position: relative;
  flex: 0 1 340px;
  min-width: 200px;
}
.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 40px 8px 36px;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font: 0.75rem var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
}

.sections {
  display: flex;
  gap: 4px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}
.sections a {
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-weight: 500;
  text-decoration: none;
}
.sections a:hover { color: var(--ink); }
.sections a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.sections .site { margin-left: auto; }
.sections .site::before { content: "\2190\00a0"; }

/* ------------------------------------------------------------------ pages */

main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}
main:focus { outline: none; }

.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

.page-head { margin-bottom: 20px; }
.page-head h1 { font: 600 1.7rem/1.2 var(--serif); }
.page-head .blurb { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }

/* The home page: a card per section. */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.shelf a {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.shelf a:hover { border-color: var(--accent); transform: translateY(-1px); }
.shelf h2 { font: 600 1.15rem/1.2 var(--serif); display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.shelf .count { font: 500 0.8rem var(--sans); color: var(--muted); }
.shelf p { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

/* A section: its entries as a list that reads at a glance. */
.filter { margin: 0 0 14px; }

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px;
}
.entries a {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: start;
  height: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  text-decoration: none;
}
.entries a:hover { border-color: var(--accent); }
.entries .swatch { grid-row: span 2; margin-top: 5px; }
.entries .name { font-weight: 600; }
.entries .sub { color: var(--muted); font-size: 0.86rem; }
.entries .tags { grid-column: 2; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--sw, var(--line));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag {
  font-size: 0.75rem;
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
}

/* An entry: what there is to say down the left, and its box down the right. */
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.entry.boxed { grid-template-columns: minmax(0, 1fr) 320px; }

.infobox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--box, var(--accent));
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.92rem;
}
.infobox-title {
  display: block;
  padding: 12px 14px 10px;
  background: var(--panel-2);
  text-align: center;
  font: 600 1.15rem/1.25 var(--serif);
}
.infobox-picture {
  display: flex;
  justify-content: center;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
}
.infobox-rows { width: 100%; border-collapse: collapse; }
.infobox-rows th,
.infobox-rows td {
  padding: 7px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.infobox-rows th { width: 38%; color: var(--muted); font-weight: 500; font-size: 0.86rem; }
.infobox-rows a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.infobox-rows a:hover { text-decoration-color: var(--accent); }
.infobox-rows a.away::after { content: " \2197"; font-size: 0.85em; }
/* A photograph is a map: 128 pixels a side, kept sharp rather than smoothed to a blur. */
.infobox-photo img { display: block; width: 100%; height: auto; image-rendering: pixelated; border-radius: 4px; }

.block { margin: 0 0 22px; }
.block h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}
.block ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.block li { padding: 4px 0 4px 14px; }
.block li .note { display: block; color: var(--muted); font-size: 0.86rem; }
.block li a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.block li a:hover { text-decoration-color: var(--accent); }
.block p { margin: 0 0 8px; max-width: 70ch; }
.block .more,
.chip {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
}
.block .more { margin: 8px 0 0 14px; }
.block .more:hover,
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* Text in a colour the game chose is coloured by wiki.js, toned for whatever background the
   page is painted - see tone() there. A tooltip keeps the game's own colours. */
.rich .b { font-weight: 700; }
.rich .i { font-style: italic; }
.rich .u { text-decoration: underline; }
.rich .s { text-decoration: line-through; }
.rich .u.s { text-decoration: underline line-through; }

.tooltip {
  display: inline-block;
  max-width: 100%;
  background: var(--tip-bg);
  border: 2px solid var(--tip-edge);
  outline: 2px solid var(--tip-bg);
  box-shadow: inset 0 0 0 1px var(--tip-edge-2);
  border-radius: 3px;
  padding: 7px 10px 8px;
  font: 15px/1.35 "Minecraft", "Monocraft", var(--mono);
  color: #aaaaaa;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55);
  word-break: break-word;
}
.tooltip .line { min-height: 1.35em; white-space: pre-wrap; }
.tooltip .line:first-child { margin-bottom: 3px; color: #ffffff; }

.empty { color: var(--muted); padding: 24px 0; }

.missing { max-width: 60ch; }
.missing h1 { font: 600 1.4rem/1.2 var(--serif); margin-bottom: 8px; }

.foot {
  padding: 16px var(--gutter) 24px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ------------------------------------------------------------------ held in a frame */

/* The whole wiki inside another page: that page has the title and the way back, so this
   keeps its search and its sections and drops the rest. Nothing is as tall as the screen,
   because the frame is as tall as the wiki and the page around it scrolls. */
.embed-page body,
.embed-box body { min-height: 0; }
.embed-page .brand,
.embed-page .sections .site,
.embed-page .skip { display: none; }
.embed-page .top { justify-content: flex-end; padding-top: 8px; }
.embed-page main { padding-top: 16px; }

/* One entry's infobox in a post: the box and nothing round it, its name a link to the rest. */
.embed-box body { background: transparent; }
.embed-box .top,
.embed-box .sections,
.embed-box .foot,
.embed-box .skip { display: none; }
.embed-box main { padding: 0; max-width: none; }
.embed-box a.infobox-title { color: inherit; text-decoration: none; }
.embed-box a.infobox-title:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ------------------------------------------------------------------ narrow */

@media (max-width: 760px) {
  :root { --gutter: 16px; }
  /* On a phone the box comes first, full width, as an encyclopaedia's does. */
  .entry.boxed { grid-template-columns: minmax(0, 1fr); }
  .entry .infobox { order: -1; }
  .search { flex-basis: 100%; }
  /* A key to press is no help on a screen with no keys. */
  .search kbd { display: none; }
  .search input { padding-right: 14px; }
  .page-head h1 { font-size: 1.45rem; }
  .entries { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .shelf a { transition: none; }
  .shelf a:hover { transform: none; }
}

}
