/* ==========================================================================
   ETHEREAL COFFEE DREAMS - PREMIUM GALLERY REBOOT
   Theme: Shimmering Bubbles & Dynamic Flows
   Palette: Deep Nebula, Lavender Mist, Amber Glow, Crystal Frost
   ========================================================================== */

:root {
    /* New UI Color Palette */
    --bg-deep: #08080C;            /* Near-black, deep void */
    --primary-ethereal: #A78BFA;   /* Soft lavender/purple for blossoms */
    --secondary-ethereal: #60A5FA; /* Soft blue for water/steam */
    --accent-shine: #FBBF24;       /* Amber/gold for the perfect roast glow */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --text-light: #F9FAFB;
    --text-muted: #9CA3AF;
    --border-subtle: rgba(167, 139, 250, 0.15);
    
    /* Animations & Physics */
    --ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    --transition-shimmer: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

body.gallery-page {
    background-color: var(--bg-deep);
    color: var(--text-light);
    overflow-x: hidden;
}

/* --- NEW: BACK BUTTON --- */
.back-btn {
    position: absolute;
    top: 40px;
    left: 40px;
    z-index: 100;
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.4s;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.back-btn:hover {
    color: var(--accent-shine);
    transform: translateX(-8px);
}

/* --- 1. DYNAMIC HERO SLIDESHOW (Ken Burns + Crossfade) --- */
.gallery-hero {
    height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: var(--bg-deep);
}

/* Slideshow Container */
.hero-slideshow {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Individual Slides */
.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    background-size: cover;
    background-position: center;
    animation: slideShowSequence 24s linear infinite;
}

/* Pure CSS Slideshow logic using Unsplash images */
.hero-slide:nth-child(1) {
    background-image: linear-gradient(to bottom, rgba(8, 8, 12, 0.7), rgba(8, 8, 12, 0.9)),
                      url('https://images.unsplash.com/photo-1497935586351-b67a49e012bf?auto=format&fit=crop&w=1920&q=80');
    animation-delay: 0s;
}
.hero-slide:nth-child(2) {
    background-image: linear-gradient(to bottom, rgba(8, 8, 12, 0.7), rgba(8, 8, 12, 0.9)),
                      url('https://images.unsplash.com/photo-1554118811-1e0d58224f24?auto=format&fit=crop&w=1920&q=80');
    animation-delay: 6s;
}
.hero-slide:nth-child(3) {
    background-image: linear-gradient(to bottom, rgba(8, 8, 12, 0.7), rgba(8, 8, 12, 0.9)),
                      url('https://images.unsplash.com/photo-1442512595331-e89e73853f31?auto=format&fit=crop&w=1920&q=80');
    animation-delay: 12s;
}
.hero-slide:nth-child(4) {
    background-image: linear-gradient(to bottom, rgba(8, 8, 12, 0.7), rgba(8, 8, 12, 0.9)),
                      url('https://images.unsplash.com/photo-1511920170033-f8396924c348?auto=format&fit=crop&w=1920&q=80');
    animation-delay: 18s;
}

/* Ken Burns (Slow Zoom) + Crossfade keyframes */
@keyframes slideShowSequence {
    0% { opacity: 0; transform: scale(1) rotate(0.01deg); }
    5% { opacity: 1; }
    25% { opacity: 1; transform: scale(1.1) rotate(0.01deg); }
    30% { opacity: 0; transform: scale(1.1) rotate(0.01deg); }
    100% { opacity: 0; }
}

.gallery-hero .hero-content {
    position: relative;
    z-index: 10;
    padding: 0 20px;
}

/* Staggard character animation on title */
.gallery-hero h1 {
    font-size: 6rem;
    color: var(--text-light);
    text-shadow: 0 0 30px rgba(167, 139, 250, 0.5);
    line-height: 1.1;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.gallery-hero h1 span.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(100px) rotateX(-90deg);
    animation: letterReveal 1.2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes letterReveal {
    to { opacity: 1; transform: translateY(0) rotateX(0); }
}

/* Apply delay in JS or manually */
.letter:nth-child(1) { animation-delay: 0.1s; }
.letter:nth-child(2) { animation-delay: 0.15s; }

.gallery-hero h1 span.highlight {
    color: var(--accent-shine);
    font-style: italic;
    position: relative;
}

/* Underline trace animation */
.gallery-hero h1 span.highlight::after {
    content: '';
    position: absolute;
    bottom: 5px; left: 0;
    width: 0%; height: 4px;
    background: var(--accent-shine);
    border-radius: 4px;
    animation: traceUnderline 1s 1.5s ease forwards;
}

@keyframes traceUnderline { to { width: 100%; } }

/* --- 2. AUTOMATIC HORIZONTAL STREAM (Refined Borders & Focus) --- */
.horizontal-marquee {
    background: #0F0F14;
    padding: 60px 0;
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
    display: flex;
}

/* Crystal-like edge fades */
.horizontal-marquee::before,
.horizontal-marquee::after {
    content: "";
    position: absolute;
    top: 0;
    width: 250px;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.horizontal-marquee::before {
    left: 0;
    background: linear-gradient(to right, #0F0F14 20%, transparent);
}

.horizontal-marquee::after {
    right: 0;
    background: linear-gradient(to left, #0F0F14 20%, transparent);
}

.marquee-track {
    display: flex;
    gap: 35px;
    width: max-content;
    animation: scrollHorizontal 35s linear infinite;
    /* Pause on hover to allow detailed viewing */
    animation-play-state: running;
}

.horizontal-marquee:hover .marquee-track {
    animation-play-state: paused;
}

.marquee-item {
    width: 380px;
    height: 260px;
    border-radius: 30px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    /* Subtle accent border */
    border: 1px solid var(--border-subtle);
    transition: var(--transition-shimmer);
    filter: grayscale(80%) brightness(0.6);
}

/* Active shine border effect on hover */
.marquee-item::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 30px;
    background: conic-gradient(from 0deg, transparent, var(--primary-ethereal), transparent 30%);
    animation: borderRotate 4s linear infinite;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}

@keyframes borderRotate { 100% { transform: rotate(360deg); } }

.marquee-item:hover {
    transform: translateY(-10px) scale(1.05);
    filter: grayscale(0%) brightness(1.1);
    box-shadow: 0 20px 50px rgba(167, 139, 250, 0.3);
}

.marquee-item:hover::after {
    opacity: 1;
}

.marquee-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 2;
    transition: transform 0.8s ease;
}

.marquee-item:hover img {
    transform: scale(1.1);
}

@keyframes scrollHorizontal {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); } 
}

/* --- 3. AMBIENT SHIFTING ORBS --- */
.gallery-body {
    position: relative;
    background: var(--bg-deep);
    overflow: hidden;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    opacity: 0.25;
    animation: orbDrift 25s infinite alternate ease-in-out;
}
/* Shifting to new ethereal colors */
.orb-1 { width: 600px; height: 600px; background: var(--primary-ethereal); top: 15%; left: -15%; }
.orb-2 { width: 500px; height: 500px; background: var(--secondary-ethereal); bottom: 15%; right: -10%; animation-delay: -7s; }

@keyframes orbDrift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(150px, 80px) scale(1.2) rotate(10deg); }
}

