/* ── Gallery – Client Page ── */

.gallery-page {
    --gallery-accent: #2d4d8a;
    --gallery-accent-soft: rgba(45, 77, 138, 0.08);
    --gallery-shade: linear-gradient(180deg, rgba(10, 24, 16, 0) 40%, rgba(10, 24, 16, 0.78) 100%);
}

/* ══════════════════════════════════════════════════════════════
   Album List — 앨범 하나 = 대표 사진 한 장, 위에 날짜·제목
   ══════════════════════════════════════════════════════════════ */

.gallery-albums {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    list-style: none;
}

.gallery-album {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.gallery-album:hover {
    border-color: var(--gallery-accent);
    box-shadow: 0 10px 24px rgba(16, 32, 51, 0.08);
}

.gallery-album__media {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--surface-muted);
}

.gallery-album__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

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

.gallery-album__count {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(10, 24, 16, 0.55);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
}

.gallery-album__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px 18px;
}

.gallery-album__date {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--gallery-accent);
}

.gallery-album__title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.45;
}

.gallery-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
    font-size: 0.95rem;
}

/* ── Pagination ── */

.gallery-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.gallery-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.15s;
}

.gallery-page-link:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.gallery-page-link.is-active {
    background: var(--gallery-accent);
    color: #fff;
    font-weight: 700;
    pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   Album View
   ══════════════════════════════════════════════════════════════ */

.gallery-detail {
    padding: 32px 28px;
}

.gallery-detail-header {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

.gallery-detail-date {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gallery-accent);
}

.gallery-detail-title {
    margin-top: 6px;
    font-size: clamp(1.3rem, 2.4vw, 1.75rem);
    line-height: 1.35;
    color: var(--text);
}

.gallery-detail-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-top: 12px;
}

.gallery-detail-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    color: var(--muted);
}

.gallery-detail-meta-item svg {
    opacity: 0.55;
}

.gallery-slideshow-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--gallery-accent);
    color: #fff;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.gallery-slideshow-btn[hidden] {
    display: none;
}

.gallery-slideshow-btn:hover {
    background: #223c6d;
}

.gallery-detail-desc {
    margin-top: 16px;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
}

/* ── 사진 흐름 격자 ──
   사진마다 비율(--r = 가로÷세로)만큼 늘어나 한 줄 높이가 고르게 맞는다. 자르지 않고 본래 모양을 살린다.
   마지막 줄은 ::after 가 남은 자리를 차지해 사진이 억지로 늘어나지 않는다. */

.photo-flow {
    --row: 260px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
}

.photo-flow::after {
    content: "";
    flex-grow: 999;
}

.photo-flow li {
    flex: var(--r) 1 calc(var(--r) * var(--row));
}

.photo-flow__item {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: var(--r);
    border-radius: 10px;
    background: var(--surface-muted);
}

.photo-flow__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.photo-flow__caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 28px 14px 12px;
    background: var(--gallery-shade);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s, transform 0.3s;
}

.photo-flow__item:hover img {
    transform: scale(1.04);
}

.photo-flow__item:hover .photo-flow__caption,
.photo-flow__item:focus-visible .photo-flow__caption {
    opacity: 1;
    transform: none;
}

/* ── Prev / Next Album ── */

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

.gallery-nav-link {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 120px;
    overflow: hidden;
    border-radius: 14px;
    background: #1a3a28;
    color: #fff;
    text-decoration: none;
    isolation: isolate;
}

.gallery-nav-link--empty {
    background: none;
}

.gallery-nav-link img {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.gallery-nav-link:not(.gallery-nav-link--empty)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(10, 24, 16, 0.6);
    transition: background 0.3s;
}

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

.gallery-nav-link:hover::after {
    background: rgba(10, 24, 16, 0.45);
}

.gallery-nav-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 18px 22px;
}

.gallery-nav-link--next .gallery-nav-text {
    margin-left: auto;
    text-align: right;
}

.gallery-nav-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.gallery-nav-title {
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Back to list button ── */

.gallery-back-wrap {
    display: flex;
    justify-content: center;
}

.gallery-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.15s;
}

.gallery-back-btn:hover {
    color: var(--text);
    border-color: var(--line-strong);
}

