/* Logic Games 42 - Style École 42 */
:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-card: #252525;
    --bg-card-hover: #2d2d2d;
    --accent: #00babc;
    --accent-light: #00d4d7;
    --accent-dark: #008f91;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --success: #00c853;
    --warning: #ffc107;
    --error: #ff5252;
    --border: #333333;
    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 20px;
}

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

.logo-icon {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid var(--accent);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-link.active {
    color: var(--accent);
    background: var(--bg-secondary);
}

.stats {
    display: flex;
    gap: 20px;
}

.stat {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stat-value {
    color: var(--accent);
    font-weight: 600;
}

/* Main */
.main {
    padding: 40px 0;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Game Card */
.game-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.game-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-4px);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: opacity 0.3s;
}

.game-card:hover::before {
    opacity: 1;
}

.game-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.game-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.game-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.game-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-difficulty {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-easy {
    background: rgba(0, 200, 83, 0.2);
    color: var(--success);
}

.difficulty-medium {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
}

.difficulty-hard {
    background: rgba(255, 82, 82, 0.2);
    color: var(--error);
}

.game-points {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
}

.game-completed {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 1.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    min-height: 300px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    gap: 12px;
}

.timer {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    color: var(--accent);
    min-width: 80px;
}

.btn {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-hint {
    background: var(--bg-card);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.btn-hint:hover {
    background: rgba(255, 193, 7, 0.2);
}

.btn-reset {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-reset:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-submit {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 600;
}

.btn-submit:hover {
    background: var(--accent-light);
}

/* Game Specific Styles */

/* Sequence Memory */
.sequence-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 300px;
    margin: 0 auto;
}

.sequence-cell {
    aspect-ratio: 1;
    background: var(--bg-card);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--border);
}

.sequence-cell:hover {
    border-color: var(--accent);
}

.sequence-cell.active {
    background: var(--accent);
    border-color: var(--accent);
}

.sequence-cell.error {
    background: var(--error);
    border-color: var(--error);
}

/* Pattern Recognition */
.pattern-container {
    text-align: center;
}

.pattern-sequence {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.pattern-item {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    background: var(--bg-card);
    padding: 16px 24px;
    border-radius: 8px;
    min-width: 70px;
}

.pattern-item.unknown {
    color: var(--accent);
    border: 2px dashed var(--accent);
    background: transparent;
}

.pattern-options {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.pattern-option {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--bg-card);
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.pattern-option:hover {
    border-color: var(--accent);
}

.pattern-option.selected {
    background: var(--accent);
    color: var(--bg-primary);
}

/* Sort Algorithm */
.sort-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.sort-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
}

.sort-bar {
    width: 40px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    cursor: grab;
    transition: background 0.2s;
    position: relative;
}

.sort-bar:active {
    cursor: grabbing;
}

.sort-bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sort-bar.dragging {
    background: var(--accent-light);
    opacity: 0.8;
}

.sort-bar.correct {
    background: var(--success);
}

/* Binary Converter */
.binary-container {
    text-align: center;
}

.binary-target {
    font-family: var(--font-mono);
    font-size: 4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
}

.binary-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.binary-bits {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.binary-bit {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    width: 50px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--border);
}

.binary-bit:hover {
    border-color: var(--accent);
}

.binary-bit.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.binary-values {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.binary-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 50px;
    text-align: center;
}

.binary-result {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.binary-result span {
    color: var(--accent);
    font-weight: 600;
}

/* Logic Gates */
.gates-container {
    text-align: center;
}

.gate-diagram {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.gate-inputs {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

.gate-input {
    text-align: center;
}

.gate-input-label {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.gate-input-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
}

.gate-operation {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--warning);
    padding: 10px 20px;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 20px;
}

.gate-output-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.gate-options {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.gate-option {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.gate-option:hover {
    border-color: var(--accent);
}

.gate-option.selected {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* Tower of Hanoi */
.hanoi-container {
    text-align: center;
}

.hanoi-towers {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

.hanoi-tower {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    width: 140px;
    height: 180px;
    padding-bottom: 10px;
    background: var(--bg-card);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.hanoi-tower::before {
    content: '';
    position: absolute;
    bottom: 10px;
    width: 6px;
    height: 140px;
    background: var(--border);
    border-radius: 3px;
}

.hanoi-tower:hover {
    border-color: var(--accent);
}

.hanoi-tower.selected {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.hanoi-disk {
    height: 25px;
    border-radius: 6px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bg-primary);
    margin-top: 4px;
}

.hanoi-disk-1 { width: 40px; background: #ff5252; }
.hanoi-disk-2 { width: 60px; background: #ffc107; }
.hanoi-disk-3 { width: 80px; background: #00c853; }
.hanoi-disk-4 { width: 100px; background: #2196f3; }
.hanoi-disk-5 { width: 120px; background: #9c27b0; }

.hanoi-labels {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.hanoi-label {
    width: 140px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.hanoi-moves {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 20px;
}

.hanoi-moves span {
    color: var(--accent);
    font-weight: 600;
}

/* Maze Solver */
.maze-container {
    text-align: center;
}

.maze-grid {
    display: inline-grid;
    gap: 2px;
    background: var(--border);
    padding: 2px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.maze-cell {
    width: 30px;
    height: 30px;
    background: var(--bg-card);
    transition: background 0.2s;
}

.maze-cell.wall {
    background: var(--bg-primary);
}

.maze-cell.start {
    background: var(--success);
}

.maze-cell.end {
    background: var(--error);
}

.maze-cell.path {
    background: var(--accent);
}

.maze-cell.visited {
    background: rgba(0, 186, 188, 0.3);
}

.maze-instructions {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.maze-instructions kbd {
    font-family: var(--font-mono);
    background: var(--bg-card);
    padding: 4px 8px;
    border-radius: 4px;
    margin: 0 4px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.animate-pulse {
    animation: pulse 0.5s ease-in-out;
}

.animate-shake {
    animation: shake 0.3s ease-in-out;
}

/* Success/Error feedback */
.feedback {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    z-index: 2000;
    transform: translateX(120%);
    transition: transform 0.3s;
}

.feedback.show {
    transform: translateX(0);
}

.feedback.success {
    background: var(--success);
    color: var(--bg-primary);
}

.feedback.error {
    background: var(--error);
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .games-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-height: none;
        min-height: 100vh;
        border-radius: 0;
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .hanoi-towers {
        gap: 20px;
    }

    .hanoi-tower {
        width: 100px;
    }

    .hanoi-label {
        width: 100px;
        font-size: 0.75rem;
    }
}
