/* =========================================================
   YH Image Gallery Layout — FINAL AUTO CAPTION
   - PC: 2열
   - Mobile: 1열
   - 이미지 원본 비율 유지
   - yh-ig-head-2가 있으면:
     PC  : 상단 2칸 제목 표시
     MOB : 상단 제목 숨김 + 사진 아래 자동 캡션 표시
   - div / span 둘 다 대응
========================================================= */

/* ---------- 카드 ---------- */
.yh-ig-card{
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  margin: 0 0 22px 0;
}

/* ---------- 기본 헤더 ---------- */
.yh-ig-head{
  text-align: center;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 16px;
  color: #0f172a;
  background: #f8fafc;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

/* =========================================================
   Grid Layout
========================================================= */
.yh-ig-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  box-sizing: border-box;
  align-items: start;
  grid-auto-flow: row;
}

/* 1장만 있을 때 자동 1열 */
.yh-ig-grid:has(> .yh-ig-item:only-child){
  grid-template-columns: 1fr;
}

/* =========================================================
   Item / Image
========================================================= */
.yh-ig-item{
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: inherit;
  border-radius: 14px;
  overflow: visible;
  will-change: transform, opacity;
  box-sizing: border-box;
}

.yh-ig-item img{
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 14px;
  box-shadow: 0 6px 14px rgba(0,0,0,.10);
  transform: translateZ(0);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

/* 미세 호버(PC에서만) */
@media (hover:hover){
  .yh-ig-item:hover img{
    transform: scale(1.015);
    box-shadow: 0 10px 22px rgba(0,0,0,.14);
    filter: saturate(1.03);
  }
}

/* 접근성 */
@media (prefers-reduced-motion: reduce){
  .yh-ig-item img{
    transition: none;
  }
}

/* =========================================================
   Masonry 제거 안전망
========================================================= */
.yh-ig-grid.yh-ig-masonry{
  display: grid !important;
  column-count: initial !important;
  column-gap: initial !important;
}

/* =========================================================
   Head 2-Column
========================================================= */
.yh-ig-head.yh-ig-head-2{
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
  position: relative;
  padding: 12px 14px;
}

/* 중앙 구분선 */
.yh-ig-head.yh-ig-head-2::after{
  content: "";
  position: absolute;
  top: 22%;
  bottom: 22%;
  left: 50%;
  width: 2px;
  border-radius: 2px;
  transform: translateX(-50%);
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(22,145,121,.85),
    transparent
  );
}

/* 기존 작업물 호환:
   .yh-ig-head-col가 있든 없든
   직계 div / span 모두 적용 */
.yh-ig-head.yh-ig-head-2 > div,
.yh-ig-head.yh-ig-head-2 > span,
.yh-ig-head.yh-ig-head-2 .yh-ig-head-col{
  display: block;
  font-weight: 800;
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
  padding: 4px 8px;
  white-space: normal;
  word-break: keep-all;
  box-sizing: border-box;
}

/* =========================================================
   자동 캡션
   - PC: 숨김
   - Mobile: 표시
========================================================= */
.yh-ig-auto-caption{
  display: none;
  width: 100%;
  margin-top: 10px;
  padding: 0 6px 2px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  color: #0f172a;
  white-space: normal;
  word-break: keep-all;
  box-sizing: border-box;
}

/* 캡션 없으면 공간 없음 */
.yh-ig-item > .yh-ig-auto-caption:last-child{
  display: none;
}

/* =========================================================
   Mobile
========================================================= */
@media (max-width:768px){
  .yh-ig-grid{
    grid-template-columns: 1fr;
  }

  .yh-ig-item{
    width: 100%;
    max-width: 100%;
    text-align: center;
  }

  .yh-ig-item img{
    max-width: 100%;
    height: auto;
    margin: 0 auto;
  }

  /* 모바일에서는 2칸 상단 제목 숨김 */
  .yh-ig-head.yh-ig-head-2{
    display: none !important;
  }

  .yh-ig-auto-caption{
    display: block !important;
    width: 100%;
    margin-top: 10px;
    font-size: 13px;
  }
}

/* PC에서 마지막 홀수 사진 중앙정렬 */
@media (min-width:769px){

  .yh-ig-grid > .yh-ig-item:last-child:nth-child(odd){
    grid-column: 1 / span 2;
    justify-self: center;
    max-width: 60%;
  }

}