/* ROVE Tabletop — a Mars table under a floating rover HUD.
   kt-styles drives the dialogs, toasts and type; the scene palette below is game-specific. */

:root {
    --rove-rust: #d2693c;
    --rove-rust-hi: #e8804f;
    --rove-rust-soft: rgba(232, 128, 79, 0.18);
    --rove-glow: rgba(232, 128, 79, 0.55);
    --rove-glass: rgba(30, 24, 21, 0.78);
    --rove-glass-hi: rgba(52, 43, 38, 0.92);
    --rove-edge: rgba(255, 190, 150, 0.16);
    --rove-ink: #f4ebe4;
    --rove-ink-muted: rgba(244, 235, 228, 0.6);
    --rove-card-shadow: 0 10px 22px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.45);
    --rove-lift-shadow: 0 26px 48px rgba(0, 0, 0, 0.6), 0 6px 12px rgba(0, 0, 0, 0.45);
    --rove-hud-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
/* kt-styles accent follows the scene (focus rings, links, modal buttons) */
:root[data-theme="dark"] {
    --kt-accent: var(--rove-rust-hi);
    --kt-accent-hover: var(--rove-rust);
    --kt-accent-soft: var(--rove-rust-soft);
}

html, body { height: 100%; }
body {
    margin: 0;
    overflow: hidden;
    color: var(--rove-ink);
    background: #000;
}

/* ---------- The table ---------- */

.table {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.55) 100%),
        url("../img/mars.jpg") center / cover no-repeat,
        #000;
}

.board {
    position: absolute;
    inset: 0;
    transform-origin: 50% 50%;
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.board.cam-follow { transition: transform 0.12s ease-out; }
.board.cam-none,
.board.no-anim { transition: none; }

.mod,
.slot,
.ghost {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--cw);
    height: var(--ch);
    border-radius: var(--cr);
    transform: var(--t);
}

.mod {
    z-index: 2;
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, filter 0.2s ease;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.mod__flipper {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    box-shadow: var(--rove-card-shadow);
    transition: transform 0.45s ease, box-shadow 0.2s ease;
}
.mod img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    pointer-events: none;
}
/* Soft inner border: drawn over the card's own edge, never outside it */
.mod__flipper { position: relative; }
.mod__flipper::after,
.ghost::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 calc(var(--cw) * 0.012) rgba(255, 255, 255, 0.9),
        inset 0 0 calc(var(--cw) * 0.035) rgba(255, 255, 255, 0.5);
}
.mod:hover .mod__flipper { box-shadow: var(--rove-card-shadow), 0 0 0 2px var(--rove-edge); }
.mod.is-selected .mod__flipper,
.mod.is-selected:hover .mod__flipper {
    box-shadow: var(--rove-card-shadow), 0 0 0 3px var(--rove-rust-hi), 0 0 28px var(--rove-glow);
}
.mod.is-option .mod__flipper {
    box-shadow: var(--rove-card-shadow), 0 0 0 3px var(--rove-rust-hi);
    animation: pulse 1.4s ease-in-out infinite;
}
.mod.is-option { cursor: pointer; }
.mod.is-dim { opacity: 0.45; filter: grayscale(0.7) brightness(0.8); cursor: default; }
.mod.is-leaving { opacity: 0.35; }
.mod.is-flipping .mod__flipper { transform: rotateY(90deg); }

.mod.is-dragging {
    z-index: 50;
    transition: none;
    cursor: grabbing;
    transform: var(--t) scale(1.05) rotate(-1.2deg);
}
.mod.is-dragging .mod__flipper { box-shadow: var(--rove-lift-shadow), 0 0 0 3px var(--rove-rust-hi); }

.board.no-anim .mod { transition: none; }
.table { cursor: grab; }
body.is-panning, body.is-panning .table { cursor: grabbing; }
.board.is-over .mod { cursor: default; }
.board.is-shuffling .mod { pointer-events: none; }
.board.is-shuffling .mod__key { opacity: 0; }

@keyframes pulse {
    50% { box-shadow: var(--rove-card-shadow), 0 0 0 3px var(--rove-rust-hi), 0 0 30px var(--rove-glow); }
}

/* Hotspot over the ★ ability strip printed on the card */
.mod__ability {
    position: absolute;
    left: 26%;
    top: 75.5%;
    width: 48%;
    height: 16%;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--kt-radius-md);
    background: transparent;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mod__ability:hover,
.mod__ability:focus-visible {
    border-color: var(--rove-rust-hi);
    box-shadow: 0 0 18px var(--rove-glow);
    outline: none;
}
.mod__ability[hidden] { display: none; }

