/* ========================================
   MAGICAL TIME-TRAVEL GALLERY PORTAL
   ======================================== */

.gallery-portal-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Background with Parallax */
.portal-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0.4);
    transition: transform 0.1s ease-out;
    z-index: 1;
}

/* Magic Particles Following Mouse */
.magic-particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.magic-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(111, 169, 154, 0.6), transparent);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFade 2s ease-out forwards;
    box-shadow: 0 0 8px rgba(111, 169, 154, 0.4);
}

@keyframes particleFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.3) translateY(-30px);
    }
}

/* Floating Images Container */
.floating-images-container {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 3;
}

.floating-image {
    position: absolute;
    left: var(--float-x);
    top: var(--float-y);
    transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg));
    width: 280px;
    height: 200px;
    cursor: pointer;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: floatAnimation 12s ease-in-out infinite;
    animation-delay: var(--float-delay);
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

.floating-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    transition: all 0.4s ease;
    filter: brightness(0.8);
}

.image-glow {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(111, 169, 154, 0.2), transparent 70%);
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: -1;
}

/* Hover Effects */
.floating-image:hover {
    transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg)) scale(1.1) rotateY(5deg) rotateX(3deg);
    z-index: 10;
}

.floating-image:hover img {
    border-color: rgba(111, 169, 154, 0.6);
    box-shadow: 0 0 30px rgba(111, 169, 154, 0.4);
}

.floating-image:hover .image-glow {
    opacity: 1;
    animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Floating Animation - Slower and more elegant */
@keyframes floatAnimation {

    0%,
    100% {
        transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg)) translateY(0) rotateZ(0deg);
    }

    25% {
        transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg)) translateY(-15px) rotateZ(1deg);
    }

    50% {
        transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg)) translateY(-8px) rotateZ(-0.5deg);
    }

    75% {
        transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg)) translateY(-18px) rotateZ(0.5deg);
    }
}

/* Portal Title */
.portal-title {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 4;
    color: #fff;
    text-shadow: 0 0 15px rgba(111, 169, 154, 0.6);
}

.portal-title h2 {
    font-size: 3.5rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    background: linear-gradient(135deg, #6fa99a, #a69072, rgba(255, 215, 0, 0.7));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleShimmer 3s ease-in-out infinite;
}

.portal-title p {
    font-size: 1.3rem;
    opacity: 0.9;
    margin: 0;
    font-weight: 300;
}

@keyframes titleShimmer {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }
}

/* Time-Travel Overlay (Hidden by default) */
.time-travel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.9), #000);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.time-travel-overlay.active {
    display: flex;
    animation: portalFadeIn 0.3s ease-out;
}

@keyframes portalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Portal Vortex */
.portal-vortex {
    position: absolute;
    width: 300px;
    height: 300px;
    background: conic-gradient(from 0deg,
            transparent,
            rgba(111, 169, 154, 0.3),
            transparent,
            rgba(167, 144, 114, 0.3),
            transparent,
            rgba(255, 215, 0, 0.3),
            transparent);
    border-radius: 50%;
    animation: vortexSpin 1.5s linear infinite, vortexExpand 1.5s ease-out forwards;
    filter: blur(10px);
}

@keyframes vortexSpin {
    from {
        transform: rotate(0deg) scale(1);
    }

    to {
        transform: rotate(360deg) scale(1);
    }
}

@keyframes vortexExpand {
    0% {
        width: 100px;
        height: 100px;
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        width: 2000px;
        height: 2000px;
        opacity: 0;
    }
}

/* Portal Rings */
.portal-rings {
    position: absolute;
    width: 100%;
    height: 100%;
}

.ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(111, 169, 154, 0.4);
    border-radius: 50%;
    animation: ringExpand 1.5s ease-out forwards;
}

.ring-1 {
    width: 150px;
    height: 150px;
    animation-delay: 0s;
}

.ring-2 {
    width: 200px;
    height: 200px;
    animation-delay: 0.2s;
    border-color: rgba(167, 144, 114, 0.4);
}

.ring-3 {
    width: 250px;
    height: 250px;
    animation-delay: 0.4s;
    border-color: rgba(255, 215, 0, 0.3);
}

@keyframes ringExpand {
    0% {
        width: 50px;
        height: 50px;
        opacity: 1;
    }

    100% {
        width: 2500px;
        height: 2500px;
        opacity: 0;
    }
}

/* Light Waves */
.light-waves {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle,
            rgba(255, 255, 255, 0.1) 0%,
            transparent 50%);
    animation: lightPulse 1s ease-in-out infinite;
}

