/**
 * 개선된 이미지 갤러리 시스템
 * 작은 썸네일 -> 클릭하면 큰 모달
 * @author Coco & Jake
 * @since 2025-06-27
 */

/* 갤러리 컨테이너 */
.image-gallery {
    margin: 25px 0;
    display: grid;
    gap: 15px;
    border-radius: 15px;
    padding: 20px;
    background: var(--bg-tertiary, #2d2d2d);
}

/* 1개 이미지: 1칸 */
.image-gallery.single-column {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 25px auto;
}

/* 2개 이미지: 2칸 */
.image-gallery.two-column {
    grid-template-columns: 1fr 1fr;
    max-width: 600px;
    margin: 25px auto;
}

/* 3개 이상: 반응형 그리드 */
.image-gallery.multi-column {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    max-width: 900px;
    margin: 25px auto;
}

/* 갤러리 아이템 */
.gallery-item {
    position: relative;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item:hover {
    transform: translateY(-5px);
    border-color: #FFD700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.25);
}

/* 썸네일 이미지 */
.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: all 0.3s ease;
    display: block;
}

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

/* 캡션 */
.gallery-item .image-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 15px 12px 12px;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
}

/* 확대 아이콘 */
.gallery-item::before {
    content: "🔍";
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2;
}

.gallery-item:hover::before {
    opacity: 1;
    background: rgba(255, 215, 0, 0.9);
}

/* 인라인 이미지 (기존 guide-image) */
.guide-image-container {
    text-align: center;
    margin: 25px 0;
}

.guide-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid transparent;
}

.guide-image:hover {
    transform: scale(1.02);
    border-color: #FFD700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.3);
}

/* 갤러리 모달 - 개선된 버전 */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-modal.show {
    opacity: 1;
}

.gallery-modal-content {
    display: block;
    margin: auto;
    max-width: 95%;
    max-height: 90vh;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    cursor: zoom-out;
    object-fit: contain;
    transition: transform 0.3s ease;
    border: 3px solid #FFD700;
}

.gallery-modal.show .gallery-modal-content {
    transform: translate(-50%, -50%) scale(1);
}

/* 닫기 버튼 */
.gallery-close {
    position: absolute;
    top: 20px;
    right: 25px;
    color: #f1f1f1;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.gallery-close:hover {
    color: #FFD700;
    transform: scale(1.1) rotate(90deg);
    background: rgba(255, 215, 0, 0.2);
    border-color: #FFD700;
}

/* 캡션 */
.gallery-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    text-align: center;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 25px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-size: 1rem;
    font-weight: 500;
    max-width: 80%;
}

/* 네비게이션 버튼 */
.gallery-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    transform: translateY(-50%);
    pointer-events: none;
}

.gallery-prev,
.gallery-next {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 24px;
    border-radius: 50%;
    transition: all 0.3s ease;
    pointer-events: auto;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-prev:hover,
.gallery-next:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
    color: #FFD700;
    transform: scale(1.1);
}

/* 로딩 스피너 */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10001;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 모달이 열렸을 때 body 스크롤 방지 */
body.gallery-modal-open {
    overflow: hidden;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .image-gallery.two-column {
        grid-template-columns: 1fr;
        max-width: 350px;
    }
    
    .image-gallery.multi-column {
        grid-template-columns: 1fr;
        max-width: 350px;
    }
    
    .gallery-item img {
        height: 180px;
    }
    
    .gallery-modal-content {
        max-width: 98%;
        max-height: 85vh;
    }
    
    .gallery-close {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 28px;
    }
    
    .gallery-nav {
        padding: 0 15px;
    }
    
    .gallery-prev,
    .gallery-next {
        width: 50px;
        height: 50px;
        font-size: 20px;
        padding: 10px;
    }
    
    .gallery-caption {
        bottom: 15px;
        font-size: 0.9rem;
        padding: 10px 20px;
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .image-gallery {
        margin: 20px 10px;
        padding: 15px;
    }
    
    .gallery-item img {
        height: 160px;
    }
}