/**
 * Folder Gallery 스타일
 */

.folder-gallery {
    width: calc(100% + 1rem);
    margin: 0 auto;
    margin-left: -.5rem;
    display: flex !important;
    flex-wrap: wrap !important;
    box-sizing: border-box !important;
}

.gallery-item {
    padding: .5rem !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin: 0 !important;
    width: var(--fg-col-width, 25%) !important;
    max-width: var(--fg-col-width, 25%) !important;
    flex: 0 0 var(--fg-col-width, 25%) !important;
}

/* 모바일에서만 한 줄에 2개씩 표시 */
@media (max-width: 767px) {
    .gallery-item {
        width: var(--fg-col-width-mobile, 50%) !important;
        max-width: var(--fg-col-width-mobile, 50%) !important;
        flex: 0 0 var(--fg-col-width-mobile, 50%) !important;
    }
}

.gallery-link {
    display: block;
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    overflow: hidden;
    border-radius: .7rem;
}

.gallery-item img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    cursor: pointer !important;
    border-radius: var(--radius) !important;
    transition: all 0.2s ease !important;
}

.gallery-item img:hover {
    filter: brightness(75%) !important;
}

/* 갤러리 모달 스타일 */
.gallery-modal {
    display: block;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0);
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    pointer-events: none;
}

.gallery-modal.show {
    background: rgba(230,229,222, 0.95);
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 90%;
    width: 90%;
    margin-top: 2.5%;
    margin-left: 5%;
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

@media (max-width: 767px) {
    .modal-content {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 95%;
        width: 94%;
        margin-top: 2.5%;
        margin-left: 3%;
        transform: scale(0.9);
        transition: transform 0.2s ease;
    }
}

.gallery-modal.show .modal-content {
    transform: scale(1);
}

.modal-close, .modal-prev, .modal-next {
    position: absolute;
    z-index: 10000;
}

.modal-image {
    max-width: 90%;
    max-height: 90%;
    border: 3px solid #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

@media (max-width: 767px) {
    .modal-image {
        max-width: 100%;
        max-height: 80%;
        border: 3px solid #fff;
        box-shadow: 0 0 20px rgba(0,0,0,0.2);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 4rem;
    color: #000;
    font-size: 5rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    user-select: none;
}

/* ✅ FIX: content: url()는 ::before/::after 전용 — span에는 적용 안 됨
   background-image 방식으로 교체 */
.modal-prev,
.modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 5rem;
    height: 5rem;
    cursor: pointer;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 50%;
    border-radius: 99rem;
    display: block;
}

.modal-prev {
    left: 3rem;
}

.modal-next {
    right: 3rem;
}

/* 모바일에서 이전, 다음 버튼을 하단 중앙에 배치 */
@media (max-width: 467px) {
    .modal-close {
        top: .8rem;
        right: 2.5rem;
        font-size: 4rem;
    }

    .modal-prev,
    .modal-next {
        top: auto;
        bottom: 3%;
        transform: none;
        width: 4.2rem;
        height: 4.2rem;
    }

    .modal-prev {
        left: calc(50% - 16%);
    }

    .modal-next {
        right: calc(50% - 16%);
    }
}

/* ✅ FIX: 모달 타이틀 — :after { content: "" } 방식은 빈 문자열이라 아무것도 표시 안 됨
   <p> 요소 자체에 스타일 적용하고, JS에서 textContent로 채우도록 변경 */
.modal-title {
    position: absolute;
    top: -1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.4rem;
    font-weight: 500;
    color: #fff;
    background: rgba(0,0,0,0.4);
    padding: .6rem 2rem;
    border-radius: 99rem;
    white-space: nowrap;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-title:empty {
    display: none;
}

@media (max-width: 767px) {
    .modal-title {
        position: absolute;
        bottom: auto;
        top: 1rem;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 99rem;
        max-width: 70%;
    }
}

/* 슬라이드 애니메이션 */
@keyframes fg-slide-from-right {
    from { transform: translateX(60px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fg-slide-from-left {
    from { transform: translateX(-60px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}
.modal-image.slide-in-right { animation: fg-slide-from-right .25s ease; }
.modal-image.slide-in-left  { animation: fg-slide-from-left  .25s ease; }
