/**
 * Guided Walkthrough Styles
 * Styles for the interactive walkthrough overlay system
 */

/* ============================================
   Backdrop Layer
   ============================================ */

.walkthrough-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;  /* Let spotlight's box-shadow create the overlay */
    z-index: 1998;
    pointer-events: none;  /* Allow clicks to pass through */
    animation: walkthroughFadeIn 0.3s ease-in;
}

/* ============================================
   Spotlight Effect
   ============================================ */

.walkthrough-spotlight {
    position: fixed;
    border: 3px solid var(--mud-palette-info, #594ae2);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7),
                0 0 20px rgba(89, 74, 226, 0.5),
                inset 0 0 20px rgba(89, 74, 226, 0.3);
    z-index: 1999;
    pointer-events: none;
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease-in-out;
    animation: walkthroughPulse 2s ease-in-out infinite;
    opacity: 1;
}

.walkthrough-spotlight.transitioning {
    opacity: 0;
    transform: scale(0.95);
}

/* ============================================
   Highlighted Element Boost
   ============================================ */

.walkthrough-highlight-boost {
    /* Applied dynamically via JavaScript */
    position: relative !important;
    z-index: 2001 !important;
    transition: z-index 0.3s ease;
    isolation: isolate;  /* Create new stacking context */
}

/* Ensure all children of highlighted elements are also above backdrop */
.walkthrough-highlight-boost *,
.walkthrough-highlight-boost *::before,
.walkthrough-highlight-boost *::after {
    /*position: relative !important;*/
    z-index: inherit !important;
}

/* ============================================
   Help Popup
   ============================================ */

.walkthrough-help-popup {
    position: fixed;
    z-index: 2002;
    background: var(--mud-palette-surface, #ffffff);
    color: var(--mud-palette-text-primary, #000000);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                0 2px 8px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    min-width: 280px;
    animation: walkthroughSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

    .walkthrough-help-popup h6 {
        margin: 0 0 0.75rem 0;
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--mud-palette-info, #594ae2);
    }

.walkthrough-help-popup p {
    margin: 0 0 1.25rem 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--mud-palette-text-primary, #333333);
}

/* ============================================
   Navigation Controls
   ============================================ */

.walkthrough-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--mud-palette-divider, #e0e0e0);
}

/* ============================================
   Progress Indicator
   ============================================ */

.walkthrough-progress {
    margin-top: 1rem;
    padding-top: 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary, #666666);
    border-top: 1px solid var(--mud-palette-divider, #e0e0e0);
}

.walkthrough-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--mud-palette-divider, #e0e0e0);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.walkthrough-progress-bar-fill {
    height: 100%;
    background: var(--mud-palette-primary, #594ae2);
    transition: width 0.3s ease;
}

/* ============================================
   Positioning Classes
   ============================================ */

.walkthrough-help-popup.position-top {
    transform-origin: bottom center;
}

.walkthrough-help-popup.position-bottom {
    transform-origin: top center;
}

.walkthrough-help-popup.position-left {
    transform-origin: right center;
}

.walkthrough-help-popup.position-right {
    transform-origin: left center;
}

.walkthrough-help-popup.position-center {
    transform-origin: center center;
}

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

.walkthrough-help-popup::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    display: none; /* Enable with .with-arrow class */
}

.walkthrough-help-popup.with-arrow.position-top::before {
    display: block;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: var(--mud-palette-surface, #ffffff);
}

.walkthrough-help-popup.with-arrow.position-bottom::before {
    display: block;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: var(--mud-palette-surface, #ffffff);
}

.walkthrough-help-popup.with-arrow.position-left::before {
    display: block;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: var(--mud-palette-surface, #ffffff);
}

.walkthrough-help-popup.with-arrow.position-right::before {
    display: block;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: var(--mud-palette-surface, #ffffff);
}

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

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

@keyframes walkthroughSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes walkthroughPulse {
    0%, 100% {
        border-color: var(--mud-palette-info, #594ae2);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7),
                    0 0 20px rgba(89, 74, 226, 0.5),
                    inset 0 0 20px rgba(89, 74, 226, 0.3);
    }
    50% {
        border-color: var(--mud-palette-info-lighten, #7c6ff0);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7),
                    0 0 30px rgba(89, 74, 226, 0.8),
                    inset 0 0 30px rgba(89, 74, 226, 0.5);
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
    .walkthrough-backdrop {
        background: rgba(0, 0, 0, 0.85);
    }
    
    .walkthrough-spotlight {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.85),
                    0 0 20px rgba(89, 74, 226, 0.6),
                    inset 0 0 20px rgba(89, 74, 226, 0.4);
    }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .walkthrough-help-popup {
        max-width: calc(100vw - 2rem);
        min-width: unset;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
    }
    
    .walkthrough-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .walkthrough-help-popup {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .walkthrough-help-popup h6 {
        font-size: 1.1rem;
    }
    
    .walkthrough-help-popup p {
        font-size: 0.9rem;
    }
    
    .walkthrough-controls {
        gap: 0.5rem;
    }
}

/* ============================================
   Accessibility
   ============================================ */

.walkthrough-help-popup:focus {
    outline: 2px solid var(--mud-palette-info, #594ae2);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .walkthrough-spotlight {
        border-width: 4px;
        border-color: var(--mud-palette-info, #594ae2);
    }
    
    .walkthrough-help-popup {
        border: 2px solid var(--mud-palette-primary, #594ae2);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .walkthrough-backdrop,
    .walkthrough-spotlight,
    .walkthrough-help-popup,
    .walkthrough-highlight-boost {
        animation: none !important;
        transition: none !important;
    }
}

