/* ============================================================
   PyQuest Walkthrough — Duolingo-Style Interactive Cards
   ============================================================ */

/* --- Layout & Background --- */
.wt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f5;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Top Bar (progress + close) --- */
.wt-topbar {
    width: 100%;
    max-width: 640px;
    padding: 20px 24px 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wt-close-btn {
    background: transparent !important;
    border: none !important;
    font-size: 24px;
    color: #aaa;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 100% !important;
    transition: background 0.2s;
}

.wt-close-btn:hover {
    background: #e0e0e0 !important;
    color: #333;
	border-radius: 100% !important;
}

/* --- Progress Bar --- */
.wt-progress-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wt-progress-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.wt-progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.wt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6C63FF, #9b59b6);
    border-radius: 5px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- XP & Streak display --- */
.wt-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 24px;
    max-width: 640px;
    width: 100%;
    box-sizing: border-box;
}

.wt-xp-badge {
    font-size: 14px;
    font-weight: 600;
    color: #6C63FF;
    background: rgba(108, 99, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
}

.wt-streak-badge {
    font-size: 14px;
    font-weight: 600;
    color: #e67e22;
    background: rgba(230, 126, 34, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    transition: transform 0.3s;
}

.wt-streak-badge.pulse {
    animation: streakPulse 0.5s ease;
}

/* --- Card Container --- */
.wt-card-area {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px 24px 100px;
    width: 100%;
    box-sizing: border-box;
}

.wt-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 28px;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    animation: cardSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* --- Step Type Badge --- */
.wt-type-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.wt-type-badge.info {
    background: #e3f2fd;
    color: #1565c0;
}

.wt-type-badge.code_demo {
    background: #e8f5e9;
    color: #2e7d32;
}

.wt-type-badge.predict {
    background: #fff3e0;
    color: #e65100;
}

.wt-type-badge.fill_blank {
    background: #fce4ec;
    color: #c62828;
}

.wt-type-badge.write_code {
    background: #ede7f6;
    color: #4527a0;
}

.wt-type-badge.quiz {
    background: #fff8e1;
    color: #f57f17;
}

/* --- Card Content --- */
.wt-card-content {
    font-size: 17px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
}

.wt-card-content strong {
    color: #222;
}

.wt-instruction {
    font-size: 16px;
    color: #444;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* --- Code Block --- */
.wt-code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    padding: 16px 20px;
    border-radius: 12px;
    margin: 12px 0;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.6;
}

/* --- Output Block --- */
.wt-output-block {
    background: #f8f9fa;
    border-left: 4px solid #6C63FF;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    color: #333;
    margin: 12px 0;
    white-space: pre;
    display: none;
}

.wt-output-block.visible {
    display: block;
    animation: fadeSlideUp 0.3s ease;
}

/* --- Explanation --- */
.wt-explanation {
    background: rgba(108, 99, 255, 0.06);
    border-radius: 12px;
    padding: 14px 18px;
    margin-top: 12px;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
    display: none;
}

.wt-explanation.visible {
    display: block;
    animation: fadeSlideUp 0.3s ease;
}

/* --- Buttons --- */
.wt-btn {
    display: inline-block;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.wt-btn:active {
    transform: scale(0.96);
}

.wt-btn-primary {
    background: #6C63FF;
    color: #fff;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.wt-btn-primary:hover {
    background: #5a52e0;
    box-shadow: 0 6px 16px rgba(108, 99, 255, 0.4);
}

.wt-btn-run {
    background: #2ecc71;
    color: #fff;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.wt-btn-run:hover {
    background: #27ae60;
}

.wt-btn-continue {
    background: #6C63FF;
    color: #fff;
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.wt-btn-continue:hover {
    background: #5a52e0;
}

.wt-btn-continue:disabled {
    background: #ccc;
    color: #888;
    box-shadow: none;
    cursor: not-allowed;
}

/* --- Option Buttons (predict/quiz) --- */
.wt-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.wt-option-btn {
    width: 100%;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 500;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    color: #333;
}

.wt-option-btn:hover {
    border-color: #6C63FF;
    background: rgba(108, 99, 255, 0.04);
}

.wt-option-btn.correct {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
    animation: correctPulse 0.5s ease;
}

.wt-option-btn.wrong {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.08);
    color: #e74c3c;
    animation: shakeWrong 0.4s ease;
}

.wt-option-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* --- Fill Blank Input --- */
.wt-fill-container {
    display: flex;
    align-items: center;
    gap: 0;
    background: #1e1e2e;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 12px 0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    color: #cdd6f4;
    flex-wrap: wrap;
}

.wt-fill-input {
    border: none;
    border-bottom: 2px dashed #6C63FF;
    background: rgba(108, 99, 255, 0.15);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    padding: 4px 8px;
    min-width: 80px;
    max-width: 160px;
    outline: none;
    border-radius: 4px;
    transition: border-color 0.2s;
}

.wt-fill-input:focus {
    border-bottom-color: #a29bfe;
    background: rgba(108, 99, 255, 0.25);
}

.wt-fill-input.correct {
    border-bottom-color: #2ecc71;
    background: rgba(46, 204, 113, 0.2);
}

.wt-fill-input.wrong {
    border-bottom-color: #e74c3c;
    background: rgba(231, 76, 60, 0.2);
    animation: shakeWrong 0.4s ease;
}

/* --- Write Code Textarea --- */
.wt-code-editor {
    width: 100%;
    min-height: 100px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    padding: 16px 20px;
    border-radius: 12px;
    border: 2px solid transparent;
    outline: none;
    resize: vertical;
    margin: 12px 0;
    line-height: 1.6;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.wt-code-editor:focus {
    border-color: #6C63FF;
}

.wt-code-editor.correct {
    border-color: #2ecc71;
}

.wt-code-editor.wrong {
    border-color: #e74c3c;
}

/* --- Hint --- */
.wt-hint {
    font-size: 13px;
    color: #888;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    display: none;
}

.wt-hint.visible {
    display: block;
    animation: fadeSlideUp 0.3s ease;
}

.wt-hint-btn {
    background: none;
    border: none;
    color: #6C63FF;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 500;
    margin-top: 8px;
}

.wt-hint-btn:hover {
    text-decoration: underline;
}

/* --- XP Popup --- */
.wt-xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #6C63FF;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    padding: 10px 24px;
    border-radius: 30px;
    pointer-events: none;
    animation: xpFloat 1.2s ease forwards;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.5);
}

/* --- Completion Screen --- */
.wt-complete {
    text-align: center;
    padding: 40px 28px;
}

.wt-complete-emoji {
    font-size: 64px;
    margin-bottom: 16px;
}

.wt-complete-title {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.wt-complete-subtitle {
    font-size: 16px;
    color: #666;
    margin-bottom: 24px;
}

.wt-complete-xp {
    font-size: 36px;
    font-weight: 700;
    color: #6C63FF;
    margin-bottom: 32px;
}

.wt-complete-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.wt-complete-buttons .wt-btn {
    min-width: 140px;
}

.wt-btn-secondary {
    background: #f0f0f5;
    color: #6C63FF;
    border: 2px solid #6C63FF;
}

.wt-btn-secondary:hover {
    background: rgba(108, 99, 255, 0.08);
}

/* --- Action Row --- */
.wt-action-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
    flex-wrap: wrap;
}

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

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

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

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes shakeWrong {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes xpFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -80%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(0.8);
    }
}

@keyframes streakPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .wt-card {
        padding: 24px 20px;
        border-radius: 16px;
    }

    .wt-topbar {
        padding: 16px 16px 0;
    }

    .wt-card-content {
        font-size: 16px;
    }

    .wt-code-block,
    .wt-code-editor {
        font-size: 13px;
        padding: 12px 14px;
    }

    .wt-complete-title {
        font-size: 24px;
    }
}