@keyframes lightPulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* Touch feedback for mobile */
.floating-image.touch-active {
    transform: translate(-50%, -50%) rotate(var(--float-rotation, 0deg)) scale(0.95);
    transition: transform 0.15s ease-out;
}

.floating-image.touch-active img {
    border-color: rgba(111, 169, 154, 0.8);
    box-shadow: 0 0 25px rgba(111, 169, 154, 0.5);
}

/* Clicked Image Animation */
.floating-image.clicked {
    animation: imageSuckIn 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    z-index: 9998;
}

@keyframes imageSuckIn {
    0% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.5) rotate(180deg);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(0) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive Design */
/* Mobile Column Layout */
@media (max-width: 600px) {
    .gallery-portal-section {
        min-height: auto;
        padding: 20px 0 40px 0;
        display: block;
    }

    .floating-images-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 25px;
        padding: 20px 0;
        position: relative;
        width: 100%;
        height: auto;
    }

    .floating-image {
        position: relative;
        left: auto;
        top: auto;
        width: 85%;
        max-width: 300px;
        height: 200px;
        margin: 0 auto;
        transform: none;
        animation: none;

        .floating-image:active img {
            border-color: rgba(111, 169, 154, 0.8);
            box-shadow: 0 0 25px rgba(111, 169, 154, 0.5);
        }
    }

    /* Mobile Column Layout - Higher specificity */
    @media (max-width: 600px) {
        .gallery-portal-section .floating-images-container {
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
            justify-content: center !important;
            gap: 25px !important;
            padding: 20px 0 !important;
            position: relative !important;
            width: 100% !important;
            height: auto !important;
        }

        .gallery-portal-section .floating-image {
            position: relative !important;
            left: auto !important;
            top: auto !important;
            width: 85% !important;
            max-width: 300px !important;
            height: 200px !important;
            margin: 0 auto !important;
            transform: none !important;
            animation: none !important;
            float: none !important;
            clear: both !important;
        }

        .floating-image img {
            border-radius: 12px;
        }

        .portal-title {
            position: relative;
            top: auto;
            left: auto;
            transform: none;
            margin: 30px 20px 20px 20px;
            padding: 0;
        }

        .portal-title h2 {
            font-size: 1.8rem;
            margin-bottom: 15px;
        }

        .portal-title p {
            font-size: 1rem;
        }

        .gallery-portal-section {
            min-height: auto;
            padding: 20px 0 40px 0;
            display: block;
        }

        /* Disable floating animation for mobile */
        .floating-image {
            animation: none;
        }

        /* Reduce portal effects for mobile */
        .portal-vortex {
            width: 200px;
            height: 200px;
        }

        .ring-1 {
            width: 100px;
            height: 100px;
        }

        .ring-2 {
            width: 150px;
            height: 150px;
        }

        .ring-3 {
            width: 200px;
            height: 200px;
        }
    }

    @media (max-width: 480px) {
        .floating-images-container {
            gap: 20px;
            padding: 15px 0;
        }

        .floating-image {
            width: 90%;
            max-width: 280px;
            height: 180px;
        }

        .portal-title {
            margin: 20px 15px 15px 15px;
        }

        .portal-title h2 {
            font-size: 1.6rem;
            margin-bottom: 10px;
        }

        .portal-title p {
            font-size: 0.9rem;
        }

        .gallery-portal-section {
            padding: 15px 0 30px 0;
        }
    }

    @media (max-width: 390px) {
        .floating-images-container {
            gap: 15px;
        }

        .floating-image {
            width: 95%;
            max-width: 260px;
            height: 160px;
        }

        .portal-title h2 {
            font-size: 1.4rem;
        }

        .portal-title p {
            font-size: 0.85rem;
        }
    }

    /* High DPI displays */
    @media (-webkit-min-device-pixel-ratio: 2),
    (min-resolution: 192dpi) {
        .floating-image img {
            border-width: 2px;
        }

        .image-glow {
            top: -8px;
            left: -8px;
            right: -8px;
            bottom: -8px;
        }
    }

    /* Landscape orientation adjustments */
    @media (max-height: 600px) and (orientation: landscape) {
        .portal-title {
            top: 5%;
        }

        .portal-title h2 {
            font-size: 1.3rem;
        }

        .floating-image {
            width: 100px;
            height: 75px;
        }

        .floating-image[data-index="1"] {
            --float-y: 25%;
        }

        .floating-image[data-index="2"] {
            --float-y: 20%;
        }

        .floating-image[data-index="3"] {
            --float-y: 45%;
        }

        .floating-image[data-index="4"] {
            --float-y: 65%;
        }

        .floating-image[data-index="5"] {
            --float-y: 60%;
        }
    }