/* =========================================
   Sketchbook5 view 본문용 사진 타일 앨범 + 팝업 최종본
========================================= */

/* 본문 기본 이미지 */
.xe_content img,
.rd_body img,
.read_body img,
.board_read img,
#bo_v_con img {
    max-width: 100%;
    height: auto;
}

/* 앨범 로딩 표시 */
.photo-tile-loading {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: none;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    margin: 0;
    background: rgba(0,0,0,.42);
    color: #555;
    font-size: 13px;
    line-height: 1.4;
    opacity: 1;
    transition: opacity .18s ease;
}

.photo-tile-loading.is-active {
    display: flex;
}

.photo-tile-loading-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 190px;
    min-height: 58px;
    padding: 15px 20px;
    border-radius: 10px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 12px 34px rgba(0,0,0,.20);
    box-sizing: border-box;
}

.photo-tile-loading.is-done {
    opacity: 0;
    pointer-events: none;
}

.photo-tile-loading-spinner {
    display: inline-block;
    width: 26px;
    height: 26px;
    border: 3px solid #d9d9d9;
    border-top-color: #333;
    border-radius: 50%;
    box-sizing: border-box;
    animation: photoTileSpin .75s linear infinite;
}

.photo-tile-loading-text {
    display: inline-block;
}

.photo-tile-loading-active,
.photo-tile-loading-active body {
    overflow: hidden;
}

@keyframes photoTileSpin {
    to {
        transform: rotate(360deg);
    }
}

/* 자동 생성되는 앨범 래퍼 */
.photo-tile-gallery {
    column-gap: 10px;
    column-width: 320px;
    margin: 10px 0 10px;
    width: 100%;
}

.photo-tile-batch-sentinel {
    width: 100%;
    height: 1px;
    clear: both;
}

.photo-tile-gallery.is-scroll-limited .photo-tile-batch-sentinel {
    grid-column: 1 / -1;
}

/* 공통 타일 박스 크기 통일 */
.photo-tile-gallery .tile-photo,
.photo-tile-gallery .tile-video {
    display: inline-block;
    width: 100%;
    margin: 0 0 10px;
    vertical-align: top;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    border-radius: 10px;
    overflow: hidden;
    background: #f6f6f6;
    box-sizing: border-box;
    position: relative;
}

/* 클릭 영역 */
.photo-tile-gallery .tile-photo .tile-photo-trigger {
    display: block;
    width: 100%;
    text-decoration: none;
    cursor: zoom-in;
    position: relative;
    background: transparent;
}

/* 이미지 동일 크기 처리 */
.photo-tile-gallery .tile-photo img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    object-fit: cover;
    border: 0;
    border-radius: 10px;
    box-sizing: border-box;
    transition: transform .18s ease, opacity .18s ease, filter .18s ease;
}

/* hover */
.photo-tile-gallery .tile-photo .tile-photo-trigger:hover img {
    transform: scale(1.015);
    opacity: .97;
    filter: brightness(.98);
}

/* 확대 아이콘 */
.photo-tile-gallery .tile-photo .tile-photo-trigger:after {
    content: "＋";
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    font-size: 22px;
    color: #fff;
    background: rgba(0,0,0,.38);
    border-radius: 50%;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.photo-tile-gallery .tile-photo .tile-photo-trigger:hover:after,
.photo-tile-gallery .tile-photo .tile-photo-trigger:focus:after {
    opacity: 1;
    transform: translateY(0);
}

/* 캡션 */
.photo-tile-gallery .tile-caption {
    display: none;
    padding: 10px 4px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #666;
    word-break: keep-all;
}

/* 앨범만 있는 게시물일 때 */
.photo-tile-gallery.is-photo-only {
    margin-top: 12px;
}

#board_read.photo-tile-scroll-read .photo-tile-gallery.is-scroll-limited {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 12px;
    column-gap: 10px;
    column-width: auto;
    max-height: var(--photo-tile-scroll-height, 70vh);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 12px 0 4px;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

#board_read.photo-tile-scroll-read .photo-tile-gallery.is-scroll-limited .tile-photo,
#board_read.photo-tile-scroll-read .photo-tile-gallery.is-scroll-limited .tile-video {
    display: block;
    width: 100%;
    margin: 0;
}

@media (max-width: 900px) {
    #board_read.photo-tile-scroll-read .photo-tile-gallery.is-scroll-limited {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    #board_read.photo-tile-scroll-read .photo-tile-gallery.is-scroll-limited {
        grid-template-columns: 1fr;
    }
}

/* 라이트박스 */
.photo-lightbox {
    display: none;
    position: fixed;
    z-index: 999999;
    inset: 0;
    background: rgba(0,0,0,.88);
    overflow: hidden;
}

.photo-lightbox.is-open {
    display: block;
}

.photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    cursor: zoom-out;
}

.photo-lightbox-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 34px 70px;
    box-sizing: border-box;
}

