/* ==========================================================================
   CKE Gaming Arena - Main Design System (CSS)
   ========================================================================== */

:root {
    --bg-darkest: #0a0e17;
    --bg-dark: #111827;
    --bg-surface: #1f2937;
    --bg-surface-elevated: #374151;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(59, 130, 246, 0.4);
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.25);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ==========================================================================
   Hub / Navigation Bar
   ========================================================================== */

.top-navbar {
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.brand-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
}

.brand-badge {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-icon {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

.btn-icon:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-secondary:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--text-secondary);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45);
}

/* Wskaźnik postępu w pasku nawigacji */
.brand-progress-badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fbbf24;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Game Engine Layout (game.html)
   ========================================================================== */

.game-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: calc(100vh - 65px);
    overflow: hidden;
}

/* Pasek poziomów u góry gry */
.levels-bar-container {
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow-x: auto;
    white-space: nowrap;
}

.level-pills {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    list-style: none;
}

.level-pill {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}

.level-pill:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.level-pill.completed {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.level-pill.completed::after {
    content: "✓";
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: var(--success);
    color: black;
    font-size: 0.65rem;
    font-weight: 900;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-pill.active {
    background: var(--accent);
    border-color: white;
    color: white;
    box-shadow: 0 0 12px var(--accent);
    transform: scale(1.1);
}

.level-pill.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================================================
   Two-Pane Workspace (Editor & Live Preview)
   ========================================================================== */

.game-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* Panel lewy: Treść zadania + Edytor */
.workspace-left {
    background: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.5rem;
}

.level-header-tags {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tag-phase {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    text-transform: uppercase;
}

.tag-exam {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-weight: 600;
}

.tag-points {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.level-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.level-instruction {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

/* Pułapka egzaminacyjna CKE */
.cke-trap-box {
    background: rgba(245, 158, 11, 0.08);
    border-left: 4px solid var(--warning);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 0.85rem 1.15rem;
    margin-bottom: 1.5rem;
}

.cke-trap-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.cke-trap-desc {
    font-size: 0.9rem;
    color: #e2e8f0;
    line-height: 1.5;
}

/* Edytor kodu */
.editor-container {
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
}

.editor-header {
    background: #161b22;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.editor-body {
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    background: #0d1117;
    position: relative;
}

.slot-editor {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.slot-locked {
    color: #6e7681;
    white-space: pre-wrap;
    user-select: none;
}

.slot-input {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: var(--radius-sm);
    color: #e6edf3;
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 0.4rem 0.6rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.slot-input:focus {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.full-editor-textarea {
    width: 100%;
    min-height: 160px;
    background: transparent;
    border: none;
    color: #e6edf3;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    outline: none;
    resize: vertical;
}

/* Pasek akcji edytora */
.workspace-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.feedback-box {
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-top: auto;
    display: none;
}

.feedback-box.active {
    display: block;
}

.feedback-box.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
    color: #34d399;
}

.feedback-box.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #f87171;
}

.feedback-box.warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    color: #fbbf24;
}

/* ==========================================================================
   Panel prawy: Live Preview & Thematic Sandbox
   ========================================================================== */

.workspace-right {
    background: var(--bg-darkest);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.preview-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.preview-header {
    background: rgba(31, 41, 55, 0.5);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.preview-canvas {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    min-height: 350px;
}

/* ==========================================================================
   Modale (Hints, Reset, Victory)
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.modal-backdrop.open .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

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

.hint-step {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.hint-step-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.hint-step-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Tryb Embed (?embed=true)
   ========================================================================== */

body.embed-mode .top-navbar {
    display: none !important;
}

body.embed-mode .game-container {
    height: 100vh !important;
}

/* ==========================================================================
   Responsywność (Mobile / Tablet)
   ========================================================================== */

@media (max-width: 900px) {
    .game-workspace {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .workspace-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: auto;
    }

    .readiness-card {
        flex-direction: column;
        text-align: center;
        gap: 1.25rem;
    }

    .readiness-info {
        text-align: center;
    }

    .readiness-percentage {
        text-align: center;
    }
}
