/* =====================================================================
   tutorial.css     Retro game-like tutorial overlay
   ===================================================================== */

#tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Tajawal', sans-serif;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    background: rgba(0, 0, 0, 0.92);
    transition: background 0.4s ease;
}

#tutorial-overlay.focus-mode {
    background: transparent;
    pointer-events: none;
}

#tutorial-overlay.focus-mode .tutorial-container,
#tutorial-overlay.focus-mode .tutorial-skip,
#tutorial-overlay.focus-mode .tutorial-sound-toggle {
    pointer-events: auto;
}

#tutorial-overlay.focus-mode::before,
#tutorial-overlay.focus-mode::after {
    opacity: 0;
}

#tutorial-overlay.hidden {
    display: none !important;
}

/* CRT scanlines */
#tutorial-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.12) 0px,
        rgba(0, 0, 0, 0.12) 1px,
        transparent 1px,
        transparent   3px
    );
    pointer-events: none;
    z-index: 2;
}

/* CRT flicker */
#tutorial-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(18, 16, 16, 0.04);
    pointer-events: none;
    z-index: 3;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.95; }
    50% { opacity: 1; }
    100% { opacity: 0.98; }
}

.tutorial-container {
    position: relative;
    width: 90%;
    max-width: 700px;
    text-align: center;
    z-index: 1;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus mode: minimize character and dialog */
#tutorial-overlay.focus-mode .tutorial-container {
    position: fixed;
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 90vw;
}

#tutorial-overlay.focus-mode .tutorial-character {
    width: 80px;
    height: 80px;
    margin: 0;
    flex-shrink: 0;
}

#tutorial-overlay.focus-mode .tutorial-character-img {
    width: 100%;
    height: 100%;
}

#tutorial-overlay.focus-mode .tutorial-name {
    font-size: 11px;
    margin-top: 4px;
}

#tutorial-overlay.focus-mode .tutorial-dialog {
    margin: 0;
    padding: 12px 16px;
    min-height: auto;
    max-width: 400px;
}

#tutorial-overlay.focus-mode .tutorial-text {
    font-size: 12px;
    line-height: 1.8;
    min-height: auto;
}

#tutorial-overlay.focus-mode .tutorial-progress {
    display: none;
}

#tutorial-overlay.focus-mode .tutorial-bubble-counter {
    display: none;
}

#tutorial-overlay.focus-mode .tutorial-btn {
    font-size: 11px;
    padding: 8px 14px;
}

/* Character avatar */
.tutorial-character {
    width: 180px;
    height: 180px;
    margin: 0 auto 24px;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.tutorial-character-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
    animation: bob 2s ease-in-out infinite;
}

