/* ===== 전역 변수 및 리셋 ===== */
:root {
    /* 라이트 모드 색상 (채도 30% 낮춤) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --accent-primary: #4d8fcc;
    /* 채도 30% 낮춤 */
    --accent-secondary: #7a7dc4;
    /* 채도 30% 낮춤 */
    --header-bg: #ffffff;
    --footer-bg: #f8f9fa;

    /* 레이아웃 */
    --max-width: 1400px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* 트랜지션 */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 다크 모드 색상 (다크 블루로 변경) */
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border-color: #30363d;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.6);
    --accent-primary: #1a4d7a;
    /* 다크 블루 - 채도 15% 증가 */
    --accent-secondary: #2872a8;
    /* 다크 블루 보조 - 채도 15% 증가 */
    --header-bg: #161b22;
    --footer-bg: #0d1117;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    width: 100%;
}

/* ===== 헤더 영역 (히어로) ===== */
.hero-wrapper {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

#hero-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* ===== 헤더 ===== */
.header {
    background: transparent;
    padding: var(--spacing-lg) 0 var(--spacing-md);
    position: relative;
    z-index: 2;
    text-align: center;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    position: relative;
    z-index: 2;
}

.title {
    font-size: 2.3rem;
    /* 30% 증가 (1.75 * 1.3) */
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.title i {
    color: var(--accent-primary);
    font-size: 2rem;
}

.subtitle {
    margin-top: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    text-align: center;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1.2rem;
    position: absolute;
    top: 0;
    right: 0;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    position: absolute;
    top: 0;
    right: 0;
}

.header-actions .theme-toggle {
    position: static;
}

.theme-toggle:hover {
    background: var(--accent-primary);
    color: #ffffff;
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* ===== 탭 네비게이션 ===== */
.tabs {
    background: transparent;
    padding: var(--spacing-md) 0;
    position: relative;
    z-index: 2;
}

.tab-buttons {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.tab-button {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: var(--transition);
}

.tab-button:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab-button.active {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
}

.tab-button i {
    font-size: 1.1rem;
}

/* ===== 메인 컨텐츠 ===== */
.main {
    flex: 1;
    padding: var(--spacing-xl) 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* ===== 정보 바 ===== */
.info-bar {
    display: flex;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.stat {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.stat i {
    color: var(--accent-primary);
    font-size: 1.2rem;
}

.stat strong {
    color: #ffffff;
    font-weight: 700;
    background: var(--accent-primary);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 1.1rem;
    min-width: 36px;
    text-align: center;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ===== 갤러리 그리드 ===== */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-lg);
    animation: fadeIn 0.5s ease;
}

/* ===== 작품 카드 ===== */
.work-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.work-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-primary);
}

.card-header {
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.card-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.card-body {
    padding: var(--spacing-md);
    flex: 1;
}

.work-image-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    position: relative;
    overflow: hidden;
}

.work-image-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.work-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.work-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.work-item:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
}

.work-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    flex: 1;
}

.work-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--accent-primary);
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.work-link:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

.work-link i {
    font-size: 0.9rem;
}

.work-count {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--accent-primary);
    color: #ffffff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== 푸터 ===== */
.footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-lg) 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: auto;
}

.footer-links {
    margin-top: var(--spacing-sm);
}

.footer-links a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.footer-links a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 768px) {
    .title {
        font-size: 1.3rem;
    }

    .title i {
        font-size: 1.2rem;
    }

    .gallery {
        grid-template-columns: 1fr;
    }

    .tabs {
    }

    .tab-button {
        font-size: 0.9rem;
        padding: var(--spacing-xs) var(--spacing-md);
    }

    .info-bar {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .header {
        padding: var(--spacing-md) 0;
    }

    .title {
        font-size: 1.1rem;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .work-image-placeholder {
        height: 160px;
        font-size: 2rem;
    }
}

/* ===== 주제별 뷰 커스텀 스타일 (1열 레이아웃 + 4열 그리드) ===== */
#categoryGallery {
    grid-template-columns: 1fr;
    /* 카테고리 카드를 전체 너비(1열)로 설정 */
}

#categoryGallery .work-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 작품 목록을 4개씩 가로로 배치 */
    gap: var(--spacing-md);
}

#categoryGallery .work-item {
    flex-direction: column;
    text-align: center;
    padding: var(--spacing-md);
    background: var(--bg-primary);
    /* 카드 내부라 구분되게 */
    height: 100%;
    justify-content: space-between;
}

#categoryGallery .work-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

#categoryGallery .work-name {
    margin-bottom: var(--spacing-sm);
    font-size: 1rem;
    font-weight: 600;
}

#categoryGallery .work-link {
    width: 100%;
    justify-content: center;
    margin-top: auto;
}

/* 주제별 뷰 반응형 처리 */
@media (max-width: 1200px) {
    #categoryGallery .work-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    #categoryGallery .work-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    #categoryGallery .work-list {
        grid-template-columns: 1fr;
    }
}

/* ===== 커스텀 배너 헤더 스타일 (작품 수 + 타이틀 통합) ===== */
.work-banner {
    height: 100px;
    /* 기존 200px에서 50% 축소 */
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    color: #ffffff;
}

.banner-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: baseline;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    width: 100%;
}

