/* Ferrous Solitaire — interactive game page.
   Palette mirrors the Bevy app's Terminal (base16-eighties) design system.
   Card faces/backs are PNG images served from /assets/cards/. */

@font-face {
    font-family: "FiraMono";
    src: url("/assets/fonts/main.ttf") format("truetype");
}

:root {
    --bg: #151515;
    --felt: #0f5232;
    --panel: #202020;
    --panel-hi: #2a2a2a;
    --text: #d0d0d0;
    --text-muted: #a0a0a0;
    --accent: #a54242;
    --accent-hi: #c25e5e;
    --red: #fb9fb1;
    --black: #151515;
    --drop-success: #acc267;
    --card-bg: #f8f5f0;
    --card-border: #c8b8a0;
    --card-w: 80px;
    --card-h: 120px;
    --gap: 12px;
    --fan: 28px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "FiraMono", "Fira Mono", monospace;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* ── Header / HUD ────────────────────────────────────────────────────── */

header {
    position: sticky;
    top: 0;
    z-index: 500;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    gap: 12px;
    flex-wrap: wrap;
}

.hud-left  { display: flex; align-items: center; gap: 12px; }
.hud-center { display: flex; gap: 20px; font-size: 14px; font-weight: 600; }
.hud-right { display: flex; align-items: center; gap: 10px; }

.hud-avatar-link { display: flex; align-items: center; text-decoration: none; }
.hud-avatar-inner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.15);
    background: var(--panel-hi);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    transition: border-color 120ms;
}
.hud-avatar-link:hover .hud-avatar-inner { border-color: var(--accent); }
.hud-avatar-inner img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.logo { font-size: 16px; font-weight: 700; }
.muted { color: var(--text-muted); font-size: 12px; }
.home-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 120ms, background 120ms;
}
.home-link:hover { color: var(--text); background: var(--panel-hi); }

button {
    background: var(--panel-hi);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 120ms;
}
button:hover { background: var(--accent); color: var(--text); }
button:disabled { opacity: 0.4; cursor: default; }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
}
.toggle-label:hover { color: var(--text); }

/* ── Board ───────────────────────────────────────────────────────────── */

.board-undo {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    font-size: 15px;
    padding: 8px 20px;
    pointer-events: auto;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Full-bleed felt surface — flex:1 reliably fills main's remaining height. */
#board {
    position: relative;
    flex: 1;
    background: var(--felt);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: default;
}

/* Natural-size coordinate space for cards and slots.
   The CSS transform scale is applied here, not on #board. */
#card-area {
    position: relative;
    flex-shrink: 0;
    width: calc(7 * var(--card-w) + 6 * var(--gap) + 40px);
    height: calc(var(--card-h) + 28px + var(--card-h) + 12 * var(--fan) + 40px);
    touch-action: none;   /* prevent browser scroll/pan from stealing pointer events */
}

/* Empty-pile slot markers */
.slot {
    position: absolute;
    top: 0; left: 0;   /* explicit insets — without these some browsers offset by padding */
    width: var(--card-w);
    height: var(--card-h);
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
}

.slot.drop-active {
    border-color: var(--drop-success);
    background: rgba(172, 194, 103, 0.10);
}

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
    position: absolute;
    top: 0; left: 0;
    width: var(--card-w);
    height: var(--card-h);
    background-color: var(--card-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.35);
    padding: 0;
    overflow: hidden;
    cursor: grab;
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity  200ms ease,
                box-shadow 120ms ease;
    will-change: transform;
}

.card:active { cursor: grabbing; }

.card.face-down {
    background-color: #2d1b69;
    color: transparent;
    border-color: #4a3a8a;
    cursor: default;
}

/* Selected / being-dragged state */
.card.selected {
    box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.5);
    z-index: 200;
    transition: none;   /* snap instantly while dragging */
}

/* Drop-target highlight on cards (top of a tableau column) */
.card.drop-target {
    box-shadow: 0 0 0 2px var(--drop-success), 0 4px 12px rgba(0,0,0,0.5);
}

/* Recycle indicator on empty stock — sized to match the slot, symbol centred */
.recycle-label {
    position: absolute;
    top: 0; left: 0;
    width: var(--card-w);
    height: var(--card-h);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: rgba(255,255,255,0.3);
    pointer-events: none;
}

/* ── Resume overlay ──────────────────────────────────────────────────── */

#resume-overlay {
    position: fixed;
    inset: 0;
    background: rgba(21, 21, 21, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#resume-overlay.hidden { display: none; }

.resume-card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 40px 48px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    max-width: 360px;
}

.resume-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.resume-detail {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.resume-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

.resume-actions button {
    padding: 12px 24px;
    font-size: 15px;
}

.resume-actions button.secondary {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-muted);
}

.resume-actions button.secondary:hover {
    background: rgba(255,255,255,0.05);
}

/* ── Win overlay ─────────────────────────────────────────────────────── */

#win-overlay {
    position: fixed;
    inset: 0;
    background: rgba(21, 21, 21, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#win-overlay.hidden { display: none; }

.win-card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 40px 48px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.win-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
}

.win-score {
    font-size: 24px;
    font-weight: 600;
}

.win-detail {
    font-size: 14px;
    color: var(--text-muted);
}

#btn-win-new {
    margin-top: 8px;
    padding: 12px 32px;
    font-size: 16px;
}

/* ── Illegal-move shake ──────────────────────────────────────────────────── */

@keyframes illegal-shake {
    0%   { transform: var(--card-tx) translateX(0); }
    20%  { transform: var(--card-tx) translateX(-6px); }
    40%  { transform: var(--card-tx) translateX(6px); }
    60%  { transform: var(--card-tx) translateX(-4px); }
    80%  { transform: var(--card-tx) translateX(4px); }
    100% { transform: var(--card-tx) translateX(0); }
}

.card.illegal {
    animation: illegal-shake 320ms ease;
}

/* ── No-moves banner ─────────────────────────────────────────────────── */

#no-moves-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    animation: slide-up 240ms ease;
}

#no-moves-banner.hidden { display: none; }

.no-moves-card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 20px 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7);
    min-width: 300px;
}

.no-moves-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.no-moves-detail {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.no-moves-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 4px;
}

.no-moves-actions button.secondary {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-muted);
}

.no-moves-actions button.secondary:hover {
    background: rgba(255,255,255,0.05);
}

@keyframes slide-up {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Foundation slot suit hints ──────────────────────────────────────────── */

.slot-hint {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    color: rgba(255,255,255,0.18);
    pointer-events: none;
}

