/* ==============================================================================
 * Master Stylesheet - Interactive Chess Web Application
 * Design System: Modern Glassmorphism & High-Contrast Cyber Aesthetics
 * Author: Praful Kumar
 * Website: https://prafulkr.xyz/
 * GitLab: https://gitlab.com/prafulkr/chess
 * ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

:root {
    /* Color Palette - Vibrant UI Reference Glassmorphism */
    --bg-primary: #0d1127;
    --bg-card: linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.08) 100%);
    --border-card: rgba(255, 255, 255, 0.4);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.35);

    --sq-light: #e2e8f0;
    --sq-dark: #334155;

    --highlight-selected: rgba(56, 189, 248, 0.5);
    --highlight-last: rgba(250, 204, 21, 0.4);
    --highlight-check: rgba(239, 68, 68, 0.65);
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-code: 'Fira Code', monospace;

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

/* Theme Variations */
body[data-theme="wood"] {
    --bg-primary: #1c130d;
    --bg-card: rgba(43, 29, 20, 0.8);
    --sq-light: #f0d9b5;
    --sq-dark: #b58863;
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.35);
}

body[data-theme="emerald"] {
    --bg-primary: #061814;
    --bg-card: rgba(11, 38, 32, 0.8);
    --sq-light: #e8f5e9;
    --sq-dark: #2e7d32;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.35);
}

body[data-theme="marble"] {
    --bg-primary: #0c0a1d;
    --bg-card: rgba(21, 19, 46, 0.8);
    --sq-light: #f1f5f9;
    --sq-dark: #475569;
    --accent: #eab308;
    --accent-glow: rgba(234, 179, 8, 0.35);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: #0d1127;
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(0, 212, 255, 0.45) 0%, transparent 45%),
        radial-gradient(circle at 90% 10%, rgba(147, 51, 234, 0.45) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.4) 0%, transparent 45%),
        radial-gradient(circle at 15% 85%, rgba(59, 130, 246, 0.45) 0%, transparent 45%),
        linear-gradient(135deg, #09132e 0%, #170d38 50%, #0a1f38 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px 15px;
}

/* Application Container */
.app-container {
    width: 90%;
    max-width: 90%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-title i {
    font-size: 1.8rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.brand-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 20px;
}

.turn-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    padding: 8px 16px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent);
}

.turn-badge.ai-thinking {
    animation: pulse 1.2s infinite alternate;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Main Layout Grid */
.main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* Board Arena Wrapper */
.board-arena {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

/* Vertical Evaluation Bar */
.eval-bar-container {
    width: 24px;
    height: 680px;
    background: #0f172a;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.eval-bar-inner {
    width: 100%;
    height: 50%;
    background: #f8fafc;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.eval-score {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    text-shadow: 0 0 4px #000;
}

/* Chessboard 8x8 Grid */
.board-wrapper {
    position: relative;
}

.chessboard {
    width: 680px;
    height: 680px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) {
    .chessboard {
        width: 100%;
        max-width: 440px;
        height: 440px;
    }
    .eval-bar-container {
        height: 440px;
    }
}

@media (max-width: 480px) {
    .chessboard {
        width: 100%;
        max-width: 320px;
        height: 320px;
    }
    .eval-bar-container {
        height: 320px;
    }
}

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.square.light {
    background-color: var(--sq-light);
}

.square.dark {
    background-color: var(--sq-dark);
}

.square.selected {
    box-shadow: inset 0 0 0 4px var(--accent);
    background-color: var(--highlight-selected) !important;
}

.square.last-move {
    background-color: var(--highlight-last) !important;
}

.square.in-check {
    background-color: var(--highlight-check) !important;
    animation: pulseCheck 1s infinite alternate;
}

@keyframes pulseCheck {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.3); }
}

/* Rank / File Annotations */
.rank-label, .file-label {
    position: absolute;
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0.6;
    pointer-events: none;
}

.square.light .rank-label, .square.light .file-label { color: #1e293b; }
.square.dark .rank-label, .square.dark .file-label { color: #f8fafc; }

.rank-label { top: 4px; left: 6px; }
.file-label { bottom: 4px; right: 6px; }

/* Legal Move Markers */
.legal-move-dot {
    width: 22px;
    height: 22px;
    background: rgba(16, 185, 129, 0.75);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
    pointer-events: none;
}

.legal-capture-halo {
    position: absolute;
    inset: 4px;
    border: 4px solid rgba(239, 68, 68, 0.85);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
    pointer-events: none;
}

/* Piece Styling */
.piece {
    width: 85%;
    height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    cursor: grab;
}

.piece:active {
    cursor: grabbing;
    transform: scale(1.15);
}

.piece svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* Sidebar Controls */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.control-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-group label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.select-control {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-card);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.select-control:focus {
    border-color: var(--accent);
}

/* Timers Display */
.timers-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.timer-box {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
}

.timer-box .timer-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.timer-box .timer-val {
    font-family: var(--font-code);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Action Buttons Grid */
.btn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.action-btn.primary {
    background: var(--accent);
    color: #090d16;
    border: none;
    font-weight: 600;
}

.action-btn.primary:hover {
    box-shadow: 0 0 15px var(--accent-glow);
    background: #0284c7;
    color: #fff;
}

.action-btn.active {
    background: var(--accent);
    color: #090d16;
}

/* Full-Width Move History & Captured Material Section */
.move-history-fullwidth {
    grid-column: 1 / -1;
    width: 100%;
}

.move-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
}

.move-history-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.captured-panel-inline {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.captured-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.captured-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.captured-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-card);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.captured-icon {
    width: 20px;
    height: 20px;
}

.captured-icon svg {
    width: 100%;
    height: 100%;
}

/* Move Log Grid */
.move-log-fullwidth {
    height: 150px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    font-family: var(--font-code);
    font-size: 0.88rem;
}

.move-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.move-num { color: var(--text-muted); font-weight: 500; }
.move-san.white { color: #f8fafc; font-weight: 600; }
.move-san.black { color: var(--accent); font-weight: 600; }

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #0f172a;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 440px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-card h2 {
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.modal-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.promo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.promo-choice {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.promo-choice:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.promo-choice svg {
    width: 80%;
    height: 80%;
}

.textarea-control {
    width: 100%;
    height: 90px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 10px;
    font-family: var(--font-code);
    font-size: 0.82rem;
    resize: none;
    margin-bottom: 16px;
}

/* ==============================================================================
 * Author & Developer Footer Component (Exact Match with Required UI)
 * ============================================================================== */
.app-footer {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-top: 20px;
}

.footer-credit {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

.footer-link-highlight {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link-highlight:hover {
    text-decoration: underline;
    color: #0284c7;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.footer-link:hover {
    color: #fff;
    transform: translateY(-1px);
}

.footer-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

.tech-badges {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.badge {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: var(--accent);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.footer-bottom {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 2px;
}
