/* The wiki: the same underground, laid out for looking things up.
   Loaded after style.css and built on its tokens. */
:root {
  --fire: #f08a5d; --water: #6cc3ee; --wood: #8fdd7f; --metal: #d3dce4; --earth: #dcae68; --neutral: #bfb6a0;
}
body.wiki { font-size: clamp(16px, .5vw + 13px, 18px); }
.fl-fire { color: var(--fire); } .fl-water { color: var(--water); } .fl-wood { color: var(--wood); }
.fl-metal { color: var(--metal); } .fl-earth { color: var(--earth); } .fl-neutral { color: var(--neutral); }
.dim { color: var(--mist); }
kbd {
  display: inline-block; min-width: 1.7em; padding: .1em .45em; margin: 0 .1em; text-align: center;
  font: 600 .8em/1.5 var(--label); letter-spacing: .06em; color: var(--parch);
  background: var(--slate-2); border: 1px solid rgba(234,223,198,.22); border-bottom-width: 2px; border-radius: 5px;
}
b.lead {
  font: 600 .78em/1 var(--label); letter-spacing: .16em; color: var(--jade); margin-right: .6em;
}
b.lead::after { content: ""; }

/* ── the bar, the head, the section strip ── */
.wbar { background: rgba(7,11,13,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); gap: 1rem; }
.wbar .bar-mark { margin-right: 0; }
.wbar-home {
  font: 500 .82rem/1 var(--label); letter-spacing: .22em; text-transform: uppercase; color: var(--jade);
  text-decoration: none; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px; margin-right: auto;
}
.wsearch { position: relative; flex: 0 1 22rem; min-width: 0; }
.wsearch input, .ftext {
  width: 100%; font: 400 1rem/1.2 var(--serif); color: var(--parch);
  background: rgba(16,23,27,.85); border: 1px solid var(--line); border-radius: 999px; padding: .55rem 1.1rem;
}
.wsearch input::placeholder, .ftext::placeholder { color: var(--mist); }
.wsearch input:focus, .ftext:focus { outline: none; border-color: var(--jade); }
.wsearch-out {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(26rem, calc(100vw - 2 * var(--gut)));
  max-height: 70vh; overflow: auto; background: var(--slate); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.wsearch-out a { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: .6rem 1rem; color: var(--parch); text-decoration: none; }
.wsearch-out a:hover, .wsearch-out a.on { background: var(--slate-2); }
.wsearch-out small { font: 500 .7rem/1 var(--label); letter-spacing: .18em; text-transform: uppercase; color: var(--mist); white-space: nowrap; }
.wsearch-out p { margin: 0; padding: .8rem 1rem; color: var(--mist); }

.whead {
  position: relative; padding: calc(env(safe-area-inset-top, 0px) + 9rem) var(--gut) 3rem;
  background: linear-gradient(to bottom, rgba(7,11,13,.35), rgba(7,11,13,.72) 55%, var(--rock)), var(--paint) center 35% / cover no-repeat;
}
@media (max-width: 800px) {
  .whead { background-image: linear-gradient(to bottom, rgba(7,11,13,.35), rgba(7,11,13,.72) 55%, var(--rock)), var(--paint-s); padding-top: calc(env(safe-area-inset-top, 0px) + 6.5rem); }
}
.whead-in { max-width: 84rem; margin: 0 auto; }
.whead .h-brush { margin-bottom: .7rem; }
.whead-lede { margin: 0; max-width: 40em; color: var(--parch); text-shadow: 0 1px 12px rgba(0,0,0,.9); }
.whead-count { margin-left: .8rem; font: 500 .78rem/1 var(--label); letter-spacing: .22em; text-transform: uppercase; color: var(--amber); white-space: nowrap; }

.wnav {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 58px); z-index: 30;
  display: flex; gap: .4rem; overflow-x: auto; padding: .7rem var(--gut);
  background: rgba(7,11,13,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.wnav::-webkit-scrollbar { display: none; }
.wnav a {
  flex: none; font: 500 .8rem/1 var(--label); letter-spacing: .2em; text-transform: uppercase;
  color: var(--parch-dim); text-decoration: none; padding: .55rem .9rem; border-radius: 999px; border: 1px solid transparent;
}
.wnav a:hover { color: var(--jade); }
.wnav a[aria-current] { color: var(--rock); background: var(--jade); }

.wmain { max-width: 84rem; margin: 0 auto; padding: 2.5rem var(--gut) 5rem; }
.wfoot { border-top: 1px solid var(--line); }
.wfoot a { color: inherit; text-decoration: none; }
.wfoot a:hover { color: var(--jade); }

/* ── the front page's tiles ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1rem; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 15rem; padding: 1.4rem;
  color: var(--parch); text-decoration: none; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: linear-gradient(to top, rgba(7,11,13,.96) 18%, rgba(7,11,13,.2) 75%), var(--paint) center / cover no-repeat;
  transition: border-color .2s, transform .2s;
}
.tile:hover { border-color: var(--jade); transform: translateY(-3px); }
.tile h2 { margin: 0 0 .3rem; font: 400 1.9rem/1.05 var(--brush); }
.tile p { margin: 0; font-size: .95rem; line-height: 1.45; color: var(--parch-dim); }
.tile-count { font: 500 .72rem/1 var(--label); letter-spacing: .22em; text-transform: uppercase; color: var(--amber); margin-bottom: .6rem; }

/* ── headings and groups ── */
.wmain section { padding-left: 0; }
.grp { margin: 0 0 3.5rem; scroll-margin-top: 8rem; }
.wh2 {
  display: flex; align-items: center; gap: .8rem; margin: 0 0 .6rem; padding-bottom: .5rem;
  font: 400 clamp(1.9rem, 3vw, 2.6rem)/1.1 var(--brush); border-bottom: 1px solid var(--line); scroll-margin-top: 8rem;
}
.wh3 { margin: 1.8rem 0 .9rem; font: 500 .85rem/1 var(--label); letter-spacing: .26em; text-transform: uppercase; color: var(--amber); }
.grp-note { margin: 0 0 1.4rem; max-width: 46em; color: var(--parch-dim); }

/* ── filters ── */
.filters { margin: 0 0 2.2rem; padding: 1rem; background: var(--slate); border: 1px solid var(--line); border-radius: 14px; }
.ftext { border-radius: 10px; margin-bottom: .2rem; }
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .7rem; }
.frow-l { width: 4.6rem; font: 500 .72rem/1 var(--label); letter-spacing: .2em; text-transform: uppercase; color: var(--mist); }
.fbtn {
  cursor: pointer; font: 500 .78rem/1 var(--label); letter-spacing: .14em; text-transform: uppercase;
  padding: .5rem .8rem; border-radius: 999px; background: transparent; border: 1px solid rgba(234,223,198,.2); color: var(--parch-dim);
}
.fbtn[class*="fl-"] { color: inherit; }
.fbtn.fl-fire { color: var(--fire); } .fbtn.fl-water { color: var(--water); } .fbtn.fl-wood { color: var(--wood); }
.fbtn.fl-metal { color: var(--metal); } .fbtn.fl-earth { color: var(--earth); } .fbtn.fl-neutral { color: var(--neutral); }
.fbtn:hover { border-color: var(--jade); }
.fbtn[aria-pressed="true"] { background: rgba(47,140,104,.3); border-color: var(--jade); color: var(--parch); }
.fcount { margin: .8rem 0 0; font: 500 .74rem/1 var(--label); letter-spacing: .2em; text-transform: uppercase; color: var(--mist); min-height: 1em; }
[data-off] { display: none !important; }

/* ── cards ── */
.wcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: .9rem; align-items: start; }
.wcards-tight { grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: .7rem; }
.wcards-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); }
.wcard {
  padding: 1rem; background: linear-gradient(160deg, var(--slate-2), var(--slate) 60%);
  border: 1px solid rgba(234,223,198,.09); border-radius: 12px; scroll-margin-top: 9rem; min-width: 0;
}
.wcard:target { border-color: var(--jade); box-shadow: 0 0 0 1px var(--jade), 0 0 40px rgba(134,232,184,.18); }
.wcard header { display: flex; gap: .9rem; align-items: flex-start; }
.wcard header > div { min-width: 0; flex: 1; }
.wcard h4 { margin: 0 0 .4rem; font: 600 1.08rem/1.25 var(--serif); color: var(--parch); overflow-wrap: anywhere; }
.item h4 { font-size: .98rem; margin-top: .2rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  font: 500 .68rem/1 var(--label); letter-spacing: .16em; text-transform: uppercase;
  padding: .32rem .5rem; border-radius: 4px; background: rgba(234,223,198,.07); color: var(--parch-dim);
}
.chip[class*="fl-"] { background: rgba(234,223,198,.05); box-shadow: inset 0 0 0 1px currentColor; }
.chip.fl-fire { color: var(--fire); } .chip.fl-water { color: var(--water); } .chip.fl-wood { color: var(--wood); }
.chip.fl-metal { color: var(--metal); } .chip.fl-earth { color: var(--earth); } .chip.fl-neutral { color: var(--neutral); }
.chip-mix { color: var(--amber); box-shadow: inset 0 0 0 1px rgba(232,162,86,.5); }
.card-body { margin-top: .8rem; font-size: .93rem; line-height: 1.5; color: var(--parch-dim); }
.card-body p { margin: 0 0 .5em; overflow-wrap: anywhere; }
.card-body p:last-child { margin-bottom: 0; }
.card-from, .card-where { margin: .6rem 0 0; font-size: .86rem; line-height: 1.45; color: var(--mist); }
.card-where { margin-top: .4rem; }
.card-from a { color: var(--jade); }
.card-gift { margin: .6rem 0 0; font-size: .93rem; line-height: 1.5; color: var(--parch); }

