/* =============================================
   CUSTOM LIGHTBOX — Blocksy Child Theme v2.0
   ============================================= */

:root {
    --lb-bg: rgba(10, 14, 13, 0.85);   /* ★ 고정 배경 투명도 85% */
    --lb-accent: #2D4B43;
    --lb-accent-light: #3d6357;
    --lb-text: #f0f0ec;
    --lb-text-muted: #9a9a94;
    --lb-border: rgba(255,255,255,0.08);
    --lb-panel-bg: rgba(15, 20, 18, 0.88);
    --lb-radius: 4px;
    --lb-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --lb-orange: #FC4C02;
}

/* ── Overlay ── */
#clb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--lb-bg);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    /* 이미지가 전체를 채우도록 flex column */
    flex-direction: column;
}
#clb-overlay.clb-open {
    display: flex;
}

/* ── 상단바 — 오버레이 방식 ── */
#clb-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, transparent 100%);
    /* 기본은 숨김 */
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
}
/* ui-visible 클래스 추가 시 표시 */
#clb-overlay.ui-visible #clb-topbar {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#clb-caption {
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
#clb-topbar-actions {
    display: flex;
    gap: 5px;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}

/* ── 버튼 공통 ── */
.clb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--lb-radius);
    background: rgba(0,0,0,0.45);
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    transition: background var(--lb-transition), color var(--lb-transition);
    flex-shrink: 0;
    text-decoration: none;
    position: relative;
    z-index: 10;
}
.clb-btn:hover {
    background: var(--lb-accent);
    color: #fff;
    border-color: var(--lb-accent);
}
.clb-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

/* ── EXIF 모드 토글 스위치 ── */
#clb-exif-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 0 4px;
}
.clb-toggle-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    transition: color 0.2s;
    white-space: nowrap;
    user-select: none;
}
.clb-toggle-label.active {
    color: var(--lb-orange);
}
#clb-toggle-track {
    width: 32px;
    height: 17px;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}
#clb-toggle-track.box-active {
    background: var(--lb-accent);
}
#clb-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: rgba(255,255,255,0.8);
    transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
#clb-toggle-track.box-active #clb-toggle-thumb {
    transform: translateX(15px);
}

/* ── 이미지 영역 — 전체 화면 채움 ── */
#clb-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* ★ 2~3px 마진만 남기고 최대 크기 */
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    cursor: zoom-in;
    margin: 2px;
}
#clb-img-wrap.zoomed { cursor: grab; }
#clb-img-wrap.zoomed:active { cursor: grabbing; }

/* box 모드일 때 하단 EXIF 패널 공간 확보 */
#clb-overlay.exif-box-mode #clb-img-wrap {
    margin-bottom: 0;
}

#clb-img {
    display: block;
    max-width: calc(100vw - 4px);
    max-height: calc(100vh - 4px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.5);
    transform-origin: center center;
    will-change: transform;
    transition: opacity 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
    flex-shrink: 0;
}
/* box 모드에서는 하단 패널 높이만큼 이미지 최대 높이 줄임 */
#clb-overlay.exif-box-mode #clb-img {
    max-height: calc(100vh - 4px - var(--lb-box-h, 80px));
}
#clb-img.clb-loading { opacity: 0; }

/* ── 스피너 ── */
#clb-spinner {
    display: none;
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid rgba(255,255,255,0.1);
    border-top-color: var(--lb-accent-light);
    border-radius: 50%;
    animation: clb-spin 0.7s linear infinite;
    z-index: 3;
}
#clb-spinner.active { display: block; }
@keyframes clb-spin { to { transform: rotate(360deg); } }

/* ── 네비 버튼 ── */
.clb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 56px;
    border-radius: var(--lb-radius);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.22s ease;
}
#clb-overlay.ui-visible .clb-nav { opacity: 1; }
#clb-prev { left: 10px; }
#clb-next { right: 10px; }
.clb-nav.hidden { opacity: 0 !important; pointer-events: none; }

/* ── 카운터 — 상단 캡션 옆으로 이동 ── */
#clb-counter {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    letter-spacing: 1px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── EXIF 오버레이 (이미지 위 하단) ── */
#clb-exif-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 15;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
    padding: 28px 14px 10px;
    display: none;
    pointer-events: none;
}
#clb-overlay.exif-overlay-mode #clb-exif-overlay {
    display: block;
}
#clb-exif-overlay-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    pointer-events: auto;
}

/* ── 하단 EXIF 박스 ── */
#clb-bottom {
    width: 100%;
    flex-shrink: 0;
    background: var(--lb-panel-bg);
    border-top: 1px solid var(--lb-border);
    padding: 10px 16px 12px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}
#clb-overlay.exif-box-mode #clb-bottom {
    display: flex;
}
#clb-exif {
    justify-content: center;
}

/* ── EXIF 공통 스타일 ── */
#clb-exif,
#clb-exif-overlay-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 0;
}
.clb-exif-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    border-right: 1px solid rgba(255,255,255,0.12);
    white-space: nowrap;
}
.clb-exif-item:last-child {
    border-right: none;
}
.clb-exif-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--lb-orange);
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}
.clb-exif-label svg {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.clb-exif-label span.clb-exif-text { display: inline; }
.clb-exif-val {
    font-size: 12px;
    color: var(--lb-text);
    font-variant-numeric: tabular-nums;
}

/* 오버레이 모드에서 텍스트 밝기 조정 */
#clb-exif-overlay-inner .clb-exif-val {
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#clb-exif-overlay-inner .clb-exif-label {
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* 렌즈 항목 — 같은 row, 텍스트만 truncate */
.clb-exif-item--lens {
    max-width: 260px;
}
.clb-exif-val.clb-exif-lens {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    border-bottom: 1px dashed rgba(255,255,255,0.2);
}
.clb-exif-val.clb-exif-lens:hover {
    border-bottom-color: var(--lb-orange);
}

/* 렌즈 토스트 */
#clb-lens-toast {
    position: absolute;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(20,26,24,0.96);
    border: 1px solid var(--lb-border);
    color: var(--lb-text);
    font-size: 12px;
    padding: 7px 14px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 30;
}
#clb-lens-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* GPS map */
#clb-map-wrap {
    width: 100%;
    height: 110px;
    border-radius: var(--lb-radius);
    overflow: hidden;
    border: 1px solid var(--lb-border);
    flex-shrink: 0;
}
#clb-map { width: 100%; height: 100%; }

/* ── 이미지 전환 ── */
@keyframes clb-fadein { from { opacity: 0; } to { opacity: 1; } }
.clb-anim { animation: clb-fadein 0.2s ease forwards; }

/* ── 모바일 ── */
@media (max-width: 768px) {
    #clb-img {
        max-width: calc(100vw - 4px);
        max-height: calc(100vh - 4px);
    }
    #clb-overlay.exif-box-mode #clb-img {
        max-height: calc(100vh - 4px - var(--lb-box-h, 70px));
    }
    .clb-nav { width: 30px; height: 44px; }
    #clb-prev { left: 4px; }
    #clb-next { right: 4px; }
    #clb-bottom { max-height: 160px; padding: 7px 10px 9px; }
    #clb-map-wrap { height: 88px; }
    .clb-exif-item { padding: 0 7px; }
    /* 모바일: 레이블 텍스트 숨기고 아이콘만 */
    .clb-exif-label span.clb-exif-text { display: none; }
    .clb-exif-label svg { width: 12px; height: 12px; }
    .clb-exif-item--lens { max-width: 140px; }
    .clb-exif-val.clb-exif-lens { max-width: 100px; }
    #clb-exif-overlay { padding: 22px 8px 7px; }
}
