/* ===========================================================================
   wiki.css -- the wiki's whole stylesheet.

   HAND-WRITTEN, unlike everything else under web/wiki/. The generator writes
   pages; this file is the one piece of the wiki that is authored, because a
   stylesheet holds no facts about the game and so cannot drift from it. It is
   the exception that proves the rule in WIKI.md: the generated half is what is
   DERIVABLE, and taste is not.

   (Step 1.4 appends a second, generated stylesheet for the icon sheet offsets,
   which ARE derived -- one class per item, positions computed from the grid.)

   The palette is copied verbatim from web/index.html so the wiki reads as part
   of the site rather than a different project. Keep them in step by hand: eight
   variables changing once a year is not worth a build step, and a wiki that
   imports the game page's stylesheet would inherit a full-viewport flexbox
   layout built around a canvas this site does not have.
   ========================================================================= */

:root {
    --bg:      #0d1014;
    --panel:   #161b22;
    --edge:    #2b333d;
    --ink:     #d6d8e0;
    --dim:     #8b95a3;
    --accent:  #f5e096;
    --ember:   #e2be5a;
    --alarm:   #e08a5a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    /* The same monospace stack as the game page. A reference full of numbers
       that have to line up in columns wants a monospace anyway -- a
       proportional font makes 135 and 215 different widths, and a temperature
       table is the main thing on this site. */
    font-family: Consolas, "SF Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.6;
}

/* --- the bar across the top --------------------------------------------- */

header.top {
    display: flex;
    align-items: baseline;
    gap: 18px;
    flex-wrap: wrap;
    padding: 9px 20px;
    border-bottom: 1px solid var(--edge);
    background: var(--panel);
    /* Sticky rather than fixed: fixed would need the body padded by exactly
       the header's height, which is a number that goes wrong the moment the
       nav wraps to a second line on a phone. */
    position: sticky;
    top: 0;
    z-index: 10;
}

header.top .brand {
    color: var(--accent);
    text-decoration: none;
    /* Explicitly cancels the underline the generic `a` rule below draws.
       Chrome on the brand and the nav is furniture, not prose links. */
    border-bottom: 0;
    font-size: 17px;
    letter-spacing: 2px;
    font-weight: 600;
    white-space: nowrap;
}
header.top .brand span { color: var(--dim); letter-spacing: 1px; }

header.top nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
header.top nav a {
    color: var(--dim);
    text-decoration: none;
    border-bottom: 0;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 13px;
}
header.top nav a:hover {
    color: var(--ink);
    border-color: var(--edge);
}
/* Which page you are on, stated rather than implied. A reference site is
   something people arrive in the middle of from a search result. */
header.top nav a.here {
    color: var(--bg);
    background: var(--ember);
    border-color: var(--ember);
}

/* --- the page ------------------------------------------------------------ */

main {
    /* Wide enough for the material table's eight columns and no wider. Prose
       past about 90 monospace characters is measurably harder to read, and the
       tables get their own full-width escape hatch below. */
    max-width: 1100px;
    margin: 0 auto;
    padding: 26px 20px 60px;
}

h1 {
    margin: 0 0 14px;
    font-size: 24px;
    letter-spacing: 1px;
    color: var(--accent);
    font-weight: 600;
}
h2 {
    margin: 34px 0 10px;
    font-size: 16px;
    letter-spacing: 1px;
    color: var(--ember);
    font-weight: 600;
    border-bottom: 1px solid var(--edge);
    padding-bottom: 5px;
}
h3 {
    margin: 22px 0 8px;
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--ink);
    font-weight: 600;
}

p { margin: 0 0 12px; max-width: 80ch; }

/* The one-line standfirst under a page title. */
p.lede { color: var(--dim); }

a       { color: var(--ember); text-decoration: none; border-bottom: 1px solid rgba(226, 190, 90, .3); }
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

ul, ol { margin: 0 0 12px; padding-left: 22px; max-width: 80ch; }
li { margin: 2px 0; }

code {
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 2px;
    padding: 0 4px;
    font-size: 13px;
}
pre {
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 3px;
    padding: 10px 12px;
    overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; }

/* --- tables -------------------------------------------------------------

   The main event. WIKI.md settles that an index is ONE table with every row in
   it, sortable by any column, because sorting the whole set is the one thing a
   table is good for and pagination destroys it. 116 rows is nothing for a
   browser.

   The wrapper scrolls sideways rather than the page, so a narrow screen can
   reach the last column without the header bar sliding off. */