/* The painted icon sheet: one image, a cell per icon. */
.ic {
  --s: 64px; flex: none; display: block; width: var(--s); height: var(--s); border-radius: 10px;
  background: url(/assets/wiki/icons.webp) calc(var(--c) * -1 * var(--s)) calc(var(--r) * -1 * var(--s)) / calc(var(--ic-cols) * var(--s)) calc(var(--ic-rows) * var(--s)) no-repeat;
}
.ic-px {
  image-rendering: pixelated;
  background-image: url(/assets/wiki/atlas.png);
  background-size: calc(var(--px-cols) * var(--s)) calc(var(--px-rows) * var(--s));
}
.ic-none, .cr-none { background: radial-gradient(circle, rgba(134,232,184,.18), transparent 65%); }
.wh2 .ic { display: inline-block; }
.cr { flex: none; display: block; width: 96px; height: 96px; background: url(/assets/wiki/creatures.webp) no-repeat; }
.cr:not(.cr-none) { background-size: var(--cr-w) var(--cr-h); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(3.9rem, 1fr)); gap: 1px; margin: .9rem 0 0; background: rgba(234,223,198,.08); border-radius: 8px; overflow: hidden; }
.stats div { background: var(--slate); padding: .55rem .6rem; }
.stats dt { font: 500 .62rem/1 var(--label); letter-spacing: .12em; text-transform: uppercase; color: var(--mist); margin-bottom: .35rem; }
.stats dd { margin: 0; font: 600 .95rem/1.2 var(--serif); color: var(--parch); }

