/* ============================================
   404 Error Page - Perfect Chess Academy
   Modern, Professional, Production-Ready
   ============================================ */

/* ========== CSS Reset & Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --color-primary: #D4AF37;
    --color-primary-dark: #B8941F;
    --color-primary-light: #F0D77D;
    --color-secondary: #1a1a1a;
    --color-background: #0A0A0A;
    --color-surface: #1A1A1A;
    --color-text-primary: #FFFFFF;
    --color-text-secondary: #B0B0B0;
    --color-chess-light: #F0D9B5;
    --color-chess-dark: #B58863;
    --color-error: #DC3545;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.6;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(212, 175, 55, 0.3);
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height-base);
    color: var(--color-text-primary);
    background-color: var(--color-background);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== Page Layout ========== */
.page-wrapper {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    overflow: hidden;
}

/* ========== Animated Chessboard Background ========== */
.chessboard-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 800px;
    height: 800px;
    opacity: 0;
    animation: fadeInChessboard 1s ease-out 0.3s forwards;
    pointer-events: none;
}

@keyframes fadeInChessboard {
    to {
        opacity: 0.08;
    }
}

.chessboard {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
}

.chess-row {
    display: contents;
}

.chess-square {
    width: 100%;
    height: 100%;
    animation: pulseSquare 4s ease-in-out infinite;
}

.chess-square.light {
    background-color: var(--color-chess-light);
    animation-delay: calc(var(--square-index, 0) * 0.05s);
}

.chess-square.dark {
    background-color: var(--color-chess-dark);
    animation-delay: calc(var(--square-index, 0) * 0.05s);
}

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

/* Add delay variation to squares */
.chess-row:nth-child(1) .chess-square:nth-child(1) { --square-index: 1; }
.chess-row:nth-child(1) .chess-square:nth-child(2) { --square-index: 2; }
.chess-row:nth-child(1) .chess-square:nth-child(3) { --square-index: 3; }
.chess-row:nth-child(1) .chess-square:nth-child(4) { --square-index: 4; }
.chess-row:nth-child(1) .chess-square:nth-child(5) { --square-index: 5; }
.chess-row:nth-child(1) .chess-square:nth-child(6) { --square-index: 6; }
.chess-row:nth-child(1) .chess-square:nth-child(7) { --square-index: 7; }
.chess-row:nth-child(1) .chess-square:nth-child(8) { --square-index: 8; }

/* ========== Main Content ========== */
.content-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 600px;
}

.error-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

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

/* ========== Error Code Styling ========== */
.error-code-wrapper {
    margin-bottom: var(--spacing-xl);
}

.error-code {
    font-size: clamp(6rem, 20vw, 12rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.02em;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1rem);
}

.digit {
    display: inline-block;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: digitFloat 3s ease-in-out infinite;
    text-shadow: 0 0 60px rgba(212, 175, 55, 0.5);
    filter: drop-shadow(0 4px 20px rgba(212, 175, 55, 0.4));
}

.digit:nth-child(1) {
    animation-delay: 0s;
}

.digit:nth-child(2) {
    animation-delay: 0.3s;
}

.digit:nth-child(3) {
    animation-delay: 0.6s;
}

.center-digit {
    position: relative;
}

.center-digit::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.3) 0%, transparent 70%);
    animation: glow 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes digitFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes glow {
    0%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* ========== Error Message ========== */
.error-message {
    margin-bottom: var(--spacing-xl);
}

.error-message h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.01em;
}

.error-message p {
    font-size: clamp(1rem, 2vw, 1.125rem);
    color: var(--color-text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ========== Action Buttons ========== */
.action-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: var(--spacing-xl);
}

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-base);
    overflow: hidden;
    border: none;
    cursor: pointer;
    min-width: 160px;
    font-family: var(--font-family);
}

.btn-text {
    position: relative;
    z-index: 2;
    transition: transform var(--transition-base);
}

.btn-hover-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    transition: transform var(--transition-base);
    transform: translateY(100%);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-secondary);
    box-shadow: var(--shadow-md);
}

.btn-primary .btn-hover-effect {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover .btn-hover-effect {
    transform: translateY(0);
}

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

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary .btn-hover-effect {
    background: var(--color-primary);
}

.btn-secondary:hover {
    color: var(--color-secondary);
    transform: translateY(-2px);
}

.btn-secondary:hover .btn-hover-effect {
    transform: translateY(0);
}

.btn-secondary:hover .btn-text {
    color: var(--color-secondary);
}

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

/* ========== Help Section ========== */
.help-section {
    margin-top: var(--spacing-2xl);
    padding-top: var(--spacing-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.help-text {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
}

.help-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.help-link:hover {
    color: var(--color-primary-light);
    text-decoration: underline;
}

/* ========== Search Form ========== */
.search-form {
    display: flex;
    max-width: 400px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color var(--transition-base);
}

.search-form:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    font-size: 0.875rem;
    font-family: var(--font-family);
    outline: none;
}

.search-input::placeholder {
    color: var(--color-text-secondary);
}

.search-btn {
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.search-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--color-primary-light);
}

.search-btn svg {
    width: 20px;
    height: 20px;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .page-wrapper {
        padding: var(--spacing-md);
    }
    
    .chessboard-container {
        width: 600px;
        height: 600px;
    }
    
    .error-message p {
        font-size: 1rem;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .chessboard-container {
        width: 400px;
        height: 400px;
    }
    
    .help-section {
        margin-top: var(--spacing-xl);
        padding-top: var(--spacing-lg);
    }
}

/* ========== Accessibility ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus-visible,
.help-link:focus-visible,
.search-btn:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

.search-input:focus {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-primary: #FFD700;
        --color-text-secondary: #CCCCCC;
    }
    
    .chess-square {
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
}
