/* =============================================================================
   MORABARABA — SHARED DESIGN SYSTEM
   A night-kraal palette (dark carved wood + brass inlay) with the board's own
   nested-square geometry reused throughout as corner brackets, dividers and
   watermarks. Used by home / login / dashboard / players / settings /
   tournaments. The gameplay board itself (index.html) keeps its own simpler
   sheet — this file is for the surrounding "clubhouse".
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,500;0,600;0,700;1,500&family=IM+Fell+English+SC&family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    /* --- Color: night kraal + brass inlay --- */
    --bg: #150f0a;
    --bg-soft: #1b140d;
    --panel: #221a12;
    --panel-2: #2a2016;
    --panel-raised: #302518;
    --line: #4a3826;
    --line-soft: #362a1c;

    --brass: #cf9d3e;
    --brass-bright: #e8bd5c;
    --brass-dim: #8a692c;
    --clay: #c15c37;
    --clay-bright: #dd7750;
    --sage: #8aa478;
    --sage-bright: #a5c290;

    --ivory: #f3ead8;
    --ivory-dim: #cabda2;
    --ivory-faint: #8f8271;

    --shadow-lift: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
    --shadow-soft: 0 4px 16px -8px rgba(0, 0, 0, 0.45);

    /* --- Type --- */
    --font-display: 'Spectral', Georgia, serif;
    --font-eyebrow: 'IM Fell English SC', 'Spectral', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    background:
        radial-gradient(ellipse 1200px 600px at 15% -10%, rgba(207, 157, 62, 0.08), transparent 60%),
        radial-gradient(ellipse 900px 500px at 100% 0%, rgba(193, 92, 55, 0.06), transparent 55%),
        var(--bg);
    color: var(--ivory);
    font-family: var(--font-body);
    font-size: 15.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brass); color: #1b140d; }

a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--brass-bright);
    outline-offset: 3px;
    border-radius: 4px;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    margin: 0;
    color: var(--ivory);
    letter-spacing: -0.01em;
}

p { margin: 0; }

img, svg { display: block; max-width: 100%; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

/* -----------------------------------------------------------------------
   Layout utilities
   ----------------------------------------------------------------------- */

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 28px;
}

.eyebrow {
    font-family: var(--font-eyebrow);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 13px;
    color: var(--brass-bright);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* -----------------------------------------------------------------------
   Signature: kraal-grid watermark (echoes the board's nested squares)
   ----------------------------------------------------------------------- */

.kraal-watermark {
    position: relative;
    overflow: hidden;
}

.kraal-watermark::before {
    content: '';
    position: absolute;
    inset: -10% -5%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%23cf9d3e' stroke-width='0.35' stroke-opacity='0.35'%3E%3Crect x='2' y='2' width='96' height='96'/%3E%3Crect x='18.67' y='18.67' width='62.66' height='62.66'/%3E%3Crect x='35.33' y='35.33' width='29.34' height='29.34'/%3E%3Cline x1='50' y1='2' x2='50' y2='98'/%3E%3Cline x1='2' y1='50' x2='98' y2='50'/%3E%3Cline x1='2' y1='2' x2='18.67' y2='18.67'/%3E%3Cline x1='98' y1='2' x2='81.33' y2='18.67'/%3E%3Cline x1='2' y1='98' x2='18.67' y2='81.33'/%3E%3Cline x1='98' y1='98' x2='81.33' y2='81.33'/%3E%3C/g%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center 10%;
    background-size: 900px 900px;
    -webkit-mask-image: linear-gradient(to bottom, black, transparent 85%);
    mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.kraal-watermark > * { position: relative; z-index: 1; }

/* Node divider: a hairline with a diamond "point", like a mid-board spot */
.node-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--brass-dim);
    margin: 0;
}
.node-divider::before,
.node-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.node-divider .node-diamond {
    width: 7px;
    height: 7px;
    background: var(--brass);
    transform: rotate(45deg);
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(207, 157, 62, 0.5);
}

/* -----------------------------------------------------------------------
   Cards — with carved corner-bracket motif (echoes the board's corner points)
   ----------------------------------------------------------------------- */

.card {
    position: relative;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.card--bracketed::before,
.card--bracketed::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    pointer-events: none;
    opacity: 0.85;
}
.card--bracketed::before {
    top: -1px;
    left: -1px;
    border-top: 2px solid var(--brass);
    border-left: 2px solid var(--brass);
    border-top-left-radius: var(--radius-lg);
}
.card--bracketed::after {
    bottom: -1px;
    right: -1px;
    border-bottom: 2px solid var(--brass);
    border-right: 2px solid var(--brass);
    border-bottom-right-radius: var(--radius-lg);
}

/* -----------------------------------------------------------------------
   Buttons
   ----------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14.5px;
    border: 1px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: linear-gradient(180deg, var(--brass-bright), var(--brass));
    color: #221807;
    box-shadow: 0 6px 20px -8px rgba(207, 157, 62, 0.55);
}
.btn--primary:hover { box-shadow: 0 8px 24px -6px rgba(207, 157, 62, 0.7); filter: brightness(1.03); }

.btn--ghost {
    background: transparent;
    color: var(--ivory);
    border-color: var(--line);
}
.btn--ghost:hover { border-color: var(--brass-dim); background: rgba(207, 157, 62, 0.06); }

.btn--danger {
    background: transparent;
    color: var(--clay-bright);
    border-color: rgba(193, 92, 55, 0.5);
}
.btn--danger:hover { background: rgba(193, 92, 55, 0.12); }

.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* -----------------------------------------------------------------------
   Forms
   ----------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field label {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ivory-dim);
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field textarea {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    color: var(--ivory);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(207, 157, 62, 0.15);
    outline: none;
}
.field .hint { font-size: 12.5px; color: var(--ivory-faint); }
.field .error { font-size: 12.5px; color: var(--clay-bright); }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ivory-dim); }
.checkbox-row input { accent-color: var(--brass); width: 15px; height: 15px; }

/* Toggle switch (settings) */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
    position: absolute; inset: 0; background: var(--line); border-radius: 999px;
    transition: background 0.15s ease; cursor: pointer;
}
.switch .track::before {
    content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    background: var(--ivory-dim); border-radius: 50%; transition: transform 0.18s ease, background 0.15s ease;
}
.switch input:checked + .track { background: var(--brass-dim); }
.switch input:checked + .track::before { transform: translateX(18px); background: var(--brass-bright); }

