/*
 * Swiper Link Cards — 前台樣式（自包含）
 * 來源：e:/editor_components/css/style.css 的 link-cards / link-swiper 段落（完全比照）
 * .custom-link-cards（靜態 grid）/ .custom-link-cards.custom-link-swiper（輪播）
 */

/* ---------- link-cards ---------- */

.custom-link-cards {
    counter-reset: link-card;
}

.custom-link-cards .card-item {
    position: relative;
    background: #ffffff;
    border: 1px solid #f5f5f5;
    border-radius: 15px;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(17, 19, 21, 0.06);
    transition:
        box-shadow 0.3s ease,
        transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.custom-link-cards .card-item:hover {
    box-shadow: 0 10px 28px rgba(17, 19, 21, 0.12);
    transform: translateY(-3px);
}

.custom-link-cards .card-item:hover::before {
    color: var(--main-color-1, #03aed2);
}

.custom-link-cards .card-item__body {
    padding: 18px 0 0;
}

/* ---------- card thumb ---------- */

.card-item__thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #e9e7e1;
    cursor: pointer;
    border-radius: 5px;
}

.card-item__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition:
        transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1),
        filter 0.4s ease;
    filter: saturate(0.9);
}

.card-item__thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(17, 19, 21, 0.35), rgba(17, 19, 21, 0) 55%);
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
    pointer-events: none;
}

.card-item:hover .card-item__thumb img {
    transform: scale(1.04);
    filter: saturate(1.05);
}

.card-item:hover .card-item__thumb::after {
    transform: translateY(0);
}

/* ---------- body ---------- */
.card-item__body {
    padding: 22px 6px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.card-item__title-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
    position: relative;
    align-self: flex-start;
}

.card-item__title-link::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 1px;
    background: #111315;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.card-item__title-link:hover::after {
    transform: scaleX(1);
}

/* CMS 樣板 CSS（cms_template_style.css / cms_editor.css）會以 h3 / p 規則
   蓋掉卡片字級（標題被改成 24px、描述被改成 16px），導致 poster.php 前台
   字體比參考檔大。字級 / 字重 / 行高加 !important 強制對齊參考檔，三處一致。 */
.card-item__title {
    font-size: 1.18rem !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    color: #111315;
    letter-spacing: 0.01em;
}

