/* ==========================================================
   BUDS 갤러리 리뉴얼 — 다크 포토 갤러리
   ========================================================== */

:root {
    --bg:      #0d0f14;
    --surface: #161a22;
    --border:  #262c38;
    --text:    #edf0f6;
    --muted:   #939eb4;
    --accent:  #ff5c7c;
    --radius:  14px;
    --maxw:    1080px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 14px; }

/* ---------- 헤더 ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(13, 15, 20, .88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.site-header .inner {
    max-width: var(--maxw); margin: 0 auto; padding: 0 14px;
    display: flex; align-items: center; justify-content: space-between;
    height: 56px;
}
.brand { display: flex; align-items: center; font-weight: 800; font-size: 19px; letter-spacing: 1px; }
.brand img { height: 26px; margin-right: 8px; }
.brand .dot { color: var(--accent); }

/* 카테고리 탭 */
.tabs {
    max-width: var(--maxw); margin: 0 auto; padding: 0 14px 10px;
    display: flex; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 0 0 auto;
    padding: 7px 16px;
    margin-right: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px; font-weight: 600;
    white-space: nowrap;
    transition: all .15s;
}
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 광고 공통 ---------- */
.ad-badge {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0, 0, 0, .6);
    color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 1px;
    padding: 2px 7px; border-radius: 5px;
    z-index: 2; pointer-events: none;
}

/* 상단 가로 배너 */
.ad-banner {
    position: relative;
    display: block;
    max-width: 720px;
    margin: 14px auto;
    border-radius: 10px; overflow: hidden;
    border: 1px solid var(--border);
}

/* ---------- 갤러리 그리드 ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 4px 0 30px;
}
.grid::after { content: ''; display: block; clear: both; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } }

/* 구형 웹뷰 폴백(float) — grid 지원 브라우저는 아래 @supports에서 원복 */
.card { float: left; width: calc(25% - 10px); margin: 5px; }
@media (max-width: 900px) { .card { width: calc(33.33% - 10px); } }
@media (max-width: 560px) { .card { width: calc(50% - 8px); margin: 4px; } }
@supports (display: grid) {
    .card { float: none; width: auto; margin: 0; }
}

.card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform .15s;
}
.card:hover { transform: translateY(-3px); }
.card .thumb {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: #1a1e28;
}
.card .cap {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 26px 10px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .78));
    font-size: 12.5px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .cnt {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0, 0, 0, .6);
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
/* 영상 카드 재생 배지 */
.card .play {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 46px; height: 46px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .55);
    border: 2px solid rgba(255, 255, 255, .85);
    border-radius: 50%;
    color: #fff; font-size: 15px; padding-left: 3px;
    pointer-events: none;
}
.card.is-video .thumb { object-position: center; }

/* 모달 내 유튜브 플레이어 (16:9) */
.viewer .vplayer {
    position: relative; width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px; overflow: hidden;
    margin-bottom: 10px; background: #000;
}
.viewer .vplayer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* 인피드 광고 카드 (그리드 셀) */
.card.ad-cell { border-color: #3a3325; }
.card.ad-cell .thumb { object-position: top; }
.card.ad-cell .cap { color: #ffd06a; }

/* 더보기 센티널 / 로더 */
#sentinel { height: 10px; }
.loader { text-align: center; color: var(--muted); padding: 18px 0 40px; font-size: 14px; }

/* ---------- 모달 뷰어 ---------- */
.viewer {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(5, 7, 11, .93);
    display: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.viewer.show { display: block; }
.viewer .vbox { max-width: 640px; margin: 0 auto; padding: 54px 12px 30px; }
.viewer .vtitle {
    font-size: 16px; font-weight: 700;
    padding: 0 2px 12px;
}
.viewer .vtitle small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
.viewer .vimg { border-radius: 12px; margin-bottom: 10px; width: 100%; }
.viewer .vclose {
    position: fixed; top: 12px; right: 14px;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff; font-size: 19px; line-height: 1;
    z-index: 102;
}
.viewer .ad-banner { margin: 16px auto; }

/* ---------- 하단 스티키 광고 ---------- */
.ad-sticky {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(22, 26, 34, .97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    display: none;
}
.ad-sticky.show { display: block; }
.ad-sticky .inner {
    max-width: 720px; margin: 0 auto;
    display: flex; align-items: center;
}
.ad-sticky .inner > * + * { margin-left: 10px; }
.ad-sticky .thumb { flex: 0 0 42px; height: 42px; border-radius: 8px; overflow: hidden; }
.ad-sticky .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.ad-sticky .txt { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); }
.ad-sticky .txt b { display: block; color: var(--text); font-size: 13.5px; }
.ad-sticky .go {
    flex: 0 0 auto;
    background: var(--accent); color: #fff;
    font-size: 13px; font-weight: 700;
    padding: 8px 14px; border-radius: 9px;
}
.ad-sticky .x { flex: 0 0 auto; background: none; border: 0; color: var(--muted); font-size: 17px; padding: 5px; }

/* ---------- 진입 팝업 ---------- */
.overlay {
    position: fixed; inset: 0; z-index: 110;
    background: rgba(5, 7, 11, .82);
    display: none; align-items: center; justify-content: center;
    padding: 22px;
}
.overlay.show { display: flex; }
.popup-ad {
    position: relative;
    width: min(300px, 84vw);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px; overflow: hidden;
}
.popup-ad img { width: 100%; aspect-ratio: 720/1050; object-fit: cover; object-position: top; }
.popup-ad .acts {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 14px; font-size: 12.5px; color: var(--muted);
}
.popup-ad .acts label { display: flex; align-items: center; cursor: pointer; }
.popup-ad .acts label input { margin-right: 6px; }
.popup-ad .acts button { background: none; border: 0; color: var(--text); font-size: 13.5px; font-weight: 700; }

/* ---------- 데스크톱 사이드 레일 ---------- */
.ad-side {
    position: fixed; right: 20px; top: 50%;
    transform: translateY(-50%);
    width: 150px; z-index: 40;
    border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border);
}
.ad-side .cta {
    display: block; text-align: center;
    background: var(--surface); color: var(--accent);
    font-size: 12px; font-weight: 700; padding: 7px 0;
}
@media (max-width: 1440px) { .ad-side { display: none; } }

/* ---------- 푸터 ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 26px 14px 96px;
    text-align: center;
    color: var(--muted); font-size: 12px;
}
.site-footer .disclosure {
    max-width: 600px; margin: 0 auto 12px;
    padding: 9px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}
