/* Safari Gallery - Compact & Elegant with Premium Animations */

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes borderGlow {
    0%, 100% {
        border-color: rgba(var(--primary-rgb), 0.3);
    }
    50% {
        border-color: rgba(var(--primary-rgb), 0.8);
    }
}

/* ============================================
   STAGGERED ENTRANCE ANIMATIONS
   ============================================ */

.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 {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

/* ============================================
   MAIN GALLERY CONTAINER
   ============================================ */

.safari-media-gallery {
    display: block;
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 40px 0 20px;
}

.gallery-section {
    padding: 0 0 20px;
    position: relative;
}

.gallery-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    border-radius: 2px;
}

/* ============================================
   GALLERY HEADER - ANIMATED
   ============================================ */

.gallery-header {
    text-align: center;
    margin-bottom: 25px;
    animation: fadeInDown 0.7s ease forwards;
}

.gallery-title {
    color: var(--dark);
    font-family: var(--font-heading);
    font-size: var(--text-h2);
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: none;
    position: relative;
    display: inline-block;
}

.gallery-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 2px;
    animation: fadeInScale 0.5s ease 0.3s forwards;
    opacity: 0;
}

.gallery-subtitle {
    color: var(--muted);
    font-family: var(--font-body);
    font-size: var(--text-body);
    font-weight: 400;
    margin-top: 12px;
    margin-bottom: 0;
    opacity: 0;
    animation: fadeInUp 0.5s ease 0.2s forwards;
}

/* ============================================
   FILTER BUTTONS - MICRO-INTERACTIONS
   ============================================ */

.gallery-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    opacity: 0;
    animation: fadeInUp 0.5s ease 0.15s forwards;
}

.filter-btn {
    padding: 8px 20px;
    background: transparent;
    color: var(--body-text);
    border: 1.5px solid #dee2e6;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--text-label);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    position: relative;
    overflow: hidden;
}

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

.filter-btn:hover::before {
    width: 200px;
    height: 200px;
}

.filter-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.35);
}

.filter-btn:active {
    transform: translateY(0) scale(0.98);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.4);
    animation: pulseGlow 2s infinite;
}

/* Gallery Grid - Responsive CSS Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 10px 0;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.gallery-nav-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   GALLERY ITEM - PREMIUM CARD EFFECTS
   ============================================ */

.gallery-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--gallery-card-bg);
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--gallery-card-border);
    transform-origin: center bottom;
}

.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left 0.5s ease;
    z-index: 10;
    pointer-events: none;
}

.gallery-item:hover::before {
    left: 100%;
}

.gallery-item:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--gallery-hover-shadow), 0 20px 40px rgba(0, 0, 0, 0.15);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.gallery-item:active {
    transform: translateY(-5px) scale(1.01);
}

.gallery-item.hidden {
    display: none;
    opacity: 0;
    transform: scale(0.9);
}

/* ============================================
   MEDIA CONTAINER - ZOOM & OVERLAY EFFECTS
   ============================================ */

.media-container {
    position: relative;
    height: 220px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.media-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.gallery-item:hover .media-container::after {
    opacity: 1;
}

.media-container img,
.media-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), filter 0.3s ease;
    filter: brightness(1);
}

.gallery-item:hover .media-container img,
.gallery-item:hover .media-container video {
    transform: scale(1.1);
    filter: brightness(1.05);
}

.media-container img {
    opacity: 0;
    animation: imageReveal 0.6s ease forwards;
}

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

.media-container img.loaded {
    animation: none;
    opacity: 1;
}

/* ============================================
   PLAY BUTTON - ANIMATED OVERLAY
   ============================================ */

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.3) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
}

.gallery-item:hover .video-overlay {
    opacity: 1;
}

.play-button {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    animation: float 2s ease-in-out infinite;
}

.play-button::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(var(--primary-rgb), 0.3);
    border-radius: 50%;
    animation: pulseGlow 1.5s infinite;
}

.play-button:hover {
    background: var(--primary);
    transform: scale(1.15);
    box-shadow: 0 8px 30px rgba(var(--primary-rgb), 0.5);
}

.play-button:hover i {
    color: #fff;
}

.play-button i {
    color: var(--primary);
    font-size: 20px;
    margin-left: 4px;
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
}

/* ============================================
   MEDIA INFO - ELEGANT TYPOGRAPHY
   ============================================ */

.media-info {
    padding: var(--space-md) 18px;
    background: var(--gallery-card-bg);
    position: relative;
}

.media-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 18px;
    right: 18px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb), 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .media-info::before {
    opacity: 1;
}

.media-title {
    font-family: var(--font-body);
    font-size: var(--text-h4);
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
    line-height: 1.3;
    transition: color 0.3s ease;
}

.gallery-item:hover .media-title {
    color: var(--primary);
}

.media-description {
    color: var(--muted);
    font-family: var(--font-body);
    font-size: var(--text-caption);
    line-height: 1.5;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.media-tag {
    padding: 3px 10px;
    background: linear-gradient(135deg, var(--primary-10) 0%, rgba(var(--primary-rgb), 0.05) 100%);
    color: var(--primary);
    border-radius: 15px;
    font-family: var(--font-body);
    font-size: var(--text-label);
    font-weight: 600;
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.media-tag:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* ============================================
   LIGHTBOX - ENHANCED TRIGGER
   ============================================ */

.lightbox-trigger {
    cursor: pointer;
    position: relative;
    display: block;
}

.lightbox-trigger::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.lightbox-trigger:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

.lightbox-trigger img {
    transition: filter 0.3s ease;
}

.lightbox-trigger:hover img {
    filter: brightness(1.1) contrast(1.05);
}

/* ============================================
   VIDEO MODAL - CINEMATIC
   ============================================ */

.video-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.98);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.video-modal-content {
    position: relative;
    margin: 5% auto;
    width: 90%;
    max-width: 800px;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: bounceIn 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.video-modal video {
    width: 100%;
    height: auto;
    max-height: 70vh;
}

.video-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.3s ease;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.video-close:hover {
    color: #fff;
    background: var(--primary);
    transform: rotate(90deg);
}

/* Responsive */
@media (max-width: 992px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .gallery-title {
        font-size: 1.3rem;
    }
    
    .gallery-subtitle {
        font-size: 0.85rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .media-container {
        height: 150px;
    }
    
    .filter-btn {
        padding: 5px 12px;
        font-size: 0.75rem;
    }
    
    .gallery-filters {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .gallery-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .gallery-filters::-webkit-scrollbar {
        display: none;
    }
    
    .filter-btn {
        flex: 0 0 auto;
    }
    
    .safari-media-gallery {
        margin: 30px 0 15px;
    }
}

/* ============================================
   ANIMATION STATES
   ============================================ */

.gallery-item.animate-in {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.gallery-item.fadeOut {
    animation: fadeOut 0.3s ease forwards;
}

.gallery-item.revealed {
    transition: transform 0.1s ease-out;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}

/* Video Hover Play */
.gallery-item video {
    pointer-events: none;
}

/* ============================================
   LOADING STATES - SKELETON & SPINNER
   ============================================ */

.gallery-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 150px;
    gap: 15px;
}

.loading-spinner {
    width: 45px;
    height: 45px;
    border: 3px solid #e9ecef;
    border-radius: 50%;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    animation: spin 0.8s ease-in-out infinite;
    position: relative;
}

.loading-spinner::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid transparent;
    border-top-color: rgba(var(--primary-rgb), 0.3);
    border-radius: 50%;
    animation: spin 1.2s linear infinite reverse;
}

.loading-text {
    color: #6c757d;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton Loading */
.gallery-skeleton {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.skeleton-item {
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.skeleton-media {
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-info {
    padding: 15px 18px;
}

.skeleton-title {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
    width: 70%;
}

.skeleton-text {
    height: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
    width: 90%;
}

.skeleton-tags {
    display: flex;
    gap: 6px;
}

.skeleton-tag {
    height: 20px;
    width: 60px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
}
