/* ===========================
   Gallery Page Styles (refactor)
   - 브랜드/헤더 CSS 변수화
   - 반응형/모바일 최적화
   - 이미지 aspect-ratio 도입
   - iOS 100dvh 보정
   =========================== */

/* ===== 0. CSS 변수 ===== */
:root {
  --brand: #6c63ff;        /* 브랜드 메인 컬러 */
  --brand-dark: #5148e5;   /* hover/darker */
  --accent: #ff6b6b;       /* 포인트 (필요 시) */
  --header-h: 64px;        /* 고정값이었던 76px -> 변수화 */
  --tab-radius: 25px;
  --tab-border: #e0e0e0;
  --text-strong: #333;
  --text-muted: #666;
  --text-light: #999;
  --card-bg: #fff;
  --shadow-soft: 0 5px 20px rgba(0,0,0,0.1);
  --shadow-hover: 0 10px 30px rgba(0,0,0,0.15);
}

/* ===== 1. 갤러리 히어로 ===== */
.gallery-hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 80px 0 40px 0;
  margin-top: var(--header-h); /* 고정값 제거 */
}

/* ===== 2. 카테고리 탭 ===== */
.category-tabs {
  background: #fff;
  padding: 30px 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  position: sticky;
  top: var(--header-h);     /* 고정값 제거 */
  z-index: 100;
}

.tab-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.category-tab {
  padding: 12px 20px;
  border-radius: var(--tab-radius);
  border: 2px solid var(--tab-border);
  background: #fff;
  color: #666;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, color .25s ease, border-color .25s ease, background .25s ease;
  font-weight: 600;
  min-width: 96px;
  text-align: center;
  line-height: 1;
}
.category-tab:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.18);
}
.category-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.24);
}

/* ===== 3. 사진 컨테이너/그리드 ===== */
.photos-container {
  padding: 40px 0;
  min-height: 500px;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* 250px -> 200px로 모바일 폭 대응 */
  gap: 20px;
  margin-top: 20px;
}

.photo-item {
  background: var(--card-bg);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform .28s ease, box-shadow .28s ease, opacity .4s ease;
  opacity: 0;
  transform: translateY(30px);
}
.photo-item.show {
  opacity: 1;
  transform: translateY(0);
}
.photo-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.photo-image {
  width: 100%;
  /* 고정 height 제거 → 비율 기반으로 안정화 */
  aspect-ratio: 4 / 3;        /* 필요 시 1/1 또는 3/2로 변경 가능 */
  object-fit: cover;
  cursor: pointer;
  transition: transform .28s ease;
}
.photo-item:hover .photo-image {
  transform: scale(1.035);
}

.photo-info { padding: 18px; }
.photo-title {
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 8px;
}
.photo-description {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: keep-all;
}

/* ===== 4. 상태 (Empty / Loading) ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
}
.empty-state i {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.5;
}

.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.loading-spinner {
  display: inline-block;
  width: 40px; height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--brand); /* 브랜드 컬러 적용 */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== 5. 이미지 모달 ===== */
.image-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100%;
  height: 100vh;        /* 기본 */
  height: 100dvh;       /* iOS 보정 */
  background-color: rgba(0,0,0,0.9);
  cursor: pointer;
  -webkit-backdrop-filter: blur(0.5px);
  backdrop-filter: blur(0.5px);
}
.modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 92%;
  max-height: 92%;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.modal-close {
  position: absolute;
  top: 16px; right: 24px;
  color: #fff;
  font-size: 36px;
  font-weight: 800;
  cursor: pointer;
  z-index: 10000;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.modal-close:hover { opacity: 0.75; }
.modal-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.82));
  color: #fff;
  padding: 28px 18px 18px 18px;
  border-radius: 0 0 10px 10px;
}
.modal-title { font-size: 1.22rem; font-weight: 700; margin-bottom: 8px; }
.modal-description { font-size: 1rem; opacity: 0.95; line-height: 1.45; }

/* ===== 6. 반응형 ===== */
@media (max-width: 992px) {
  .photos-grid {
    gap: 18px;
  }
  .photo-info { padding: 16px; }
}

@media (max-width: 768px) {
  .photos-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }
  .photo-info { padding: 14px; }
  .category-tab {
    padding: 10px 18px;
    min-width: 80px;
    font-size: 0.92rem;
  }
  .tab-container { gap: 10px; }
  .gallery-hero h1 { font-size: 2.4rem; }
}

@media (max-width: 576px) {
  .photos-grid { gap: 12px; }
  .photo-info { padding: 12px; }
  .photo-title { font-size: 1rem; }
  .photo-description { font-size: 0.86rem; }
}

@media (min-width: 1200px) {
  .photos-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 992px) and (max-width: 1199px) {
  .photos-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== 7. 접근성(애니메이션 최소화) ===== */
@media (prefers-reduced-motion: reduce) {
  .category-tab,
  .photo-item,
  .photo-image {
    transition: none !important;
  }
}


/* ==== Hero size tweaks (override) ==== */
.gallery-hero {
  padding: 56px 0 28px 0; /* 기존 80/40 → 축소 */
}
.gallery-hero .display-4 {
  font-size: clamp(1.75rem, 4.2vw, 2.6rem); /* 반응형 축소 */
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.gallery-hero .lead {
  font-size: clamp(1rem, 2.4vw, 1.125rem);
  opacity: .95;
}

/* 카드 그리드 밀도 약간 증가 */
.photos-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.photo-image { height: 220px; }           /* 3번째 스샷 느낌 유지 */
@media (max-width: 768px) {
  .photo-image { height: 160px; }
}

/* 로딩/빈 상태를 display:none 할 때 공간도 접기 */
#loadingState[style*="display: none"],
#emptyState[style*="display: none"] {
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