.banner-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.banner-count {
    font-size: 1rem;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

.banner-bg-icon {
    position: absolute;
    right: -20px;
    bottom: -20px;
    font-size: 8rem;
    opacity: 0.15;
    transform: rotate(-15deg);
    pointer-events: none;
}

/* ===== 썸네일 이미지 스타일 ===== */
#categoryGallery .work-item {
    padding: 0;
    /* 기존 패딩 제거 */
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.work-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    /* 비디오 비율 유지 */
    background: var(--bg-secondary);
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.work-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 꽉 차게 */
    transition: transform 0.4s ease;
}

#categoryGallery .work-item:hover .work-thumbnail img {
    transform: scale(1.05);
    /* 호버 시 살짝 확대 */
}

.work-info {
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
}

#categoryGallery .work-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* ===== 학생별 뷰도 주제별 뷰와 동일한 레이아웃 적용 ===== */
#studentGallery {
    grid-template-columns: 1fr;
    display: grid;
    gap: var(--spacing-lg);
}

#studentGallery .work-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

#studentGallery .work-item {
    padding: 0;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

#studentGallery .work-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

#studentGallery .work-item:hover .work-thumbnail img {
    transform: scale(1.05);
}

#studentGallery .work-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* 링크 스타일 초기화 */
.work-thumbnail-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* 반응형 처리 공통화 */
@media (max-width: 1200px) {

    #categoryGallery .work-list,
    #studentGallery .work-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {

    #categoryGallery .work-list,
    #studentGallery .work-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {

    #categoryGallery .work-list,
    #studentGallery .work-list {
        grid-template-columns: 1fr;
    }
}

/* ===== 퀵 네비게이션바 ===== */
.quick-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nav-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-chip:hover {
    background: var(--accent-primary);
    color: #ffffff;
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.nav-chip i {
    font-size: 0.8rem;
}

/* ===== 비디오 모달 ===== */
.video-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.video-modal.active {
    display: flex;
}

.video-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.video-modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.video-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
}

.video-modal-close:hover {
    background: rgba(255, 0, 0, 0.8);
    transform: scale(1.1);
}

.video-modal-header {
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.video-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 비율 */
    height: 0;
    overflow: hidden;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* 홍보 영상 아이템에 재생 아이콘 표시 */
.work-item.video-item .work-thumbnail::after {
    content: '\f04b';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: var(--transition);
}

.work-item.video-item .work-thumbnail {
    position: relative;
}

.work-item.video-item:hover .work-thumbnail::after {
    transform: translate(-50%, -50%) scale(1.2);
    color: #ff0000;
}

/* 홍보 영상 썸네일 - 우측 재생목록 자르기 (영상 부분만 표시) */
.work-item.video-item .work-thumbnail {
    position: relative;
    overflow: hidden;
}

.work-item.video-item .work-thumbnail img {
    object-fit: cover;
    width: 100%;
    height: 100%;
    transform: scaleX(1.35) translateX(-13%);
    /* 우측 30% 잘라내기 */
}
/* YouTube 임베드 플레이어 스타일 */
.work-thumbnail.youtube-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 비율 */
    height: 0;
    overflow: hidden;
    background: #000;
}

.work-thumbnail.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px 8px 0 0;
}

    
    .header {
        padding-top: calc(var(--spacing-lg) + env(safe-area-inset-top));
    }
    
    .gallery {
        display: grid !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .work-card {
        margin-bottom: var(--spacing-lg);
    }
}

/* Final Mobile Layout Fixes */
@media (max-width: 768px) {
    .hero-wrapper {
        min-height: auto !important;
        overflow: visible !important;
        height: auto !important;
    }
    
    .header {
        padding-top: calc(var(--spacing-md) + env(safe-area-inset-top) + 20px) !important;
        padding-bottom: var(--spacing-sm) !important;
        position: relative !important;
    }

    .header-content {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .header-actions {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        justify-content: center !important;
        margin-top: 10px !important;
    }

    .tabs {
        position: relative !important;
        top: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        padding: 10px 0 !important;
        z-index: 100 !important;
    }

    .tab-buttons {
        display: flex !important;
        visibility: visible !important;
    }

    .main {
        padding-top: 20px !important;
    }

    .card-body, .work-list {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .work-list {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .work-item {
        display: flex !important;
        flex-direction: column !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    .work-thumbnail-link {
        display: block !important;
        width: 100% !important;
        pointer-events: auto !important;
    }
}

@media (max-width: 768px) {
    .tab-content.active {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .work-thumbnail {
        min-height: 150px !important;
    }
}

/* Critical Fix for Canvas Interception and Missing Thumbnails */
#hero-canvas {
    pointer-events: none !important;
}

.work-thumbnail {
    height: auto !important;
    min-height: 160px !important;
    position: relative !important;
    display: block !important;
    background-color: #f0f0f0 !important; /* Placeholder color */
}

.work-thumbnail img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 160px !important;
    object-fit: cover !important;
}

.work-item {
    cursor: pointer !important;
    pointer-events: auto !important;
}

.work-thumbnail-link {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: auto !important;
}

/* Ensure main content is always on top for touches */
.main, .tabs, .header {
    position: relative !important;
    z-index: 10 !important;
    pointer-events: auto !important;
}
