/* ==================== 1. Layout System ==================== */
.sydt-portfolio-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

.sydt-layout-has-sidebar {
    display: flex;
    flex-wrap: nowrap;
    gap: 40px;
    align-items: flex-start;
}

.sydt-content-area {
    flex: 1;
    min-width: 0;
}

/* ==================== 2. Section Headers & Groups ==================== */
.sydt-parent-group {
    margin-bottom: 50px;
    scroll-margin-top: 120px;
}

.sydt-section-header {
    margin-bottom: 25px;
    padding-bottom: 10px;
}

.sydt-section-title {
    margin: 0;
    font-weight: 700;
}

.sydt-section-desc {
    color: #666;
    font-size: 16px;
    margin-top: 10px;
    line-height: 1.6;
}

/* [修改] 子分類區塊與標題設計 */
.sydt-subsection {
    margin-bottom: 40px;
    scroll-margin-top: 140px;
}

.sydt-subsection-title {
    font-size: 18px;
    font-weight: 600;
    background-color: #fff1f0; /* 淺紅色背景 */
    padding: 10px 15px; /* 增加內距 */
    border-radius: 6px; /* 圓角 */
    margin-bottom: 20px;
    display: inline-block; /* 寬度隨內容 */
    /* 移除舊的 border-left */
    border-left: none; 
}

.sydt-group-divider {
    border: 0;
    border-top: 1px solid #000;
    margin: 40px 0 !important;
}

/* ==================== 3. Sidebar Navigation (巢狀結構) ==================== */

.sydt-sidebar-nav-wrapper {
    transition: all 0.3s ease;
}

.sydt-nav-list, .sydt-sub-nav-list {
    list-style: none !important; 
    margin: 0 !important;
    padding: 0 !important;
}

/* 桌機版 (1024px+) */
@media (min-width: 1024px) {
    .sydt-sidebar-nav-wrapper {
        position: -webkit-sticky;
        position: sticky;
        top: 100px;
        width: 240px;
        z-index: 9;
        display: block;
        flex-shrink: 0;
    }

    .sydt-sidebar-nav {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    }

    /* 父連結樣式 */
    .sydt-nav-link.parent-link {
        display: block;
        padding: 8px 12px;
        color: #333;
        font-weight: 700;
        text-decoration: none;
        border-radius: 4px;
        margin-top: 10px;
        font-size: 15px;
    }
    
    .sydt-nav-link.parent-link:hover {
        color: #a00000;
        background-color: #fff1f0;
    }

    /* 子選單容器 (縮排) */
    .sydt-sub-nav-list {
        padding-left: 15px !important;
        margin-top: 5px !important;
        border-left: 2px solid #f0f0f0;
        margin-left: 10px !important;
    }

    /* 子連結樣式 */
    .sydt-nav-link.child-link {
        display: block;
        padding: 6px 10px;
        color: #666;
        text-decoration: none;
        font-size: 14px;
        border-radius: 4px;
        transition: all 0.2s;
    }

    .sydt-nav-link.child-link:hover {
        color: #a00000;
        background-color: #fafafa;
    }

    .sydt-nav-link.child-link.active {
        color: #a00000;
        font-weight: 600;
        background-color: #fff1f0;
    }

    .sydt-nav-link.parent-link.parent-active {
        color: #a00000;
        background-color: #fff; /* 保持白底，或微調 */
        /* 可選：加上左側紅線標示 */
        box-shadow: inset 3px 0 0 #a00000; 
    }
}

/* 手機版 (1023px-)：底部橫向滑動 */
@media (max-width: 1023px) {
    .sydt-layout-has-sidebar {
        display: flex;
        flex-direction: column;
        padding-bottom: 80px; 
    }

    .sydt-sidebar-nav-wrapper {
        position: fixed !important; 
        bottom: 0 !important;       
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        top: auto !important;
        z-index: 999999 !important;
        background: #fff;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        border-top: 1px solid #e5e5e5;
        padding: 10px 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important; 
        display: block !important;
    }

    .sydt-sidebar-nav {
        background: transparent; border: none; padding: 0 15px; box-shadow: none; width: 100%; 
    }

    /* 強制將所有連結 (父+子) 變成橫向排列，這裡我們只顯示子連結或全部平鋪 */
    .sydt-nav-list {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 10px;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        align-items: center;
    }
    
    .sydt-nav-list::-webkit-scrollbar { display: none; }
    
    /* 隱藏父子結構的縮排，改成平鋪 */
    .sydt-nav-item-parent { display: flex; gap: 10px; }
    .sydt-sub-nav-list { display: flex; gap: 10px; padding: 0 !important; margin: 0 !important; border: none; }
    .sydt-nav-list li { margin: 0; flex-shrink: 0; list-style: none; }

    .sydt-nav-link {
        display: inline-block;
        padding: 6px 14px;
        background: #f5f5f5;
        border-radius: 20px;
        font-size: 13px;
        color: #555;
        white-space: nowrap;
        text-decoration: none;
    }
    
    /* 父標籤樣式區隔 */
    .sydt-nav-link.parent-link {
        font-weight: bold;
        background: #e6e6e6;
        color: #333;
    }

    .sydt-nav-link.active {
        background-color: #a00000;
        color: #fff;
    }
}

