/**
 * BMR Gallery Styles
 * Dedicated CSS for Best Marathon Registration Gallery
 * Prefix: .bmr-gallery- to avoid conflicts
 */

/* Gallery Container */
.bmr-gallery-container {
    margin: 20px 0;
    position: relative;
}

/* Gallery title removed as per user request */

/* Gallery Grid */
.bmr-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.bmr-gallery-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.bmr-gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.bmr-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.bmr-gallery-item:hover img {
    transform: scale(1.05);
}

/* Gallery Modal */
.bmr-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.bmr-gallery-modal.active {
    display: flex;
}

/* Modal Header */
.bmr-gallery-modal-header {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 18px;
    font-weight: 500;
    z-index: 10001;
}

/* Close Button */
.bmr-gallery-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.bmr-gallery-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* Modal Content */
.bmr-gallery-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bmr-gallery-modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    transition: transform 0.3s ease;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
}

.bmr-gallery-modal-image.bmr-dragging {
    cursor: grabbing;
    transition: none;
}

.bmr-gallery-modal-image:active {
    cursor: grabbing;
}

/* Navigation Buttons - Enhanced */
.bmr-gallery-nav-prev,
.bmr-gallery-nav-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.bmr-gallery-nav-prev {
    left: 30px;
}

.bmr-gallery-nav-next {
    right: 30px;
}

.bmr-gallery-nav-prev:hover,
.bmr-gallery-nav-next:hover {
    background: rgba(255, 184, 0, 0.9);
    border-color: rgba(255, 184, 0, 0.8);
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 6px 25px rgba(255, 184, 0, 0.4);
}

.bmr-gallery-nav-prev:active,
.bmr-gallery-nav-next:active {
    transform: translateY(-50%) scale(1.05);
}

/* Photo Counter */
.bmr-gallery-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .bmr-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .bmr-gallery-modal-close {
        top: 15px;
        right: 15px;
        font-size: 24px;
        width: 35px;
        height: 35px;
    }
    
    .bmr-gallery-nav-prev,
    .bmr-gallery-nav-next {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .bmr-gallery-nav-prev {
        left: 15px;
    }
    
    .bmr-gallery-nav-next {
        right: 15px;
    }
    
    .bmr-gallery-modal-header {
        top: 15px;
        font-size: 16px;
    }
    
    .bmr-gallery-counter {
        bottom: 20px;
        font-size: 14px;
        padding: 6px 12px;
    }
    
    /* Hide navigation arrows on mobile, use swipe instead */
    .bmr-gallery-nav-prev,
    .bmr-gallery-nav-next {
        display: none;
    }
}

/* Swipe Indicator for Mobile - Below Image */
.bmr-swipe-indicator {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6));
    padding: 10px 18px;
    border-radius: 25px;
    pointer-events: none;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    opacity: 0;
    z-index: 1002;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.bmr-swipe-indicator.bmr-show-indicator {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: smoothPulse 4s ease-in-out;
}

.bmr-swipe-indicator.bmr-hide-indicator {
    opacity: 0;
    transform: translateX(-50%) translateY(-15px);
    transition: all 0.3s ease-out;
}

@media (max-width: 768px) {
    .bmr-swipe-indicator {
        display: block;
    }
}

@media (min-width: 769px) {
    .bmr-swipe-indicator {
        display: none;
    }
}

@keyframes smoothPulse {
    0%, 100% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    20% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1.05);
    }
    40% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    60% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1.02);
    }
    80% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .bmr-gallery-modal-image {
        cursor: default;
    }
    
    .bmr-gallery-modal-image.bmr-dragging {
        cursor: default;
    }
}

/* Helper classes for drag/swipe */
.bmr-no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure modal content allows touch events */
.bmr-gallery-modal-content {
    touch-action: pan-y pinch-zoom;
    position: relative;
}

.bmr-gallery-modal-image {
    touch-action: none; /* Disable default touch behaviors on image */
    pointer-events: auto;
}

@media (max-width: 480px) {
    .bmr-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .bmr-gallery-modal-content {
        max-width: 95%;
        max-height: 70%;
    }
}
