/* Ronix theme previews: the gallery (index.html) and each theme's viewer (<theme>/index.html).
   The gallery's one loud element is the hotbar: the themes as items, picked as in the game. Everything around it
   stays quiet: smooth-stone grey, violet ink, the Ronix purple of the logo for actions. */

:root {
    --stone: #e3e5e8;
    --stone-deep: #cfd3d9;
    --ink: #1a1625;
    --ink-soft: #4b4559;
    --hotbar: #2b2e35;
    --slot: #3a3e47;
    --brand: #725cf7;
    --brand-deep: #5a45d6;
    --theme: var(--brand);
    --font: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
    --pixel: 'Silkscreen', ui-monospace, monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--stone);
    color: var(--ink);
    font: 400 1.0625rem/1.55 var(--font);
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 3px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* the Ronix icon and the full logo, in the text colour */
.mark {
    display: block;
    width: 25px;
    height: 28px;
    flex: none;
}

/* ── The gallery ── */

.masthead,
.intro,
.wiki,
.footer {
    width: min(100% - 3rem, 1240px);
    margin-inline: auto;
}

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding-block: 1.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
}

.masthead nav {
    display: flex;
    gap: 1.5rem;
    font-size: 0.95rem;
}

.masthead nav a,
.footer a {
    color: var(--ink-soft);
    text-decoration: none;
}

.masthead nav a:hover,
.footer a:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 3.5rem;
    align-items: start;
    padding-block: 2.5rem 5rem;
}

h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(2.6rem, 5.4vw, 4.4rem);
    font-weight: 800;
    line-height: 0.98;
    letter-spacing: -0.035em;
}

.lede {
    max-width: 36ch;
    margin: 0 0 2.75rem;
    font-size: 1.15rem;
    color: var(--ink-soft);
}

/* the theme the hotbar holds */
.chosen {
    padding-top: 1.25rem;
    border-top: 2px solid var(--ink);
}

.chosen h2 {
    margin: 0;
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.025em;
}

.chosen-meta {
    margin: 0.35rem 0 1rem;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.chosen-blurb {
    max-width: 44ch;
    margin: 0 0 1.75rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.button {
    display: inline-flex;
    align-items: center;
    padding: 0.85rem 1.35rem;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 0 var(--brand-deep);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 var(--brand-deep);
}

.button:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--brand-deep);
}

.soon {
    font-size: 0.95rem;
    color: var(--ink-soft);
}

/* the second action, beside the live demo: the theme's wiki */
.text-link {
    font-weight: 700;
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--brand);
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
}

.text-link:hover {
    color: var(--brand-deep);
}

/* a wiki row: the whole row is the link */
.wiki-list a {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 1rem;
    color: inherit;
    text-decoration: none;
}

.wiki-list a:hover .wiki-name {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.wiki-list a .wiki-status {
    border-color: var(--brand);
    color: var(--brand-deep);
}

/* the stage: the theme's home page on a wide screen, its phone view at the corner, the hotbar along the bottom */
.stage {
    position: relative;
    padding-bottom: 3.75rem;
}

.screens {
    position: relative;
    display: block;
    aspect-ratio: 1440 / 900;
    border-radius: 14px;
    background: var(--hotbar);
    box-shadow: 0 0 0 1px rgb(26 22 37 / 0.08), 0 36px 60px -34px rgb(26 22 37 / 0.6);
}

.screens img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.screens .desktop {
    border-radius: 14px;
}

.screens .phone {
    position: absolute;
    top: -7%;
    right: -3.5%;
    width: 22%;
    height: auto;
    aspect-ratio: 390 / 844;
    border: 5px solid var(--ink);
    border-radius: 20px;
    background: var(--ink);
    box-shadow: 0 24px 40px -20px rgb(26 22 37 / 0.7);
}

.screens img.missing {
    visibility: hidden;
}

/* the hotbar: on the stage's lower edge, as in the game; the theme's name rises above it when it changes */
.hud {
    position: absolute;
    left: 50%;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    transform: translateX(-50%);
}

.item-name {
    margin: 0;
    min-height: 1.6em;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    text-shadow: 2px 2px 0 #3c3c3c;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.item-name.shown {
    opacity: 1;
    transition: none;
}

.hotbar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--hotbar);
    border: 2px solid #17181c;
    box-shadow: inset 0 0 0 2px #4a4e57, 0 18px 30px -18px rgb(26 22 37 / 0.8);
}

