/* ============================================
   Tutorial System Styles
   - Spotlight effect
   - Neon pulse highlighting
   - Character dialogue bubbles
   - Animated tooltips
   - Progress bar
   ============================================ */

/* ==================== Base Styles ==================== */

body.tutorial-active {
    /* Allow scrolling during tutorial */
    overflow: auto;
}

/* ==================== Overlay & Spotlight ==================== */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9990;
    pointer-events: none;
}

.tutorial-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.tutorial-spotlight {
    position: absolute;
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.5),
        0 0 30px 10px rgba(255, 230, 109, 0.5),
        inset 0 0 20px rgba(255, 230, 109, 0.3);
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 9991;
}

/* ==================== Neon Highlight Effect ==================== */

.tutorial-highlight {
    position: relative;
    z-index: 9992 !important;
    pointer-events: auto !important;
    animation: tutorialNeonPulse 1.5s ease-in-out infinite;
}

@keyframes tutorialNeonPulse {
    0%, 100% {
        box-shadow:
            0 0 5px var(--accent, #ffe66d),
            0 0 10px var(--accent, #ffe66d),
            0 0 20px var(--accent, #ffe66d),
            0 0 40px rgba(255, 230, 109, 0.5);
    }
    50% {
        box-shadow:
            0 0 10px var(--accent, #ffe66d),
            0 0 20px var(--accent, #ffe66d),
            0 0 40px var(--accent, #ffe66d),
            0 0 60px rgba(255, 230, 109, 0.7);
    }
}

/* Add outline for better visibility */
.tutorial-highlight::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid var(--accent, #ffe66d);
    border-radius: inherit;
    animation: tutorialBorderPulse 1.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes tutorialBorderPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.02);
    }
}

/* ==================== Tooltip ==================== */

.tutorial-tooltip {
    position: fixed;
    z-index: 9995;
    max-width: 380px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: tutorialTooltipIn 0.4s ease-out;
}

.tutorial-tooltip.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

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

.tutorial-tooltip-content {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 35, 0.98));
    border: 2px solid var(--accent, #ffe66d);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 230, 109, 0.2);
    backdrop-filter: blur(10px);
}

.tutorial-tooltip-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent, #ffe66d);
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tutorial-tooltip-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 1.25rem 0;
}

.tutorial-tooltip-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Tooltip Arrow */
.tutorial-tooltip-arrow {
    position: absolute;
    width: 16px;
    height: 16px;
    background: rgba(30, 30, 50, 0.98);
    border: 2px solid var(--accent, #ffe66d);
    transform: rotate(45deg);
    z-index: -1;
}

.tutorial-tooltip[data-position="bottom"] .tutorial-tooltip-arrow {
    top: -10px;
    left: 50%;
    margin-left: -8px;
    border-right: none;
    border-bottom: none;
}

.tutorial-tooltip[data-position="top"] .tutorial-tooltip-arrow {
    bottom: -10px;
    left: 50%;
    margin-left: -8px;
    border-left: none;
    border-top: none;
}

.tutorial-tooltip[data-position="left"] .tutorial-tooltip-arrow {
    right: -10px;
    top: 50%;
    margin-top: -8px;
    border-left: none;
    border-bottom: none;
}

.tutorial-tooltip[data-position="right"] .tutorial-tooltip-arrow {
    left: -10px;
    top: 50%;
    margin-top: -8px;
    border-right: none;
    border-top: none;
}

/* ==================== Tutorial Close Button ==================== */

.tutorial-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10000;
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.tutorial-close-btn:hover {
    background: var(--primary, #ff6b6b);
    transform: scale(1.1);
}

.tutorial-close-btn:active {
    transform: scale(0.95);
}

/* ==================== Tutorial Buttons ==================== */

.tutorial-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.tutorial-btn-next {
    background: linear-gradient(135deg, var(--accent, #ffe66d), #ffd93d);
    color: #1a1a2e;
    border: none;
    flex: 1;
}

.tutorial-btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 230, 109, 0.4);
}

.tutorial-btn-skip {
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tutorial-btn-skip:hover {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Ensure tutorial buttons are always clickable */
.tutorial-tooltip-actions {
    position: relative;
    z-index: 10000;
}

.tutorial-tooltip-actions .tutorial-btn {
    pointer-events: auto !important;
    position: relative;
    z-index: 10001;
}

/* ==================== Character Bubble ==================== */

.tutorial-character {
    position: fixed;
    z-index: 9994;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    max-width: 400px;
    animation: tutorialCharacterIn 0.5s ease-out;
}

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

/* Character Positions */
.tutorial-character[data-position="bottom-left"] {
    bottom: 30px;
    left: 30px;
}

.tutorial-character[data-position="bottom-right"] {
    bottom: 30px;
    right: 30px;
    flex-direction: row-reverse;
}

.tutorial-character[data-position="top-left"] {
    top: 100px;
    left: 30px;
}

.tutorial-character[data-position="top-right"] {
    top: 100px;
    right: 30px;
    flex-direction: row-reverse;
}

.tutorial-character-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--accent, #ffe66d);
    box-shadow:
        0 0 20px rgba(255, 230, 109, 0.4),
        0 5px 20px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    animation: tutorialAvatarBounce 2s ease-in-out infinite;
}

@keyframes tutorialAvatarBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.tutorial-character-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tutorial-character-bubble {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 35, 0.95));
    border: 2px solid var(--primary, #ff6b6b);
    border-radius: 20px;
    padding: 1rem 1.25rem;
    position: relative;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.4);
}

/* Speech bubble tail */
.tutorial-character-bubble::before {
    content: '';
    position: absolute;
    bottom: 20px;
    width: 0;
    height: 0;
    border: 12px solid transparent;
}

.tutorial-character[data-position="bottom-left"] .tutorial-character-bubble::before,
.tutorial-character[data-position="top-left"] .tutorial-character-bubble::before {
    left: -22px;
    border-right-color: var(--primary, #ff6b6b);
}

.tutorial-character[data-position="bottom-right"] .tutorial-character-bubble::before,
.tutorial-character[data-position="top-right"] .tutorial-character-bubble::before {
    right: -22px;
    border-left-color: var(--primary, #ff6b6b);
}

.tutorial-character-name {
    font-family: 'Raze', 'Impact', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary, #ff6b6b);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
}

.tutorial-character-text {
    color: white;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Typing animation */
.tutorial-character.typing .tutorial-character-text {
    overflow: hidden;
    animation: tutorialTyping 0.5s steps(20);
}

@keyframes tutorialTyping {
    from { max-width: 0; }
    to { max-width: 100%; }
}

/* ==================== Progress Bar ==================== */

.tutorial-progress {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9996;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.tutorial-progress-bar {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.tutorial-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent, #ffe66d), var(--secondary, #4ecdc4));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.tutorial-progress-text {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==================== Completion Animation ==================== */

.tutorial-completion {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.tutorial-completion.active {
    background: rgba(0, 0, 0, 0.9);
}

.tutorial-completion-content {
    text-align: center;
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-completion.active .tutorial-completion-content {
    transform: scale(1);
    opacity: 1;
}

.tutorial-completion-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: tutorialCompleteBounce 0.6s ease-out 0.3s both;
}

@keyframes tutorialCompleteBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.tutorial-completion h2 {
    font-size: 2.5rem;
    color: var(--accent, #ffe66d);
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
    animation: tutorialCompleteSlide 0.5s ease-out 0.4s both;
}

.tutorial-completion p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    animation: tutorialCompleteSlide 0.5s ease-out 0.5s both;
}

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

/* ==================== Pointer Arrow (optional) ==================== */

.tutorial-pointer {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 9993;
    animation: tutorialPointerBounce 1s ease-in-out infinite;
    pointer-events: none;
}

.tutorial-pointer::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 20px solid transparent;
    border-top-color: var(--accent, #ffe66d);
    filter: drop-shadow(0 0 10px rgba(255, 230, 109, 0.5));
}

@keyframes tutorialPointerBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

/* ==================== Special Highlights for Specific Elements ==================== */

/* Start Button - Allow clicking even when disabled during tutorial */
#startBtn.tutorial-highlight {
    pointer-events: auto !important;
    cursor: pointer !important;
    opacity: 1 !important;
}

#startBtn.tutorial-highlight:disabled {
    background: linear-gradient(135deg, var(--primary), var(--neon-purple)) !important;
    opacity: 0.7 !important;
}

/* Colors Grid - Make all color items pop during tutorial */
.colors-grid.tutorial-highlight {
    background: rgba(30, 30, 50, 0.95);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
}

.colors-grid.tutorial-highlight .color-item {
    position: relative;
    z-index: 9993 !important;
    pointer-events: auto !important;
    animation: colorItemPulse 1.5s ease-in-out infinite;
    box-shadow:
        0 0 10px rgba(255, 230, 109, 0.5),
        0 0 20px rgba(255, 230, 109, 0.3),
        inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.colors-grid.tutorial-highlight .color-item:nth-child(odd) {
    animation-delay: 0.2s;
}

.colors-grid.tutorial-highlight .color-item:nth-child(even) {
    animation-delay: 0.4s;
}

@keyframes colorItemPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            0 0 10px rgba(255, 230, 109, 0.5),
            0 0 20px rgba(255, 230, 109, 0.3),
            inset 0 0 10px rgba(255, 255, 255, 0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow:
            0 0 15px rgba(255, 230, 109, 0.7),
            0 0 30px rgba(255, 230, 109, 0.5),
            inset 0 0 15px rgba(255, 255, 255, 0.3);
    }
}

/* Brand tabs - Make them visible during tutorial */
#brandTabs.tutorial-highlight {
    background: rgba(30, 30, 50, 0.95);
    padding: var(--spacing-sm);
    border-radius: var(--radius-lg);
}

#brandTabs.tutorial-highlight .brand-tab {
    position: relative;
    z-index: 9993 !important;
    pointer-events: auto !important;
}

/* Loadout grid - Make slots visible */
#loadoutGrid.tutorial-highlight {
    background: rgba(30, 30, 50, 0.95);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
}

#loadoutGrid.tutorial-highlight .loadout-slot {
    position: relative;
    z-index: 9993 !important;
    pointer-events: auto !important;
    animation: slotPulse 2s ease-in-out infinite;
}

@keyframes slotPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 230, 109, 0.3);
    }
    50% {
        box-shadow:
            0 0 15px rgba(255, 230, 109, 0.5),
            0 0 30px rgba(255, 230, 109, 0.3);
    }
}

/* ==================== Mobile Responsive ==================== */

@media (max-width: 767px) {
    .tutorial-tooltip {
        max-width: calc(100vw - 40px);
        left: 20px !important;
        right: 20px;
    }

    .tutorial-character {
        max-width: calc(100vw - 40px);
        flex-direction: column !important;
        align-items: flex-start;
    }

    .tutorial-character[data-position="bottom-right"],
    .tutorial-character[data-position="top-right"] {
        right: 20px;
        left: auto;
    }

    .tutorial-character[data-position="bottom-left"],
    .tutorial-character[data-position="top-left"] {
        left: 20px;
    }

    .tutorial-character-avatar {
        width: 60px;
        height: 60px;
    }

    .tutorial-character-bubble::before {
        display: none;
    }

    .tutorial-progress-bar {
        width: 150px;
    }
}
/* === MOBILE TUTORIAL FIX === */
@media (max-width: 767px) {
  .tutorial-tooltip {
    left: 50% !important;
    right: auto !important;
    bottom: 12px !important;
    top: auto !important;
    transform: translateX(-50%) !important;
    max-width: calc(100vw - 24px);
  }

  .tutorial-tooltip-content {
    max-height: 60vh;
    overflow-y: auto;
  }
}
