/*
 * 갤러리형 최신글 위젯 (m_gallery)
 * — 카드 안에 게시판 제목 헤더 + 2열 또는 3열 썸네일 그리드
 * — 썸네일 없을 땐 no-image 톤 placeholder
 */

.m-latest-gallery {
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius-lg);
    box-shadow: var(--m-shadow);
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
}
.m-latest-gallery:hover {
    transform: translateY(-2px);
    box-shadow: var(--m-shadow-md);
    border-color: var(--m-border-hover);
}

.m-latest-gallery .m-latest-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--m-border);
}
.m-latest-gallery .m-latest-title { margin: 0; font-size: var(--m-text-lg); font-weight: 700; }
.m-latest-gallery .m-latest-title a { color: var(--m-text); text-decoration: none; transition: color 0.2s; }
.m-latest-gallery .m-latest-title a:hover { color: var(--m-primary); }
.m-latest-gallery .m-latest-more {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: var(--m-text-sm); color: var(--m-text-muted);
    text-decoration: none;
    transition: color 0.2s, transform 0.2s;
}
.m-latest-gallery .m-latest-more:hover { color: var(--m-primary); transform: translateX(2px); }

.m-latest-gallery-grid {
    list-style: none; margin: 0; padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.m-latest-gallery-item { position: relative; }
.m-latest-gallery-link {
    display: block; text-decoration: none; color: inherit;
}

.m-latest-gallery-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: var(--m-radius);
    overflow: hidden;
    background: var(--m-surface-2);
    border: 1px solid var(--m-border);
    transition: border-color 0.3s;
}
.m-latest-gallery-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.m-latest-gallery-link:hover .m-latest-gallery-thumb img { transform: scale(1.06); }
.m-latest-gallery-link:hover .m-latest-gallery-thumb { border-color: rgba(99, 102, 241, 0.3); }

/* 썸네일 없음 placeholder */
.m-latest-gallery-thumb-empty {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    color: var(--m-text-faint);
    font-size: var(--m-text-xs);
    background: var(--m-surface-2);
    transition: background-color 0.3s;
}
.m-latest-gallery-link:hover .m-latest-gallery-thumb-empty {
    background: var(--m-primary-soft);
    color: var(--m-primary);
}

/* 댓글 수 / 추천 등 썸네일 우상단 chip */
.m-latest-gallery-cmt {
    position: absolute; top: 8px; right: 8px;
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 8px;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    border-radius: 999px;
    font-size: 10px; font-weight: 700;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background-color 0.2s, transform 0.2s;
    z-index: 2;
}
.m-latest-gallery-link:hover .m-latest-gallery-cmt {
    background: var(--m-primary);
    transform: scale(1.05);
}

.m-latest-gallery-body {
    margin-top: 10px;
    padding: 0 2px;
}
.m-latest-gallery-subject {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--m-text);
    font-size: var(--m-text-base);
    font-weight: 600;
    line-height: 1.45;
    transition: color 0.2s;
}
.m-latest-gallery-link:hover .m-latest-gallery-subject { color: var(--m-primary); }

/* 공지 뱃지 — 반투명 캡슐 스타일 */
.m-latest-gallery .m-latest-notice {
    display: inline-block;
    margin-right: 4px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px; font-weight: 700; line-height: 1.2;
    background: rgba(239, 68, 68, 0.12); color: #ef4444;
    vertical-align: middle;
}
[data-theme="dark"] .m-latest-gallery .m-latest-notice {
    background: rgba(239, 68, 68, 0.22); color: #f87171;
}

.m-latest-gallery-meta {
    margin-top: 6px;
    display: flex; gap: 6px;
    font-size: var(--m-text-xs); color: var(--m-text-faint);
}
.m-latest-gallery-meta .m-latest-gallery-name {
    color: var(--m-text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 80px;
}
.m-latest-gallery-meta .m-latest-gallery-date { margin-left: auto; }

.m-latest-gallery-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--m-text-faint);
    font-size: var(--m-text-sm);
    grid-column: 1 / -1;
}

/* 더 작은 화면에서 한 열로 */
@media (max-width: 480px) {
    .m-latest-gallery-grid { grid-template-columns: 1fr; padding: 14px; gap: 14px; }
}
