/* Dark UI throughout - the page is a colour-mixing surface so any bright chrome
   would interfere with reading subtle hue differences. Background is a deep
   neutral, not pure black, so tile output close to (0,0,0) still reads as
   distinguishable from the page surround. */

:root {
    --bg: #0d1014;
    --panel: #161a20;
    --panel-edge: #232830;
    --text: #d8dde4;
    --text-dim: #8a9099;
    --text-faint: #5a6068;
    --accent: #6db1ff;
    --reserved: #2a2f37;
}

* { box-sizing: border-box; }

[v-cloak] { display: none; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

body {
    min-height: 100vh;
    padding: 16px 20px;
}

header {
    margin-bottom: 12px;
}

h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.subtitle {
    margin: 4px 0 0;
    color: var(--text-dim);
    font-size: 12px;
}

main {
    display: grid;
    grid-template-columns: 280px auto 320px;
    gap: 16px;
    align-items: start;
}

aside, .viewport {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    padding: 12px;
}

.viewport {
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
    border: 1px solid var(--panel-edge);
    cursor: crosshair;
    display: block;
}

/* Subtle tile-grid overlay so individual 20-pixel tiles remain visible
   even where the lighting render hits perfectly uniform regions. Drawn as
   a CSS pattern so it stays out of the canvas pixel buffer (accurate
   colour-readback via getImageData stays unaffected). The overlay sits
   above the canvas but is pointer-events: none so hover detection still
   reaches the canvas. */
.canvas-stack {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.grid-overlay {
    position: absolute;
    inset: 1px;            /* sits inside the canvas's 1px border */
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            to right,
            transparent 0 19px,
            rgba(255, 255, 255, 0.06) 19px 20px),
        repeating-linear-gradient(
            to bottom,
            transparent 0 19px,
            rgba(255, 255, 255, 0.06) 19px 20px);
}

fieldset {
    border: 1px solid var(--panel-edge);
    border-radius: 4px;
    margin: 0 0 12px 0;
    padding: 10px 12px 12px;
}

fieldset:last-child { margin-bottom: 0; }

legend {
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 6px;
}

label {
    display: block;
    margin: 8px 0;
    color: var(--text);
}

label.checkbox,
label.radio {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}

.radio-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    margin-top: 4px;
}

input[type="color"] {
    flex: 1;
    height: 32px;
    border: 1px solid var(--panel-edge);
    background: transparent;
    cursor: pointer;
    min-width: 0;
}

.colour-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.hex-input {
    flex: 0 0 90px;
    height: 32px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
    padding: 0 8px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
    text-transform: lowercase;
}

.hex-input:focus {
    outline: 1px solid var(--accent);
    outline-offset: -1px;
}

.hex-input.invalid {
    border-color: #aa3030;
    color: #ff8080;
}

select {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
    padding: 4px 6px;
}

.num {
    float: right;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.hint {
    margin: 6px 0 0;
    color: var(--text-faint);
    font-size: 11px;
}

/* 16x16 swatch grid for picking the background colour. Palette index 0
   is the transparent slot; reserved indices (255 in TFTD) are also dimmed.
   These are still clickable so the user can experiment, but they're
   excluded from nearest-colour searches. */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 1px;
    background: var(--panel-edge);
    padding: 1px;
    border-radius: 2px;
}

.swatch-grid button {
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    cursor: pointer;
    position: relative;
    min-width: 0;
}

.swatch-grid button.reserved::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg, rgba(0, 0, 0, 0.5) 0 2px, transparent 2px 4px
    );
}

/* Blocked swatches: red diagonal stripe overlay distinct from the
   greyscale "reserved" hatching above. */
.swatch-grid button.blocked::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        135deg, rgba(255, 64, 64, 0.85) 0 1.5px, transparent 1.5px 4px
    );
}

.swatch-grid button.selected {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    z-index: 1;
}

.bg-readout {
    margin-top: 8px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.bg-readout.block-info {
    margin-top: 4px;
    justify-content: space-between;
}

.clear-blocked {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
}

.clear-blocked:hover:not(:disabled) {
    border-color: var(--accent);
}

.clear-blocked:disabled {
    color: var(--text-faint);
    cursor: default;
}

.rgb-pair {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rgb-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid var(--panel-edge);
    vertical-align: middle;
}

dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 12px;
}

dt {
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 1px;
}

dd {
    margin: 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

dd .rgb-swatch {
    margin-right: 4px;
}

.mono {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11px;
}

code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.92em;
    background: var(--bg);
    padding: 1px 4px;
    border-radius: 2px;
    color: var(--text);
}

/* Diagnostic 1D radial-slice strips. Three stacked, one per metric, all
   updated each render. The active metric's strip is highlighted to make
   the 2D-canvas <-> strip correspondence obvious. */
.strip-section {
    margin-top: 12px;
    width: 100%;
}

.strip-intro {
    margin: 0 0 8px;
    color: var(--text-dim);
    font-size: 11px;
}

.strip-row {
    margin-bottom: 8px;
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
    padding: 6px;
    background: var(--bg);
}

.strip-row.active {
    border-color: var(--accent);
}

.strip-row:last-child {
    margin-bottom: 0;
}

.strip-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    font-size: 11px;
}

.strip-label .metric-name {
    color: var(--text);
    font-weight: 500;
}

.strip-label .strip-band-count {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.strip-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    width: 100%;
    border: 1px solid var(--panel-edge);
}
