/* Works 섹션 스타일 */
#works {
    /* 헤더와 푸터, 약간의 여백을 제외한 뷰포트 높이를 최소 높이로 설정 */
    min-height: calc(100vh - var(--header-height) - 100px);
    box-sizing: border-box;
}

.works-grid {
    position: relative;
    margin: 0px 15px 0px 15px;
    padding-bottom: 0px;
    box-sizing: border-box;
}

.work-link {
    display: block;
    overflow: hidden;
}

.work-image {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease;
    opacity: 0;
}

.work-item:hover .work-image {
    transform: scale(1.05);
}

.work-image.loaded {
    opacity: 1;
}

.work-text-content {
    padding: clamp(0.1rem, 1vw, 0.25rem) 0 clamp(0.75rem, 2vw, 1rem) 0;
    text-align: left;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.work-text-content.loaded {
    opacity: 1;
}

.work-text-content p {
    font-family: var(--font-secondary);
    font-weight: 600;
    font-size: clamp(12px, 2vw, 14px);
    color: var(--color-text);
    margin: 0;
}

/* 미디어 쿼리 */
@media (min-width: 1281px) {
    .work-item {
        width: calc(33.333% - 6.666px);
    }
     .works-grid {
        margin: 0px 0px 30px 0px;
    }
}

@media (min-width: 769px) and (max-width: 1900px) {
    .work-item {
        width: calc(50% - 5px);
    }
    .works-grid {
        margin: 0px 10px 20px 10px;
    }
}

@media (max-width: 768px) {
    .work-item {
        width: 100%;
    }
    .works-grid {
        margin: -20px 5px 30px 5px;
    }
}

/*
 * ========================================
 * 4. 모달 팝업 (Modal Popup)
 * ========================================
 */
#work-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; 
  background-color: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
}

#work-modal.active {
  display: flex;
  overflow: auto; 
}

#work-modal {
    --modal-line-height: 2px;
    --modal-line-gap: 7.8px;
    --modal-vertical-offset: -26px;
}

#work-modal::before,
#work-modal::after,
.modal-yellow-line {
    content: '';
    position: fixed;
    left: 0;
    width: 100%;
    height: var(--modal-line-height);
    background: var(--color-primary);
    z-index: -1;
}

#work-modal::before {
    top: calc(50% + var(--modal-vertical-offset) - var(--modal-line-height) / 2);
}

#work-modal::after {
    top: calc(50% + var(--modal-vertical-offset) - var(--modal-line-gap) - var(--modal-line-height) * 1.5);
}

.modal-yellow-line {
    top: calc(50% + var(--modal-vertical-offset) + var(--modal-line-gap) + var(--modal-line-height) / 2);
}

.modal-content {
    position: relative;
    margin: auto;
    padding: 40px;
    width: 90%;
    height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.video-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content iframe,
.modal-content img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border: none;
}

.modal-content .iframe-horizontal {
    aspect-ratio: 16 / 9;
}

.modal-content .iframe-vertical {
    aspect-ratio: 9 / 16;
}

.modal-close-button {
    color: var(--color-white);
    position: absolute;
    top: -20px;
    right: 0px;
    font-size: 35px;
    font-weight: normal;
    cursor: pointer;
    z-index: 1002;
    padding: 10px;
    background: transparent;
    border: none;
}

.modal-close-button:hover,
.modal-close-button:focus {
    outline: none;
}

.modal-title {
    color: var(--color-white);
    font-family: var(--font-secondary);
    font-size: 12px;
    font-weight: normal;
    text-align: center;
    position: absolute;
    top: 0px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    margin: 0;
    padding: 0 50px;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 갤러리 이미지 컨테이너 */
.image-gallery-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.image-gallery-container::-webkit-scrollbar {
    display: none;
}
.image-gallery-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.image-gallery-container img {
    flex-shrink: 0;
    width: 100%;
    height: auto;
    object-fit: contain;
    scroll-snap-align: center;
    margin: 1vw;
}