/**
 * YAO Linked Filters - 主要樣式檔案
 *
 * @package YaoLinkedFilters
 */

/* ==========================================================================
   1. 基礎重置與變數
   ========================================================================== */

:root {
    --yao-primary-color: #7A6CB7;
    --yao-text-color: #333;
    --yao-border-color: #ddd;
    --yao-background-color: #fff;
    --yao-hover-color: #6A5CA7;
    --yao-grid-gap-caseshare: 30px;
    --yao-grid-gap-personal: 20px;
    --yao-border-radius: 5px;
    --yao-transition: all 0.3s ease;
}

/* 比例盒 fallback：在部分環境中輔助維持 1:1 高度 */
.yao-before-after-wrapper::before {
    content: '';
    display: block;
    padding-bottom: 100%;
}

/* 桌機板（≥1280px）caseshare 卡片左右 80px、上下 100px */
@media (min-width: 1280px) {
    .elementor-element-5d374790 {
        margin: 100px 80px;
    }

    /* personal：1280 以上固定 4 欄，卡片 311px 等寬且置中 */
    .yao-filter--personal .elementor-loop-container {
        grid-template-columns: repeat(4, 311px);
        justify-content: center;
    }

    /* personal 卡片外距：上下 40px、左右 4px */
    .elementor-element-7ea08ee5 {
        margin: 40px 4px;
    }
}

/* personal 卡片間距：統一左右 6px、上下 40px */
@media (min-width: 1025px) {
    .elementor-element-7ea08ee5 {
        margin: 40px 6px;
    }
}

@media (max-width: 767px) {
    .elementor-element-7ea08ee5 {
        margin: 40px 6px;
    }
}

/* 避免上層小工具樣式影響顯示（保險） */
.pt_plus_before_after .yao-before-after-wrapper {
    display: block;
}

/* ==========================================================================
   2. 篩選器樣式
   ========================================================================== */

.yao-filter {
    width: 100%;
    margin: 20px 0;
}

/* 篩選表單 */
.yao-filter__form {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 auto 30px auto; /* 居中對齊 */
    padding: 0; /* 移除內距 */
    border: none; /* 移除邊框 */
    box-shadow: none; /* 移除陰影 */
    background: transparent;
    max-width: 824px; /* 1280px 以上的固定寬度 */
}

/* 隱藏標籤 */
.yao-filter__label {
    display: none !important;
}

/* 選單基礎樣式 */
.yao-filter__parent,
.yao-filter__child {
    padding: 10px 15px;
    border: 1px solid var(--yao-border-color);
    border-radius: var(--yao-border-radius);
    background: linear-gradient(0deg, #F2F2F2 0%, #F2F2F2 100%);
    color: var(--yao-text-color);
    font-size: 14px;
    line-height: 1.4;
    transition: var(--yao-transition);
    min-width: 150px;
    /* 自訂下拉箭頭 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='21' viewBox='0 0 20 21' fill='none'%3E%3Cpath d='M17.671 4.4165L2.33002 4.41649L10.0005 14.5835L17.671 4.4165Z' fill='black' fill-opacity='0.7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px 21px;
    padding-right: 40px; /* 預留箭頭空間 */
}

.yao-filter__parent:focus,
.yao-filter__child:focus,
.yao-filter__parent:focus-visible,
.yao-filter__child:focus-visible {
    outline: none; /* 移除紫色外框 */
    border-color: var(--yao-border-color);
    box-shadow: none;
}

.yao-filter__child:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* 響應式：平板版等比例縮小但保持 inline */
@media (min-width: 768px) and (max-width: 1279px) {
    .yao-filter__form {
        max-width: calc(824px * 0.85); /* 85% 等比例縮小 */
    }
}

/* 響應式：手機版改為垂直排列 */
@media (max-width: 767px) {
    .yao-filter__form {
        flex-direction: column;
        align-items: stretch;
        max-width: 100%; /* 手機版全寬 */
    }

    .yao-filter__parent,
    .yao-filter__child {
        width: 100%;
        min-width: auto;
    }
}

/* ==========================================================================
   3. Grid 佈局系統
   ========================================================================== */

/* Caseshare 佈局：2欄2列 */
.yao-filter--caseshare .elementor-loop-container.elementor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--yao-grid-gap-caseshare);
    margin-bottom: 100px; /* 與頁碼距離 100px */
}

