/* SPDX-FileCopyrightText: Copyright (C) 2026 plenarius */
/* SPDX-License-Identifier: GPL-3.0-or-later */

:root {
    --bg: #f6f5f2;
    --panel: #ffffff;
    --text: #1d2230;
    --muted: #616a7d;
    --line: #d8d8d4;
    --accent: #2b5bb8;
    --bad: #b3261e;
    --good: #2e7d32;
    --mark: #e8b04a;
    color-scheme: light dark;
}

/* Dark: the system's choice unless the bar's Theme says Light (theme.js sets data-theme), or Dark whatever the system says.
   WebKitGTK takes the system's choice from the GTK theme. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #16181d;
        --panel: #1f2229;
        --text: #e6e6e3;
        --muted: #9aa1ae;
        --line: #343844;
        --accent: #7aa7ff;
        --bad: #ff8a80;
        --good: #81c784;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #16181d;
    --panel: #1f2229;
    --text: #e6e6e3;
    --muted: #9aa1ae;
    --line: #343844;
    --accent: #7aa7ff;
    --bad: #ff8a80;
    --good: #81c784;
    color-scheme: dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font:
        14px / 1.45 system-ui,
        sans-serif;
}

a {
    color: var(--accent);
}

code {
    font:
        12px / 1.4 ui-monospace,
        monospace;
    overflow-wrap: anywhere;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--panel);
    color: var(--text);
    padding: 3px 10px;
    cursor: pointer;
}

button:hover {
    border-color: var(--accent);
}

button.link {
    border: 0;
    background: none;
    color: var(--accent);
    padding: 0;
    text-decoration: underline;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--panel);
    color: var(--text);
    padding: 3px 6px;
}

input[type="number"] {
    width: 6em;
}

.muted {
    color: var(--muted);
}

.error,
.missing {
    color: var(--bad);
}

.offscreen {
    position: fixed;
    left: -9999px;
}

/* The bar at the top. */
.theme select {
    margin-left: 4px;
}

.bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.bar nav {
    display: flex;
    gap: 4px;
}

.bar nav a {
    padding: 4px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
}

.bar nav a.on {
    background: var(--accent);
    color: var(--panel);
}

#module-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

main {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.screen {
    padding: 8px 16px 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.screen[hidden] {
    display: none;
}

h2 {
    margin: 4px 0 8px;
    font-size: 20px;
}

h3,
h4 {
    margin: 12px 0 6px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
}

.panel label,
.game-form label {
    display: block;
    margin: 4px 0;
}

.buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.toolbar h2 {
    margin: 0;
}

.columns {
    display: flex;
    gap: 24px;
    min-height: 0;
}

.columns > div:first-child {
    width: 280px;
    flex: none;
}

.grow {
    flex: 1;
    min-width: 0;
}

.scroll {
    max-height: 60vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}

ul.recent {
    margin: 0;
    padding-left: 18px;
}

ol.haks {
    padding-left: 24px;
    margin: 0;
}

table.areas {
    border-collapse: collapse;
    width: 100%;
}

table.areas th,
table.areas td {
    text-align: left;
    padding: 3px 8px;
    border-bottom: 1px solid var(--line);
}

table.areas thead th {
    position: sticky;
    top: 0;
    background: var(--panel);
}

tr.failed td {
    color: var(--bad);
}

/* The atlas: a virtual grid, cards placed by transform. */
.atlas {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.atlas .spacer {
    width: 1px;
}

.card {
    position: absolute;
    top: 0;
    left: 0;
    width: 232px;
    height: 210px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
}

.card:hover {
    border-color: var(--accent);
}

.card.failed {
    border-color: var(--bad);
}

.card .thumb {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card .thumb p {
    margin: 0;
    font-size: 12px;
    overflow: auto;
    max-height: 100%;
}

.card .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card small {
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* An area. */
form.look {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
    margin-bottom: 6px;
}

.tabs {
    display: flex;
    gap: 2px;
}

.tabs button[aria-selected="true"] {
    background: var(--accent);
    color: var(--panel);
}

.area-body {
    flex: 1;
    min-height: 320px;
    display: flex;
    gap: 12px;
}

.viewport {
    position: relative;
    flex: 1;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: repeating-conic-gradient(var(--panel) 0 25%, var(--bg) 0 50%) 0 0 / 24px 24px;
    cursor: crosshair;
    touch-action: none;
}

.viewport .inner {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

.viewport img {
    display: block;
    user-select: none;
}

.mark {
    position: absolute;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: var(--mark);
    border: 2px solid #000;
    box-shadow: 0 0 0 2px #fff;
}

.mark.dead {
    background: var(--bad);
}

.side {
    width: 260px;
    overflow: auto;
}

ul.links {
    padding-left: 18px;
    margin: 0;
}

.point {
    display: inline-block;
    min-width: 16em;
}

.command {
    background: var(--panel);
    padding: 2px 6px;
    border-radius: 4px;
}

/* The job panel. */
.jobs {
    max-height: 45vh;
    overflow: auto;
    border-top: 1px solid var(--line);
    background: var(--panel);
    padding: 8px 16px;
}

.jobs .settings {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
}

.jobs .settings p {
    flex-basis: 100%;
    margin: 0;
}

.job {
    border-top: 1px solid var(--line);
    padding: 6px 0;
}

.job p {
    margin: 2px 0;
}

.job.failed strong {
    color: var(--bad);
}

.job.done strong {
    color: var(--good);
}

.job progress {
    width: 240px;
    vertical-align: middle;
}

.command-line code {
    color: var(--muted);
}

.toast {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 6px 14px;
    border-radius: 6px;
}

/* An area in 3D. */
a.button {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--panel);
    color: var(--text);
    padding: 3px 10px;
    text-decoration: none;
}

a.button:hover {
    border-color: var(--accent);
}

.controls3d {
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.stage3d {
    background: var(--bg);
    cursor: default;
}

.stage3d canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}

dl.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    margin: 0 0 8px;
}

dl.facts dd {
    margin: 0;
}

.hint {
    margin: 6px 0 0;
}

/* The version in the bar, and a newer release offered beside it (update.js). */
.update {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.update-offer {
    border-color: var(--accent);
    color: var(--accent);
}

.update-dialog {
    max-width: 560px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
}

.update-notes {
    font: inherit;
    max-height: 280px;
    overflow: auto;
    white-space: pre-wrap;
}

/* Screen 6, characters: the form scrolls beside the 3D view. */
.columns.characters {
    flex: 1;
}

.characters .side {
    width: 300px;
    flex: none;
    overflow: auto;
    padding-right: 4px;
}

.characters .stage {
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.characters textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    font-family: ui-monospace, monospace;
    font-size: 12px;
}

.viewer {
    position: relative;
    flex: 1 0 320px;
    min-height: 320px;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: #2a2d36;
}

.viewer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.viewer .error {
    position: absolute;
    inset: 12px;
}

table.parts {
    border-collapse: collapse;
}

table.parts th {
    text-align: left;
    font-weight: normal;
    padding-right: 8px;
}

table.parts input {
    width: 56px;
}

.colours {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
}

.colours label.colour {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.colours input {
    width: 56px;
}

.portrait {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.portrait img.picture {
    max-width: 260px;
    max-height: 260px;
    background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 16px 16px;
    border: 1px solid var(--line);
}

.portrait code {
    word-break: break-all;
}

ul.missing-items {
    margin: 0;
    padding-left: 18px;
    color: var(--bad);
}

.characters .side select {
    max-width: 100%;
}

.characters .side .panel {
    overflow-wrap: anywhere;
}
