/* =============================================================================
   Chess Platform — Shared Styles
   Aesthetic: Old-world chess club. Cream paper, deep walnut, brass accent.
   Typography: Cormorant Garamond display + IBM Plex Mono for fixed-width.
   ============================================================================= */

:root {
    --paper: #f3eddf;
    --paper-edge: #e8dfca;
    --ink: #1a1612;
    --ink-soft: #4a3f33;
    --walnut: #2d211a;
    --walnut-light: #4d3a2c;
    --brass: #b08c4a;
    --brass-bright: #d4a85e;
    --crimson: #8b2e2e;
    --olive: #6b5d3e;
    --rule: #c9bfa5;

    --shadow-sm: 0 1px 2px rgba(26, 22, 18, 0.08);
    --shadow-md: 0 4px 16px rgba(26, 22, 18, 0.12);
    --shadow-lg: 0 12px 36px rgba(26, 22, 18, 0.18);

    --serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
    --mono: "IBM Plex Mono", "Courier New", ui-monospace, monospace;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.55;
    color: var(--ink);
    background:
        radial-gradient(ellipse at top, #f7f1e2 0%, var(--paper) 40%, var(--paper-edge) 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Paper grain overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.04;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/></svg>");
    z-index: 1;
}

main, header, footer, nav, .container {
    position: relative;
    z-index: 2;
}

/* ---------- typography ---------- */

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--walnut);
}

h1 { font-size: 3rem; line-height: 1.1; }
h2 { font-size: 2rem; line-height: 1.2; }
h3 { font-size: 1.4rem; }

.eyebrow {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--brass);
}

a {
    color: var(--crimson);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
a:hover { color: var(--walnut); }

/* ---------- nav ---------- */

.topbar {
    border-bottom: 1px solid var(--rule);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(243,237,223,0.95), rgba(243,237,223,0.7));
    backdrop-filter: blur(4px);
}

.brand {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--walnut);
    letter-spacing: -0.02em;
    text-decoration: none;
}
.brand::before {
    content: "♞";
    color: var(--brass);
    margin-right: 0.4rem;
    font-size: 1.6rem;
    vertical-align: -0.1em;
}

.topbar nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.topbar nav a {
    text-decoration: none;
    font-size: 0.95rem;
    color: var(--ink-soft);
}
.topbar nav a:hover { color: var(--walnut); }

.coins-pill {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--walnut);
    background: var(--paper-edge);
    border: 1px solid var(--rule);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
}
.coins-pill::before {
    content: "◆ ";
    color: var(--brass);
}

/* ---------- containers ---------- */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

.container--narrow {
    max-width: 480px;
}

/* ---------- cards ---------- */

.card {
    background: #fbf6e8;
    border: 1px solid var(--rule);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    position: relative;
}
.card::before, .card::after {
    content: "";
    position: absolute;
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--brass);
}
.card::before {
    top: -0.5rem;
    left: -0.5rem;
    border-right: none;
    border-bottom: none;
}
.card::after {
    bottom: -0.5rem;
    right: -0.5rem;
    border-left: none;
    border-top: none;
}

/* ---------- forms ---------- */

label {
    display: block;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-family: var(--serif);
    font-size: 1.05rem;
    color: var(--ink);
    background: #fdfaf0;
    border: 1px solid var(--rule);
    border-bottom: 2px solid var(--walnut-light);
    transition: border-color 0.15s, background 0.15s;
}
input:focus, select:focus {
    outline: none;
    border-bottom-color: var(--brass);
    background: #fff;
}

.field {
    margin-bottom: 1.25rem;
}

.btn {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 0.85rem 1.6rem;
    border: 1px solid var(--walnut);
    background: var(--walnut);
    color: var(--paper);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn:hover {
    background: var(--walnut-light);
    color: var(--paper);
}
.btn--ghost {
    background: transparent;
    color: var(--walnut);
}
.btn--ghost:hover {
    background: var(--walnut);
    color: var(--paper);
}
.btn--brass {
    background: var(--brass);
    border-color: var(--brass);
    color: var(--walnut);
}
.btn--brass:hover {
    background: var(--brass-bright);
    border-color: var(--brass-bright);
    color: var(--walnut);
}
.btn--small {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- alerts ---------- */

.alert {
    padding: 0.9rem 1.1rem;
    border-left: 3px solid;
    background: #f7f1e2;
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    font-family: var(--sans);
}
.alert--error { border-color: var(--crimson); color: var(--crimson); }
.alert--info  { border-color: var(--olive); color: var(--olive); }

/* ---------- chess board container ---------- */

.board-wrap {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
    box-shadow: var(--shadow-lg);
    border: 8px solid var(--walnut);
}

#board {
    width: 100%;
    height: 100%;
}


/* ---------- layout for play page ---------- */

.play-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2.5rem;
    align-items: start;
}

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

.side-panel {
    background: #fbf6e8;
    border: 1px solid var(--rule);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.move-list {
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.8;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.75rem;
    background: var(--paper-edge);
    border: 1px solid var(--rule);
    color: var(--ink);
    word-spacing: 0.3em;
}

.status-line {
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brass);
    margin-bottom: 0.75rem;
}

/* ---------- footer ---------- */

footer {
    text-align: center;
    padding: 3rem 2rem 1.5rem;
    font-size: 0.85rem;
    color: var(--ink-soft);
    border-top: 1px solid var(--rule);
    margin-top: 4rem;
}

/* ---------- inline chessboard (shared by play and replay) ---------- */
.cb-board {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    box-shadow: var(--shadow-lg);
    border: 8px solid var(--walnut);
    user-select: none;
}
.cb-sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}
.cb-sq.light { background: #ede0c4; }   /* overridden by data-board-theme */
.cb-sq.dark  { background: #8b6f4e; }
.cb-sq.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 4px rgba(176, 140, 74, 0.85);
    pointer-events: none;
}
.cb-sq.legal::before {
    content: "";
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(40, 30, 20, 0.28);
    pointer-events: none;
}
.cb-sq.legal.has-piece::before {
    width: 86%;
    height: 86%;
    background: transparent;
    border: 5px solid rgba(139, 46, 46, 0.55);
}
.cb-sq.last-move      { background: #d4c89a !important; }   /* overridden by theme */
.cb-sq.dark.last-move { background: #9d8252 !important; }

.highlight1-32417, .highlight2-9c5d2 {
    box-shadow: inset 0 0 0 4px rgba(180, 240, 76, 0.55) !important;
}
.cb-piece {
    width: 88%;
    height: 88%;
    cursor: grab;
    pointer-events: auto;
}
.cb-piece:active { cursor: grabbing; }
.cb-piece.dragging { opacity: 0.4; }
.cb-coords {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: rgba(45, 33, 26, 0.55);
    position: absolute;
    pointer-events: none;
}
.cb-coord-file { right: 4px; bottom: 2px; }
.cb-coord-rank { left: 4px; top: 2px; }