.tutorial-name {
    color: #ffd700;
    font-size: 12px;
    margin-top: 8px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    letter-spacing: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tutorial-name {
    color: #ffd700;
    font-size: 12px;
    margin-top: 8px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    letter-spacing: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Speech bubble dialog */
.tutorial-dialog {
    background: #0a0a0a;
    border: 3px solid #333;
    border-radius: 999px;
    padding: 20px 28px;
    margin: 16px auto;
    position: relative;
    box-shadow:
        0 0 0 1px #000,
        0 0 30px rgba(0, 0, 0, 0.8),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
    min-height: 100px;
    max-width: 90%;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Speech bubble arrow */
.tutorial-dialog::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #333;
}

.tutorial-dialog::after {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #0a0a0a;
}

.tutorial-text {
    color: #ffd700;
    font-size: 15px;
    line-height: 2;
    text-align: right;
    direction: rtl;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
    min-height: 50px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.tutorial-text .cursor {
    display: inline-block;
    width: 10px;
    height: 16px;
    background: #ffd700;
    margin-right: 4px;
    animation: blink 0.7s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Bubble counter */
.tutorial-bubble-counter {
    color: #555;
    font-size: 12px;
    margin-top: 8px;
}

/* Progress bar */
.tutorial-progress {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
}

.tutorial-progress-dot {
    width: 12px;
    height: 12px;
    border: 2px solid #333;
    border-radius: 50%;
    transition: all 0.3s;
}

.tutorial-progress-dot.active {
    border-color: #ffd700;
    background: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.tutorial-progress-dot.done {
    border-color: #ffd700;
    background: #ffd700;
}

/* Buttons */
.tutorial-btn {
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    padding: 12px 24px;
    border: 2px solid #333;
    background: #0a0a0a;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tutorial-btn:hover {
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.tutorial-btn.primary {
    border-color: #ffd700;
    color: #ffd700;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.4); }
}

.tutorial-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tutorial-skip {
    position: absolute;
    top: 20px;
    left: 20px;
    font-family: 'Tajawal', sans-serif;
    font-size: 12px;
    color: #555;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
}

.tutorial-skip:hover {
    color: #888;
}

/* Highlight spotlight */
.tutorial-spotlight {
    position: fixed;
    z-index: 99998;
    pointer-events: none;
    border: 3px solid #ffd700;
    border-radius: 8px;
    box-shadow:
        0 0 30px rgba(255, 215, 0, 0.3),
        inset 0 0 20px rgba(255, 215, 0, 0.1);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.tutorial-spotlight.visible {
    opacity: 1;
}

.tutorial-spotlight::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 8px;
    animation: spotlight-pulse 1.5s ease-in-out infinite;
}

@keyframes spotlight-pulse {
    0%, 100% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 50px rgba(255, 215, 0, 0.6); }
}

/* Pointer arrow */
.tutorial-pointer {
    position: fixed;
    z-index: 99999;
    font-size: 24px;
    color: #ffd700;
    pointer-events: none;
    animation: point-bounce 0.8s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
}

.tutorial-pointer.visible {
    opacity: 1;
}

@keyframes point-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Tutorial background block */
.tutorial-blocker {
    position: fixed;
    inset: 0;
    z-index: 99997;
    background: transparent;
    pointer-events: all;
}

/* Sound toggle */
.tutorial-sound-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 16px;
    background: none;
    border: 1px solid #333;
    color: #666;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tutorial-sound-toggle:hover {
    border-color: #666;
    color: #aaa;
}

/* Completion screen */
.tutorial-complete {
    animation: complete-in 0.5s ease-out;
}

@keyframes complete-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tutorial-complete-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: celebrate 0.6s ease-in-out;
}

@keyframes celebrate {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
    .tutorial-text {
        font-size: 12px;
        line-height: 1.8;
    }

    .tutorial-dialog {
        padding: 16px;
        min-height: 80px;
    }

    .tutorial-btn {
        font-size: 11px;
        padding: 10px 16px;
    }

    .tutorial-character {
        width: 120px;
        height: 120px;
    }

    .tutorial-character-img {
        width: 100%;
        height: 100%;
    }

    #tutorial-overlay.focus-mode .tutorial-container {
        flex-direction: column;
        align-items: center;
        max-width: 90vw;
    }

    #tutorial-overlay.focus-mode .tutorial-dialog {
        max-width: 90vw;
    }
}

/* ===== PROFESSIONAL tutorial buttons (cyan theme) ===== */
.tutorial-btn { font-family: Tajawal, sans-serif; font-size: 14px; font-weight: 800; padding: 13px 26px; border-radius: 14px; border: 1px solid rgba(125,211,252,0.4); background: linear-gradient(180deg, rgba(125,211,252,0.12), rgba(13,22,34,0.85)); color: #cfeaff; cursor: pointer; transition: all 0.25s ease; text-transform: none; letter-spacing: 0; box-shadow: 0 4px 14px rgba(0,0,0,0.35), inset 0 1px 0 rgba(125,211,252,0.15); }
.tutorial-btn:hover { border-color: rgba(125,211,252,0.85); color: #fff; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.45), 0 0 22px rgba(125,211,252,0.35), inset 0 1px 0 rgba(125,211,252,0.25); }
.tutorial-btn:active { transform: translateY(0); }
.tutorial-btn.primary { border-color: rgba(125,211,252,0.9); color: #0a1622; background: linear-gradient(135deg, #7dd3fc, #3b82f6 60%, #83f2d0); box-shadow: 0 6px 22px rgba(125,211,252,0.45), 0 0 30px rgba(125,211,252,0.3); animation: tutorialPrimaryPulse 2.4s infinite ease-in-out; }
@keyframes tutorialPrimaryPulse { 0%,100% { box-shadow: 0 6px 22px rgba(125,211,252,0.45), 0 0 30px rgba(125,211,252,0.3); } 50% { box-shadow: 0 6px 28px rgba(125,211,252,0.6), 0 0 44px rgba(125,211,252,0.45); } }
.tutorial-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tutorial-skip { color: #7dd3fc; font-weight: 800; text-decoration: underline; }
.tutorial-skip:hover { color: #aee6ff; }
