/* ==============================================
   색상 변수 정의
   ============================================== 
   여기서 전체 사이트의 색상을 한 번에 조절할 수 있습니다.
   
   --bg-color: 전체 배경 색상 (기본: 흰색)
   --text-color: 기본 텍스트 색상 (기본: 검은색)
   --text-secondary: 보조 텍스트 색상, 작품 설명 등 (기본: 회색)
   --border-color: 테두리 색상 (기본: 연한 회색)
   --highlight-bg: 선택된 항목 배경색 (기본: 연초록)
   --hover-color: 마우스 오버시 배경색 (기본: 형광연두) 
                  ⭐ 이 색을 변경하면 호버 효과 색상이 바뀝니다
   --link-hover: 링크 호버 텍스트 색상
   --sidebar-width: 사이드바 너비 (기본: 280px)
                    ⭐ 이 값을 변경하면 사이드바 너비가 바뀝니다
*/
:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --highlight-bg: #00d4ff;
    --hover-color: #b8ff57;
    --link-hover: #000000;
    --sidebar-width: 280px;
}

/* ==============================================
   리셋 및 기본 스타일
   ============================================== 
   브라우저 기본 스타일을 초기화하고 통일합니다
*/

/* 모든 요소의 여백과 패딩을 0으로 초기화 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;  /* 패딩과 테두리를 width에 포함 */
}

html {
    overflow-x: hidden; /* 좌우 스크롤 완전 차단 */
    width: 100%;
}

/* body 전체 스타일
   - font-family: 시스템 기본 폰트 사용 (맥/윈도우 자동 대응)
   - font-size: 기본 글자 크기 15px ⭐ 전체 글자 크기 조절
   - line-height: 줄 간격 1.6배
   - display: flex로 사이드바와 메인 영역을 나란히 배치
*/
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; /* 좌우 스크롤 방지 */
    width: 100%;
    position: relative;
}

/* ==============================================
   사이드바 (왼쪽 고정 메뉴)
   ============================================== 
   - position: fixed → 스크롤해도 고정
   - width: 280px (--sidebar-width 변수로 제어)
   - height: 100vh → 화면 전체 높이
   - overflow-y: auto → 내용이 많으면 스크롤 가능
   - padding: 40px 30px → 상하 40px, 좌우 30px 여백
*/
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 40px 30px;
    overflow-y: auto;
    background: var(--bg-color);
    z-index: 100;
}

/* 작가 이름 (Lee Jaewon)
   - font-size: 24px ⭐ 작가 이름 크기 조절
   - margin-bottom: 50px ⭐ 작가 이름과 메뉴 사이 간격
*/
.artist-name {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 50px;
    letter-spacing: -0.02em;
}

.project-nav {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.project-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.project-group.standalone {
    gap: 8px;
}

.project-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-color);
    position: relative;
    display: inline-block;
}

.title-toggle {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    user-select: none;
    display: inline-block;
}

.title-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.title-toggle::before {
    content: '▼';
    display: inline-block;
    margin-right: 6px;
    font-size: 10px;
    transition: transform 0.3s ease;
}

.title-toggle.collapsed::before {
    transform: rotate(-90deg);
}

/* 프로젝트 링크 컨테이너
   ============================================== 
   - max-height: 2000px → 항목이 많아도 모두 표시 가능
   - 접혔을 때만 max-height: 0
*/
.project-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0px;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.project-links.collapsed {
    max-height: 0;
    opacity: 0;
}

/* 작품 링크 스타일
   ============================================== 
   사이드바의 각 작품 링크 스타일
   
   - 기본: 검은 글씨, 투명 배경
   - 호버 (마우스 올렸을 때): 형광연두 배경 + 검은 글씨
   - active (현재 페이지): 연초록 배경
   
   ⭐ 호버 색상 변경: 상단 :root의 --hover-color 값 수정
*/
.work-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    cursor: pointer;
}

/* 마우스 오버시 형광연두 배경 */
.work-link:hover,
.work-link:active {
    background: var(--hover-color);
    color: var(--text-color);
}

/* 현재 페이지 표시 (연초록 배경) */
.work-link.active {
    background: var(--highlight-bg);
    color: var(--text-color);
}

/* 현재 페이지에 마우스 오버시 */
.work-link.active:hover,
.work-link.active:active {
    background: var(--hover-color);
    color: var(--text-color);
}