/* Personal 佈局：4欄2列 */
.yao-filter--personal .elementor-loop-container {
    display: grid;
    /* 桌機以 311px 為最小卡片寬，auto-fit 自動收合欄位避免溢出 */
    grid-template-columns: repeat(auto-fit, minmax(311px, 1fr));
    gap: var(--yao-grid-gap-personal);
    margin-bottom: 30px;
    justify-items: center; /* 個別卡片置中 */
    justify-content: center; /* 使整體網格在可用空間中置中 */
}

/* 響應式 Grid */
@media (max-width: 1024px) {
    .yao-filter--personal .elementor-loop-container {
        /* 平板改以 285px 為最小寬，避免 768~1280 區間超出 */
        grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
        justify-content: center; /* 平板置中 */
    }
}

@media (max-width: 768px) {
    .yao-filter--caseshare .elementor-loop-container.elementor-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .yao-filter--personal .elementor-loop-container {
        grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
        gap: 15px;
        justify-content: center; /* 手機置中 */
    }
}

@media (max-width: 480px) {
    .yao-filter--personal .elementor-loop-container {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   4. Caseshare 項目樣式
   ========================================================================== */

.elementor-element-5d374790 {
    background: #FAFAFA; /* caseshare 卡片底色 */
    border-radius: 0 0 40px 0; /* 只有右下角 40px 圓角 */
    overflow: hidden;
    box-shadow: none; /* 取消陰影 */
    transition: none; /* 取消 hover 動畫 */
    margin: 50px 0; /* 其他螢幕寬度：上下距離 50px，左右 0 */
}

.elementor-element-5d374790:hover {
    transform: none; /* 取消浮起效果 */
    box-shadow: none; /* 取消 hover 陰影 */
}

/* Before/After 區域 */
.yao-before-after-container {
    width: 100%;
    display: block; /* 取消置中，讓內容貼齊容器 */
    padding: 0; /* 與卡片貼合，無內距 */
}

.yao-before-after-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 0; /* 內層不需要圓角，交由外層卡片控制 */
    cursor: ew-resize;
    width: 100%; /* 撐滿卡片寬度 */
    height: auto; /* 高度交由比例控制 */
    aspect-ratio: 1 / 1; /* 保持 1:1 比例 */
    max-width: 100%;
}

.yao-before-image,
.yao-after-image {
    position: absolute;
    top: 0;
    height: 100%;
    overflow: hidden;
}

.yao-before-image {
    left: 0;
    width: 100%; /* 底層，全寬顯示 */
    z-index: 1;
    /* 預設 50% 分割（JS 啟動前的安全預設） */
    clip-path: inset(0 50% 0 0);
}

.yao-after-image {
    left: 0; /* 覆蓋層，從左側開始，使用 clip-path 控制顯示範圍 */
    width: 100%; /* 全幅，避免與 clip-path 邏輯衝突 */
    z-index: 2;
    /* 預設 50% 分割（JS 啟動前的安全預設） */
    clip-path: inset(0 0 0 50%);
}

.yao-before-image img,
.yao-after-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
    max-width: none;
}

.yao-separator {
    position: absolute;
    top: 0;
    left: 50%; /* 初始置中，JS 會動態變更 left 百分比 */
    width: 50px; /* 使用 line.png 的寬度 */
    height: 100%;
    transform: translateX(-50%);
    cursor: ew-resize;
    transition: left 0.3s ease;
    z-index: 10; /* 確保在圖片層之上 */
    background-image: url('../images/line.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 50px 100%;
}

.yao-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    user-select: none;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 11;
}

.yao-handle:hover {
    background: #f0f0f0;
}

/* 內容區域 */
.elementor-element-2d07998d {
    padding: 32px 0 34px 0; /* caseshare 內容左右無內距 */
}

.elementor-element-2d46778e h2 {
    font-family: 'Noto Serif TC', serif;
    font-size: 32px;
    font-weight: 600;
    line-height: 41.4px;
    margin: 0 0 24px 0;
    padding-bottom: 24px;
    border-bottom: 1px solid #333;
}

