/**
 * Haunted Lineage Lab - Tutorial System Styles
 * Overlay, highlights, and tutorial card UI
 */

/* Tutorial Overlay - Creates dark background with spotlight cutout */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483600 !important;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.tutorial-overlay.active {
    display: block;
    opacity: 1;
    z-index: 2147483600 !important;
}

/* Ensure elements in spotlight are interactive if needed */
#tutorial-highlight {
    pointer-events: none;
    z-index: 2147483630 !important;
}

/* Keep the application visible. The target is emphasized with a border only. */
.tutorial-overlay::before,
.tutorial-overlay::after {
    display: none;
}

/* Tutorial Card - Main tutorial UI container */
.tutorial-card {
    position: fixed;
    bottom: auto;
    top: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: rgba(10, 14, 22, 0.98) !important;
    border: 2px solid var(--success, #10b981) !important;
    border-radius: var(--border-radius-lg, 12px);
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(16, 185, 129, 0.5), 0 0 24px rgba(16, 185, 129, 0.35) !important;
    z-index: 2147483645 !important;
    animation: slideInRight 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    pointer-events: auto;
    transition: top 0.25s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.25s cubic-bezier(0.16, 1, 0.3, 1), left 0.25s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Tutorial Card Header */
.tutorial-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(16, 185, 129, 0.35);
}

.tutorial-step-counter {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tutorial-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Tutorial Card Body */
.tutorial-card-body {
    padding: 16px 20px;
}

.tutorial-title {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.tutorial-description {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tutorial Card Footer */
.tutorial-card-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(16, 185, 129, 0.35);
}

.tutorial-nav-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.tutorial-next-btn,
.tutorial-prev-btn {
    flex: 1;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tutorial-next-btn {
    background: var(--accent);
    color: white;
}

.tutorial-next-btn:hover {
    background: #e41111;
    transform: translateY(-2px);
}

.tutorial-prev-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.tutorial-prev-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tutorial-skip-link {
    width: 100%;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.tutorial-skip-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Element Highlight - Spotlight cutout overlay */
#tutorial-highlight {
    position: fixed;
    display: none;
    z-index: 2147483630 !important;
    border: 2.5px solid #ffffff;
    border-radius: 6px;
    pointer-events: none;
    box-sizing: border-box !important;
    box-shadow: 0 0 0 2.5px rgba(212, 17, 17, 0.95), 0 0 16px 4px rgba(255, 255, 255, 0.85), 0 0 28px 7px rgba(212, 17, 17, 0.75);
    animation: tutorialHighlightPulse 1.25s ease-in-out infinite;
    transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}

@keyframes tutorialHighlightPulse {
    0%, 100% {
        border-color: #ffffff;
        opacity: 1;
        box-shadow: 0 0 0 2.5px rgba(212, 17, 17, 0.95), 0 0 14px 3px rgba(255, 255, 255, 0.8), 0 0 24px 5px rgba(212, 17, 17, 0.6);
    }
    50% {
        border-color: #ff3b30;
        opacity: 0.88;
        box-shadow: 0 0 0 3.5px rgba(255, 255, 255, 0.95), 0 0 22px 6px rgba(255, 255, 255, 0.95), 0 0 36px 10px rgba(212, 17, 17, 0.9);
    }
}

/* Tutorial Prompt Modal - Initial welcome screen */
.tutorial-prompt-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2147483640 !important;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tutorial-prompt-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
    padding: 40px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    animation: slideInDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.tutorial-prompt-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent), #ff4444);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin: 0 auto 24px;
    box-shadow: 0 8px 24px rgba(212, 17, 17, 0.3);
}

.tutorial-prompt-content h2 {
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.tutorial-prompt-content p {
    margin: 0 0 24px 0;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tutorial-prompt-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.tutorial-prompt-buttons .btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

#tutorial-start-btn {
    background: var(--accent);
    color: white;
}

#tutorial-start-btn:hover {
    background: #e41111;
    transform: translateY(-2px);
}

#tutorial-skip-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

#tutorial-skip-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tutorial-prompt-footer {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .tutorial-card {
        width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(56vh - env(safe-area-inset-top, 0px)) !important;
        box-sizing: border-box !important;
    }

    .tutorial-card-body {
        padding: 12px 16px;
    }

    .tutorial-title {
        font-size: 16.5px;
        margin-bottom: 8px;
        color: #ffffff !important;
        font-weight: 700;
    }

    .tutorial-description {
        font-size: 13.5px;
        line-height: 1.5;
        color: #e2e8f0 !important;
    }

    .tutorial-card-footer {
        padding: 10px 16px 14px;
    }

    .tutorial-nav-buttons .btn {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 42px;
    }

    .tutorial-prompt-content {
        padding: 24px 18px;
        width: calc(100vw - 32px);
        max-width: 420px;
        box-sizing: border-box;
    }

    .tutorial-prompt-content h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .tutorial-prompt-content p {
        font-size: 13.5px;
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    .tutorial-card {
        max-height: calc(56vh - env(safe-area-inset-top, 0px)) !important;
    }

    .tutorial-prompt-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
        margin-bottom: 16px;
    }
}

/* Active Tutorial Overrides - Prevent backdrop overlays from hiding content */
body.tutorial-active #tools-quick-menu-modal {
    background: rgba(0, 0, 0, 0.45) !important;
}

body.tutorial-active .sidebar-backdrop {
    background: rgba(0, 0, 0, 0.35) !important;
}

/* Accessibility - Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .tutorial-overlay,
    .tutorial-card,
    .tutorial-close-btn,
    .tutorial-next-btn,
    .tutorial-prev-btn,
    .tutorial-skip-link,
    #tutorial-highlight {
        animation: none !important;
        transition: none !important;
    }
}
