/* SPDX-FileCopyrightText: Copyright (C) 2026 plenarius */
/* SPDX-License-Identifier: MIT */

/* The page itself: the colours (custom properties on :root), the top bar, the tool column, the view, the status line and
   the report over the view. */

:root {
    --bg: #1d2228;
    --panel: #262c34;
    --panel-2: #303844;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --accent: #d8a24a;
    --good: #7ec46a;
    --warn: #ff9a1f;
    /* Red text on the panels: 4.5:1 or better against --panel (#ff6a55: 5.0:1); --bad-fill is red behind white text. */
    --bad: #ff6a55;
    --bad-fill: #b8321f;
    /* A texture the library hasn't got: the magenta of its checker on the ground (missing.js). */
    --missing: #ff5cff;
}

* {
    box-sizing: border-box;
    scrollbar-color: #4a5462 var(--panel);
    scrollbar-width: thin;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font:
        15px / 1.4 system-ui,
        -apple-system,
        "Segoe UI",
        sans-serif;
    overflow: hidden;
}

body {
    display: grid;
    grid-template-columns: 160px 1fr;
    grid-template-rows: 64px 1fr 30px;
    grid-template-areas: "top top" "tools view" "status status";
}

#topbar {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background: var(--panel);
    border-bottom: 1px solid #000;
}

.brand {
    display: grid;
    grid-template-areas: "nwn name version";
    align-items: baseline;
    column-gap: 0.3em;
    margin-right: 6px;
    font-size: 18px;
    color: var(--muted);
}
.brand > span {
    grid-area: nwn;
}
.brand b {
    grid-area: name;
    color: var(--accent);
}
.brand-badge {
    grid-column: 1 / -1;
    justify-self: start;
    margin-top: 3px;
    padding: 0 7px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--accent);
    font-size: 10px;
    line-height: 14px;
    text-decoration: none;
}
.brand-badge:hover {
    background: var(--accent);
    color: var(--panel);
}
.spacer {
    flex: 1;
}
/* At most two lines, cut short where the bar is short of room (the app's Help menu, a narrow window); its title has it all. */
#areaInfo {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-width: 60px;
    line-clamp: 2;
    overflow: hidden;
    color: var(--muted);
}

.icon {
    display: inline-block;
    width: 28px;
    height: 28px;
}
.icon svg {
    width: 100%;
    height: 100%;
}

button {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid #000;
    border-radius: 6px;
    cursor: pointer;
}

.top-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    background: var(--panel-2);
    border: 1px solid #000;
    border-radius: 8px;
}
.top-btn:hover {
    background: #3a4452;
}
.top-btn.active {
    border-color: var(--accent);
    background: #3d3a30;
}
.top-btn:disabled {
    opacity: 0.45;
    cursor: default;
}
.top-btn {
    white-space: nowrap;
}
.top-btn.live {
    gap: 6px;
    min-width: 7em;
    font-variant-numeric: tabular-nums;
}
.top-btn.live .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #66707c;
    flex: none;
}
.top-btn.live.busy .dot {
    background: #8fb3e0;
    animation: livePulse 1s ease-in-out infinite;
}
.top-btn.live.ok .dot {
    background: #6cc070;
}
.top-btn.live.bad .dot {
    background: #e0554a;
}
.top-btn.live.warn .dot {
    background: #e0a040;
}
.top-btn.live.off {
    opacity: 0.6;
}
@keyframes livePulse {
    50% {
        opacity: 0.3;
    }
}
.top-btn.primary {
    background: var(--accent);
    color: #1d1a12;
    font-weight: 600;
}
.top-btn.primary:hover {
    background: #e6b562;
}

#tools {
    grid-area: tools;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--panel);
    border-right: 1px solid #000;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Two equal columns, whatever the labels (a long one doesn't widen its column). */
#toolButtons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 110px;
    padding: 5px 4px 4px;
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.2;
}
.tool .icon {
    width: 36px;
    height: 36px;
}
.tool:hover {
    background: #3a4452;
}
.tool.active {
    border-color: var(--accent);
    background: #3d3a30;
    color: #fff;
}
.tool .key {
    font-size: 11px;
    color: var(--muted);
}
.tool.toggle.on {
    border-color: var(--bad);
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 2px;
    font-size: 13px;
    color: var(--muted);
}
.slider-group .slider-head {
    display: flex;
    justify-content: space-between;
    white-space: nowrap;
    gap: 6px;
}
.slider-group output {
    color: var(--text);
}
input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

#viewport {
    grid-area: view;
    position: relative;
    min-height: 0;
    overflow: hidden;
}
/* Out of the layout flow, or sizing the canvas would resize the cell. */
#viewport canvas {
    position: absolute;
    inset: 0;
    display: block;
}

#status {
    grid-area: status;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 14px;
    background: var(--panel);
    border-top: 1px solid #000;
    color: var(--muted);
    font-size: 13px;
}

#report {
    position: absolute;
    right: 16px;
    top: 80px;
    width: 340px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 16px 18px;
    background: rgba(38, 44, 52, 0.96);
    border: 1px solid #000;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
#report h3 {
    margin: 0 0 10px;
}
#report .big {
    font-size: 22px;
    font-weight: 600;
}
#report .good {
    color: var(--good);
}
#report .warn {
    color: var(--warn);
}
#report .bad {
    color: var(--bad);
}
#report .note {
    color: var(--muted);
    font-size: 13px;
}
#report code {
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
}
#reportClose {
    position: absolute;
    right: 8px;
    top: 4px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--muted);
}

/* The keyboard's place: a ring on whatever has the focus from the keyboard (not from a click). */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* The version beside the title: small and quiet; a click shows the engine's and the editor's, and the release notes. Where the
   top bar is short of room the title takes two lines, and the version goes beside NWN, above Landscaper. */
#menuAbout {
    grid-area: version;
    font-size: 15px;
}
@media (max-width: 1500px) {
    .brand {
        grid-template-areas: "nwn version" "name name";
        line-height: 1.25;
        margin-right: 0;
    }
    /* Three lines in the 64 px bar: the title's two closer together. */
    .brand:has(.brand-badge) {
        line-height: 1.05;
    }
    .version-other {
        display: none;
    }
}
.menu-btn.version-btn {
    padding: 1px 4px;
    font-size: 12px;
    color: var(--muted);
    background: transparent;
    border-color: transparent;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.menu-btn.version-btn::after {
    content: none;
}
.menu-btn.version-btn:hover,
.menu-btn.version-btn.active {
    color: var(--text);
    background: var(--panel-2);
    border-color: #000;
}
.menu-btn.version-btn.mismatch {
    color: var(--warn);
}
.version-lines p {
    margin: 0 0 4px;
}
a.menu-item {
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
}
