/* ============================================
   GALLERY PAGE ANIMATIONS
   ============================================ */

/* Gallery Header */
.gallery-header {
    animation: fadeIn 0.8s ease-out;
}

.gallery-header h1 {
    animation: fadeInUp 0.6s ease-out 0.2s backwards;
}

.gallery-header p {
    animation: fadeInUp 0.6s ease-out 0.4s backwards;
}

/* Gallery Controls Container */
.gallery-controls {
    animation: fadeInUp 0.6s ease-out 0.3s backwards;
}

/* View Toggle Buttons */
.view-toggle {
    animation: fadeInUp 0.5s ease-out 0.4s backwards;
}

.view-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.view-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(75, 175, 213, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.view-btn:hover::before {
    width: 120px;
    height: 120px;
}

.view-btn:hover:not(.active) {
    background-color: var(--light-gray);
    transform: translateY(-2px);
}

.view-btn.active {
    animation: viewBtnActivate 0.4s ease-out;
}

@keyframes viewBtnActivate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.view-btn svg {
    transition: transform 0.3s ease;
}

.view-btn:hover svg {
    transform: scale(1.1);
}

/* Search Input */
.gallery-search {
    animation: fadeInUp 0.5s ease-out 0.5s backwards;
}

.search-wrapper {
    position: relative;
}

.search-input {
    transition: all 0.3s ease;
}

.search-input:focus {
    animation: searchInputFocus 0.3s ease-out;
}

@keyframes searchInputFocus {
    0% {
        box-shadow: 0 0 0 0 rgba(75, 175, 213, 0.4);
    }
    100% {
        box-shadow: 0 0 0 4px rgba(75, 175, 213, 0.1);
    }
}

.search-icon {
    transition: color 0.3s ease;
}

.search-input:focus ~ .search-icon {
    color: var(--serene-blue);
}

.search-clear {
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
}

.search-clear.visible {
    opacity: 1;
    transform: scale(1);
    animation: searchClearAppear 0.3s ease-out;
}

@keyframes searchClearAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-90deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.search-clear:hover {
    color: var(--terracotta);
    transform: scale(1.1) rotate(90deg);
}

/* Sort Select */
.gallery-sort {
    animation: fadeInUp 0.5s ease-out 0.6s backwards;
}

.sort-select {
    transition: all 0.3s ease;
}

.sort-select:focus {
    border-color: var(--serene-blue);
    box-shadow: 0 0 0 4px rgba(75, 175, 213, 0.1);
}

.sort-select:hover {
    border-color: var(--sage-green);
}

/* Gallery Grid */
.gallery-grid {
    animation: fadeIn 0.6s ease-out 0.4s backwards;
}

.gallery-grid.grid-view {
    animation: gridViewActivate 0.5s ease-out;
}

.gallery-grid.map-view {
    animation: mapViewActivate 0.5s ease-out;
}

@keyframes gridViewActivate {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes mapViewActivate {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Gallery Items (Grid Cards) */
.gallery-item {
    animation: galleryItemAppear 0.5s ease-out backwards;
    transition: all 0.3s ease;
}

/* Staggered animation for gallery items */
.gallery-item:nth-child(1) { animation-delay: 0.05s; }
.gallery-item:nth-child(2) { animation-delay: 0.1s; }
.gallery-item:nth-child(3) { animation-delay: 0.15s; }
.gallery-item:nth-child(4) { animation-delay: 0.2s; }
.gallery-item:nth-child(5) { animation-delay: 0.25s; }
.gallery-item:nth-child(6) { animation-delay: 0.3s; }
.gallery-item:nth-child(7) { animation-delay: 0.35s; }
.gallery-item:nth-child(8) { animation-delay: 0.4s; }
.gallery-item:nth-child(9) { animation-delay: 0.45s; }
.gallery-item:nth-child(10) { animation-delay: 0.5s; }
.gallery-item:nth-child(11) { animation-delay: 0.55s; }
.gallery-item:nth-child(12) { animation-delay: 0.6s; }
.gallery-item:nth-child(13) { animation-delay: 0.65s; }
.gallery-item:nth-child(14) { animation-delay: 0.7s; }
.gallery-item:nth-child(15) { animation-delay: 0.75s; }
.gallery-item:nth-child(16) { animation-delay: 0.8s; }
.gallery-item:nth-child(17) { animation-delay: 0.85s; }
.gallery-item:nth-child(18) { animation-delay: 0.9s; }
.gallery-item:nth-child(19) { animation-delay: 0.95s; }
.gallery-item:nth-child(20) { animation-delay: 1s; }

@keyframes galleryItemAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.gallery-item-image {
    overflow: hidden;
}

.gallery-item img {
    transition: transform 0.5s ease, filter 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
    filter: brightness(1.05);
}

/* Gallery Item Overlay */
.gallery-item-overlay {
    transition: opacity 0.3s ease;
    opacity: 0;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

/* Gallery Item Info */
.gallery-item-info {
    transition: transform 0.3s ease 0.1s;
    transform: translateY(10px);
}

.gallery-item:hover .gallery-item-info {
    transform: translateY(0);
}

.gallery-item-title {
    transition: color 0.3s ease;
}

.gallery-item:hover .gallery-item-title {
    color: var(--terracotta);
}

/* View Details Button */
.view-details-btn {
    transition: all 0.3s ease;
    transform: translateY(10px);
    opacity: 0;
}

.gallery-item:hover .view-details-btn {
    transform: translateY(0);
    opacity: 1;
    transition-delay: 0.1s;
}

.view-details-btn:hover {
    background-color: var(--white);
    color: var(--terracotta);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* No Results Message */
.no-results {
    animation: fadeInUp 0.5s ease-out;
}

/* Map View Container */
.gallery-map-container {
    animation: fadeIn 0.5s ease-out;
    position: relative;
}

.gallery-map-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, var(--light-gray) 25%, #f0f0f0 50%, var(--light-gray) 75%);
    background-size: 200% 100%;
    animation: mapShimmer 1.5s ease-in-out infinite;
    z-index: 1000;
    border-radius: 8px;
    pointer-events: none;
}

.gallery-map-container.loaded::before {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes mapShimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Leaflet Map Popup */
.leaflet-popup-content-wrapper {
    animation: popupAppear 0.3s ease-out;
}

@keyframes popupAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.leaflet-popup {
    animation: popupBounce 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popupBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Custom Map Marker Animation */
.leaflet-marker-icon {
    animation: markerDrop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes markerDrop {
    0% {
        transform: translateY(-50px);
        opacity: 0;
    }
    60% {
        transform: translateY(5px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.leaflet-marker-icon:hover {
    animation: markerBounce 0.5s ease;
}



/* Marker Cluster */
.marker-cluster {
    animation: clusterPulse 2s ease-in-out infinite;
}

@keyframes clusterPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Gallery Modal */
.gallery-modal {
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.gallery-modal.closing {
    animation: modalFadeOut 0.3s ease-out;
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.modal-content {
    animation: modalSlideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(100px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.gallery-modal.closing .modal-content {
    animation: modalSlideDown 0.3s ease-out;
}

@keyframes modalSlideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(100px) scale(0.8);
    }
}

/* Modal Close Button */
.modal-close {
    transition: all 0.3s ease;
}

.modal-close:hover {
    transform: rotate(90deg) scale(1.15);
    background-color: var(--terracotta);
    color: var(--white);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.9);
}

/* Modal Image Container */
.modal-image-container {
    animation: fadeIn 0.5s ease-out 0.2s backwards;
}

.modal-main-image img {
    animation: imageZoomIn 0.5s ease-out;
}

@keyframes imageZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Image Change Animation */
.modal-main-image.changing img {
    animation: imageChange 0.4s ease-out;
}

@keyframes imageChange {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slider Navigation Buttons */
.slider-btn {
    transition: all 0.3s ease;
    opacity: 0.7;
}

.slider-btn:hover {
    opacity: 1;
    background-color: var(--terracotta);
    transform: scale(1.1);
}

.slider-btn:active {
    transform: scale(0.95);
}

.slider-btn-prev:hover {
    transform: scale(1.1) translateX(-3px);
}

.slider-btn-next:hover {
    transform: scale(1.1) translateX(3px);
}

.slider-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.slider-btn:disabled:hover {
    transform: scale(1);
    background-color: rgba(255, 255, 255, 0.2);
}

/* Thumbnails Container */
.modal-thumbnails {
    animation: fadeInUp 0.5s ease-out 0.3s backwards;
}

.thumbnail {
    transition: all 0.3s ease;
    opacity: 0.6;
    position: relative;
    overflow: hidden;
}

.thumbnail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s ease;
    z-index: 1;
}

.thumbnail:hover::before {
    opacity: 0;
}

.thumbnail:hover {
    opacity: 1;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.thumbnail.active {
    opacity: 1;
    border-color: var(--terracotta);
    transform: scale(1.05);
    animation: thumbnailActivate 0.3s ease-out;
}

@keyframes thumbnailActivate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1.05);
    }
}

.thumbnail.active::before {
    opacity: 0;
}

.thumbnail img {
    transition: transform 0.3s ease;
}

.thumbnail:hover img {
    transform: scale(1.1);
}

/* Modal Project Info */
.modal-project-info {
    animation: fadeInUp 0.5s ease-out 0.4s backwards;
}

.project-detail-item {
    animation: fadeInLeft 0.4s ease-out backwards;
}

.project-detail-item:nth-child(1) { animation-delay: 0.5s; }
.project-detail-item:nth-child(2) { animation-delay: 0.6s; }
.project-detail-item:nth-child(3) { animation-delay: 0.7s; }
.project-detail-item:nth-child(4) { animation-delay: 0.8s; }
.project-detail-item:nth-child(5) { animation-delay: 0.9s; }

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.project-detail-icon {
    transition: all 0.3s ease;
}

.project-detail-item:hover .project-detail-icon {
    transform: scale(1.15) rotate(5deg);
    color: var(--terracotta);
}

/* Modal Description */
.modal-description {
    animation: fadeInUp 0.5s ease-out 0.5s backwards;
}

/* Image Counter */
.image-counter {
    animation: fadeIn 0.5s ease-out 0.6s backwards;
}

/* Loading State */
.gallery-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Filtering Animation */
.gallery-item.filtering-out {
    animation: filterOut 0.3s ease-out forwards;
}

.gallery-item.filtering-in {
    animation: filterIn 0.4s ease-out forwards;
}

@keyframes filterOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
        height: 0;
        margin: 0;
    }
}

@keyframes filterIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Keyboard Navigation Indicator */
.keyboard-hint {
    animation: fadeInUp 0.5s ease-out 1s backwards;
}

/* Zoom Effect on Main Image Hover */
.modal-main-image:hover img {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* Full Screen Animation */
.gallery-modal.fullscreen .modal-content {
    animation: expandFullscreen 0.4s ease-out;
}

@keyframes expandFullscreen {
    from {
        transform: scale(0.95);
    }
    to {
        transform: scale(1);
    }
}

/* Responsive: Reduce animations on mobile */
@media (max-width: 768px) {
    .gallery-item {
        animation-duration: 0.3s;
    }
    
    .gallery-item:nth-child(n) {
        animation-delay: 0s;
    }
    
    .modal-content {
        animation: modalSlideUpMobile 0.3s ease-out;
    }
    
    @keyframes modalSlideUpMobile {
        from {
            opacity: 0;
            transform: translateY(50px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .modal-content,
    .thumbnail,
    .view-btn,
    .gallery-controls * {
        animation: none !important;
        transition: none !important;
    }
    
    .gallery-item:hover,
    .thumbnail:hover {
        transform: none;
    }
}