/* ── the book ── */
.wsplit { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; align-items: start; }
.toc { position: sticky; top: 8.5rem; max-height: calc(100vh - 10rem); overflow: auto; padding-right: .5rem; scrollbar-width: thin; }
.toc-h { margin: 1.3rem 0 .5rem; font: 500 .72rem/1 var(--label); letter-spacing: .24em; text-transform: uppercase; color: var(--amber); }
.toc-h:first-child { margin-top: 0; }
.toc a { display: block; padding: .22rem 0; font-size: .92rem; line-height: 1.35; color: var(--parch-dim); text-decoration: none; }
.toc a:hover { color: var(--jade); }
.leaves .wh2 { margin-top: 3rem; }
.leaves .wh2:first-child { margin-top: 0; }
.leaf { max-width: 44rem; padding: 1.6rem 0 2rem; border-bottom: 1px solid rgba(234,223,198,.08); scroll-margin-top: 8rem; }
.leaf h3 { margin: 0 0 1rem; font: 600 1.5rem/1.2 var(--serif); }
.leaf .said { margin: 0 0 1.4rem; }
.leaf .said p { margin: 0 0 .5em; }
.leaf-facts p { margin: 0 0 .9em; color: var(--parch-dim); }
@media (max-width: 900px) {
  .wsplit { grid-template-columns: 1fr; gap: 1.5rem; }
  .toc { position: static; max-height: none; columns: 2; column-gap: 1.5rem; padding: 1rem; background: var(--slate); border: 1px solid var(--line); border-radius: 12px; }
  .toc-h { break-after: avoid; }
}
@media (max-width: 480px) { .toc { columns: 1; } }