.slot {
    position: relative;
    display: grid;
    width: 60px;
    height: 60px;
    place-items: center;
    padding: 0;
    border: 0;
    background: var(--slot);
    box-shadow: inset 2px 2px 0 #23252b, inset -2px -2px 0 #575b65;
    color: #fff;
    cursor: pointer;
}

.slot img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    image-rendering: pixelated;
}

.slot-key {
    position: absolute;
    top: 4px;
    left: 5px;
    font: 400 9px/1 var(--pixel);
    color: #b9bdc6;
}

/* the selected slot: the game's thick white frame, a little wider than the slot */
.slot[aria-checked='true']::after {
    content: '';
    position: absolute;
    inset: -6px;
    border: 4px solid #fff;
    box-shadow: 0 0 0 2px #17181c, inset 0 0 0 2px #17181c;
    pointer-events: none;
}

.slot:focus-visible {
    outline-offset: 8px;
}

.hint {
    margin: 0;
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2.4rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.themes-fallback {
    margin: 1rem 0 0;
    padding-left: 1.25rem;
}

/* the wiki: one row per theme */
.wiki {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 3.5rem;
    padding-block: 3rem 4.5rem;
    border-top: 2px solid var(--ink);
}

.wiki h2 {
    margin: 0 0 0.75rem;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.wiki p {
    max-width: 38ch;
    margin: 0;
    color: var(--ink-soft);
}

.wiki-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wiki-list li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-block: 0.85rem;
    border-bottom: 1px solid var(--stone-deep);
}

.wiki-list li:first-child {
    border-top: 1px solid var(--stone-deep);
}

.wiki-list img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: pixelated;
}

.wiki-name {
    flex: 1;
    font-weight: 600;
}

.wiki-status {
    padding: 0.15rem 0.7rem;
    border: 1px solid var(--ink-soft);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1.5rem 2.5rem;
    border-top: 1px solid var(--stone-deep);
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.footer nav {
    display: flex;
    gap: 1.25rem;
}

/* one column: the title and its line, then the stage with the hotbar, then the theme's details */
@media (max-width: 1023px) {
    .intro {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding-top: 1rem;
    }

    .pitch {
        display: contents;
    }

    .intro h1 {
        order: 1;
        margin: 0;
    }

    .lede {
        order: 2;
        margin: 0;
    }

    .stage {
        order: 3;
        margin-block: 1.5rem 0.5rem;
    }

    .chosen {
        order: 4;
    }

    .wiki {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* the keys mean nothing without a keyboard */
@media (hover: none), (max-width: 599px) {
    .hint {
        display: none;
    }
}

@media (max-width: 599px) {
    .masthead nav {
        gap: 1rem;
    }

    .masthead nav a:first-child {
        display: none;
    }

    .screens .phone {
        display: none;
    }

    .stage {
        padding-bottom: 3.25rem;
    }

    .hotbar {
        gap: 2px;
        padding: 3px;
    }

    .slot {
        width: 42px;
        height: 42px;
    }

    .slot img {
        width: 28px;
        height: 28px;
    }

    .slot-key {
        display: none;
    }

    .slot[aria-checked='true']::after {
        inset: -4px;
        border-width: 3px;
    }

    .chosen h2,
    .wiki h2 {
        font-size: 2rem;
    }
}

/* ── The viewer: the demo under a bar ── */

body.viewer {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.25rem;
    padding: 0.55rem 1rem;
    background: var(--ink);
    color: #fff;
    font-size: 0.95rem;
}

.bar a {
    text-decoration: none;
}

.bar-back {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
}

.bar-back .mark {
    width: 22px;
    height: 24px;
}

.brand .logo {
    display: block;
    width: auto;
    height: 34px;
}

.bar-themes {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--hotbar);
    box-shadow: inset 0 0 0 2px #4a4e57;
}

.bar-themes a {
    position: relative;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    background: var(--slot);
    box-shadow: inset 2px 2px 0 #23252b, inset -2px -2px 0 #575b65;
}

.bar-themes img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    image-rendering: pixelated;
}

.bar-themes a[aria-current='page']::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 3px solid #fff;
    pointer-events: none;
}

.bar-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.bar-page {
    position: relative;
}