.photo-lightbox-figure {
    position: relative;
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    text-align: center;
}

.photo-lightbox-img {
    display: block;
    max-width: calc(100vw - 140px);
    max-height: calc(100vh - 120px);
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.45);
    background: #111;
}

.photo-lightbox-caption {
    margin-top: 12px;
    color: #fff;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
    word-break: keep-all;
}

.photo-lightbox-btn {
    position: absolute;
    z-index: 2;
    border: 0;
    background: rgba(0,0,0,.35);
    color: #fff;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    line-height: 48px;
    text-align: center;
    font-size: 28px;
    padding: 0;
    transition: background .15s ease, opacity .15s ease, transform .15s ease;
}

.photo-lightbox-btn:hover {
    background: rgba(0,0,0,.55);
    transform: scale(1.03);
}

.photo-lightbox-close {
    top: 18px;
    right: 18px;
    font-size: 30px;
}

.photo-lightbox-prev {
    top: 50%;
    left: 18px;
    transform: translateY(-50%);
}

.photo-lightbox-next {
    top: 50%;
    right: 18px;
    transform: translateY(-50%);
}

.photo-lightbox-counter {
    position: absolute;
    left: 20px;
    top: 20px;
    z-index: 2;
    color: #fff;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0,0,0,.30);
}

/* 공통 미디어 프레임: 모두 같은 높이 */
.photo-tile-gallery .tile-media-frame {
    position: relative;
    width: 100%;
    height: 260px;   /* 원하는 고정 높이 */
    overflow: hidden;
    border-radius: 10px;
    background: #ddd;
}


/* 매우 넓은 화면 */
@media (min-width: 1800px) {
    .photo-tile-gallery {
        column-width: 300px;
        column-gap: 10px;
    }
}

/* 일반 PC */
@media (max-width: 1439px) {
    .photo-tile-gallery {
        column-width: 300px;
        column-gap: 10px;
    }
}

/* 태블릿 */
@media (max-width: 1000px) {
    .photo-tile-gallery {
        column-width: 300px;
        column-gap: 10px;
    }

    .photo-tile-gallery .tile-photo {
        margin-bottom: 18px;
        border-radius: 10px;
    }

    .photo-tile-gallery .tile-photo img {
        border-radius: 10px;
    }

    .photo-lightbox-inner {
        padding: 24px 56px;
    }

    .photo-lightbox-img {
        max-width: calc(100vw - 112px);
        max-height: calc(100vh - 96px);
    }
	.photo-tile-gallery .tile-media-frame {
        height: 220px;
    }	
}

/* 모바일 */
@media (max-width: 767px) {
	.photo-tile-gallery .tile-media-frame {
        height: 220px;
    }

    .photo-tile-gallery {
        column-count: 1;
        column-width: auto;
        column-gap: 0;
        margin: 18px 0 6px;
    }

    .photo-tile-gallery .tile-photo {
        margin-bottom: 10px;
        border-radius: 10px;
    }

    .photo-tile-gallery .tile-photo img {
        border-radius: 10px;
    }

    .photo-lightbox-inner {
        padding: 16px 12px 28px;
    }

    .photo-lightbox-img {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 120px);
        border-radius: 10px;
    }

    .photo-lightbox-btn {
        width: 42px;
        height: 42px;
        line-height: 42px;
        font-size: 24px;
    }

    .photo-lightbox-close {
        top: 10px;
        right: 10px;
    }

    .photo-lightbox-prev {
        left: 8px;
    }

    .photo-lightbox-next {
        right: 8px;
    }

    .photo-lightbox-counter {
        top: 10px;
        left: 10px;
        font-size: 12px;
        padding: 6px 10px;
    }

    .photo-tile-gallery .tile-photo .tile-photo-trigger:after {
        opacity: 1;
        transform: none;
        width: 30px;
        height: 30px;
        line-height: 30px;
        font-size: 19px;
        right: 10px;
        bottom: 10px;
    }
}

/* 유튜브 iframe radius 처리 */
.urllink iframe[src*="youtube.com"],
.urllink iframe[src*="youtube-nocookie.com"],
.urllink iframe[src*="youtu.be"],
.rd_body iframe[src*="youtube.com"],
.rd_body iframe[src*="youtube-nocookie.com"],
.rd_body iframe[src*="youtu.be"] {
    display: block;
    width: 100%;
    max-width: 550px;
    border: 0;
    border-radius: 10px;
    overflow: hidden;
    box-sizing: border-box;
}

/* wrapper가 붙은 경우 더 안정적으로 잘리도록 */
.youtube-radius-wrap {
    border-radius: 10px;
    overflow: hidden;
    display: inline-block;
    width: 100%;
    max-width: 550px;
    line-height: 0;
    box-sizing: border-box;
}

.youtube-radius-wrap iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 0;
    border-radius: 10px;
}

/* 유튜브 iframe 동일 크기 처리 */
.photo-tile-gallery .tile-video iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 10px;
}
