/* ========================================
   Chess Replay - Modern Dark Theme
   ======================================== */

:root {
    /* Color Palette - Emerald & Charcoal */
    --bg-primary: #0d0f0e;
    --bg-secondary: #151917;
    --bg-tertiary: #1a1f1c;
    --bg-elevated: #1e2421;
    
    --accent-primary: #10b981;
    --accent-secondary: #34d399;
    --accent-glow: rgba(16, 185, 129, 0.15);
    --accent-dim: rgba(16, 185, 129, 0.4);
    
    --text-primary: #f0fdf4;
    --text-secondary: #a7b5ae;
    --text-muted: #6b7a72;
    
    --border-color: #2d3833;
    --border-accent: #3f4f48;
    
    /* Board Colors */
    --board-light: #e8eddf;
    --board-dark: #3d5a4a;
    --board-highlight: rgba(16, 185, 129, 0.45);
    --board-last-move: rgba(255, 214, 0, 0.35);
    
    /* Typography */
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* ========================================
   Reset & Base
   ======================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-display);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(16, 185, 129, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 185, 129, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

/* Gradient accent blur */
body::after {
    content: '';
    position: fixed;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   Layout
   ======================================== */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ========================================
   Header
   ======================================== */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 2rem;
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.game-status {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--spacing-xl);
    flex: 1;
}

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

/* ========================================
   Board Section
   ======================================== */

.board-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.board-wrapper {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

#chessboard {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

/* Chessboard.js overrides */
.board-b72b1 {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.white-1e1d7 {
    background-color: var(--board-light) !important;
}

.black-3c85d {
    background-color: var(--board-dark) !important;
}

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

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

.board-labels {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-md);
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.turn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.turn-dot.white {
    background: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.turn-dot.black {
    background: #1a1a1a;
    border: 2px solid #666;
}

/* ========================================
   Controls
   ======================================== */

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    gap: var(--spacing-sm);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.control-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.play-btn {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #059669 100%);
    border: none;
    color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glow);
}

.control-btn.play-btn:hover {
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    transform: translateY(-3px);
    box-shadow: 0 0 40px var(--accent-glow);
}

.control-btn.play-btn svg {
    width: 28px;
    height: 28px;
}

.control-btn.play-btn.playing {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.2);
}

.speed-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.speed-control label {
    font-weight: 500;
}

#speedSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

#speedSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-fast);
}

#speedSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px var(--accent-glow);
}

#speedValue {
    font-family: var(--font-mono);
    min-width: 40px;
    color: var(--accent-primary);
}

/* ========================================
   Moves Section
   ======================================== */

.moves-section {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.moves-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.moves-header h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.move-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.moves-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-sm);
    max-height: 500px;
}

/* Custom scrollbar */
.moves-list::-webkit-scrollbar {
    width: 6px;
}

.moves-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.moves-list::-webkit-scrollbar-thumb {
    background: var(--border-accent);
    border-radius: var(--radius-full);
}

.moves-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.move-row {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.move-row:hover {
    background: var(--bg-tertiary);
}

.move-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.move-cell {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.move-cell:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.move-cell.active {
    background: var(--accent-primary);
    color: white;
    font-weight: 500;
    box-shadow: 0 0 12px var(--accent-glow);
}

.move-cell.white-move {
    background: rgba(255, 255, 255, 0.05);
}

.move-cell.black-move {
    background: rgba(0, 0, 0, 0.15);
}

.moves-footer {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--transition-normal);
}

/* ========================================
   Footer
   ======================================== */

.footer {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    margin: 0 2px;
}

/* ========================================
   Animations
   ======================================== */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.move-row {
    animation: slideIn 0.3s ease forwards;
}

/* Stagger animation for move rows */
.move-row:nth-child(1) { animation-delay: 0.02s; }
.move-row:nth-child(2) { animation-delay: 0.04s; }
.move-row:nth-child(3) { animation-delay: 0.06s; }
.move-row:nth-child(4) { animation-delay: 0.08s; }
.move-row:nth-child(5) { animation-delay: 0.10s; }
.move-row:nth-child(6) { animation-delay: 0.12s; }
.move-row:nth-child(7) { animation-delay: 0.14s; }
.move-row:nth-child(8) { animation-delay: 0.16s; }
.move-row:nth-child(9) { animation-delay: 0.18s; }
.move-row:nth-child(10) { animation-delay: 0.20s; }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .app-container {
        padding: var(--spacing-md);
    }
    
    .header {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }
    
    .board-wrapper {
        padding: var(--spacing-md);
    }
    
    .moves-section {
        order: -1;
        max-height: 250px;
    }
    
    .moves-list {
        max-height: 150px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .control-btn.play-btn {
        width: 56px;
        height: 56px;
    }
    
    .footer {
        display: none;
    }
}
