/*
    The wiki's look. Its colours and header come from /site.css, which every wiki page links first. The pages are made by
    WikiGenerator, this file and the scripts beside it are served as they are.
*/

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
}

/* Links are known by their color, not underlined */
a {
    color: var(--accent-hover);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    color: var(--text-main);
}

/* For the keyboard, past the header straight to the page. Out of sight until it is tabbed to. */
.skip {
    position: absolute;
    left: 1rem;
    top: -3rem;
    padding: 0.5rem 1rem;
    z-index: 30;
    color: var(--text-main);
    background-color: var(--accent);
    border-radius: 6px;
}

.skip:focus {
    top: 1rem;
}

/* The header is the site's, see Website/wwwroot/site.css. In the wiki it holds only a link to the wiki's home, whose
   cards lead to the sections, the search and the languages, so it stays one line. */

/* The same page in other languages, a menu dropping down from a globe */
.languages {
    position: relative;
}

.languages summary {
    display: flex;
    padding: 0.3rem;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
}

.languages summary::-webkit-details-marker {
    display: none;
}

.languages summary:hover,
.languages[open] summary {
    color: var(--text-main);
}

.languages svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.languages div {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    min-width: 9rem;
    margin: 0;
    padding: 0.3rem 0;
    list-style: none;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.languages div a {
    display: block;
    padding: 0.3rem 0.9rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.languages div a:hover,
.languages div a:focus-visible {
    color: var(--text-main);
    background-color: var(--border-color);
}

.languages div a[aria-current] {
    color: var(--text-main);
    font-weight: 600;
}

/* Back to the page's section, above its title */
.crumbs {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
}

.crumbs a {
    color: var(--text-muted);
}

.crumbs a:hover {
    color: var(--accent-hover);
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem 1.25rem;
}

h1 {
    margin: 0 0 1.25rem 0;
    font-size: 2.2rem;
}

h2 {
    margin: 2rem 0 0.75rem 0;
    font-size: 1.3rem;
}

.intro {
    color: var(--text-muted);
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* A table too wide for a phone scrolls sideways on its own, the page stays put */
.scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.links {
    margin: 0;
}

th,
td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

th {
    color: var(--text-muted);
    font-weight: 600;
}

table.facts {
    width: auto;
    min-width: 320px;
    margin-bottom: 1rem;
}

table.facts th {
    width: 12rem;
}

/*
    An item as the game draws it: the 32 pixel icon two pixels into the 36 pixel slot.
    Scaled up as pixel art, without blurring.
    Sizes are in --px, how big one pixel of art is drawn. pixels.js sets --px1 to --px4 to whole screen pixels.
*/
.slot {
    --px: var(--px2, 2px);
    position: relative;
    display: inline-block;
    width: calc(36 * var(--px));
    height: calc(36 * var(--px));
    margin: 2px;
    vertical-align: middle;
    background: url("/wiki/img/slot.png") center / 100% 100% no-repeat;
    image-rendering: pixelated;
    color: var(--text-main);
    text-decoration: none;
}

.slot img {
    position: absolute;
    left: calc(2 * var(--px));
    top: calc(2 * var(--px));
    width: calc(32 * var(--px));
    height: calc(32 * var(--px));
    image-rendering: pixelated;
}

/* An item named anywhere, in a sentence, a table or a list: its slot then its name, one link */
.named {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    vertical-align: middle;
}

a.named:hover .slot,
a.named:focus-visible .slot {
    outline: 2px solid var(--accent-hover);
    outline-offset: 1px;
}

.slot-small {
    --px: var(--px1, 1px);
    flex: none;
    margin: 0;
}

.slot-large {
    --px: var(--px4, 4px);
    margin: 0;
}

/* Items side by side, wrapping, or one under another in a table's cell */
.items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
}

td .items {
    flex-direction: column;
    gap: 0.3rem;
}

/* How many, after the name */
.named .count {
    color: var(--text-main);
}

/* A grid object's own image, its size in pixels of art given by --w and --h and its scale by --px on the element */
.picture {
    --px: var(--px1, 1px);
    width: calc(var(--w) * var(--px));
    height: calc(var(--h) * var(--px));
    image-rendering: pixelated;
}

/*
    The top of every page, what it is and its facts, with its picture in a frame beside them. The picture stands on
    the frame's bottom the way it stands on the ground.
*/
.summary {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.summary > div:first-child {
    flex: 1;
    min-width: 0;
}

.summary .intro:first-child {
    margin-top: 0;
}

.summary table.facts {
    margin-bottom: 0;
}

.portrait {
    flex: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-width: 11rem;
    min-height: 11rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.portrait .slot {
    align-self: center;
}

/* Pages as cards, an object standing on the bottom of its card the way it stands on the ground */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.75rem;
}

.gallery a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.gallery a:hover,
.gallery a:focus-visible {
    border-color: var(--accent-hover);
}

/* A short row of cards that should fit on one line, such as the places to craft */
.gallery-narrow {
    grid-template-columns: repeat(auto-fill, minmax(7.25rem, 1fr));
}

.book {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

#search {
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 1rem 0 0.5rem 0;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}

#search:focus {
    border-color: var(--accent);
}

.results {
    list-style: none;
    padding: 0;
    margin: 0;
}

.results li {
    padding: 0.25rem 0;
}

/* The search on every page, its results dropping down over the page */
.header-search {
    position: relative;
}

.header-search input {
    width: 12rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}

.header-search input:focus {
    border-color: var(--accent);
}

.header-search .results {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    width: 20rem;
    max-width: 90vw;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 20;
    background-color: var(--card-bg);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.header-search .results:not(:empty) {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
}

.category {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* The sections on the home page, each saying what is in it */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 1.25rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}

.card strong {
    font-size: 1.1rem;
}

.card span {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.card:hover,
.card:focus-visible {
    color: var(--text-main);
    border-color: var(--accent);
    transform: translateY(-2px);
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.8rem;
    }

    /* The picture above the facts, across the screen */
    .summary {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 1rem;
    }

    .portrait {
        min-height: 0;
    }

    .slot-large {
        --px: var(--px3, 3px);
    }

    /*
        On a phone the header is two lines: the brand with the wiki's link, the language and Download on its right,
        then the search across the screen. The site's own pages put their links on a line of their own, the wiki has
        only the one.
    */
    .site-header nav {
        order: 1;
        width: auto;
        margin-left: auto;
    }

    .site-header .languages {
        order: 2;
    }

    .site-header .btn-small {
        order: 3;
        margin-left: 0;
    }

    .header-search {
        order: 4;
    }

    .header-search,
    .header-search input {
        width: 100%;
    }

    th,
    td {
        padding: 0.4rem;
    }
}
