/* --- SEARCH OVERLAY & LAYOUT --- */
@keyframes lightning-flash {
    0%, 100% { opacity: 0; transform: skew(-15deg) scale(0.8); }
    10%, 90% { opacity: 1; transform: skew(-15deg) scale(1); }
    50% { opacity: 0.8; transform: skew(-15deg) scale(1.1); }
}
@keyframes pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes spotlight-pulse {
    from { box-shadow: 0 0 0 4px #facc15, 0 0 20px rgba(250, 204, 21, 0.4); }
    to { box-shadow: 0 0 0 6px #facc15, 0 0 40px rgba(250, 204, 21, 0.8); }
}

/* --- KEN BURNS KEYFRAMES --- */
.kenburns-pan-L-R { animation-name: gpu-pan-L-R; }
@keyframes gpu-pan-L-R {
    0%   { transform: scale(1.35) translate3d(5%, 0, 0); }
    100% { transform: scale(1.35) translate3d(-5%, 0, 0); }
}

.kenburns-pan-TR-BL { animation-name: gpu-pan-TR-BL; }
@keyframes gpu-pan-TR-BL {
    0%   { transform: scale(1.35) translate3d(-5%, 5%, 0); }
    100% { transform: scale(1.35) translate3d(5%, -5%, 0); }
}

.kenburns-pan-T-BR { animation-name: gpu-pan-T-BR; }
@keyframes gpu-pan-T-BR {
    0%   { transform: scale(1.35) translate3d(0, 5%, 0); }
    100% { transform: scale(1.25) translate3d(0, -5%, 0); }
}

.kenburns-pan-BR-TL { animation-name: gpu-pan-BR-TL; }
@keyframes gpu-pan-BR-TL {
    0%   { transform: scale(1.25) translate3d(-3%, -3%, 0); }
    100% { transform: scale(1.45) translate3d(3%, 3%, 0); }
}
.search-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; 
    pointer-events: none; opacity: 0; transition: opacity 0.3s; 
    background: rgba(0,0,0,0.85); 
    overscroll-behavior: none; touch-action: none;

&.active { pointer-events: auto; opacity: 1; }

/* --- LIGHTNING LOADER --- */
#loadingAnimation {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 10001; background: #121015;
    opacity: 1; transition: opacity 0.5s ease-out;
}
#loadingAnimation.hidden { opacity: 0; pointer-events: none; }

.lightning-bolt {
    width: 15px; height: 60px;
    background: #facc15;
    clip-path: polygon(40% 0%, 100% 0%, 60% 100%, 0% 100%);
    animation: lightning-flash 1s infinite;
    box-shadow: 0 0 20px #facc15;
    transform: skew(-15deg);
}
.lightning-bolt.secondary {
    position: absolute; width: 10px; height: 40px;
    /* Earthy Orange Color */
    background: #d97706; 
    box-shadow: 0 0 15px #d97706;
    animation: lightning-flash 1.2s infinite 0.2s;
    margin-left: 25px; margin-top: 20px;
}
.loading-text {
    margin-top: 20px; font-family: 'Oxanium', sans-serif;
    color: white; letter-spacing: 1px; font-size: 1.2rem;
    animation: pulse 1s infinite;
}


/* --- TUTORIAL DIMMER & SPOTLIGHT --- */
#tutorialDimmer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9998; /* Below controls but above cards */
    opacity: 0; transition: opacity 0.5s; pointer-events: none;
}
#tutorialDimmer.active { opacity: 1; }

/* Cloned elements for spotlight effect */
.tutorial-clone {
    position: fixed; z-index: 10002; pointer-events: none;
    box-shadow: 0 0 0 4px #facc15, 0 0 30px rgba(250, 204, 21, 0.6);
    transition: all 0.3s ease;
    animation: spotlight-pulse 1s infinite alternate;
}


/* --- CARD STACK & CARDS --- */
#cafeCardStack {
    width: 100%; height: 100%; position: relative;
    touch-action: none; overscroll-behavior: none; perspective: 1000px;
}

.cafe-card {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 12px;
    overflow: hidden;
    background-color: #1a1a1a;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out; 
    cursor: grab;
    contain: layout paint; 
}