/* 詳細資訊區域 */
.elementor-element-17669332 {
    padding: 0 0 24px 0; /* caseshare 詳細資訊左右無內距 */
}

.elementor-element-6b9ebfa3 {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-left: 20px;
}

.elementor-element-55f4cc8a,
.elementor-element-54c64814,
.elementor-element-4d14668e {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
}

.elementor-element-62e8ffed,
.elementor-element-782da451,
.elementor-element-36ff0049 {
    width: 200px;
    flex-shrink: 0;
}

.elementor-element-51b5c3c3,
.elementor-element-2c797ef9,
.elementor-element-6338726 {
    flex: 1;
}

.elementor-element-52416cb0 h3,
.elementor-element-5492c3a7 h3,
.elementor-element-737037d3 h3 {
    font-size: 18px;
    font-weight: 400;
    line-height: 28.8px;
    letter-spacing: 1.8px;
    color: var(--yao-primary-color);
    margin: 0;
}

.elementor-element-16b93637 .elementor-heading-title,
.elementor-element-679a1a45 .elementor-heading-title,
.elementor-element-dc998e6 .elementor-heading-title {
    font-size: 18px;
    font-weight: 400;
    line-height: 28.8px;
    letter-spacing: 1.8px;
    color: var(--yao-text-color);
    margin: 0;
}

/* 查看更多按鈕 */
.elementor-element-2b9a7db5 {
    padding: 0; /* caseshare 查看更多區塊左右無內距 */
}

/* 改為圖片連結的樣式（readmore.png） */
.yao-readmore-link {
    display: inline-block;
    text-decoration: none;
}

.yao-readmore-link img {
    display: block;
    max-width: 100%;
    height: auto; /* 使用圖片本身比例與尺寸，不放大 */
}

/* ==========================================================================
   5. Personal 項目樣式
   ========================================================================== */

.elementor-element-7ea08ee5 {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: none; /* 移除特效 */
    box-shadow: none; /* 確保無陰影 */
    width: 311px; /* personal 整張卡片與精選圖片等寬 */
}

.elementor-element-7ea08ee5:hover {
    transform: none; /* 移除 hover 效果 */
    box-shadow: none; /* 移除 hover 陰影 */
}

.elementor-element-48bc2a20 {
    position: relative;
    width: 311px; /* personal 精選圖片寬 */
    height: 285px; /* personal 精選圖片高 */
    min-height: 285px;
    flex-shrink: 0;
    aspect-ratio: 311 / 285;
    margin-bottom: 16px;
    padding: 17px 0 0 20px;
    border-radius: 0; /* personal 卡片不要任何圓角 */
    overflow: hidden;
}

/* 1280 以下，personal 卡片與精選圖片改為 285 x 285，並確保標題不超出寬度 */
@media (max-width: 1279px) {
    .elementor-element-7ea08ee5 {
        width: 285px;
    }
    .elementor-element-48bc2a20 {
        width: 285px;
        height: 285px;
        aspect-ratio: 1 / 1;
    }
    .elementor-element-5e4ec06 h2 {
        max-width: 100%;
        overflow-wrap: anywhere; /* 避免長字超出 */
        word-break: break-word;
    }
}

.elementor-element-76a12c8b {
    display: inline-block;
    padding: 8px 16px;
    background-color: #6454aa; /* personal 紫色標籤底色 */
    border-radius: 0; /* personal 標籤不要圓角 */
    width: 39%;
}

.elementor-element-76a12c8b h3 {
    color: white;
    font-size: 16px;
    font-weight: 400;
    line-height: 25.6px;
    letter-spacing: 1.6px;
    text-align: center;
    margin: 0;
}

.elementor-element-5e4ec06 h2 {
    font-size: 16px;
    font-weight: 400;
    line-height: 25.6px;
    letter-spacing: 1.6px;
    color: var(--yao-text-color);
    text-align: center;
    margin: 0;
}

/* ==========================================================================
   6. 分頁樣式
   ========================================================================== */

.yao-pagination {
    margin: 30px 0;
    text-align: center;
}

.yao-pagination__wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.yao-pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none; /* 移除預設邊框 */
    background: transparent !important; /* 預設無背景 */
    color: #333 !important; /* 預設文字顏色 */
    text-decoration: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--yao-transition);
    user-select: none;
}

