/* ===================================
   산애들발효원 - 갤러리 스타일
   =================================== */

/* ---- 갤러리 섹션 ---- */
.gallery-section {
    background: var(--bg-light);
    min-height: 60vh;
}

/* ---- 필터 탭 ---- */
.gallery-filter {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 50px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 28px;
    border-radius: 30px;
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--text-mid);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Noto Sans KR', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* ---- 갤러리 그리드 ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-bottom: 50px;
}

/* ---- 게시글 카드 ---- */
.gallery-card {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px var(--shadow);
}

.gallery-card-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--bg-cream);
    position: relative;
}

.gallery-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.gallery-card:hover .gallery-card-thumb img {
    transform: scale(1.06);
}

.gallery-card-thumb .thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--text-light);
    font-size: 13px;
}

.gallery-card-thumb .thumb-placeholder i {
    font-size: 40px;
    color: var(--border);
}

.photo-count-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.gallery-card-body {
    padding: 20px;
}

.gallery-card-category {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--accent);
    background: var(--bg-cream);
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.gallery-card-title {
    font-family: 'Noto Serif KR', serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 12px;
}

.gallery-card-date {
    display: flex;
    align-items: center;
    gap: 5px;
}

.gallery-card-views {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---- 로딩 스피너 ---- */
.gallery-loading {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-light);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* ---- 빈 상태 ---- */
.gallery-empty {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-light);
}

.gallery-empty .empty-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.gallery-empty h3 {
    font-size: 20px;
    color: var(--text-mid);
    margin-bottom: 10px;
}

.gallery-empty p {
    font-size: 14px;
}

/* ---- 페이지네이션 ---- */
.gallery-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.page-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-mid);
    font-size: 14px;
    font-family: 'Noto Sans KR', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* ---- 게시글 상세 모달 ---- */
.post-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.post-modal.open {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    z-index: 1;
    background: var(--white);
    border-radius: 20px;
    width: 90%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    animation: modalIn 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--bg-cream);
    color: var(--text-mid);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--primary);
    color: var(--white);
}

.modal-header {
    padding: 30px 30px 0;
}

.modal-title {
    font-family: 'Noto Serif KR', serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
    padding-right: 40px;
}

.modal-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.modal-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ---- 모달 슬라이더 ---- */
.modal-slider {
    position: relative;
    background: #000;
    overflow: hidden;
}

.modal-slides {
    display: flex;
    transition: transform 0.4s ease;
}

.modal-slide-item {
    min-width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-slide-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 5;
}

.modal-arrow:hover {
    background: rgba(255,255,255,0.5);
}

.modal-prev { left: 14px; }
.modal-next { right: 14px; }

.modal-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-counter {
    position: absolute;
    bottom: 14px;
    right: 16px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
}

.modal-dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.modal-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.45);
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.modal-dot.active {
    background: #fff;
}

/* ---- 모달 썸네일 ---- */
.modal-thumbnails {
    display: flex;
    gap: 8px;
    padding: 14px 30px;
    overflow-x: auto;
    background: var(--bg-cream);
    scrollbar-width: thin;
}

.modal-thumb-item {
    min-width: 70px;
    width: 70px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.modal-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-thumb-item.active {
    border-color: var(--primary);
}

/* ---- 모달 본문 ---- */
.modal-content-text {
    padding: 24px 30px 30px;
    font-size: 15px;
    color: var(--text-mid);
    line-height: 1.8;
    border-top: 1px solid var(--border);
    white-space: pre-line;
}

/* ---- 반응형 ---- */
@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

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

    .gallery-filter {
        gap: 8px;
        margin-bottom: 30px;
    }

    .filter-btn {
        padding: 8px 18px;
        font-size: 13px;
    }

    .modal-container {
        width: 96%;
        max-height: 92vh;
        border-radius: 14px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-header {
        padding: 20px 20px 0;
    }

    .modal-content-text {
        padding: 18px 20px 24px;
    }

    .modal-thumbnails {
        padding: 12px 20px;
    }
}