.cafe-card:not(:first-child) {
    transform: scale(0.95) translateY(20px);
    opacity: 0.8;
}
.cafe-card:nth-child(2) { z-index: 4; }
.cafe-card:nth-child(3) { z-index: 3; transform: scale(0.9) translateY(40px); opacity: 0.6; }
.cafe-card:nth-child(4) { z-index: 2; transform: scale(0.85) translateY(60px); opacity: 0.4; }
.cafe-card:first-child { z-index: 5; }

.cafe-card.swiping {
    transition: none; 
}

/* --- GPU OPTIMIZED SLIDESHOW --- */
.slideshow-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden; 
    border-radius: 12px;
    transform: translateZ(0); 
}

.image-slide {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; 
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.8s ease-out; 
    /* Note: will-change is handled by JS for memory safety */
}

.image-slide.active {
    opacity: 1;
    animation-duration: 12s; 
    animation-timing-function: ease-out;
    animation-fill-mode: forwards;
    will-change: transform;
}

/* --- OVERLAY CONTENT & TEXT --- */
.content-gradient {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 40%, rgba(0,0,0,0) 60%);
    z-index: 1;
}

.overlay-content {
    position: absolute; bottom: 0; left: 0; width: 100%;
    z-index: 2;
    padding: 1.5rem;
    color: white;
}

.description-wrapper {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: max-height 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    max-height: 5.5rem; 
    overflow: hidden;
}
.description-wrapper.expanded {
    max-height: 70vh; 
    overflow-y: auto;
    cursor: default;
}
.description-header {
    display: block; width: 100%; font-size: 1.25rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
}
.description-wrapper.expanded .description-header { white-space: normal; }
.description-wrapper:not(.expanded) .description-header::after {
    content: '... (tap to read more)'; font-weight: 400; font-size: 0.9rem;
    color: #ccc; padding-left: 4px;
}

/* --- STATS GRID --- */
.stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem;
    margin: 1rem 0; text-align: center;
}
.stat-item {
    background: rgba(255, 255, 255, 0.1); padding: 0.5rem;
    border-radius: 8px; display: flex; flex-wrap: wrap;
    align-content: flex-start; justify-content: center;
}
.stat-item .image-wrapper {
    display: flex; column-gap: 3px; margin-bottom: 15px;
    color: #aaa; font-size: .75em;
}
.stat-item .image-wrapper.rating { flex-wrap: wrap; justify-content: center; }
.stat-item .image-wrapper img { width: 17px; height: 17px; object-fit: contain; }
.stat-item .value { font-weight: 700; font-size: 1.1rem; }
.stat-item .label { font-size: 0.75rem; text-transform: uppercase; color: #aaa; }
.stat-item .wrapper.flex { display: flex; gap: 2px; align-items: center; justify-content: center; height: 20px; }
.stat-item .wrapper.flex img { width: 14px; height: 14px; object-fit: contain; }

/* --- BUTTONS & CONTROLS --- */
.get-directions-btn {
    background-color: var(--accent); color: #121015; font-family: 'Oxanium', sans-serif;
    font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; text-align: center;
}
.view-details-btn {
    background-color: #333; color: white; font-weight: 700;
    padding: 0.75rem 1rem; border-radius: 8px; text-align: center; margin-top: 1rem;
}

.overlay-control {
    position: absolute; z-index: 1000; background: rgba(0,0,0,0.6); 
    backdrop-filter: blur(5px); border: 1px solid rgba(255,255,255,0.1);
    color: white; border-radius: 20px; padding: 8px 12px;
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    font-family: sans-serif; font-weight: 600; font-size: 0.9rem;
}
.overlay-control img, .overlay-control svg { width: 20px; height: 20px; }
.overlay-control.top-left { top: 15px; left: 15px; }

.top-right-controls {
    position: absolute; top: 15px; right: 15px; z-index: 1000;
    display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}

.closeFindCafes {
    color: white; background: var(--black-bg-bright); border-radius: 14px;
    height: 40px; width: 45px; display: flex; border: none;
    align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 1px 1px 2px #000000, inset 1px 1px 1px #444444;
}
.closeFindCafes img {
    height: 20px; width: 20px; filter: invert(1); object-fit: contain;
}
            
#quickTimeDisplay {
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    padding: 6px 10px; border-radius: 8px;
    font-size: 0.85rem; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    opacity: 0; transition: opacity 0.3s; pointer-events: none;
    white-space: nowrap; border: 1px solid rgba(255,255,255,0.1);
}
#quickTimeDisplay.visible { opacity: 1; }
#quickTimeDisplay img { width: 12px; opacity: 0.9; filter: invert(1); }