/* 갤러리 호버시 사이드바 하이라이트 */
.work-link.temp-highlight {
    background: var(--hover-color);
    color: var(--text-color);
}

/* ==============================================
   하위 메뉴 스타일 (Unfold and Fold 1~7 등)
   ============================================== 
   클릭하면 펼쳐지거나 접히는 하위 항목들
   - padding-left: 15px → 들여쓰기로 계층 구조 표시
   - max-height: 1000px → 하위 항목이 많아도 모두 표시 가능
*/
.sub-menu {
    padding-left: 15px;
    display: flex;
    flex-direction: column;
    gap: 0px;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

/* 접힌 상태 */
.sub-menu.collapsed {
    max-height: 0;
    opacity: 0;
}

/* 하위 메뉴 토글 버튼 (예: "Unfold and Fold" 클릭 영역)
   ============================================== 
   클릭하면 하위 항목이 펼쳐지거나 접힘
*/
.sub-menu-toggle {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    color: var(--text-color);
    text-decoration: none;
}

/* 마우스 오버시 형광연두 배경 */
.sub-menu-toggle:hover,
.sub-menu-toggle:active {
    background: var(--hover-color);
    color: var(--text-color);
}

/* 펼침/접힘 아이콘 (▼) */
.sub-menu-toggle::before {
    content: '▼';
    display: inline-block;
    margin-right: 6px;
    font-size: 8px;
    transition: transform 0.3s ease;
}

/* 접혔을 때 아이콘 회전 (▶) */
.sub-menu-toggle.collapsed::before {
    transform: rotate(-90deg);
}

/* 메인 콘텐츠 */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 60px 80px;
    max-width: 100%;
    overflow-x: hidden;
}

.gallery-section {
    margin-bottom: 80px;
}

.section-title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 30px;
    text-align: center;
    letter-spacing: -0.01em;
}

/* 갤러리 그리드 */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.gallery-item {
    text-decoration: none;
    color: var(--text-color);
    display: block;
    transition: transform 0.3s ease;
    text-align: center;
}

.gallery-item:hover,
.gallery-item:active {
    transform: translateY(-4px);
}

/* 갤러리 아이템 하이라이트 효과
   ============================================== 
   사이드바 호버 or 갤러리 자체 호버시 캡션 배경색 변경
*/
.gallery-item.highlight .image-caption {
    background: var(--hover-color);
    color: var(--text-color);
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
}

.image-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    overflow: hidden;
    background: #f5f5f5;
    margin-bottom: 12px;
}

.image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

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

.image-caption {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

/* 작품 상세 페이지 */
.work-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 60px 80px;
    max-width: 1000px;
    overflow-x: hidden;
}

/* 텍스트 페이지 */
.text-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 60px 80px;
    max-width: 900px;
    min-height: 100vh;
    overflow-x: hidden;
}
#textContainer {
    width: 100%;
}

.work-header {
    margin-bottom: 40px;
    position: relative;
}

.work-title {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 10px;
    white-space: pre-line; /* \n 줄바꿈 지원 */
}