/* --- 4. PERFECT CIRCLE "BUBBLE" FLOATING GRID --- */
.floating-grid {
    display: grid;
    /* Symmetrical squares for perfect circles */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 280px; 
    gap: 50px;
    padding: 80px 40px 160px;
    position: relative;
    z-index: 10;
    justify-items: center; /* Center circles in grid cells */
}

.bubble-card {
    position: relative;
    width: 100%;
    height: 100%;
    /* New physics-like floating with varying intensity */
    animation: bubblePhysics 9s ease-in-out infinite alternate;
}

/* Enhanced staggered floating */
.bubble-card:nth-child(even) { animation-delay: -2s; animation-duration: 8s; }
.bubble-card:nth-child(3n) { animation-delay: -4s; animation-duration: 10s; }
.bubble-card:nth-child(5n) { animation-delay: -6s; animation-duration: 12s; }

@keyframes bubblePhysics {
    0% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-30px) rotate(1.5deg) translateX(5px); }
    66% { transform: translateY(-10px) rotate(-1deg) translateX(-5px); }
    100% { transform: translateY(-40px) rotate(2deg); }
}

/* Core bubble appearance (THE CIRCLE FIX) */
.bubble-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%; /* PERFECT CIRCLE SHAPE */
    overflow: hidden;
    position: relative;
    /* Advanced shadow for depth */
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(167, 139, 250, 0.2);
    background: #111116;
    border: 1px solid var(--border-subtle);
    transition: var(--transition-shimmer);
}

/* Bubble Shine Pseudo-element */
.bubble-inner::before {
    content: '';
    position: absolute;
    top: 15%; left: 15%;
    width: 30%; height: 30%;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Hover Transformation */
.bubble-card:hover .bubble-inner {
    transform: scale(1.1) translateY(-15px);
    box-shadow: 
        0 40px 80px rgba(167, 139, 250, 0.4),
        inset 0 0 30px rgba(251, 191, 36, 0.3); /* Amber glow inside */
    z-index: 50;
    border-color: rgba(251, 191, 36, 0.5); /* Amber border */
}

/* Refract image inside bubble on hover */
.bubble-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1s var(--ease-elastic), filter 0.5s ease;
}