.tablewrap {
    overflow-x: auto;
    border: 1px solid var(--edge);
    border-radius: 3px;
    margin: 0 0 18px;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
thead th {
    background: var(--panel);
    color: var(--dim);
    text-align: left;
    font-weight: 600;
    padding: 7px 10px;
    border-bottom: 1px solid var(--edge);
    white-space: nowrap;
    /* The header stays put under the top bar while a hundred rows go past.
       Without this, sorting a long table means scrolling back up to find out
       which column you sorted by. */
    position: sticky;
    top: 39px;
    z-index: 5;
}
/* Sortable headers announce themselves as clickable. */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th.sortable::after { content: " \2195"; opacity: .3; }
thead th.asc::after  { content: " \2191"; opacity: 1; color: var(--ember); }
thead th.desc::after { content: " \2193"; opacity: 1; color: var(--ember); }

tbody td {
    padding: 5px 10px;
    border-bottom: 1px solid rgba(43, 51, 61, .5);
    white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(245, 224, 150, .05); }

/* Numeric columns right-align so magnitudes are comparable down the column --
   the whole reason to put 116 materials in one sortable table. */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.dim { color: var(--dim); }

/* --- filtering ---------------------------------------------------------- */

.filterbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 0 12px;
}
.filterbar input {
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--edge);
    border-radius: 3px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 13px;
    min-width: 220px;
}
.filterbar input:focus { outline: none; border-color: var(--ember); }
.filterbar .count { color: var(--dim); font-size: 12px; }

/* Kind/tier chips. Plain buttons, so they work without being styled into
   something that looks like it might not be clickable. */
.chip {
    background: none;
    color: var(--dim);
    border: 1px solid var(--edge);
    border-radius: 10px;
    padding: 2px 10px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip.on { color: var(--bg); background: var(--ember); border-color: var(--ember); }

/* --- icons --------------------------------------------------------------

   Every icon is one cell of the generated sheet, addressed by a class the
   generator writes. Doubled to 28px because the source art is 14x14 and this
   is a game whose entire look is that the cells are visible -- so it scales by
   an exact integer and never smooths. A 1.7x icon would be mush.

   image-rendering is belt and braces: browsers differ on which keyword they
   honour, and getting this wrong is the one failure that makes the wiki look
   like a different game. */
.icon {
    display: inline-block;
    width: 28px;
    height: 28px;
    vertical-align: middle;
    background-image: url("icons.png");
    background-repeat: no-repeat;
    background-size: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}
/* In a table cell the icon should not stretch the row. */
td .icon { margin-right: 6px; }

/* --- the hub ------------------------------------------------------------ */

.doors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 18px 0 0;
}
.door {
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 3px;
    padding: 14px 16px;
}
.door h2 { margin-top: 0; }
.door ol, .door ul { padding-left: 20px; }
.door .n { color: var(--dim); font-size: 12px; }

/* --- stat blocks on a detail page --------------------------------------- */

dl.stats {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 2px 16px;
    margin: 0 0 16px;
}
dl.stats dt { color: var(--dim); }
dl.stats dd { margin: 0; }

/* A chain of transitions -- ignites at 135 C, becomes Fuel Fire. Laid out
   inline so a three-step chain reads as one sentence. */
.chain { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.chain .arrow { color: var(--dim); }

/* Spoilers: bosses and the ending. Visible but clearly gated -- WIKI.md asks
   for marked, not hidden. */
.spoiler {
    border: 1px solid var(--alarm);
    border-radius: 3px;
    padding: 12px 14px;
    margin: 18px 0;
}
.spoiler > h2 { margin-top: 0; color: var(--alarm); border-bottom-color: var(--alarm); }

/* The failure list on a tutorial, which WIKI.md expects to be the longest
   section on the page. Flagged so it cannot be mistaken for the happy path. */
.whenitdoesnt { border-left: 2px solid var(--alarm); padding-left: 14px; }

/* --- footer ------------------------------------------------------------- */

footer {
    border-top: 1px solid var(--edge);
    margin-top: 50px;
    padding: 16px 20px 30px;
    color: var(--dim);
    font-size: 12px;
}
footer p { max-width: none; margin: 0 0 4px; }
footer .stamp { opacity: .7; }
footer code { font-size: 11px; }

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

@media (max-width: 620px) {
    main { padding: 18px 12px 40px; }
    h1 { font-size: 20px; }
    header.top { gap: 10px; padding: 8px 12px; }
    /* The sticky table header is positioned against the top bar's height, and
       on a narrow screen the nav wraps and that height changes. Rather than
       chase it with a guess, stop pinning the header here. */
    thead th { position: static; }
}