.work-info {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* 타이틀 아래 추가 정보 */
/* works-data.js에서: subInfo: '추가 정보' */
/* 줄바꿈: subInfo: '줄1\n줄2' */
.work-sub-info {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-top: 8px;
    white-space: pre-line;
}

/* 이미지 아래 추가 정보 */
/* works-data.js에서: bottomInfo: '하단 정보' */
/* 줄바꿈: bottomInfo: '줄1\n줄2' */
.work-bottom-info {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-top: 40px;
    white-space: pre-line;
}

/* info / subInfo / bottomInfo 내부 링크 스타일 */
.work-info a,
.work-sub-info a,
.work-bottom-info a {
    color: var(--text-secondary);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.work-info a:hover,
.work-sub-info a:hover,
.work-bottom-info a:hover {
    color: var(--text-color);
}

.work-nav {
    position: fixed;
    right: 40px;
    top: 60px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 50;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
}

.nav-btn:hover {
    background: #f5f5f5;
    border-color: var(--text-color);
}

.work-images {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 100%;
}

.work-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.work-image:hover {
    opacity: 0.9;
}

/* 라이트박스 */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    display: block;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* 반응형 */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
    
    .main-content {
        padding: 40px 40px;
    }
}

/* 모바일 세로 모드 (portrait) */
@media (max-width: 768px) and (orientation: portrait) {
    /* 사이드바 - 너비 증가 */
    .sidebar {
        width: 110px; /* 100px → 110px */
        padding: 15px 8px 15px 12px;
        font-size: 9px;
        overflow-y: auto; /* 세로 스크롤만 */
        overflow-x: hidden; /* 가로 스크롤 차단 */
    }
    
    /* 작가 이름 */
    .artist-name {
        font-size: 12px;
        margin-bottom: 20px;
        font-weight: 600; /* 굵게 */
    }
    
    /* 메뉴 글자 크기 */
    .project-title {
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .work-link,
    .sub-menu-toggle {
        font-size: 9px;
        padding: 1px 2px;
    }
    
    /* 하위 메뉴 들여쓰기 */
    .sub-menu {
        padding-left: 5px;
        gap: 0px;
    }
    
    /* 화살표 아이콘 크기 */
    .title-toggle::before,
    .sub-menu-toggle::before {
        font-size: 6px;
        margin-right: 3px;
    }
    
    /* 메인 콘텐츠 - 사이드바 너비에 맞춤 */
    .main-content,
    .work-content,
    .text-content {
        margin-left: 110px; /* 100px → 110px */
        padding: 15px 24px 15px 10px;
        max-width: calc(100vw - 110px); /* 100px → 110px */
        width: calc(100vw - 110px); /* 100px → 110px */
        overflow-x: hidden;
    }
    
    /* 갤러리 섹션 간격 축소 */
    .gallery-section {
        margin-bottom: 40px !important; /* 80px → 40px */
    }
    
    /* 갤러리 섹션 타이틀 축소 */
    .section-title {
        font-size: 15px !important; /* 16px → 15px */
        margin-bottom: 15px !important; /* 30px → 15px */
    }
    
    /* 갤러리 2열 */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    /* 이미지 캡션 */
    .image-caption {
        font-size: 8px;
    }
    
    /* 작품 이미지 - 사이 여백 제거 */
    .work-images {
        max-width: 100%;
        width: 100%;
    }
    
    .work-image {
        max-width: 100%;
        width: 100%;
        height: auto;
        margin-bottom: 0 !important; /* 여백 제거 */
    }
    
    /* 비디오 링크 컨테이너 - 사이 여백 제거 */
    .work-images a[target="_blank"] {
        display: block;
        margin-bottom: 0 !important; /* 여백 제거 */
    }
    
    .work-images a[target="_blank"] > div {
        position: relative !important;
        padding-bottom: 56.25% !important; /* 16:9 비율 강제 */
        height: 0 !important;
        overflow: hidden !important;
        background: #000 !important;
    }
    
    .work-images a[target="_blank"] > div img {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* 플레이 버튼 크기 조정 */
    .work-images a[target="_blank"] > div > div {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        font-size: 35px !important;
        width: 60px !important;
        height: 60px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* 작품 페이지 - 제목 한 줄 처리 */
    .work-title {
        font-size: 14px !important;
        margin-bottom: 8px;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* 작품 정보 */
    .work-info,
    .work-sub-info,
    .work-bottom-info {
        font-size: 10px !important;
        line-height: 1.6 !important;
        margin-bottom: 10px;
    }
    
    .work-info a,
    .work-sub-info a,
    .work-bottom-info a {
        font-size: 10px !important;
    }
    
    /* 텍스트 페이지 본문 */
    #workImages h2,
    #workImages h3,
    .text-content h2,
    .text-content h3 {
        font-size: 15px !important;
        margin-bottom: 10px !important;
    }
    
    #workImages p,
    #workImages div,
    .text-content p,
    .text-content div,
    .work-content p,
    .work-content div {
        font-size: 10px !important;
        line-height: 1.6 !important;
        margin-bottom: 8px;
    }
    
    /* 인라인 스타일 덮어쓰기 */
    .text-content div[style],
    .work-content div[style],
    #workImages div[style] {
        font-size: 10px !important;
        line-height: 1.6 !important;
    }
    
    /* 네비게이션 버튼 */
    .work-nav {
        right: 5px;
        top: 5px;
        gap: 5px;
    }
    
    .nav-btn {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
    
    /* 푸터 위치 수정 */
    .site-footer {
        margin-left: 0 !important;
        padding: 10px !important;
        font-size: 7px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        text-align: center;
    }
}

/* 모바일 가로 모드 (landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    /* 사이드바 - 여백 증가 */
    .sidebar {
        width: 140px;
        padding: 20px 15px; /* 여백 증가 */
        font-size: 10px;
        overflow-y: auto;
    }
    
    /* 작가 이름 */
    .artist-name {
        font-size: 15px;
        margin-bottom: 25px;
        font-weight: 600; /* 굵게 */
    }
    
    /* 메뉴 */
    .project-title {
        font-size: 11px;
    }
    
    .work-link,
    .sub-menu-toggle {
        font-size: 10px;
    }
    
    .sub-menu {
        padding-left: 8px;
    }
    
    /* 메인 콘텐츠 - 여백 증가 */
    .main-content,
    .work-content,
    .text-content {
        margin-left: 140px;
        padding: 20px 60px 20px 20px; /* 오른쪽 여백 3배 */
        max-width: calc(100vw - 140px);
        overflow-x: hidden;
        width: calc(100vw - 140px);
    }
    
    /* 갤러리 3열 - 여백 증가 */
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px; /* 여백 증가 */
        width: 100%;
        padding: 0 10px; /* 좌우 여백 추가 */
    }
    
    .image-caption {
        font-size: 9px;
    }
    
    /* 작품 이미지 */
    .work-images {
        max-width: 100%;
        width: 100%;
    }
    
    .work-image {
        max-width: 100%;
        width: 100%;
        height: auto;
    }
    
    /* 비디오 링크 컨테이너 비율 수정 */
    .work-images a[target="_blank"] > div {
        position: relative !important;
        padding-bottom: 56.25% !important; /* 16:9 비율 강제 */
        height: 0 !important;
        overflow: hidden !important;
        background: #000 !important;
    }
    
    .work-images a[target="_blank"] > div img {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* 플레이 버튼 크기 조정 */
    .work-images a[target="_blank"] > div > div {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        font-size: 40px !important; /* 삼각형 크기 증가 */
        width: 70px !important; /* 동그라미 크기 */
        height: 70px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* 작품 페이지 - 제목은 크게 유지 */
    .work-title {
        font-size: 18px !important;
        margin-bottom: 8px;
    }
    
    /* 작품 정보 텍스트 */
    .work-info,
    .work-sub-info,
    .work-bottom-info {
        font-size: 11px !important;
        line-height: 1.5 !important;
    }
    
    .work-info a,
    .work-sub-info a,
    .work-bottom-info a {
        font-size: 11px !important;
    }
    
    /* 텍스트 페이지 본문 */
    #workImages h2,
    #workImages h3,
    .text-content h2,
    .text-content h3 {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }
    
    #workImages p,
    #workImages div,
    .text-content p,
    .text-content div,
    .work-content p,
    .work-content div {
        font-size: 9px !important; /* 10px → 9px */
        line-height: 1.5 !important;
    }
    
    /* 인라인 스타일 덮어쓰기 */
    .text-content div[style],
    .work-content div[style],
    #workImages div[style] {
        font-size: 9px !important; /* 10px → 9px */
        line-height: 1.5 !important;
    }
    
    /* 네비게이션 */
    .work-nav {
        right: 8px;
        top: 8px;
        gap: 8px;
    }
    
    .nav-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    /* 푸터 위치 수정 */
    .site-footer {
        margin-left: 0 !important; /* 왼쪽 여백 제거 */
        padding: 10px !important;
        font-size: 7px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        text-align: center;
    }
}

/* 스크롤바 스타일 */
.sidebar::-webkit-scrollbar {
    width: 0px;
    display: none;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: transparent;
}

/* Firefox용 스크롤바 숨기기 */
.sidebar {
    scrollbar-width: none;
}

/* IE, Edge용 스크롤바 숨기기 */
.sidebar {
    -ms-overflow-style: none;
}

/* ==============================================
   이미지 보호
   ============================================== */
img {
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none; /* 갤러리 이미지 드래그 차단 */
}

/* 클릭은 되어야 하는 이미지들 (작품 상세, 갤러리) */
.work-image,
.gallery-item img,
.image-wrapper img {
    pointer-events: auto;
}

/* ==============================================
   푸터
   ============================================== */
.site-footer {
    margin-left: var(--sidebar-width);
    padding: 30px 80px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: auto; /* 항상 맨 아래로 */
}