.bubble-card:hover img {
    transform: scale(1.15) rotate(2deg);
    filter: brightness(1.1) contrast(1.1);
}

/* --- GLASSMORPHISM TEXT OVERLAY --- */
.bubble-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    /* Frosted glass effect */
    background: radial-gradient(circle at center, transparent 30%, rgba(13, 13, 17, 0.8) 100%);
    backdrop-filter: blur(0px); /* Will increase on hover */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    opacity: 0;
    z-index: 10;
    transition: opacity 0.4s ease, backdrop-filter 0.4s ease;
}

.bubble-card:hover .bubble-overlay {
    opacity: 1;
    backdrop-filter: blur(5px);
}

.bubble-overlay h3 {
    color: var(--text-light);
    font-family: var(--font-heading);
    font-size: 1.6rem;
    text-align: center;
    line-height: 1.2;
    transform: scale(0.8) rotate(-10deg);
    transition: transform 0.6s var(--ease-elastic);
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.bubble-card:hover h3 {
    transform: scale(1) rotate(0deg);
}

/* --- 5. PREMIUM GLASS FILTER UI --- */
.gallery-filters-container {
    display: flex;
    justify-content: center;
    margin: 60px 0 20px 0;
    padding: 0 20px;
}

.gallery-filters {
    display: inline-flex;
    flex-wrap: wrap; /* Handle smaller screens gracefully */
    justify-content: center;
    gap: 12px;
    padding: 10px;
    /* Frosty glassmorphism */
    background: rgba(15, 15, 20, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 50px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.filter-btn {
    padding: 12px 30px;
    border-radius: 40px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-shimmer);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Ethereal color indicator */
.filter-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--secondary-ethereal), var(--primary-ethereal));
    z-index: -1;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.4s var(--ease-elastic), opacity 0.3s ease;
}

/* Shine/Glass highlight on button */
.filter-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
    z-index: 2;
}

.filter-btn.active {
    color: #000; /* Contrast on primary color */
    box-shadow: 0 5px 15px rgba(167, 139, 250, 0.4);
}

.filter-btn.active::before {
    transform: translateY(0);
    opacity: 1;
}

.filter-btn:hover:not(.active) {
    color: var(--text-light);
    background: rgba(167, 139, 250, 0.1);
    border-color: rgba(167, 139, 250, 0.3);
}

.filter-btn:hover::after {
    left: 100%;
}

/* --- 6. CINEMATIC LIGHTBOX --- */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    background: rgba(8, 8, 12, 0.98); /* Nebula-dark */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.4s ease;
}

/* Tint blur effect inside lightbox */
.lightbox::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, transparent 20%, rgba(167, 139, 250, 0.1) 100%);
    pointer-events: none;
}

.lightbox.active {
    display: flex;
}

.lightbox-img {
    max-width: 85%;
    max-height: 85vh;
    border-radius: 20px;
    box-shadow: 0 40px 120px rgba(0,0,0,0.8);
    transform: scale(0.95);
    animation: zoomIn 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    border: 1px solid var(--border-subtle);
}

@keyframes zoomIn {
    to { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(50px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-lightbox {
    position: absolute;
    top: 30px;
    right: 50px;
    color: var(--text-muted);
    font-size: 60px;
    font-weight: 200;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 2010;
}

.close-lightbox:hover {
    color: var(--accent-shine);
    transform: rotate(90deg) scale(1.1);
}

/* Staggered Reveal class adjustments for 30 images */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   7. MOBILE RESPONSIVE FIXES (NEW)
   ========================================================================== */
@media (max-width: 768px) {
    /* Mobile Back Button Adjustment */
    .back-btn {
        top: 20px;
        left: 20px;
    }

    /* Scale down the massive Hero Title */
    .gallery-hero h1 {
        font-size: 3.2rem;
        flex-wrap: wrap; 
        line-height: 1.2;
    }

    /* Fix Floating Grid Overflow */
    .floating-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); 
        grid-auto-rows: 320px; /* Adjust height to match full width */
        gap: 30px;
        padding: 40px 20px 80px; 
    }

    /* Scale down Horizontal Marquee Items */
    .marquee-item {
        width: 280px; 
        height: 200px;
    }

    /* Fix Edge Fades on Mobile Marquee */
    .horizontal-marquee::before,
    .horizontal-marquee::after {
        width: 80px; 
    }

    /* Fix Lightbox Close Button bounds */
    .close-lightbox {
        top: 15px;
        right: 25px;
        font-size: 45px;
    }

    /* Scale down background Orbs so they don't break page width */
    .ambient-orb {
        transform: scale(0.5);
    }
}

@media (max-width: 480px) {
    .gallery-hero h1 {
        font-size: 2.5rem;
    }
    
    /* Make filter buttons fit screen */
    .filter-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}