:root {
    --bg-color: #121418;
    --sidebar-bg: #0a0b0d;
    --text-color: #e0e0e0;
    --text-secondary: #8a94a8;
    --accent-color: #d4af37;
    --font-title: 'Bebas Neue', cursive;
    --font-serif: 'Nanum Myeongjo', serif;
    --font-sans: 'Pretendard', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* MODIFIED: Allow scrolling */
    overflow-x: hidden;
}

/* ---- 4분할 레이아웃 (좌:25% / 우:75%) ---- */
.jumok-page-wrapper {
    display: flex;
    width: 100vw;
    height: 100vh;
    /* Keep as 100vh to act as the hero section */
}

/* Sidebar (좌측 고정 25%) */
.jumok-sidebar {
    flex: 0 0 25vw;
    /* 정확히 25% */
    width: 25vw;
    background-color: var(--sidebar-bg);
    /* Fallback */
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* MODIFIED: Align items to the top */
    align-items: center;
    color: var(--text-color);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    z-index: 2;
    position: relative;
    /* For video background */
    overflow: hidden;
    /* For video background */
}

/* --- NEW: Sidebar Background Video --- */
.sidebar-bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: 1;
    filter: brightness(1.1);
}

.sidebar-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(10, 11, 13, 0.3);
    z-index: 2;
}

/* Ensure content is above video and overlay */
.back-link,
.sijo-container,
.sidebar-footer {
    position: relative;
    z-index: 3;
}


/* 뒤로가기 */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: color .3s, transform .3s;
    align-self: flex-start;
}

.back-link:hover {
    color: #fff;
    transform: translateX(-5px);
}

/* --- UPDATED: Sijo Style Sidebar Content --- */
.sijo-container {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* ✅ 세로쓰기 문단의 정렬을 위쪽(시작점)으로 변경 */
    gap: 2rem;
    font-family: var(--font-serif);
    margin-top: 3vh;
    /* NEW: Added top margin for spacing */
}

.sijo-title {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 0.5rem;
    margin: 0;
    padding-right: 1.5rem;
    border-right: 2px solid var(--accent-color);
    margin-top: 3.5rem;
}

.sijo-body {
    display: flex;
    flex-direction: column;
    /* 각 시조 라인을 컨테이너의 시작점(위쪽)에 정렬합니다. */
    align-items: flex-start;
    /* This creates horizontal space between the stanzas */
    gap: 1.8rem;
    /* ✅ 제목과의 수직 간격을 주기 위해 상단 여백 추가 (값을 조절하여 위치 변경) */
    margin-top: 4.5rem;
}

.sijo-line {
    font-size: 1.2rem;
    line-height: 2.4;
    /* Horizontal spacing for wrapped lines */
    letter-spacing: 0.15rem;
    /* Vertical spacing between characters */
    color: var(--text-color);
    margin: 0;
    white-space: pre-wrap;
}


.sijo-author {
    font-size: 0.8rem;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    letter-spacing: 0.5rem;
    margin-top: 12rem;
}


.sidebar-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    align-self: flex-start;
    margin-top: auto;
    /* NEW: Pushes footer to the bottom */
}

/* ---- Gallery (우측 고정 75%) ---- */
.jumok-gallery {
    flex: 0 0 75vw;
    /* 정확히 75% */
    width: 75vw;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* ★ flex 자식 폭 0 이슈 방지 */
    overflow: hidden;
    /* 블러 효과가 적용된 pseudo-element를 담기 위해 추가 */
}

/* ✅ NEW: 유리(블러) 효과를 위한 배경 레이어 */
.jumok-gallery::before {
    content: '';
    position: absolute;
    inset: -10px;
    /* 블러 처리 시 가장자리가 흐려지는 것을 방지하기 위해 확장 */
    background-image: linear-gradient(rgba(10, 11, 13, 0.5), rgba(10, 11, 13, 0.5)), url('../assets/images/facility/jumokbg.jpg');
    background-size: cover;
    background-position: center;
    filter: blur(2px);
    /* 블러 효과 적용 */
    z-index: 1;
}

