/* =====================================================================
   Fancybox Gallery — CKEditor 編輯器內顯示樣式（contentsCss）
   ---------------------------------------------------------------------
   編輯器內套件產出的相簿柵欄外觀，與前端 css/fancybox_gallery.css 一致。
   前端頁面（demo.php / poster.php）請維持引用 css/fancybox_gallery.css。

   RWD 欄數：電腦 5 欄 / 平板（≤991px）3 欄 / 手機（≤575px）2 欄
   ===================================================================== */

.fancyboxGallery,
.editor-area > p:has(> a[data-fancybox] > img) {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 1.5rem;
}

.fancyboxGallery a,
.editor-area > p > a[data-fancybox]:has(> img) {
    display: block;
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(17, 19, 21, 0.08);
    transition: box-shadow .3s ease, transform .3s ease;
}

.fancyboxGallery a:hover,
.editor-area > p > a[data-fancybox]:has(> img):hover {
    box-shadow: 0 10px 28px rgba(17, 19, 21, 0.18);
    transform: translateY(-3px);
}

.fancyboxGallery a::after,
.editor-area > p > a[data-fancybox]:has(> img)::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(17, 19, 21, 0) 55%, rgba(17, 19, 21, 0.35) 100%);
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}

.fancyboxGallery a:hover::after,
.editor-area > p > a[data-fancybox]:has(> img):hover::after {
    opacity: 1;
}

/* 鎖定縮圖填滿等高比例（CMS 樣板對 img / .img-fluid 設了 height:auto，需覆寫） */
.fancyboxGallery a img,
.editor-area > p > a[data-fancybox] > img {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    border: 0 !important;
    object-fit: cover;
    transition: transform .35s ease;
}

.fancyboxGallery a:hover img,
.editor-area > p > a[data-fancybox]:hover > img {
    transform: scale(1.06);
}

@media (max-width: 991px) {
    .fancyboxGallery,
    .editor-area > p:has(> a[data-fancybox] > img) {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 575px) {
    .fancyboxGallery,
    .editor-area > p:has(> a[data-fancybox] > img) {
        grid-template-columns: repeat(2, 1fr);
    }
}