.mod__key {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
.mod:hover .mod__key,
.mod.is-selected .mod__key { opacity: 1; }
.mod.is-dragging .mod__key { opacity: 0; }

/* Legal destination: dark well with a pale edge so it reads on the orange planet */
.slot {
    z-index: 1;
    display: grid;
    place-items: center;
    border: 2px dashed rgba(255, 222, 200, 0.9);
    background: rgba(18, 10, 6, 0.42);
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    animation: slot-in 0.18s ease;
    transition: background-color 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
/* Slots on top of a module (Motor pushes) must sit above it to be clickable */
.slot.is-over { z-index: 4; background: rgba(18, 10, 6, 0.3); }
.slot:hover,
.slot.is-hot {
    border-style: solid;
    border-color: var(--rove-rust-hi);
    background: rgba(232, 128, 79, 0.3);
    box-shadow: 0 0 30px var(--rove-glow), inset 0 0 30px rgba(232, 128, 79, 0.3);
}
.slot__label {
    padding: 2px 10px;
    border-radius: var(--kt-radius-full);
    background: var(--rove-glass-hi);
    color: var(--rove-ink);
    font-family: var(--kt-font-mono);
    font-size: var(--kt-fs-md);
    font-weight: var(--kt-weight-bold);
    pointer-events: none;
}
.slot:hover .slot__label,
.slot.is-hot .slot__label { visibility: hidden; }

@keyframes slot-in {
    from { opacity: 0; transform: var(--t) scale(0.94); }
    to   { opacity: 1; transform: var(--t) scale(1); }
}

/* Preview of where modules end up */
.ghost {
    z-index: 5;
    pointer-events: none;
    opacity: 0.8;
    box-shadow: 0 0 0 3px var(--rove-rust-hi), 0 0 26px var(--rove-glow);
}
.ghost img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

/* ---------- HUD ---------- */

.hud {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.hud > * { pointer-events: auto; }
.hud.is-hidden { opacity: 0; }
.hud.is-hidden > * { pointer-events: none; }

.hud__panel {
    position: absolute;
    background: var(--rove-glass);
    border: 1px solid var(--rove-edge);
    border-radius: var(--kt-radius-lg);
    box-shadow: var(--rove-hud-shadow);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.hud__label {
    font-family: var(--kt-font-mono);
    font-size: var(--kt-fs-sm);
    font-weight: var(--kt-weight-bold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rove-ink-muted);
}

.hud__brand {
    top: var(--kt-space-4);
    left: var(--kt-space-4);
    display: flex;
    align-items: center;
    gap: var(--kt-space-4);
    padding: var(--kt-space-2) var(--kt-space-4);
}
.brand {
    font-family: var(--kt-font-mono);
    font-size: var(--kt-fs-lg);
    font-weight: var(--kt-weight-bold);
    letter-spacing: 0.32em;
    color: var(--rove-rust-hi);
}
.mission-track { display: flex; flex-direction: column; gap: 4px; }
.pips { display: flex; gap: 4px; }
.pip {
    width: 22px;
    height: 6px;
    border-radius: var(--kt-radius-full);
    background: rgba(255, 255, 255, 0.12);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.pip.is-done { background: var(--rove-rust-hi); box-shadow: 0 0 8px var(--rove-glow); }
.pip.is-current { background: rgba(232, 128, 79, 0.35); }

.hud__tools {
    top: var(--kt-space-4);
    right: var(--kt-space-4);
    display: flex;
    gap: var(--kt-space-1);
    padding: var(--kt-space-1);
}

.hud__bar {
    bottom: var(--kt-space-4);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--kt-space-3);
    padding: var(--kt-space-2) var(--kt-space-2) var(--kt-space-2) var(--kt-space-4);
    white-space: nowrap;
}
.counter { display: flex; flex-direction: column; align-items: flex-start; min-width: 4.5rem; }
.counter__value {
    font-family: var(--kt-font-mono);
    font-size: var(--kt-fs-lg);
    font-weight: var(--kt-weight-bold);
    line-height: 1.1;
    color: var(--rove-ink);
    font-variant-numeric: tabular-nums;
}
.counter__value.is-bump { animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.3); color: var(--rove-rust-hi); } }

/* Buttons: rover control panel */
.hud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--kt-space-2);
    height: 36px;
    min-width: 36px;
    padding: 0 var(--kt-space-3);
    font: inherit;
    color: var(--rove-ink);
    background: var(--rove-glass-hi);
    border: 1px solid var(--rove-edge);
    border-radius: var(--kt-radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}
.hud-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: rgba(70, 58, 51, 0.95);
    box-shadow: inset 0 0 10px rgba(232, 128, 79, 0.2);
}
.hud-btn:active:not(:disabled) { transform: translateY(0); }
.hud-btn:disabled { opacity: 0.4; cursor: default; }
.hud-btn:focus-visible { outline: 2px solid var(--rove-rust-hi); outline-offset: 2px; }