/* ==================== 4. Grid & Card ==================== */
.sydt-portfolio-grid { display: grid; gap: 30px; width: 100%; }
.sydt-portfolio-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.sydt-portfolio-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.sydt-portfolio-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .sydt-portfolio-grid.cols-3,
    .sydt-portfolio-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .sydt-portfolio-grid.cols-2,
    .sydt-portfolio-grid.cols-3,
    .sydt-portfolio-grid.cols-4 { grid-template-columns: 1fr; }
}

/* Card Styles */
.sydt-card {
    background-color: #fff;
    border-radius: 8px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid #ddd;
    border-top: 4px solid #000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    display: flex; flex-direction: column; height: 100%;
}

.sydt-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(160, 0, 0, 0.1);
    border-color: #ffccc7;
}

/* [修改] 圖片區塊 - 置中設定 */
.sydt-card-image {
    width: 100%;
    aspect-ratio: 16 / 9; 
    overflow: hidden;
    background-color: #fff; /* 白底 */
    border-bottom: 1px solid #eee;
    position: relative;
    /* [新增] Flex 置中設定 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.sydt-card-image img {
    width: 100%;
    height: 100%;
    /* [建議] 改為 contain 避免在白底被裁切，若要填滿請改回 cover */
    object-fit: contain; 
    padding: 10px; /* 留白 */
    transition: transform 0.5s ease;
}

.sydt-card:hover .sydt-card-image img {
    transform: scale(1.08);
}

.sydt-card-image.no-image {
    color: #ccc;
    font-size: 14px;
    background-color: #f0f0f0;
}

.sydt-card-body {
    padding: 20px;
    display: flex; flex-direction: column; flex: 1;
}

.sydt-cat-badge {
    display: inline-block;
    font-size: 12px;
    color: #a00000;
    background-color: #fff1f0;
    padding: 4px 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    align-self: flex-start;
    font-weight: 600;
    border: 1px solid rgba(160, 0, 0, 0.1);
}

.sydt-card-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 700;
    color: #333;
}
.sydt-card-title a { text-decoration: none !important; color: inherit; transition: color 0.2s; }
.sydt-card-title a:hover { color: #a00000; }

.sydt-card-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
}

/* Buttons */
.sydt-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #f5f5f5;
}
.sydt-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px; font-size: 0.85rem; font-weight: 500;
    text-decoration: none; cursor: pointer; transition: all 0.3s ease; border: none; line-height: 1.2;
}
.sydt-btn svg { width: 16px; height: 16px; }
.sydt-btn-view { background: #f0f0f0; color: #333; }
.sydt-btn-view:hover { background: #e0e0e0; transform: translateY(-1px); color: #333; }
.sydt-btn-link { background: #a00000; color: #fff; }
.sydt-btn-link:hover { background: #cf1322 !important; transform: translateY(-1px); color: #fff !important; }

/* Modal */
.sydt-modal {
    display: none; position: fixed; z-index: 99999; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6); backdrop-filter: blur(3px); animation: sydtFadeIn 0.3s;
}
.sydt-modal-content {
    background-color: #fefefe; margin: 20px auto; padding: 20px; border-radius: 12px;
    width: 90%; max-width: 800px; max-height: 90vh; overflow-y: auto; position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25); animation: sydtSlideUp 0.3s;
    border-top: 5px solid #a00000;
}
.sydt-modal-content h2.sydt-modal-title {font-size: 1.2rem !important; color: #333;}
.sydt-modal-close {
    color: #a00000; position: sticky; top: 0px; right: 0px;
    font-size: 32px; font-weight: bold; cursor: pointer; transition: color 0.2s;
    line-height: 1; z-index: 10; float: right;
}
.sydt-modal-close:hover { color: #cf1322; }
.sydt-modal-title {
    margin-top: 0; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 2px solid #f0f0f0;
}
.sydt-modal-body { font-size: 16px; line-height: 1.8; color: #333; }
.sydt-modal-body img { max-width: 100%; height: auto; border-radius: 4px; margin: 15px 0; }
@keyframes sydtFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sydtSlideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sydt-empty-message { text-align: center; padding: 40px; background: #f9f9f9; border-radius: 8px; color: #666; }
