/* Irida — minimal layout */

:root {
    --bg: #0f0f0f;
    --surface: #181818;
    --border: #2e2e2e;
    --text: #e8e8e8;
    --muted: #8a8a8a;
    --accent: #d4d4d4;
    --primary-fg: #0a0a0a;
    --primary-bg: #e5e5e5;
    --warn: #eab308;
    --danger: #f87171;
    --ok: #4ade80;
    --log-in: #93c5fd;
    --log-out: #fcd34d;
    --radius: 8px;
    --font: "DM Sans", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
}

/* Shell */
.shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
}

/* Desktop-style toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.toolbar--secondary {
    margin-bottom: 1rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.toolbar-brand {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    margin-right: 0.25rem;
    padding-right: 0.5rem;
    border-right: 1px solid var(--border);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.toolbar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.toolbar-spacer {
    flex: 1 1 12px;
    min-width: 0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.toolbar-fill {
    flex: 1 1 2rem;
    min-width: 0;
}

.toolbar-mini {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.toolbar--uci {
    margin-bottom: 1rem;
}

.toolbar-status {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    padding: 0.2rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 2px;
}

.thinking .toolbar-status {
    color: var(--warn);
    border-color: rgba(234, 179, 8, 0.35);
}

.toolbar-raw {
    flex: 1 1 180px;
    min-width: 0;
    font-family: var(--mono);
    font-size: 13px;
}

.board-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 0 auto;
    touch-action: manipulation;
}

.board-wrap--locked #board {
    opacity: 0.55;
    pointer-events: none;
}

.main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
}

@media (max-width: 720px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1rem;
}

.card--log {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card-title {
    margin: 0 0 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.card-title--sub {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.card-head .card-title {
    margin: 0;
}

/* Board — fewer double-tap-zoom / pan fights on touch */
#board.chessboard-root {
    border-radius: 4px;
    overflow: hidden;
    touch-action: manipulation;
}

#board .square--tap-selected {
    box-shadow: inset 0 0 0 3px rgba(74, 222, 128, 0.85);
}

/* Forms */
.label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.label-inline {
    font-size: 0.75rem;
    color: var(--muted);
    margin-right: 0.25rem;
}

.input-fen {
    width: 100%;
    min-height: 3rem;
    resize: vertical;
    font-family: var(--mono);
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 0.5rem 0.6rem;
    background: #0a0a0a;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.input-fen:focus {
    outline: none;
    border-color: #555;
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

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

.field-row--split {
    align-items: center;
}

.input-block {
    flex: 1 1 140px;
    min-width: 0;
}

.input-depth {
    width: 3.25rem;
    text-align: center;
}

input,
select {
    font-family: var(--font);
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 0.45rem 0.5rem;
    background: #0a0a0a;
    color: var(--text);
}

input:focus,
select:focus {
    outline: none;
    border-color: #555;
}

.input-depth::-webkit-outer-spin-button,
.input-depth::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-depth[type="number"] {
    appearance: textfield;
}

/* Buttons */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 0.45rem 0.75rem;
    border-radius: 2px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.btn-primary {
    background: var(--primary-bg);
    color: var(--primary-fg);
    border-color: var(--primary-bg);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.shell.thinking {
    outline: 1px solid rgba(234, 179, 8, 0.25);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Analysis */
.analysis {
    font-size: 14px;
    line-height: 1.5;
    min-height: 3rem;
}

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

.loader {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 13px;
    color: var(--muted);
}

.loader[hidden] {
    display: none !important;
}

#llm-explanation[hidden] {
    display: none !important;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Moves */
.move-list {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
    min-height: 2.5rem;
}

.move-list:empty::before {
    content: "—";
    color: var(--muted);
}

/* Log */
.log {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    flex: 1;
    min-height: 180px;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.6rem 0.65rem;
    background: #0a0a0a;
    border: 1px solid var(--border);
    border-radius: 2px;
}

.log-line {
    padding: 0.1rem 0;
    word-break: break-word;
}

.log-line--in {
    color: var(--log-in);
}

.log-line--out {
    color: var(--log-out);
}

.log-line--sys {
    color: var(--ok);
}

.log-line--result {
    color: var(--danger);
    font-weight: 600;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive */
@media (max-width: 480px) {
    .field-row--split {
        flex-direction: column;
        align-items: stretch;
    }

    .input-depth {
        width: 100%;
    }
}