/* NEW: 모바일 전용 히어로 섹션 */
.jumok-hero-mobile {
    display: none;
    /* 데스크탑에서는 숨김 */
}

.scroll-down-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    color: #fff;
    animation: bounce 2.2s infinite ease-in-out;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translate(-50%, 0);
    }

    40% {
        transform: translate(-50%, -15px);
    }

    60% {
        transform: translate(-50%, -7px);
    }
}


/* 모바일 전용 헤더: 데스크탑에서는 숨김 */
.jumok-header-mobile {
    display: none;
}

/* Swiper 컨테이너 */
.jumok-swiper {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    /* ★ Swiper 내부 계산 0 방지 */
    height: 100%;
    opacity: 0;
    /* 초기 깜빡임 방지 */
    transition: opacity .2s ease;
    position: relative;
    /* 블러 배경 위에 콘텐츠를 올리기 위해 추가 */
    z-index: 2;
    padding: 0 4vw;
    /* 좌우 여백 추가 */
    box-sizing: border-box;
}

.jumok-swiper.ready {
    opacity: 1;
}

/* 슬라이드: 세로형 이미지가 “다 보이도록” */
.swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 10px;
    /* 이미지 간격 */
    box-sizing: border-box;
}

/* 650x1400 비율을 유지하며 최대한 크게 */
.swiper-slide img {
    display: block;
    width: auto;
    height: 90%;
    max-height: calc(100vh - 40px);
    /* 위아래 여백 감안 */
    max-width: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .3);
}

/* 네비게이션 */
.swiper-button-prev,
.swiper-button-next {
    color: #fff;
    background: rgba(0, 0, 0, .3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    backdrop-filter: blur(4px);
    transition: all .3s;
    z-index: 3;
}

.swiper-button-prev:hover,
.swiper-button-next:hover {
    background: rgba(0, 0, 0, .6);
    transform: scale(1.08);
}

.swiper-button-prev::after,
.swiper-button-next::after {
    font-size: 1.5rem;
    font-weight: 800;
}

/* 페이지네이션 */
.swiper-pagination-bullet {
    background: rgba(255, 255, 255, .5);
    opacity: 1;
    width: 10px;
    height: 10px;
}

.swiper-pagination-bullet-active {
    background: var(--accent-color);
    width: 25px;
    border-radius: 5px;
}


/* ---- NEW: Photo Gallery Section ---- */
.photo-gallery-section {
    background-color: var(--sidebar-bg);
    padding: 8rem 4rem;
    color: var(--text-color);
}

.photo-gallery-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 4rem auto;
}

.photo-gallery-header h2 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1.4;
    margin: 0 0 1.5rem 0;
}

.photo-gallery-header p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-auto-rows: 200px;
    grid-auto-flow: dense;
    gap: 1.5rem;
}

.gallery-item {
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    /* Animation styles */
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, box-shadow 0.3s ease;
}

.gallery-item.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

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

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

/* Masonry-like layout */
.gallery-item:nth-child(11n + 1) {
    grid-column: span 2;
    grid-row: span 2;
}

.gallery-item:nth-child(11n + 4) {
    grid-column: span 1;
    grid-row: span 2;
}

.gallery-item:nth-child(11n + 8) {
    grid-column: span 2;
    grid-row: span 1;
}