.bar-page select {
    appearance: none;
    min-width: 11rem;
    padding: 0.45rem 2.2rem 0.45rem 0.8rem;
    border: 1px solid #4b4559;
    border-radius: 8px;
    background: #2a2536;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.bar-page::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0.85rem;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid #cfc8e3;
    border-bottom: 2px solid #cfc8e3;
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.bar-sizes {
    display: flex;
    gap: 0.35rem;
}

.bar-sizes button {
    padding: 0.4rem 0.75rem;
    border: 1px solid #4b4559;
    border-radius: 8px;
    background: transparent;
    color: #d9d4e8;
    font: inherit;
    cursor: pointer;
}

.bar-sizes button[aria-pressed='true'] {
    border-color: #fff;
    background: #fff;
    color: var(--ink);
}

.bar-open {
    margin-left: auto;
    color: #d9d4e8;
}

/* the viewer's link to the theme's wiki, on the right with "Open full page" (alone there on phones) */
.bar-wiki {
    margin-left: auto;
    color: #d9d4e8;
}

.bar-wiki + .bar-open {
    margin-left: 0;
}

.bar-wiki:hover,
.bar-open:hover {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.frame-wrap {
    display: flex;
    justify-content: center;
    overflow: auto;
    background: var(--stone);
}

.frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

/* a tablet or a phone: the demo at that width, in a device's frame (its border outside the demo's width) */
.frame-wrap[data-size='tablet'],
.frame-wrap[data-size='phone'] {
    padding: 1.5rem;
}

.frame-wrap[data-size='tablet'] .frame,
.frame-wrap[data-size='phone'] .frame {
    box-sizing: content-box;
    flex: none;
    height: calc(100% - 16px);
    border: 8px solid var(--ink);
    box-shadow: 0 30px 50px -30px rgb(26 22 37 / 0.6);
}

.frame-wrap[data-size='tablet'] .frame {
    width: 820px;
    max-height: 1180px;
    border-radius: 20px;
}

.frame-wrap[data-size='phone'] .frame {
    width: 390px;
    max-height: 844px;
    border-radius: 30px;
}

@media (max-width: 899px) {
    .bar-sizes,
    .bar-open {
        display: none;
    }

    .frame-wrap[data-size] {
        padding: 0;
    }

    .frame-wrap[data-size] .frame {
        box-sizing: border-box;
        width: 100%;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
}

/* ── The wiki: each theme's guide (<theme>/wiki/), written by scripts/wiki.cjs from the theme's README ── */

.wiki-page .bar {
    position: sticky;
    top: 0;
    z-index: 10;
}

.wiki-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 780px) 200px;
    justify-content: center;
    gap: 2.5rem;
    width: min(100% - 3rem, 1320px);
    margin-inline: auto;
    padding-block: 2.5rem 4rem;
}

.wiki-nav,
.wiki-toc {
    position: sticky;
    top: 5rem;
    align-self: start;
    max-height: calc(100vh - 6rem);
    overflow: auto;
}

.wiki-nav-title {
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
    font-weight: 800;
}

.wiki-nav-title span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-soft);
}

.wiki-nav ul,
.wiki-toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wiki-nav a {
    display: block;
    padding: 0.45rem 0.8rem;
    border-left: 3px solid transparent;
    color: var(--ink-soft);
    text-decoration: none;
}

.wiki-nav a:hover {
    background: var(--stone-deep);
    color: var(--ink);
}