/* ══════════════════════════════════════════════════════════════
   Lightbox — 어두운 전체 화면 · 위 줄(번호·앨범 이름) · 아래 필름 줄
   ══════════════════════════════════════════════════════════════ */

.is-lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: #0b1610;
    color: #fff;
}

.lightbox[hidden] {
    display: none;
}

.lightbox__top {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    padding: 0 88px 0 24px;
    font-size: 0.82rem;
}

.lightbox__count {
    flex: none;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.lightbox__title {
    overflow: hidden;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lightbox__stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 0 88px;
}

.lightbox__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.lightbox__img.is-shown {
    opacity: 1;
}

.lightbox__caption {
    min-height: 1.6em;
    padding: 14px 24px 0;
    text-align: center;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.75);
}

.lightbox__strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 16px 24px 20px;
    scrollbar-width: none;
}

.lightbox__strip::-webkit-scrollbar {
    display: none;
}

/* 필름 줄이 화면보다 짧으면 가운데로 모은다 */
.lightbox__thumb:first-child { margin-left: auto; }
.lightbox__thumb:last-child { margin-right: auto; }

.lightbox__thumb {
    flex: none;
    width: 72px;
    height: 52px;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    opacity: 0.4;
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: opacity 0.2s, outline-color 0.2s;
}

.lightbox__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox__thumb:hover,
.lightbox__thumb:focus-visible {
    opacity: 0.8;
}

.lightbox__thumb.is-current {
    opacity: 1;
    outline-color: #8fd3a8;
}

.lightbox--single .lightbox__strip,
.lightbox--single .lightbox__btn--prev,
.lightbox--single .lightbox__btn--next {
    display: none;
}

.lightbox__btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox__btn:hover,
.lightbox__btn:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox__btn::before {
    content: "";
    width: 11px;
    height: 11px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
}

.lightbox__btn--prev { left: 20px; top: 50%; margin-top: -24px; }
.lightbox__btn--prev::before { transform: translateX(2px) rotate(-135deg); }
.lightbox__btn--next { right: 20px; top: 50%; margin-top: -24px; }
.lightbox__btn--next::before { transform: translateX(-2px) rotate(45deg); }
.lightbox__btn--close { top: 8px; right: 20px; }

/* 닫기는 X 모양 — 두 선을 겹친다 */
.lightbox__btn--close::before,
.lightbox__btn--close::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 0;
    border: 0;
    border-top: 2px solid currentColor;
    transform: rotate(45deg);
}

.lightbox__btn--close::after {
    transform: rotate(-45deg);
}

/* ══════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .gallery-albums {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .photo-flow {
        --row: 200px;
    }
}

@media (max-width: 768px) {
    .gallery-albums {
        gap: 12px;
    }

    .gallery-album {
        border-radius: 12px;
    }

    .gallery-album__count {
        top: 8px;
        right: 8px;
        padding: 2px 8px;
    }

    .gallery-album__body {
        padding: 12px 12px 14px;
    }

    .gallery-album__title {
        font-size: 0.85rem;
    }

    .gallery-detail {
        padding: 22px 16px;
    }

    .photo-flow {
        --row: 120px;
        gap: 6px;
    }

    .photo-flow__item {
        border-radius: 8px;
    }

    .photo-flow__caption {
        display: none;
    }

    .gallery-nav {
        grid-template-columns: minmax(0, 1fr);
    }

    .gallery-nav-link {
        min-height: 96px;
    }

    .gallery-nav-link--empty {
        display: none;
    }

    .lightbox__top {
        padding-right: 72px;
    }

    .lightbox__stage {
        padding: 0;
    }

    .lightbox__img {
        border-radius: 0;
    }

    .lightbox__thumb {
        width: 56px;
        height: 42px;
    }

    /* 좁은 화면은 밀어서 넘긴다. 단추는 필름 줄 위 양옆에 작게 둔다 */
    .lightbox__btn--prev,
    .lightbox__btn--next {
        top: auto;
        bottom: 96px;
        width: 40px;
        height: 40px;
        margin-top: 0;
    }

    .lightbox__btn--prev { left: 12px; }
    .lightbox__btn--next { right: 12px; }
}

@media (max-width: 480px) {
    .gallery-albums {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-album__media img,
    .photo-flow__item img,
    .gallery-nav-link img,
    .lightbox__img {
        transition: none;
    }
}