input:-webkit-autofill, input:autofill {
    background-color: var(--bg-soft) !important;
    color: var(--ivory) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-soft) inset !important;
    box-shadow: inset 0 0 0px 1000px var(--bg-soft) !important;
    -webkit-text-fill-color: var(--ivory);
}

/* -----------------------------------------------------------------------
   Pieces / avatars — literal game pieces used as identity markers
   ----------------------------------------------------------------------- */

.piece-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
    color: #1b140d;
    text-shadow: 0 1px 0 rgba(255,255,255,0.25);
    /* Piece colours are still never per-account (see gameLogic.js
       PIECE_COLOR_1/2 comment) — every chip stays in the brass family.
       What's new is dimension: a simulated light source (top-left highlight,
       bottom-right shadow) plus a brass-bright → brass → brass-dim sweep,
       instead of one flat fill. */
    background:
        radial-gradient(circle at 32% 26%, rgba(255,255,255,0.4), transparent 46%),
        radial-gradient(circle at 72% 80%, rgba(0,0,0,0.28), transparent 55%),
        linear-gradient(155deg, var(--brass-bright), var(--brass) 55%, var(--brass-dim));
    box-shadow:
        inset 0 1px 2px rgba(255,255,255,0.4),
        inset 0 -3px 5px rgba(0,0,0,0.35),
        0 3px 8px rgba(0,0,0,0.4);
}
/* A thin engraved ring set just inside the outer edge — reads as a stamped
   medallion/cattle-brand coin rather than a plain filled circle. Purely
   decorative; an absolutely positioned pseudo-element, no layout impact. */
.piece-avatar::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 1px solid rgba(27,20,13,0.25);
    pointer-events: none;
}

.piece-avatar--sm { width: 30px; height: 30px; font-size: 12px; padding-top: 3px; }
.piece-avatar--sm::after { inset: 2px; }
.piece-avatar--lg { width: 64px; height: 64px; font-size: 22px; }
.piece-avatar--lg::after { inset: 4px; }

/* -----------------------------------------------------------------------
   Badges / pills
   ----------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}
.badge--brass { background: rgba(207, 157, 62, 0.14); color: var(--brass-bright); border-color: rgba(207, 157, 62, 0.3); }
.badge--sage { background: rgba(138, 164, 120, 0.14); color: var(--sage-bright); border-color: rgba(138, 164, 120, 0.3); }
.badge--clay { background: rgba(193, 92, 55, 0.14); color: var(--clay-bright); border-color: rgba(193, 92, 55, 0.3); }
.badge--neutral { background: var(--panel-raised); color: var(--ivory-dim); border-color: var(--line); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot--online { background: var(--sage-bright); box-shadow: 0 0 6px rgba(165, 194, 144, 0.7); }
.status-dot--offline { background: var(--ivory-faint); }
.status-dot--live { background: var(--clay-bright); box-shadow: 0 0 6px rgba(221, 119, 80, 0.7); animation: pulse-dot 1.6s ease-in-out infinite; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* -----------------------------------------------------------------------
   Data display: mono stat numerals
   ----------------------------------------------------------------------- */

.stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ivory);
}

/* -----------------------------------------------------------------------
   Table
   ----------------------------------------------------------------------- */

table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ivory-faint);
    font-weight: 600;
    padding: 0 14px 12px;
    border-bottom: 1px solid var(--line-soft);
}
.data-table td {
    padding: 14px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 14px;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover { background: rgba(207, 157, 62, 0.05); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--brass-bright); }
.data-table th.sortable .arrow { opacity: 0.4; margin-left: 4px; }
.data-table th.sortable.sort-active .arrow { opacity: 1; color: var(--brass-bright); }

/* -----------------------------------------------------------------------
   Scrollbar (webkit) — subtle, in-theme
   ----------------------------------------------------------------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--brass-dim); }
