/* Masonry column sizer (not rendered, used for column width calculation) */
.grid .grid-sizer {
  width: calc((100% - 60px) / 4); /* 4 columns: (100% - 3×20px) / 4 */
}

/* Masonry gutter sizer (not rendered, used for horizontal gap calculation) */
.grid .gutter-sizer {
  width: 20px;
}

/* Collection item as link */
a.collection-item {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

/* Collection line label */
.collection-line-label {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 12px;
  margin-bottom: 6px;
  align-self: flex-start;
}

/* Collection item */
.collection-item {
  width: calc((100% - 60px) / 4); /* must match .grid-sizer */
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255,255,255,0.98);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

/* Image thumbnail — natural height for Masonry effect */
.collection-item-thumb {
  background-color: #ebe4da;
  background-image: linear-gradient(135deg, #f4eee6 0%, #ebe4da 100%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  position: relative;
  padding-top: 75%;
}

.collection-item-body {
  padding: 18px 20px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.collection-item-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.collection-item-desc {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.collection-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.collection-gallery-thumb {
  position: relative;
  padding-top: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: #f4eee6;
}

.collection-gallery-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.collection-gallery-thumb.is-broken img {
  display: none;
}

.collection-gallery-thumb.has-more::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
}

.collection-gallery-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  z-index: 1;
}

.collection-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.collection-tag-chip {
  color: var(--muted);
}

/* Collection detail */
.collection-detail-specs {
  margin-bottom: 24px;
}

.collection-detail-specs h3,
.collection-detail-desc h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.spec-list {
  margin: 0;
}

.spec-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

.spec-row:first-child {
  border-top: 1px solid var(--border-subtle);
}

.spec-row dt {
  min-width: 60px;
  color: var(--muted);
  font-weight: 500;
}

.spec-row dd {
  margin: 0;
  font-weight: 500;
}

.collection-detail-desc {
  margin-bottom: 20px;
}

.collection-detail-cta {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* Responsive — adjust Masonry column widths per breakpoint */
@media (max-width: 960px) {
  .grid .grid-sizer,
  .collection-item {
    width: calc((100% - 40px) / 3); /* 3 columns: (100% - 2×20px) / 3 */
  }
}

@media (max-width: 720px) {
  .grid .grid-sizer,
  .collection-item {
    width: calc((100% - 20px) / 2); /* 2 columns: (100% - 1×20px) / 2 */
  }
}

/* ============================================================
   collection-detail.php 상세 공통 (detail.css 통합)
   ============================================================ */

/* Detail hero meta (날짜, 뱃지) */
.detail-hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

/* 목록으로 버튼 */
.detail-back-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Article 래퍼 */
.detail-article {
  margin-bottom: 48px;
}

/* 이미지 갤러리 */
.detail-gallery {
  margin-bottom: 32px;
}

.detail-gallery-main {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #f4eee6;
}

.detail-gallery-main img {
  width: 100%;
  max-height: 560px;
  object-fit: cover;
  display: block;
}

.detail-gallery-main.is-broken {
  display: none;
}

/* 본문 */
.detail-content {
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 28px;
}

.detail-content h2,
.detail-content h3 {
  margin: 1.5em 0 0.5em;
}

.detail-content p {
  margin: 0 0 1em;
}

.detail-content img {
  max-width: 100%;
  border-radius: var(--radius-lg);
}

/* 태그 */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.detail-tag-chip {
  font-size: 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 4px 12px;
}

/* 관련 링크 */
.detail-external-link {
  margin-top: 20px;
}

/* 이전/다음 글 탐색 */
.detail-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--border-subtle);
}

.detail-nav-item a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--text);
}

.detail-nav-item a:hover .detail-nav-title {
  color: var(--accent);
}

.detail-nav-label {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.detail-nav-title {
  font-size: 16px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-nav-next {
  text-align: right;
}

/* 갤러리 썸네일 버튼 */
.detail-gallery-thumb-btn {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: none;
  padding: 0;
}

.detail-gallery-thumb-btn.is-active {
  border-color: var(--accent);
}

.detail-gallery-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 720px) {
  .detail-nav {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .detail-nav-next {
    text-align: left;
  }
  .detail-gallery-main img {
    max-height: 400px;
  }
  .detail-gallery-thumb-btn {
    width: 60px;
    height: 60px;
  }
}
