/* 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;
}

/* 스태거 큐 방식: Masonry transitionDuration 0s이므로 CSS transition 불필요 */
.work-item {
  /* position transition 제거 – Masonry가 0s로 배치하므로 충돌 없음 */
}

.works-grid.is-loading {
  opacity: 1;
  visibility: visible;
}

/* 이미지는 스태거 큐에 의해 순서대로 페이드 인 */
.work-link {
  display: block;
  overflow: hidden;
}

.work-image {
  display: block;
  width: 100%;
  height: auto;
  /* 페이드 인: 살짝 아래서 올라오며 자연스럽게 등장 */
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.55s ease-out, transform 0.55s ease-out;
}

.work-image.loaded {
  opacity: 1;
  transform: translateY(0);
}

/* hover: .loaded 이후에 선언해야 구체성 충돌 없이 scale 적용됨 */
.work-item:hover .work-image.loaded {
  transform: scale(1.05);
}

.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.4s ease-out 0.15s; /* 이미지보다 약간 늦게 */
}

.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 (max-width: 768px) {
  /* 모바일: 1컬럼 */
  .work-item {
    width: 100%;
  }
  .works-grid {
    margin: -20px 5px 30px 5px;
  }
}

@media (min-width: 769px) and (max-width: 1280px) {
  /* 태블릿 / 소형 데스크톱: 2컬럼 */
  .work-item {
    width: calc(50% - 5px);
  }
  .works-grid {
    margin: 0px 10px 20px 10px;
  }
}

@media (min-width: 1281px) {
  /* 대형 데스크톱: 3컬럼 */
  .work-item {
    width: calc(33.333% - 6.666px);
  }
  .works-grid {
    margin: 0px 0px 30px 0px;
  }
}

/*
 * ========================================
 * 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;
}