#quickTimeDisplay.closing-urgent { color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
#quickTimeDisplay.closing-soon { color: #86efac; border-color: rgba(134, 239, 172, 0.3); }
#quickTimeDisplay.open-long { color: #22c55e; border-color: rgba(34, 197, 94, 0.3); }
#quickTimeDisplay.closed { color: #f87171; border-color: rgba(248, 113, 113, 0.3); }

/* --- SWIPE FEEDBACK TEXT --- */
.swipe-feedback {
    position: absolute; top: 35%; left: 50%;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.5);
    font-family: 'Oxanium', sans-serif; font-size: 3.5rem; font-weight: 900;
    text-transform: uppercase; letter-spacing: 2px;
    /* Z-INDEX CRITICAL: Must be > 9998 (dimmer) */
    opacity: 0; z-index: 10000; pointer-events: none;
    transition: all 0.2s ease-out; text-shadow: 2px 2px 0px #000;
}
.swipe-feedback.left { color: #ef4444; transform: translate(-65%, -50%) rotate(-15deg) scale(0.5); left: 35%; }
.swipe-feedback.right { color: #3b82f6; transform: translate(-35%, -50%) rotate(15deg) scale(0.5); left: 65%; }
.swipe-feedback.up { color: #22c55e; transform: translate(-50%, -50%) rotate(5deg) scale(0.5); }

#sortToggle img{
    object-fit: contain;
}
}
.galactic-ui-container {
            /* Container Setup */
            position: relative;
            width: 100%;
            height: 175px; /* Adjust height as needed */
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #050510; 
            font-family: 'Inter', sans-serif;
            border-radius: 6%; /* Optional: rounds corners of the container */
            isolation: isolate; /* Creates a new stacking context */
}

        /* --- BACKGROUND LAYERS (Scoped & Flattened) --- */

        /* FIXED: Flattened selector and increased visibility */
        .galactic-ui-container .bg-spotlight {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 150%; 
            height: 150%;
            /* Brightened color and increased opacity (0.15 -> 0.4) for visibility */
            background: radial-gradient(circle, rgba(147, 51, 234, 0.4) 0%, rgba(123, 44, 191, 0.1) 40%, transparent 70%);
            transform: translate(-50%, -50%);
            z-index: 1;
            pointer-events: none;
            /* Ensure animation is triggered */
            animation: galactic-move-spotlight 10s infinite ease-in-out alternate;
            will-change: transform;
        }

        .galactic-ui-container .bg-grid {
            position: absolute;
            inset: 0;
            z-index: 2;
            background-image: 
                linear-gradient(rgba(56, 189, 248, 0.1) 1px, transparent 1px),
                linear-gradient(90deg, rgba(56, 189, 248, 0.1) 1px, transparent 1px);
            background-size: 50px 50px;
            pointer-events: none;
        }

        /* --- THE BUTTON (Scoped) --- */

        .galactic-ui-container .node-button-wrapper {
            perspective: 1000px;
            position: relative;
            z-index: 50;
        }

        .galactic-ui-container .node-button {
            --mesh-color-1: #00f2ff; /* Bright Cyan */
            --mesh-color-2: #7b2cbf; /* Deep Purple */
            
            background: #101025;
            border: 2px solid var(--mesh-color-1);
            padding: 1.5rem 4rem;
            border-radius: 8px;
            color: #fff;
            font-size: 1.5rem;
            font-weight: 800;
            letter-spacing: 2px;
            cursor: pointer;
            position: relative;
            transition: all 0.2s ease-in-out;
            transform: translateY(-5px);
            box-shadow: 
                0 10px 0 #000,
                0 0 20px rgba(0, 242, 255, 0.4);
            /* Reset button defaults */
            appearance: none;
            text-decoration: uppercase;
            line-height: normal;
        }

        .galactic-ui-container .node-button::after {
            content: '';
            position: absolute;
            inset: 4px;
            border: 1px dashed rgba(255, 255, 255, 0.3);
            border-radius: 4px;
        }

        .galactic-ui-container .node-button:active {
            transform: translateY(0);
            box-shadow: 
                0 0 0 #000,
                inset 0 0 20px rgba(0, 242, 255, 0.6);
        }

        /* --- THE NODES (Scoped) --- */

        .galactic-ui-container .visible-node {
            position: absolute; /* Changed from fixed to absolute for container containment */
            border-radius: 50%;
            z-index: 10; 
            background: #fff;
            box-shadow: 0 0 15px #00f2ff, 0 0 30px #00f2ff;
        }

        .galactic-ui-container .visible-node::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 200px;
            height: 1px;
            background: linear-gradient(90deg, #00f2ff, transparent);
            transform-origin: left;
            transform: rotate(45deg);
            opacity: 0.5;
            transition: background 0.5s;
            pointer-events: none;
        }

        /* --- KEYFRAMES (Unique Names) --- */

        @keyframes galactic-move-spotlight {
            0% { transform: translate(-60%, -60%); }
            100% { transform: translate(-40%, -40%); }
        }

        @keyframes galactic-float-around {
            0% { transform: translate(0, 0); }
            100% { transform: translate(30px, 30px); }
        }

        @keyframes galactic-cycle-color {
            0% {
                background: #ff00ff; 
                box-shadow: 0 0 20px #ff00ff, 0 0 40px #ff00ff;
                transform: scale(1.2);
            }
            20% {
                background: #fff;
                box-shadow: 0 0 15px #00f2ff, 0 0 30px #00f2ff;
                transform: scale(1);
            }
            100% {
                background: #fff;
                box-shadow: 0 0 15px #00f2ff, 0 0 30px #00f2ff;
                transform: scale(1);
            }
        }

        /* --- NODE CONFIGURATION --- */
        
        .galactic-ui-container .n1 { 
            top: 8%; left: 9%; 
            width: 15px; height: 15px; 
            animation: galactic-float-around 8s infinite alternate, galactic-cycle-color 10s infinite;
            animation-delay: 0s;
        }
        .galactic-ui-container .n2 { 
            top: 70%; left: 80%; 
            width: 20px; height: 20px; 
            animation: galactic-float-around 9s infinite alternate-reverse, galactic-cycle-color 10s infinite;
            animation-delay: 2s;
        }
        .galactic-ui-container .n3 { 
            top: 20%; left: 57%; 
            width: 10px; height: 10px; 
            animation: galactic-float-around 7s infinite alternate, galactic-cycle-color 10s infinite;
            animation-delay: 4s;
        }
        .galactic-ui-container .n4 { 
            top: 80%; left: 15%; 
            width: 25px; height: 25px; 
            animation: galactic-float-around 10s infinite alternate-reverse, galactic-cycle-color 10s infinite;
            animation-delay: 6s;
        }
        .galactic-ui-container .n5 {
            top: 15%; left: 85%;
            width: 12px; height: 12px;
            animation: galactic-float-around 12s infinite alternate, galactic-cycle-color 10s infinite;
            animation-delay: 8s;
        }
.finderToolDistanceInfo{
    margin-top: -3px;
    width: 100%;
    cursor: pointer;
    justify-content: flex-end;
    display: flex;
    align-items: center;
    padding-right: 3vw;
    font-size: var(--font-size-small);
    color:var(--gray-soft);

    span{
        margin: 0 3px;
    }

    & img{
        height: 12px;
        margin-left: 7px;
    }
}

@media only screen and (min-width: 1030px) {
    #searchOverlay{
        #cafeCardStack{
            left: max(50% - 450px, 25%);
            width: min(50%, 900px);
        }
        .overlay-control.top-left {
            left: max(50% - 435px, 25% + 15px);
        }
        .top-right-controls{
            right: max(50% - 435px, 25% + 15px);
        }
    }

    .galactic-ui-container{
        border-radius: 18px;
        height: 145px;
        width: 92%;
        margin: 0 auto;
        /* padding: 0 min(150px, 12vw); */
    }

    .galactic-ui-container .n3{
        top: 14%;
    }
    .galactic-ui-container .node-button-wrapper{
        margin-top: 10px;
    }
}