/* Hover 狀態：紫色圓底白字 */
.yao-pagination__btn:hover:not(:disabled) {
    background-color: var(--yao-primary-color) !important;
    color: white !important;
}

/* Focus 狀態（鍵盤導航）：紫色圓底白字 + outline */
.yao-pagination__btn:focus:not(:disabled),
.yao-pagination__btn:focus-visible:not(:disabled) {
    background-color: var(--yao-primary-color) !important;
    color: white !important;
    outline: 2px solid rgba(122, 108, 183, 0.3);
    outline-offset: 2px;
}

.yao-pagination__btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    color: #999;
}

/* Active 狀態：紫色圓形背景白字 */
.yao-pagination__btn--active {
    background-color: var(--yao-primary-color) !important;
    color: white !important;
}

.yao-pagination__ellipsis {
    padding: 0 5px;
    color: #999;
    font-size: 14px;
}

/* 上一頁/下一頁按鈕 */
.yao-pagination__prev,
.yao-pagination__next {
    font-size: 16px;
}

/* ==========================================================================
   7. 載入與錯誤狀態
   ========================================================================== */

.yao-loading,
.yao-error,
.yao-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

.yao-loading {
    position: relative;
}

.yao-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--yao-primary-color);
    border-radius: 50%;
    animation: yao-spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes yao-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.yao-error {
    color: #d63638;
    background: #fff2f2;
    border: 1px solid #f8d7da;
    border-radius: var(--yao-border-radius);
}

/* ==========================================================================
   8. 響應式調整
   ========================================================================== */

/* 響應式 Before/After 容器縮放 */
@media (max-width: 650px) {
    .yao-before-after-wrapper {
        width: 90vw !important;
        height: 90vw !important;
        max-width: 500px !important;
        max-height: 500px !important;
    }
}

@media (max-width: 500px) {
    .yao-before-after-wrapper {
        width: 95vw !important;
        height: 95vw !important;
        max-width: 400px !important;
        max-height: 400px !important;
    }
}

@media (max-width: 600px) {
    .elementor-element-48bc2a20 {
        width: 100%;
        min-height: 200px;
    }

    .elementor-element-55f4cc8a,
    .elementor-element-54c64814,
    .elementor-element-4d14668e {
        flex-direction: column;
        gap: 10px;
    }

    .elementor-element-62e8ffed,
    .elementor-element-782da451,
    .elementor-element-36ff0049 {
        width: 100%;
    }

    .elementor-element-2d46778e h2 {
        font-size: 24px;
        line-height: 1.3;
    }

    .yao-pagination__btn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
}

/* ==========================================================================
   9. 可訪問性增強
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高對比模式支援 */
@media (prefers-contrast: high) {
    .yao-filter__parent,
    .yao-filter__child {
        border: 2px solid var(--yao-text-color);
    }

    .yao-pagination__btn {
        border: 2px solid var(--yao-text-color);
    }
}

/* 鍵盤導航增強 */
.yao-filter__parent:focus-visible,
.yao-filter__child:focus-visible,
.yao-pagination__btn:focus-visible {
    outline: 2px solid var(--yao-primary-color);
    outline-offset: 2px;
}

/* ==========================================================================
   10. 打印樣式
   ========================================================================== */

@media print {
    .yao-filter__form,
    .yao-pagination {
        display: none;
    }

    .yao-before-after-wrapper {
        break-inside: avoid;
    }

    .elementor-element-5d374790,
    .elementor-element-7ea08ee5 {
        break-inside: avoid;
        box-shadow: none;
    }
}

/* ==========================================================================
   11. Personal grid override (ensure 4 columns on >=1280px)
   ========================================================================== */
@media (min-width: 1280px) {
    /* 固定 4 欄，每欄 311px，移除 gap 以避免總寬超出容器 */
    .yao-filter--personal .elementor-loop-container {
        grid-template-columns: repeat(4, 311px) !important;
        gap: 0 !important;
        justify-content: center;
    }

    /* 卡片寬與外距：確保等寬並置中 */
    .elementor-element-7ea08ee5 {
        width: 311px !important;
        margin: 40px 4px !important; /* 上下40 左右4 */
    }
}