.card-item__desc {
    font-size: 0.9rem !important;
    line-height: 1.7 !important;
    color: #4a4f55;
    margin: 0 0 14px !important;
    text-align: justify;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    line-clamp: 3;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

/* ---------- CTA (圖示按鈕) ---------- */
.card-item__cta {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    align-self: flex-start;
    padding: 12px 22px;
    border-radius: 6px;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    letter-spacing: 0.02em;
    line-height: 1 !important;
    text-decoration: none;
    color: #ffffff;
    border: 1px solid #111315;
    background: #111315;
    transition:
        color 0.25s ease,
        background-color 0.3s ease,
        border-color 0.25s ease,
        transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.card-item__cta-label {
    letter-spacing: 0.5px;
}

.card-item__cta::after {
    content: '';
    width: 22px;
    height: 11px;
    flex: none;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2026%2012'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='square'%3E%3Cpath%20d='M0%206%20H23%20M18%201%20L24%206%20L18%2011'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2026%2012'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='square'%3E%3Cpath%20d='M0%206%20H23%20M18%201%20L24%206%20L18%2011'/%3E%3C/svg%3E") no-repeat center / contain;
    transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.card-item__cta:hover {
    color: #ffffff;
    background: var(--main-color-1, #03aed2);
    border-color: var(--main-color-1, #03aed2);
}

.card-item__cta:hover::after {
    transform: translateX(4px);
}

.card-item__cta:focus-visible {
    outline: 2px solid var(--main-color-1, #03aed2);
    outline-offset: 3px;
}

/* ---------- link-cards 靜態 grid（未掛 .custom-link-swiper）---------- */
/* 同一份 swiper 結構，沒有初始化輪播時用 grid 排版呈現三欄 */

.custom-link-cards:not(.custom-link-swiper) .swiper {
    overflow: visible;
}

.custom-link-cards:not(.custom-link-swiper) .swiper-wrapper {
    display: grid;
    grid-template-columns: repeat(var(--col-mobile, 1), 1fr);
    gap: 24px;
    transform: none !important;
}

/* grid 子項目防撐爆：min-width 預設 auto 會讓圖片把軌道撐大，需歸零才會平分容器 */
.custom-link-cards:not(.custom-link-swiper) .swiper-slide {
    min-width: 0;
}

@media (min-width: 768px) {
    .custom-link-cards:not(.custom-link-swiper) .swiper-wrapper {
        grid-template-columns: repeat(var(--col-tablet, 2), 1fr);
    }
}

@media (min-width: 992px) {
    .custom-link-cards:not(.custom-link-swiper) .swiper-wrapper {
        grid-template-columns: repeat(var(--col-desktop, 3), 1fr);
        gap: 32px;
    }
}

/* ---------- card-item 進場動畫（fade-up） ---------- */
/* 用 backwards（不保留結束狀態），動畫結束後 transform 歸零，
   不會蓋掉 .card-item:hover 的 translateY 位移 */

/* 靜態 grid：每張卡片滾動進畫面時個別淡入上移（JS 加 .is-fadeup） */
.custom-link-cards:not(.custom-link-swiper) .card-item {
    opacity: 0;
}

.custom-link-cards:not(.custom-link-swiper) .card-item.is-fadeup {
    opacity: 1;
    animation: hero-rise 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

/* 輪播：slide 滑入可視範圍（Swiper 加 .swiper-slide-visible）時淡入上移 */
.custom-link-swiper .card-item {
    opacity: 0;
}

.custom-link-swiper .swiper-slide-visible .card-item {
    opacity: 1;
    animation: hero-rise 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

@media (prefers-reduced-motion: reduce) {

    .custom-link-cards .card-item {
        opacity: 1 !important;
        animation: none !important;
    }
}

@keyframes hero-rise {
    from {
        opacity: 0;
        transform: translateY(28px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- link-swiper ---------- */


.custom-link-cards {
    margin-bottom: 48px;
}

.custom-link-swiper .swiper {
    padding: 4px 2px 2px;
}

/* Swiper 預設給 slide height:100% 會塌成內容高度;
   改 auto 讓 flex 把所有 slide 拉成等高,卡片才能撐滿、按鈕貼底 */
.custom-link-swiper .swiper-slide {
    height: auto;
}

.custom-link-swiper .card-item {
    height: 100%;
}

.link-swiper__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin-top: 28px;
}

.link-swiper__btn {
    position: relative;
    width: 46px;
    height: 46px;
    flex: none;
    padding: 0;
    border: 1px solid;
    border-radius: 50%;
    cursor: pointer;
    transition:
        border-color 0.25s ease,
        background-color 0.25s ease,
        color 0.25s ease,
        transform 0.25s ease;
}

.link-swiper__btn::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 11px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2026%2012'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='square'%3E%3Cpath%20d='M0%206%20H23%20M18%201%20L24%206%20L18%2011'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2026%2012'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='square'%3E%3Cpath%20d='M0%206%20H23%20M18%201%20L24%206%20L18%2011'/%3E%3C/svg%3E") no-repeat center / contain;
}

.link-swiper__btn--prev::after {
    transform: scaleX(-1);
}

.link-swiper__btn:hover {
    border-color: var(--main-color-1, #03aed2);
    background: var(--main-color-1, #03aed2);
    color: #ffffff;
    transform: translateY(-2px);
}

.link-swiper__btn:focus-visible {
    outline: 2px solid var(--main-color-1, #03aed2);
    outline-offset: 3px;
}

.link-swiper__btn.swiper-button-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* 淺色版（link-swiper，紙底）：透明描邊 + 墨色箭頭 */
.link-swiper__btn {
    border-color: #d6d8db;
    background: transparent;
    color: #111315;
}

.custom-link-swiper .link-swiper__pagination.swiper-pagination-bullets {
    position: static;
    inset: auto;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: auto;
}

.custom-link-swiper .link-swiper__pagination.swiper-pagination-bullets .swiper-pagination-bullet {
    position: relative;
    cursor: pointer;
    width: 11px;
    height: 11px;
    margin: 0 !important;
    background: transparent;
    border: 1px solid var(--main-color-1, #111315);
    opacity: 1;
    border-radius: 50%;
    transition:
        background-color 0.25s ease,
        border-color 0.25s ease;
}

.custom-link-swiper .link-swiper__pagination.swiper-pagination-bullets .swiper-pagination-bullet-active {
    background: var(--main-color-1, #111315);
    border-color: var(--main-color-1, #111315);
}

/* ===================================================================
   以下為 CKEditor 編輯區專用（前台不受影響）— 參考檔 e:/editor_components
   為純前台環境不需要這段；本專案在 CKEditor 編輯器內無前台 JS，需要這組規則。
   =================================================================== */

/* 編輯區不跑前台 JS，卡片不會被加 .is-fadeup / .swiper-slide-visible，
   會卡在 opacity:0 看不到內容 → 強制顯示、關閉進場動畫。 */
body.cke_editable:not(.cke-preview) .custom-link-cards .card-item {
    opacity: 1 !important;
    animation: none !important;
}

/* CMS 樣板 CSS（cms_editor.css 等）在編輯區會蓋掉 body 內距與 title-link 的
   margin（字級 / 標題 / 描述 margin 已由前台規則的 !important 涵蓋）。
   此處補強 body 內距與 title-link 歸零，讓編輯器內外觀與前台一致。前台不受影響。 */
body.cke_editable:not(.cke-preview) .custom-link-cards .card-item__body {
    padding: 18px 0 0 !important;
    margin: 0 !important;
}
body.cke_editable:not(.cke-preview) .custom-link-cards .card-item__title-link {
    margin: 0 !important;
    padding: 0 !important;
}

/* 編輯區「輪播版」預覽排版：不跑 Swiper JS，預設 flex 會變一行一張；
   改用 grid 依 data-column-desktop 的 1~6 欄顯示，貼近前台欄數。 */
body.cke_editable:not(.cke-preview) .custom-link-swiper .swiper {
    overflow: visible;
}
body.cke_editable:not(.cke-preview) .custom-link-swiper .swiper-wrapper {
    display: grid;
    gap: 24px;
    transform: none !important;
    grid-template-columns: repeat(4, 1fr);
}
body.cke_editable:not(.cke-preview) .custom-link-swiper[data-column-desktop="1"] .swiper-wrapper { grid-template-columns: repeat(1, 1fr); }
body.cke_editable:not(.cke-preview) .custom-link-swiper[data-column-desktop="2"] .swiper-wrapper { grid-template-columns: repeat(2, 1fr); }
body.cke_editable:not(.cke-preview) .custom-link-swiper[data-column-desktop="3"] .swiper-wrapper { grid-template-columns: repeat(3, 1fr); }
body.cke_editable:not(.cke-preview) .custom-link-swiper[data-column-desktop="4"] .swiper-wrapper { grid-template-columns: repeat(4, 1fr); }
body.cke_editable:not(.cke-preview) .custom-link-swiper[data-column-desktop="5"] .swiper-wrapper { grid-template-columns: repeat(5, 1fr); }
body.cke_editable:not(.cke-preview) .custom-link-swiper[data-column-desktop="6"] .swiper-wrapper { grid-template-columns: repeat(6, 1fr); }
body.cke_editable:not(.cke-preview) .custom-link-swiper .swiper-slide { min-width: 0; height: auto; }

/* 擴大圓點可點擊範圍（視覺大小不變） */
.custom-link-swiper .link-swiper__pagination.swiper-pagination-bullets .swiper-pagination-bullet::after {
    content: '';
    position: absolute;
    inset: -5px;
}
