/* ========================================
   Gallery Styles v2.0
   Enhanced layouts, animations & effects
   ======================================== */

/* ---- Masonry Layout ---- */
.gallery-masonry {
    column-count: 3;
    column-gap: 15px;
}

.gallery-masonry .gallery-item {
    break-inside: avoid;
    margin-bottom: 15px;
}

.gallery-masonry .gallery-image-wrap {
    aspect-ratio: auto !important;
}

/* ---- Justified Layout ---- */
.gallery-justified {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gallery-justified .gallery-item {
    flex-grow: 1;
    height: 250px;
    min-width: 200px;
}

.gallery-justified .gallery-image-wrap {
    height: 100%;
    aspect-ratio: auto !important;
}

/* ---- Carousel Layout ---- */
.gallery-carousel-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-medium);
}

.gallery-carousel {
    display: flex;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.gallery-carousel .gallery-item {
    flex: 0 0 100%;
    min-width: 0;
}

.gallery-carousel .gallery-image-wrap {
    aspect-ratio: 16/9;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-secondary);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.carousel-nav:hover {
    background: var(--color-primary);
    color: var(--color-white);
    transform: translateY(-50%) scale(1.1);
}

.carousel-prev { left: 20px; }
.carousel-next { right: 20px; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.carousel-dot.active {
    background: var(--color-primary);
    transform: scale(1.2);
}

.carousel-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

/* ---- Enhanced Animations ---- */

/* Fade Up Stagger */
.gallery-item.anim-fade-up {
    opacity: 0;
    transform: translateY(40px);
}

.gallery-item.anim-fade-up.visible {
    animation: fadeUp 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* Slide Left */
.gallery-item.anim-slide-left {
    opacity: 0;
    transform: translateX(-60px) scale(0.95);
}

.gallery-item.anim-slide-left.visible {
    animation: slideLeft 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideLeft {
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Scale with Blur */
.gallery-item.anim-scale {
    opacity: 0;
    transform: scale(0.8);
    filter: blur(10px);
}

.gallery-item.anim-scale.visible {
    animation: scaleBlur 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes scaleBlur {
    0% { opacity: 0; transform: scale(0.8); filter: blur(10px); }
    50% { filter: blur(0); }
    100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* Rotate In */
.gallery-item.anim-rotate {
    opacity: 0;
    transform: perspective(800px) rotateY(-15deg) rotateX(5deg);
}

.gallery-item.anim-rotate.visible {
    animation: rotateIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes rotateIn {
    to { opacity: 1; transform: perspective(800px) rotateY(0) rotateX(0); }
}

/* Blur Reveal */
.gallery-item.anim-blur {
    opacity: 0;
    filter: blur(20px);
    transform: scale(1.1);
}

.gallery-item.anim-blur.visible {
    animation: blurReveal 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes blurReveal {
    0% { opacity: 0; filter: blur(20px); transform: scale(1.1); }
    60% { filter: blur(0); }
    100% { opacity: 1; filter: blur(0); transform: scale(1); }
}

/* Flip Card */
.gallery-item.anim-flip {
    opacity: 0;
    transform: perspective(1000px) rotateX(-90deg);
    transform-origin: center bottom;
}

.gallery-item.anim-flip.visible {
    animation: flipIn 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes flipIn {
    0% { opacity: 0; transform: perspective(1000px) rotateX(-90deg); }
    40% { opacity: 1; }
    100% { opacity: 1; transform: perspective(1000px) rotateX(0); }
}

/* Parallax 3D */
.gallery-item.anim-parallax {
    opacity: 0;
    transform: perspective(1000px) translateZ(-200px) rotateY(10deg);
}

.gallery-item.anim-parallax.visible {
    animation: parallax3d 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes parallax3d {
    to { opacity: 1; transform: perspective(1000px) translateZ(0) rotateY(0); }
}

/* ---- Enhanced Hover Effects ---- */

/* Hover Lift + Shadow */
.gallery-link {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-link:hover {
    transform: translateY(-8px);
}

/* Hover Glow Ring */
.gallery-image-wrap::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, var(--color-primary), var(--color-accent), var(--color-primary));
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

.gallery-link:hover .gallery-image-wrap::before {
    opacity: 1;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Hover Zoom + Overlay */
.gallery-image {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.4s ease;
}

.gallery-link:hover .gallery-image {
    transform: scale(1.08);
    filter: brightness(1.1);
}

/* ---- Overlay Enhancements ---- */
.gallery-overlay {
    background: linear-gradient(
        180deg,
        rgba(91, 192, 190, 0.1) 0%,
        rgba(15, 26, 46, 0.4) 40%,
        rgba(15, 26, 46, 0.9) 100%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
}

.gallery-link:hover .gallery-overlay {
    opacity: 1;
}

.overlay-content {
    transform: translateY(30px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s;
}

.gallery-link:hover .overlay-content {
    transform: translateY(0);
    opacity: 1;
}

/* View Icon Animation */
.view-icon {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.view-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.gallery-link:hover .view-icon::before {
    width: 100%;
    height: 100%;
}

.gallery-link:hover .view-icon {
    transform: rotate(90deg) scale(1.1);
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* ---- Image Loading State ---- */
.gallery-image.loading {
    opacity: 0;
    filter: blur(10px);
}

.gallery-image.loaded {
    animation: imageReveal 0.6s ease forwards;
}

@keyframes imageReveal {
    from { opacity: 0; filter: blur(10px); }
    to { opacity: 1; filter: blur(0); }
}

/* ---- Skeleton Loading ---- */
.gallery-image-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    opacity: 0;
    z-index: 1;
}

.gallery-image-wrap:not(:has(.loaded))::after {
    opacity: 1;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Category Badge ---- */
.gallery-category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 12px;
    background: var(--color-primary);
    color: var(--color-white);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 20px;
    z-index: 2;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease 0.2s;
}

.gallery-link:hover .gallery-category-badge {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Image Counter Badge ---- */
.gallery-count-badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--color-white);
    font-size: 0.75rem;
    border-radius: 20px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease 0.3s;
}

.gallery-link:hover .gallery-count-badge {
    opacity: 1;
}

/* ---- Enhanced Single Gallery ---- */
.single-gallery-header {
    position: relative;
    height: 50vh;
    min-height: 350px;
    overflow: hidden;
}

.single-gallery-header .bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transform: scale(1.05);
    transition: transform 8s ease-out;
    filter: brightness(0.7);
}

.single-gallery-header:hover .bg-image {
    transform: scale(1);
}

.single-gallery-header .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        rgba(15, 26, 46, 0.3) 0%,
        rgba(15, 26, 46, 0.5) 50%,
        rgba(15, 26, 46, 0.85) 100%
    );
}

.single-gallery-header .content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ---- Gallery Grid Responsive ---- */
@media (max-width: 1024px) {
    .gallery-masonry {
        column-count: 2;
    }
    .gallery-justified .gallery-item {
        height: 200px;
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .gallery-masonry {
        column-count: 2;
    }
    .gallery-carousel .carousel-nav {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    .carousel-prev { left: 10px; }
    .carousel-next { right: 10px; }
}

@media (max-width: 480px) {
    .gallery-masonry {
        column-count: 1;
    }
    .gallery-justified .gallery-item {
        height: 180px;
        min-width: 100%;
    }
}
