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

/* The side panels over the left of the view (textures, sky and the others), the tool buttons, and what must not be
   selected by a drag. */

/* Texture picker and sky panel, over the left of the view. */
.side-panel {
    position: absolute;
    left: 12px;
    top: 12px;
    bottom: 12px;
    width: 268px;
    z-index: 1;
    overflow-y: auto;
    padding: 10px 12px;
    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);
}
.side-panel h3 {
    margin: 0 0 6px;
    font-size: 16px;
}
.side-panel h4 {
    margin: 12px 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
/* The Paint panel's categories: each heading a button that collapses its textures (palette.js), and Collapse all and Expand
   all over them. */
.palette-all {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin: 2px 0 -4px;
}
.palette-all button {
    padding: 2px 8px;
    font-size: 12px;
    color: var(--muted);
    background: none;
    border-color: transparent;
}
.palette-all button:hover:not(:disabled) {
    color: var(--text);
    background: var(--panel-2);
}
.palette-all button:disabled {
    opacity: 0.45;
    cursor: default;
}
.side-panel h4:has(> .category) {
    margin: 8px 0 4px;
}
.side-panel h4 .category {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 4px 4px 2px;
    font: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    text-align: left;
    background: none;
    border: none;
}
.side-panel h4 .category:hover {
    color: var(--text);
    background: var(--panel-2);
}
.category .chevron::before {
    content: "▾";
    display: inline-block;
    width: 10px;
    transition: transform 0.12s;
}
.category[aria-expanded="false"] .chevron::before {
    transform: rotate(-90deg);
}
.category .count {
    margin-left: auto;
    padding: 0 7px;
    font-size: 11px;
    letter-spacing: 0;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 9px;
}
/* The Paint panel's mix (mixpanel.js): One texture or Mix, and the mix's strip with its settings. It stays at the top of the panel
   as the library scrolls under it, so the mix shows whichever categories are collapsed. */
.mix {
    position: sticky;
    top: -10px;
    z-index: 1;
    margin: 0 -12px;
    padding: 6px 12px 4px;
    background: rgba(38, 44, 52, 0.98);
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
}
.mix .note {
    margin: 2px 0 6px;
}
.mix-strip {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.mix-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 64px 34px 22px;
    align-items: center;
    gap: 6px;
    padding: 2px 3px;
    font-size: 12px;
    background: var(--panel-2);
    border-radius: 7px;
}
.mix-row img,
.mix-row .img {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    display: block;
    background: #555;
}
.mix-row .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mix-row input[type="range"] {
    width: 64px;
    margin: 0;
}
.mix-row output {
    color: var(--muted);
    text-align: right;
}
.mix-row .remove {
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: none;
}
.mix-row .remove:hover {
    color: var(--text);
    background: #3a4452;
}
.mix-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.mix-options button {
    padding: 3px 10px;
    font-size: 13px;
}
#mixPanel[hidden] {
    display: none;
}
.swatches[hidden],
.swatch[hidden] {
    display: none;
}

.swatches {
    display: grid;
    grid-template-columns: repeat(3, 76px);
    gap: 8px;
}
.swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 3px 3px 4px;
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
}
.swatch img {
    width: 66px;
    height: 66px;
    border-radius: 6px;
    display: block;
}
.swatch:hover {
    background: #3a4452;
}
.swatch.active {
    border-color: var(--accent);
    background: #3d3a30;
    color: #fff;
}
.swatch .used {
    color: var(--accent);
}
/* Where a placeable comes from (a hak, or the game), under its name. */
.swatch .source {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 10px;
}
.swatches .more {
    grid-column: 1 / -1;
}
select.from {
    width: 100%;
    margin: 0 0 6px;
    padding: 5px 8px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid #000;
    border-radius: 6px;
}
select.from[hidden] {
    display: none;
}