/* ── tables ── */
.tablewrap { overflow-x: auto; border: 1px solid rgba(234,223,198,.09); border-radius: 12px; }
.rtable { width: 100%; border-collapse: collapse; font-size: .93rem; line-height: 1.45; }
.rtable th { text-align: left; font: 500 .7rem/1 var(--label); letter-spacing: .2em; text-transform: uppercase; color: var(--mist); padding: .8rem 1rem; background: var(--slate); }
.rtable td { padding: .7rem 1rem; border-top: 1px solid rgba(234,223,198,.07); vertical-align: top; color: var(--parch-dim); }
.rtable td:first-child { color: var(--parch); font-weight: 600; min-width: 12rem; }
.rtable tr.wcard { display: table-row; background: none; }
.rtable tr:target td { background: rgba(47,140,104,.18); }
.ktable td:first-child { white-space: nowrap; min-width: 0; }

/* ── the ladder and the lines ── */
.wladder { list-style: none; margin: 0; padding: 0 0 0 1.6rem; border-left: 1px solid var(--jade-deep); display: flex; flex-direction: column-reverse; gap: 1.6rem; }
.wladder li { position: relative; scroll-margin-top: 9rem; }
.wladder li::before { content: ""; position: absolute; left: calc(-1.6rem - 5px); top: .7rem; width: 9px; height: 9px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 14px var(--jade); }
.wladder h3 { margin: 0 0 .3rem; font: 400 1.8rem/1.1 var(--brush); }
.wladder p { margin: 0; }
.wladder .stats { grid-template-columns: repeat(4, 1fr); max-width: 52rem; }
@media (max-width: 640px) { .wladder .stats { grid-template-columns: repeat(2, 1fr); } }
.doll { flex: none; width: 64px; height: 112px; object-fit: contain; }
.levels { list-style: none; margin: 1rem 0 0; padding: 0; counter-reset: lvl; }
.levels li { display: grid; grid-template-columns: 1.6rem 1fr; column-gap: .4rem; padding: .5rem 0; border-top: 1px solid rgba(234,223,198,.07); counter-increment: lvl; font-size: .93rem; line-height: 1.4; }
.levels li::before { content: counter(lvl); grid-row: span 2; font: 600 .8rem/1.6 var(--label); color: var(--amber); }
.levels b { font-weight: 600; color: var(--parch); }
.levels span { grid-column: 2; font-size: .84rem; }

@media (max-width: 640px) {
  .wbar .bar-mark { font-size: 1.25rem; }
  .wsearch { flex: 1 1 auto; }
  .frow-l { width: 100%; }
  .wcard { padding: .85rem; }
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }
