/* SCDev Gallery Pro - Frontend Styles */

.scdev-gallery {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* Grid Layout */
.scdev-gallery.scdev-gallery-grid {
    display: grid;
    grid-auto-flow: row;
    grid-auto-rows: 300px;
}

.scdev-gallery.scdev-gallery-grid.scdev-cols-1 {
    grid-template-columns: 1fr;
}

.scdev-gallery.scdev-gallery-grid.scdev-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.scdev-gallery.scdev-gallery-grid.scdev-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Masonry Layout - 2 columns with repeating pattern */
.scdev-gallery.scdev-gallery-masonry {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-flow: dense;
    grid-auto-rows: 300px;
    gap: inherit;
}

.scdev-gallery.scdev-gallery-masonry.scdev-cols-1 {
    grid-template-columns: 1fr;
}

.scdev-gallery.scdev-gallery-masonry.scdev-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.scdev-gallery.scdev-gallery-masonry.scdev-cols-3 {
    grid-template-columns: repeat(2, 1fr);
}

/* Masonry pattern: every 3 items repeat - 1st item spans 2 rows, 2nd and 3rd are 1 row each */
.scdev-gallery.scdev-gallery-masonry .scdev-gallery-item:nth-child(3n+1) {
    grid-row: span 2;
}

.scdev-gallery.scdev-gallery-masonry .scdev-gallery-item:nth-child(3n+2),
.scdev-gallery.scdev-gallery-masonry .scdev-gallery-item:nth-child(3n+3) {
    grid-row: span 1;
}

/* Masonry image fills the item */
.scdev-gallery.scdev-gallery-masonry .scdev-gallery-image {
    height: 100%;
}

/* Gallery Item */
.scdev-gallery-item {
    background: inherit;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.scdev-gallery-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

/* Gallery Link */
.scdev-gallery-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative !important;
}

/* Overlay Title Position */
.scdev-gallery.scdev-title-overlay .scdev-gallery-link {
    position: relative;
}

.scdev-gallery.scdev-title-overlay .scdev-gallery-item {
    position: relative;
}

/* Gallery Image Container */
.scdev-gallery-image {
    width: 100% !important;
    height: 100% !important;
    background: transparent;
    overflow: hidden;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    flex-shrink: 0;
    z-index: 1 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scdev-gallery-image.no-image {
    background: var(--no-image-bg, #e8e8e8);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.scdev-gallery-image.no-image img {
    display: none !important;
}

.scdev-gallery-image.no-image::before {
    display: none;
}

.scdev-gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Hover Effects */
.scdev-gallery-item.scdev-hover-zoom .scdev-gallery-image img {
    transform: scale(1);
}

.scdev-gallery-item.scdev-hover-zoom:hover .scdev-gallery-image img {
    transform: scale(1.1);
}

.scdev-gallery-item.scdev-hover-fade .scdev-gallery-image {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.scdev-gallery-item.scdev-hover-fade:hover .scdev-gallery-image {
    opacity: 0.8;
}

.scdev-gallery-item.scdev-hover-slide .scdev-gallery-image img {
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.scdev-gallery-item.scdev-hover-slide:hover .scdev-gallery-image img {
    transform: translateX(10px);
}

.scdev-gallery-item.scdev-hover-lift {
    transform: translateY(0);
}

.scdev-gallery-item.scdev-hover-lift:hover {
    transform: translateY(-8px);
}

/* Gallery Content */
.scdev-gallery-content {
    position: absolute !important;
    bottom: 8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 16px) !important;
    padding: 6px 8px 2px 8px !important;
    background: var(--overlay-bg, rgba(0, 0, 0, 0.85)) !important;
    color: #ffffff !important;
    z-index: 20 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100px !important;
    min-height: 100px !important;
    overflow: visible !important;
    border-radius: 12px !important;
    pointer-events: auto;
    box-sizing: border-box !important;
    max-width: calc(100% - 16px) !important;
}

/* When no image, keep the same size as cards with images */
.scdev-gallery-item.scdev-gallery-no-image .scdev-gallery-content {
    position: absolute !important;
    bottom: 8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 16px) !important;
    height: 100px !important;
    min-height: 100px !important;
    padding: 6px 8px !important;
}

.scdev-gallery.scdev-title-overlay .scdev-gallery-content {
    position: absolute !important;
    bottom: 8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 16px) !important;
    padding: 6px 8px !important;
    background: var(--overlay-bg, rgba(0, 0, 0, 0.85)) !important;
    color: #ffffff !important;
    z-index: 20 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100px !important;
    min-height: 100px !important;
    overflow: visible !important;
    border-radius: 12px !important;
    pointer-events: auto;
    box-sizing: border-box !important;
    max-width: calc(100% - 16px) !important;
}

.scdev-gallery-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--title-text-color, #00d4ff) !important;
    line-height: 1.2 !important;
    text-align: center !important;
    display: block !important;
    margin-bottom: 2px !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.scdev-gallery-excerpt {
    margin: 0 !important;
    font-size: 13px !important;
    color: var(--excerpt-text-color, #ffffff) !important;
    line-height: 1.2 !important;
    flex-grow: 0 !important;
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    line-clamp: 2 !important;
    max-height: none !important;
    padding: 0 !important;
    min-width: 0 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    box-sizing: border-box !important;
}

.scdev-gallery-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--meta-color, #ffd700);
    margin: 2px 0 0 0 !important;
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
}

.scdev-gallery-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* When meta is shown, height stays consistent */
.scdev-gallery-content:has(.scdev-gallery-meta) {
    height: 100px !important;
    min-height: 100px !important;
}

.scdev-gallery-content:has(.scdev-gallery-meta) .scdev-gallery-excerpt {
    max-height: none !important;
}

.scdev-gallery.scdev-title-overlay .scdev-gallery-content:has(.scdev-gallery-meta) {
    height: 100px !important;
}

/* When no image and meta is shown, height stays consistent */
.scdev-gallery-item.scdev-gallery-no-image .scdev-gallery-content:has(.scdev-gallery-meta) {
    height: 100px !important;
    min-height: 100px !important;
}

.scdev-gallery-item.scdev-gallery-no-image .scdev-gallery-content:has(.scdev-gallery-meta) .scdev-gallery-excerpt {
    max-height: none !important;
}

/* Animations */
.scdev-gallery-item.scdev-anim-fade-up {
    opacity: 0;
    transform: translateY(20px);
    animation: scdev-fade-up 0.6s ease forwards;
}

.scdev-gallery-item.scdev-anim-fade-in {
    opacity: 0;
    animation: scdev-fade-in 0.6s ease forwards;
}

.scdev-gallery-item.scdev-anim-slide-up {
    opacity: 0;
    transform: translateY(30px);
    animation: scdev-slide-up 0.7s ease forwards;
}

.scdev-gallery-item.scdev-anim-zoom-in {
    opacity: 0;
    transform: scale(0.8);
    animation: scdev-zoom-in 0.7s ease forwards;
}

@keyframes scdev-fade-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scdev-fade-in {
    to {
        opacity: 1;
    }
}

@keyframes scdev-slide-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scdev-zoom-in {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stagger animations */
.scdev-gallery-item:nth-child(1) { animation-delay: 0.1s; }
.scdev-gallery-item:nth-child(2) { animation-delay: 0.2s; }
.scdev-gallery-item:nth-child(3) { animation-delay: 0.3s; }
.scdev-gallery-item:nth-child(4) { animation-delay: 0.4s; }
.scdev-gallery-item:nth-child(5) { animation-delay: 0.5s; }
.scdev-gallery-item:nth-child(6) { animation-delay: 0.6s; }
.scdev-gallery-item:nth-child(n+7) { animation-delay: 0.7s; }

/* Lightbox Styles */
.scdev-lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scdev-lightbox-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.scdev-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: scdev-lightbox-zoom 0.3s ease;
}

@keyframes scdev-lightbox-zoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scdev-lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.scdev-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.scdev-lightbox-close:hover {
    transform: scale(1.2);
}

.scdev-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 4px;
    transition: background 0.2s ease;
    z-index: 10000;
}

.scdev-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.4);
}

.scdev-lightbox-prev {
    left: -60px;
}

.scdev-lightbox-next {
    right: -60px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .scdev-gallery.scdev-gallery-grid.scdev-cols-3,
    .scdev-gallery.scdev-gallery-masonry.scdev-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .scdev-gallery-image {
        height: 200px;
    }
    
    .scdev-lightbox-prev {
        left: -40px;
    }
    
    .scdev-lightbox-next {
        right: -40px;
    }
}

@media (max-width: 480px) {
    .scdev-gallery.scdev-gallery-grid,
    .scdev-gallery.scdev-gallery-masonry {
        grid-template-columns: 1fr;
    }
    
    .scdev-gallery-image {
        height: 180px;
    }
    
    .scdev-gallery-content {
        padding: 12px;
    }
    
    .scdev-gallery-title {
        font-size: 14px;
    }
    
    .scdev-gallery-excerpt {
        font-size: 12px;
    }
    
    .scdev-lightbox-close {
        top: 10px;
        right: 10px;
    }
    
    .scdev-lightbox-prev,
    .scdev-lightbox-next {
        display: none;
    }
}