/* ---- 반응형 (<=1024px) ---- */
@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .jumok-page-wrapper {
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 80vh;
    }

    .jumok-sidebar {
        display: none;
    }

    /* 모바일에서 사이드바 숨김 */

    /* 모바일 전용 히어로 섹션 보이기 */
    .jumok-hero-mobile {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        position: relative;
        height: 100vh;
        width: 100%;
        color: #fff;
        overflow: hidden;
    }

    .jumok-hero-mobile .hero-bg-video {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        min-width: 100%;
        min-height: 100%;
        width: auto;
        height: auto;
        z-index: 1;
        filter: brightness(0.8);
    }

    .jumok-hero-mobile .hero-overlay {
        position: absolute;
        inset: 0;
        background-color: rgba(10, 11, 13, 0.5);
        z-index: 2;
    }

    /* Apply Sijo styles to mobile hero */
    .jumok-hero-mobile .sijo-container {
        position: relative;
        z-index: 3;
        animation: hero-fade-in 1s ease-out 0.5s both;
    }

    .jumok-hero-mobile .sijo-title {
        font-size: 2rem;
        letter-spacing: 0.4rem;
        padding-right: 1.2rem;
    }

    .jumok-hero-mobile .sijo-body {
        gap: 1.5rem;
    }

    .jumok-hero-mobile .sijo-line {
        font-size: 0.9rem;
        line-height: 2.2;
        letter-spacing: 0.1rem;
    }

    @keyframes hero-fade-in {
        from {
            opacity: 0;
            transform: translateY(20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* 모바일 상단 헤더 노출 */
    .jumok-header-mobile {
        display: block;
        padding: 2.5rem 1.5rem 1rem;
        text-align: center;
        position: relative;
        z-index: 2;
    }

    .jumok-header-mobile h1 {
        font-family: var(--font-serif);
        font-size: 1.5rem;
        color: var(--accent-color);
        margin: 0 0 .75rem;
    }

    .jumok-header-mobile p {
        font-size: 0.8rem;
        line-height: 1.7;
        color: var(--text-secondary);
        max-width: 640px;
        margin: 0 auto;
    }

    .jumok-gallery {
        width: 100vw;
        height: auto;
        min-height: 100vh;
    }

    /* ✅ 모바일에서 스크롤 시 배경이 고정된 것처럼 보이는 효과(Parallax)를 블러 레이어에 적용 */
    .jumok-gallery::before {
        background-attachment: fixed;
    }

    .jumok-swiper {
        height: 60vh;
        /* 화면 대부분 사용 */
        padding: 0 3rem;
        /* 모바일 좌우 여백 */
    }

    .swiper-button-prev,
    .swiper-button-next {
        display: none;
    }

    .photo-gallery-section {
        padding: 4rem 1.5rem;
    }

    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        grid-auto-rows: 120px;
        gap: 1rem;
    }

    /* 모바일은 버튼 숨김(스와이프/드래그 중심) */
}

@media (max-width: 600px) {
    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        grid-auto-rows: 100px;
    }
}

/* ---- NEW: Photo Gallery Lightbox ---- */
.photo-gallery-section.is-focused .photo-gallery,
.photo-gallery-section.is-focused .photo-gallery-header {
    filter: blur(8px);
    transform: scale(0.98);
    transition: filter 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.gallery-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    cursor: pointer;
}

.gallery-lightbox-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.gallery-lightbox-overlay img {
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s ease;
    cursor: default;
}

.gallery-lightbox-overlay.visible img {
    transform: scale(1);
    opacity: 1;
}

/* NEW: Navigation Buttons for Lightbox */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    /* Above image */
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: clamp(1rem, 5vw, 3rem);
}

.lightbox-next {
    right: clamp(1rem, 5vw, 3rem);
}

.lightbox-nav svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
}


/* NEW: Footer */
.facility-footer {
    padding: 1rem 1rem;
    background-color: var(--bg-dark);
    color: var(--text-secondary);
    border-top: 2px solid;
    border-image: linear-gradient(to right, transparent, var(--accent-color), transparent) 1;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.copyright {
    font-size: 0.8rem;
    margin: 0;
}


@media (max-width: 768px) {

    /* Base transform for mobile is rotate(0). The transition on the `img` tag will handle changes. */
    .gallery-lightbox-overlay.visible img.portrait {
        transform: scale(1) rotate(0deg);
    }

    .gallery-lightbox-overlay img.landscape {
        /* Swap constraints to fit the rotated image */
        max-width: 90vh;
        max-height: 90vw;
    }

    /* When the overlay becomes visible, animate landscape images to scale(1) and rotate(90deg) */
    .gallery-lightbox-overlay.visible img.landscape {
        transform: scale(1) rotate(90deg);
    }

    /* Set the initial state for landscape images before the animation starts */
    .gallery-lightbox-overlay img.landscape {
        transform: scale(0.9) rotate(90deg);
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }
}