.panel-close {
    position: absolute;
    right: 8px;
    top: 4px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--muted);
}
.segmented {
    display: flex;
    margin: 8px 0;
    border: 1px solid #000;
    border-radius: 8px;
    overflow: hidden;
}
.segmented button {
    flex: 1;
    padding: 8px;
    background: var(--panel-2);
    border: none;
}
.segmented button.active {
    background: var(--accent);
    color: #1d1a12;
    font-weight: 600;
}
.side-panel .check {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
    font-size: 14px;
}
.presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.preset {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 4px 6px;
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 12px;
}
.preset .look {
    height: 44px;
    border-radius: 6px;
}
.preset:hover {
    background: #3a4452;
}
.preset.active {
    border-color: var(--accent);
    background: #3d3a30;
    color: #fff;
}
/* The chosen sky's picture: the horizon all around (720 by 60 px). */
.sky-strip {
    display: block;
    width: 100%;
    aspect-ratio: 12;
    margin: 0 0 6px;
    border-radius: 6px;
    background: var(--panel-2);
}
.sky-strip[hidden] {
    display: none;
}
.radios {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
}
.colours {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}
.colours label {
    display: flex;
    align-items: center;
    gap: 8px;
}
.colours small {
    color: var(--muted);
}
input[type="color"] {
    width: 40px;
    height: 28px;
    padding: 0;
    border: 1px solid #000;
    border-radius: 6px;
    background: none;
}
/* A slider row: its <label> (pointed at the slider), the readout and the slider. The row was the <label> once; the cursor and
   unicode-bidi are what a <label> has, so the row looks and behaves as before. */
.side-panel .slider,
#cutRow {
    cursor: default;
    unicode-bidi: normal;
}
.side-panel .slider {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 8px 0 2px;
    font-size: 14px;
}
.side-panel .slider output {
    color: var(--muted);
}

.side-panel input[type="search"] {
    width: 100%;
    padding: 8px 10px;
    margin: 4px 0 6px;
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid #000;
    border-radius: 8px;
}
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.chips button {
    padding: 4px 10px;
    font-size: 13px;
    background: var(--panel-2);
    border: 1px solid #000;
    border-radius: 14px;
}
.chips button:hover {
    background: #3a4452;
}
.chips button.active {
    border-color: var(--accent);
    background: #3d3a30;
    color: #fff;
}
.side-panel .note {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 8px;
}
.swatch img.thumb {
    background: #1d2228;
}

/* Tools two to a row: square, big icon over a short name. */
#toolButtons .tool {
    width: auto;
    min-width: 0;
    padding: 5px 2px 3px;
    font-size: 12px;
    border-radius: 10px;
}
#toolButtons .tool > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
}
#toolButtons .tool .icon {
    width: 32px;
    height: 32px;
}
#toolButtons .tool .key {
    font-size: 10px;
}

/* Dragging across the view must not select the panels' text. */
#tools,
.side-panel,
#topbar,
#status {
    user-select: none;
    -webkit-user-select: none;
}
.side-panel input {
    user-select: text;
    -webkit-user-select: text;
}

/* The underlay panel: its buttons in a row that wraps, and its width and turn side by side. */
.underlay-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}
.underlay-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}
.underlay-fields label {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    white-space: nowrap;
}
.underlay-fields input {
    width: 5.5em;
}
#underlayMove.active,
#underlayMeasure.active {
    border-color: var(--accent);
    color: var(--accent);
}

/* The Ambience tool: a kind a row (ticked for Fill, the brush's outlined), its day and night colours, and the live count's bars. */
.amb-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
}
.amb-kind {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    text-align: left;
}
.amb-kind.active {
    border-color: var(--accent);
    background: #3d3a30;
    color: #fff;
}
.amb-kind .amb-name {
    flex: 1;
}
.amb-dot {
    width: 14px;
    height: 14px;
    border: 1px solid #0008;
    border-radius: 50%;
}
.amb-wind {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    font-size: 14px;
}
#ambienceLive.heavy {
    color: #f0a040;
}
/* The Light tool: a swatch of each light's colour beside its list, and the presets that suit the area outlined. */
.light-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin: 0 6px;
    vertical-align: middle;
    border: 1px solid #0008;
    border-radius: 3px;
}
#lightPanel select {
    display: block;
    width: 100%;
    margin: 4px 0 8px;
}
#lightPresets .look {
    align-self: stretch;
}
#lightPresets .preset.suits:not(.active) {
    border-color: #6d7a8c;
}