.hud-btn--primary {
    height: 40px;
    padding: 0 var(--kt-space-5);
    font-family: var(--kt-font-mono);
    font-weight: var(--kt-weight-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(145deg, var(--rove-rust-hi), var(--rove-rust));
    border-color: rgba(255, 190, 150, 0.35);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 200, 160, 0.35);
}
.hud-btn--primary:hover:not(:disabled) {
    background: linear-gradient(145deg, #f08c5a, var(--rove-rust-hi));
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), 0 0 18px var(--rove-glow);
}
.hud-btn svg { width: 18px; height: 18px; display: block; }
.hud-btn--quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--rove-ink-muted); }

/* Instruction banner */
.prompt {
    position: absolute;
    top: var(--kt-space-4);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--kt-space-3);
    padding: var(--kt-space-2) var(--kt-space-2) var(--kt-space-2) var(--kt-space-4);
    max-width: min(640px, calc(100% - 520px));
    background: var(--rove-glass);
    border: 1px solid var(--rove-rust-hi);
    border-radius: var(--kt-radius-lg);
    box-shadow: var(--rove-hud-shadow), 0 0 20px var(--rove-glow);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.prompt.is-quiet {
    border-color: var(--rove-edge);
    box-shadow: var(--rove-hud-shadow);
    padding-right: var(--kt-space-4);
    color: var(--rove-ink-muted);
}
.prompt:empty { display: none; }

/* Selected module / ability info */
.context {
    left: var(--kt-space-4);
    bottom: var(--kt-space-4);
    width: 300px;
    padding: var(--kt-space-3) var(--kt-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--kt-space-2);
}
.context:empty { display: none; }
.context__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--kt-space-2);
    font-family: var(--kt-font-mono);
    font-size: var(--kt-fs-md);
    font-weight: var(--kt-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.context p { margin: 0; color: var(--rove-ink); line-height: var(--kt-leading-snug); }
.context .muted { color: var(--rove-ink-muted); }
.tag {
    font-family: var(--kt-font-mono);
    font-size: var(--kt-fs-sm);
    letter-spacing: 0.08em;
    padding: 1px 8px;
    border-radius: var(--kt-radius-full);
    border: 1px solid var(--rove-edge);
    color: var(--rove-ink-muted);
}
.tag--spent { color: #ff9a8a; border-color: rgba(255, 120, 100, 0.4); }
.glyph { font-size: var(--kt-fs-md); color: var(--rove-rust-hi); }

/* History drawer */
.drawer {
    top: 72px;
    right: var(--kt-space-4);
    bottom: 88px;
    width: 300px;
    display: flex;
    flex-direction: column;
}
.drawer[hidden] { display: none; }
.drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--kt-space-2) var(--kt-space-2) var(--kt-space-2) var(--kt-space-4);
    border-bottom: 1px solid var(--rove-edge);
}
.drawer__actions {
    display: flex;
    flex-direction: column;
    gap: var(--kt-space-2);
    padding: var(--kt-space-3);
    border-top: 1px solid var(--rove-edge);
}
.log__list {
    list-style: none;
    margin: 0;
    padding: var(--kt-space-1) 0;
    overflow-y: auto;
    flex: 1 1 0;
}
.log__list li { padding: var(--kt-space-1) var(--kt-space-4); color: var(--rove-ink-muted); }
.log__list li + li { border-top: 1px solid rgba(255, 190, 150, 0.07); }
.log__list li.is-mission { color: var(--rove-rust-hi); font-weight: var(--kt-weight-bold); }
.log__list li.is-ability::before { content: "★ "; color: var(--rove-rust-hi); }

.show-hud {
    position: fixed;
    right: var(--kt-space-4);
    bottom: var(--kt-space-4);
    z-index: 100;
    opacity: 0.55;
}
.show-hud:hover { opacity: 1; }
.show-hud[hidden] { display: none; }

.arrow-cell { font-size: var(--kt-fs-md); white-space: nowrap; }

/* Toasts over the table, above the bottom bar */
.kt-toast-stack { bottom: 84px; right: 50%; transform: translateX(50%); }