.wiki-nav a[aria-current='page'] {
    border-left-color: var(--theme);
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.wiki-toc-title {
    margin: 0 0 0.6rem;
    font-family: var(--pixel);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.wiki-toc a {
    display: block;
    padding: 0.25rem 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
    text-decoration: none;
}

.wiki-toc a:hover {
    color: var(--ink);
}

/* the page: a white sheet; the settings tables scroll sideways on their own when they do not fit */
.prose {
    padding: 2.25rem 2.5rem 2.5rem;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 0 var(--stone-deep);
}

.prose h1 {
    margin: 0 0 1rem;
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.prose h2,
.prose h3,
.prose h4 {
    scroll-margin-top: 5rem;
    line-height: 1.25;
}

.prose h2 {
    margin: 2.4rem 0 0.75rem;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.prose h3 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.prose h4 {
    margin: 1.4rem 0 0.4rem;
    font-size: 1.05rem;
}

.prose p,
.prose ul,
.prose ol {
    margin: 0 0 1rem;
}

.prose li {
    margin: 0.3rem 0;
}

.prose li > ul,
.prose li > ol {
    margin: 0.3rem 0 0;
}

.prose a {
    color: var(--brand-deep);
    text-underline-offset: 3px;
}

.prose code {
    padding: 0.1em 0.35em;
    border-radius: 5px;
    background: #f1eff7;
    font: 0.88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.prose .anchor {
    margin-left: 0.45rem;
    color: var(--stone-deep);
    text-decoration: none;
    opacity: 0;
}

.prose :is(h2, h3, h4):hover .anchor,
.prose .anchor:focus-visible {
    opacity: 1;
}

.table-wrap {
    margin: 0 0 1.25rem;
    overflow-x: auto;
    border: 1px solid var(--stone-deep);
    border-radius: 10px;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.prose th,
.prose td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--stone-deep);
    text-align: left;
    vertical-align: top;
}

.prose th {
    background: #f6f5f9;
    white-space: nowrap;
}

.prose tr:last-child td {
    border-bottom: 0;
}

.prose td:first-child {
    font-weight: 600;
}

.wiki-hero {
    margin: 1.5rem 0 0.5rem;
}

.wiki-hero img {
    width: 100%;
    height: auto;
    border: 1px solid var(--stone-deep);
    border-radius: 12px;
}

.wiki-hero figcaption {
    margin-top: 0.6rem;
    color: var(--ink-soft);
}

/* the settings page: the part of the demo store a group changes, at its own size or the page's width */
.wiki-shot {
    margin: 0 0 1rem;
}

.wiki-shot img {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--stone-deep);
    border-radius: 10px;
}

.wiki-shot figcaption {
    margin-top: 0.5rem;
    font-size: 0.92rem;
    color: var(--ink-soft);
}

/* Tebex's panel under an installation step: the picture opens at full size */
.prose li .wiki-panel {
    margin: 0.85rem 0 1.1rem;
}

.wiki-panel a {
    display: block;
}

.wiki-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    padding: 0;
    list-style: none;
}

.prose .wiki-cards li {
    margin: 0;
}

.wiki-cards a {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    height: 100%;
    padding: 1rem 1.1rem;
    border: 1px solid var(--stone-deep);
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
}

.wiki-cards a:hover {
    border-color: var(--theme);
    box-shadow: 0 0 0 1px var(--theme);
}

.wiki-cards span {
    font-size: 0.92rem;
    color: var(--ink-soft);
}

.pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
}

.pager a {
    display: flex;
    flex-direction: column;
    padding: 0.8rem 1.1rem;
    border-radius: 12px;
    background: #fff;
    font-weight: 700;
    text-decoration: none;
}

.pager a:hover {
    box-shadow: 0 0 0 2px var(--theme);
}

.pager a span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-soft);
}

.pager .next {
    margin-left: auto;
    text-align: right;
}

.wiki-footer {
    width: min(100% - 3rem, 1320px);
}

@media (max-width: 1199px) {
    .wiki-layout {
        grid-template-columns: 200px minmax(0, 1fr);
    }

    .wiki-toc {
        display: none;
    }
}

/* phones: the pages as a row of tabs over the sheet */
@media (max-width: 799px) {
    .wiki-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
        width: min(100% - 2rem, 780px);
        padding-top: 1.25rem;
    }

    /* the bar takes three rows here: it stays at the top of the page, so a heading opened from a link is not under it */
    .wiki-page .bar {
        position: static;
    }

    .wiki-nav {
        position: static;
        max-height: none;
    }

    .wiki-nav ul {
        display: flex;
        gap: 0.35rem;
        overflow-x: auto;
        padding-bottom: 0.3rem;
    }

    .wiki-nav li {
        flex: none;
    }

    .wiki-nav a {
        border-left: 0;
        border-bottom: 3px solid transparent;
        border-radius: 8px;
        white-space: nowrap;
    }

    .wiki-nav a[aria-current='page'] {
        border-bottom-color: var(--theme);
    }

    .prose {
        padding: 1.5rem 1.15rem 1.75rem;
        border-radius: 12px;
    }

    .prose h1 {
        font-size: 2rem;
    }

    .wiki-page .bar-open {
        display: inline;
    }

    .wiki-footer {
        width: min(100% - 2rem, 780px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }
}
