/* ========================================
   The Cosmic Guide Theme (Driver.js Override)
   ======================================== */

/* 0. Layout Stability Fix */
/* Prevents layout shifts when Driver.js locks the body scrollbar */
html {
    scrollbar-gutter: stable;
}

/* 1. The Spotlight (Radial Gradient) */
.driver-overlay path {
    fill: rgba(5, 7, 20, 0.85) !important; /* Deep Indigo Base */
    /* Note: Driver.js uses SVG paths for the overlay, so we can't easily do a radial gradient on the path itself, 
       but we can set the base color to our deep indigo. */
}

/* 2. The Artifact (Popover) */
.driver-popover {
    background: rgba(15, 23, 42, 0.95); /* Deep Indigo */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 215, 0, 0.3); /* Starlight Gold Border */
    border-radius: 16px;
    box-shadow: 
        0 0 30px rgba(106, 17, 203, 0.3), /* Mystic Purple Glow */
        inset 0 0 20px rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 20px;
    max-width: 350px;
    font-family: 'Space Grotesk', sans-serif;
}

/* 3. Typography */
.driver-popover-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffd700; /* Gold */
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.driver-popover-description {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

/* 4. Buttons */
.driver-popover-footer {
    margin-top: 10px;
}

.driver-popover-footer button {
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Next / Done Button */
.driver-popover-next-btn {
    background: linear-gradient(45deg, #6a11cb, #2575fc) !important;
    border: none !important;
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
    box-shadow: 0 4px 15px rgba(106, 17, 203, 0.3);
}

.driver-popover-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(106, 17, 203, 0.5);
}

/* Previous Button */
.driver-popover-prev-btn {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: rgba(255, 255, 255, 0.7) !important;
}

.driver-popover-prev-btn:hover {
    border-color: rgba(255, 255, 255, 0.8) !important;
    color: white !important;
}

/* Close Button */
.driver-popover-close-btn {
    color: rgba(255, 255, 255, 0.5) !important;
    transition: color 0.3s ease;
}

.driver-popover-close-btn:hover {
    color: #ffd700 !important;
}

/* 5. The Pulse Animation (Target Highlight) */
/* Driver.js doesn't natively support adding classes to the highlighted element easily without callbacks,
   but we can style the active stage if needed. For now, we rely on the popover's presence. */

/* 6. Mobile HUD Mode */
@media (max-width: 768px) {
    .driver-popover.cosmic-hud {
        position: fixed !important;
        top: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 90% !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        bottom: auto !important;
        z-index: 100000000 !important; /* Above everything */
        margin: 0 !important;
        /* Remove arrow in HUD mode */
    }
    
    .driver-popover.cosmic-hud .driver-popover-arrow {
        display: none !important;
    }
}

/* 7. The "Toast" Invitation */
#cosmic-guide-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid #ffd700;
    border-radius: 12px;
    padding: 15px 20px;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 15px;
    transform: translateY(150%);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    max-width: 300px;
}

#cosmic-guide-toast.visible {
    transform: translateY(0);
}

#cosmic-guide-toast:hover {
    transform: translateY(-5px);
}

.toast-icon {
    font-size: 1.5rem;
    color: #ffd700;
    animation: pulse-gold 2s infinite;
}

.toast-content h4 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    color: #ffd700;
}

.toast-content p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.8);
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
}

.toast-close:hover {
    color: white;
}

@keyframes pulse-gold {
    0% { text-shadow: 0 0 0 rgba(255, 215, 0, 0); }
    50% { text-shadow: 0 0 10px rgba(255, 215, 0, 0.7); }
    100% { text-shadow: 0 0 0 rgba(255, 215, 0, 0); }
}

@keyframes pulse-glow-gold {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

@keyframes pulse-glow-white {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Floating Help Button (Restart Trigger) */
#cosmic-guide-trigger {
    position: fixed;
    bottom: 90px; /* Stacked above the chat button (usually at 20px) */
    right: 25px; /* Centered relative to 60px chat button (20px right + 5px offset) */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c0b4a 0%, #5a189a 100%);
    border: 1px solid #ffd700;
    color: #ffd700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
    opacity: 0; /* Hidden by default, shown via JS if toast is dismissed */
    pointer-events: none;
    animation: pulse-glow-gold 2s infinite;
}

/* Add pulse to chat button as well for consistency */
.chat-toggle-btn {
    animation: pulse-glow-white 2s infinite;
}

/* Add pulse to menu button for consistency */
.menu-toggle {
    animation: pulse-glow-white 2s infinite;
}

#cosmic-guide-trigger.visible {
    opacity: 1;
    pointer-events: auto;
}

#cosmic-guide-trigger:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

@media (max-width: 768px) {
    #cosmic-guide-trigger {
        bottom: 140px; /* Stacked above menu button (80px bottom + 56px height + 4px gap) */
        right: 23px; /* Centered relative to 56px buttons (20px right + 3px offset) */
    }
}

/* 8. Custom Highlight Shapes for Chart Houses */
/* North Indian Chart - Diamond Shape */
.driver-highlighted-element.diamond {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    border-radius: 0 !important;
}

/* North Indian Chart - Triangle Down (Houses 2, 12) */
.driver-highlighted-element.triangle-down {
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    border-radius: 0 !important;
}

/* North Indian Chart - Triangle Up (Houses 6, 8) */
.driver-highlighted-element.triangle-up {
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
    border-radius: 0 !important;
}

/* North Indian Chart - Triangle Right (Houses 3, 5) */
.driver-highlighted-element.triangle-right {
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    border-radius: 0 !important;
}

/* North Indian Chart - Triangle Left (Houses 9, 11) */
.driver-highlighted-element.triangle-left {
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
    border-radius: 0 !important;
}

/* South Indian Chart - Rectangle (Default) */
.driver-highlighted-element.south-click-zone {
    border-radius: 4px !important;
}

/* 9. Programmatic Glow for Tour Animation */
/* Replicates the :hover state of .north-click-zone and .south-click-zone but MUCH brighter for the tour */
.north-click-zone.tour-active-glow {
    background: rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 15px rgba(255, 255, 255, 0.9) !important;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
}

.south-click-zone.tour-active-glow {
    background: rgba(255, 255, 255, 0.3) !important;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.7) !important;
}

/* 10. Fix for "Touch the Stars" Clipping */
/* Ensure the chart column doesn't clip the overflowing buttons when highlighted */
.driver-highlighted-element.chart-column {
    overflow: visible !important;
}

/* Force the controls to stay on top of the overlay when the column is highlighted */
.driver-highlighted-element.chart-column .chart-controls-container {
    z-index: 10000002 !important; /* Higher than driver overlay */
    position: absolute !important;
}

/* 11. Fix for "Shift Perspectives" Clipping */
/* The buttons are absolutely positioned with negative margins, which confuses driver.js.
   We force the highlight box to be larger and shifted to cover them properly. */
.driver-highlighted-element.chart-controls-container {
    /* Reset any restrictive sizing */
    width: auto !important;
    height: auto !important;
    /* Add massive padding to ensure the cutout covers everything */
    padding: 20px !important;
    /* Shift it slightly to center the visual weight */
    margin-left: -10px !important;
    margin-top: -10px !important;
    /* Ensure background is transparent so we see the buttons */
    background: transparent !important;
    box-shadow: none !important;
}
