/* ===========================================
   右側Tab導航樣式
=========================================== */
.smc-nav-tabs-container {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* 減少間距 */
}

.smc-nav-tab {
    background: #333333;
    color: white;
    padding: 15px 5px;
    cursor: pointer;
    border-radius: 8px 0 0 8px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 0.1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border-right: unset;
}

.smc-nav-tab:hover {
    background: #555555;
}

.smc-nav-tab:active {
    transform: scale(0.98);
}

/* ===========================================
   左側面板通用樣式
=========================================== */
.smc-nav-panel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 420px;
    height: 100vh;
    z-index: 2000;
    transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    color: white;
    overflow-y: auto;
    backdrop-filter: blur(5px);
    display: none;
}

.smc-nav-panel.open {
    left: 0;
    display: block;
}

/* 當面板打開時，禁止背景頁面滾動 */
body.smc-panel-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* 方案2：關閉按鈕在面板內固定於頂部 */
.smc-close-btn {
    position: sticky;
    top: 0px;
    right: 0px;
    float: right;
    background: rgba(0, 0, 0, 0.8);
    border: 0.1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    margin-bottom: -45px; /* 負邊距避免影響內容佈局 */
}

.smc-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.smc-panel-content {
    padding: 80px 30px 30px;
    position: relative;
    clear: right; /* 清除浮動影響 */
}

.smc-panel-content h3 {
    margin: 0 0 30px 0;
    font-size: 24px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

/* ===========================================
   Projects面板卡片樣式
=========================================== */
.smc-projects-grid {
    display: grid;
    gap: 20px;
}

.smc-project-card {
    background: #333333;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.smc-project-card:hover {
    background: #555555;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.smc-project-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    transition: all 0.3s ease;
}

.smc-project-card:hover .smc-project-thumb {
    transform: scale(1.05);
}

.smc-project-content {
    padding: 20px;
}

.smc-project-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
}

.smc-project-link {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
}

.smc-project-link:hover {
    color: rgba(255, 255, 255, 0.7);
}

.smc-sub-projects {
    list-style: none;
    padding: 0;
    margin: 0;
}

.smc-sub-projects li {
    margin-bottom: 8px;
    padding-left: 0;
    position: relative;
}

.smc-sub-projects li .fa-circle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 8px;
    margin-right: 8px;
    vertical-align: middle;
}

.smc-sub-projects strong {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 14px;
    display: inline;
    margin-bottom: 0;
}

.smc-sub-project-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

.smc-sub-project-link:hover {
    color: white;
}

/* 子分類下的文章列表樣式 */
.smc-sub-sub-projects {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 8px;
}

.smc-sub-sub-projects li {
    margin-bottom: 4px;
    padding-left: 0;
    position: relative;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.smc-sub-sub-projects li .fa-circle {
    color: rgba(255, 255, 255, 0.4);
    font-size: 6px;
    flex-shrink: 0;
}

.smc-sub-sub-projects a {
    color: rgba(255, 255, 255, 1);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
    display: block;
    padding: 2px 0;
    flex: 1;
}

.smc-sub-sub-projects a:hover {
    color: rgba(255, 255, 255, 0.95);
}

/* ===========================================
   文章卡片樣式
=========================================== */
#smc-card-container {
    position: fixed;
    bottom: 0;
    left: 5%;
    width: 90%;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

.smc-card {
    position: absolute;
    width: 280px;
    background: #333333;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    cursor: grab;
    pointer-events: auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    /* 硬體加速優化 */
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    /* 確保立即可見 */
    opacity: 1;
    visibility: visible;
}

.smc-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    background: #555555;
}

.smc-card.smc-dragging {
    cursor: grabbing;
    transform: rotate(2deg) scale(1.03);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    transition: none; /* 拖拽時移除過渡效果 */
}

.smc-card-thumb {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
    background-color: #222; /* 載入前的背景色 */
    display: block;
}

.smc-card:hover .smc-card-thumb {
    transform: scale(1.1);
}

.smc-card-content {
    padding: 20px;
    /* 確保內容立即顯示 */
    opacity: 1;
    visibility: visible;
}

.smc-card-title {
    margin: 0;
    color: white;
    cursor: pointer;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.smc-card-title:hover {
    color: #ccc;
}

.smc-card-category {
    font-size: 11px;
    margin-top: 8px;
    line-height: 1.2;
    font-weight: 400;
}

/* Grid模式樣式 */
#smc-card-container.smc-grid-mode {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 30px !important;
    pointer-events: auto !important;
    margin: 0 auto !important;
}

#smc-card-container.smc-grid-mode .smc-card {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    cursor: default !important;
    height: fit-content;
}

/* ===========================================
   Modal彈窗樣式
=========================================== */
.smc-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.smc-modal-content {
    background: #333333;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 20px;
    max-width: 650px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 8px;
    position: relative;
    margin: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

.smc-modal-content h2 {
    color: white;
    margin-top: 0;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.smc-modal-content p {
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.smc-modal-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===========================================
   響應式設計 - 手機版修正
=========================================== */
@media (max-width: 1200px) {
    /* 在較小的桌面螢幕上顯示3列 */
    #smc-card-container.smc-grid-mode {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {
    /* 手機版Tab位置修正：保持與桌面版一致，右側垂直排列 */
    .smc-nav-tabs-container {
        /* 保持桌面版設定不變 */
        position: fixed;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        z-index: 1000;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .smc-nav-tab {
        /* 保持桌面版樣式，移除原本的橢圓形設定 */
        background: #333333;
        color: white;
        padding: 15px 5px;
        cursor: pointer;
        border-radius: 8px 0 0 8px; /* 保持方形，不是橢圓 */
        writing-mode: vertical-rl;
        text-orientation: mixed;
        font-size: 14px;
        font-weight: 700;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border: 0.1px solid rgba(255, 255, 255, 0.3);
        text-align: center;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        border-right: unset;
    }
    
    .smc-nav-tab:hover {
        background: #555555;
        /* 移除原本錯誤的 transform: none */
    }
    
    /* 隱藏佈局切換按鈕在手機版 */
    #smc-layout-toggle-btn {
        display: none;
    }
    
    /* 左側面板在手機版佔滿全螢幕 */
    .smc-nav-panel {
        width: 100vw;
        left: -100vw;
    }
    
    /* 手機版關閉按鈕調整 */
    .smc-close-btn {
        position: sticky;
        top: 10px;
        right: 10px;
        width: 25px;
        height: 25px;
        margin-bottom: -40px;
    }
    
    /* 手機版圖片高度修正 */
    .smc-card-thumb, 
    .smc-project-thumb {
        height: auto !important; /* 改為自動高度 */
        min-height: 120px; /* 設定最小高度 */
        max-height: 200px; /* 設定最大高度，防止過高 */
        object-fit: cover;
        width: 100%;
        background-color: #222;
        display: block;
    }
    
    /* 手機版卡片內容立即顯示修正 */
    .smc-card-content {
        opacity: 1 !important;
        visibility: visible !important;
        transition: none !important;
        padding: 15px;
    }
    
    /* 手機版強制Grid模式，2列 */
    #smc-card-container, 
    #smc-card-container.smc-grid-mode {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
        padding: 15px 0 !important;
        pointer-events: auto !important;
        overflow-y: visible !important;
        margin: 20px 0 !important;
    }
    
    /* 手機版卡片樣式修正 */
    .smc-card, 
    #smc-card-container.smc-grid-mode .smc-card {
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        pointer-events: auto !important;
        cursor: default !important;
        height: fit-content;
        /* 移除動畫效果，確保立即顯示 */
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Modal在手機版的調整 */
    .smc-modal-content {
        margin: 10px;
        padding: 20px;
        max-height: 90vh;
    }
    
    .smc-modal-content h2 {
        font-size: 22px;
    }
    
    /* Projects面板在手機版的調整 */
    .smc-panel-content {
        padding: 80px 20px 200px 20px;
    }
    
    .smc-project-thumb {
        height: unset; !important;
        min-height: 150px;
        max-height: unset; !important;
    }
}

@media (max-width: 480px) {
    /* 小螢幕手機版顯示1列 */
    #smc-card-container, 
    #smc-card-container.smc-grid-mode {
        grid-template-columns: 1fr !important;
        padding: 10px 0 !important;
        gap: 10px !important;
    }
    
    /* 手機版圖片進一步限制高度 */
    .smc-card-thumb {
        max-height: unset; !important;
        min-height: 100px;
    }
    
    .smc-modal-content {
        margin: 5px;
        padding: 15px;
    }
    
    /* 右側標籤稍微調整 */
    .smc-nav-tab {
        padding: 12px 8px;
        font-size: 12px;
        min-width: 40px;
    }
    
    /* 手機版小螢幕關閉按鈕進一步調整 */
    .smc-close-btn {
        top: 10px;
        right: 10px;
        width: 25px;
        height: 25px;
        font-size: 20px;
        margin-bottom: -35px;
    }
}

/* ===========================================
   動畫效果
=========================================== */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.smc-modal {
    animation: modalFadeIn 0.3s ease;
}

/* ===========================================
   手機版載入問題額外修正
=========================================== */
@media (max-width: 768px) {
    /* 確保手機版所有元素都立即可見 */
    .smc-card * {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* 移除可能造成延遲的 will-change */
    .smc-card {
        will-change: auto !important;
        backface-visibility: visible !important;
        transform-style: flat !important;
    }
    
    /* 圖片載入優化 */
    .smc-card-thumb {
        image-rendering: auto;
        image-rendering: crisp-edges;
        image-rendering: -webkit-optimize-contrast;
    }
}


/* ===========================================
   絲滑動畫效果
=========================================== */

/* 卡片出場動畫 */
@keyframes cardFadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.smc-card.animating {
    animation: cardFadeInUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 圓形按鈕圖標切換動畫 */
@keyframes iconRotateIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes iconRotateOut {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

.smc-nav-tab-circle i {
    display: inline-block;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.smc-nav-tab-circle.icon-out i {
    animation: iconRotateOut 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.smc-nav-tab-circle.icon-in i {
    animation: iconRotateIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 圓形按鈕本身的動畫 */
.smc-nav-tab-circle {
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.smc-nav-tab-circle:hover {
    transform: scale(1.15) rotate(5deg) !important;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

.smc-nav-tab-circle:active {
    transform: scale(0.95) rotate(-5deg) !important;
}

.smc-nav-tab-circle.switching {
    animation: buttonPulse 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.15) rotate(90deg);
    }
    50% {
        transform: scale(1) rotate(180deg);
    }
    75% {
        transform: scale(1.1) rotate(270deg);
    }
}


.smc-nav-tab-circle:active::before {
    transform: scale(1.5);
    opacity: 0;
}

/* 卡片懸浮時的絲滑效果 */
.smc-card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                background 0.3s ease;
}

.smc-card:hover {
    transform: translateY(-5px) scale(1.02) !important;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
}

/* 拖拽時的絲滑效果 */
.smc-card.smc-dragging {
    cursor: grabbing;
    transform: rotate(3deg) scale(1.05) !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
    transition: box-shadow 0.2s ease;
}

/* Grid 模式切換動畫 */
#smc-card-container {
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#smc-card-container.smc-grid-mode .smc-card {
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 性能優化 */
.smc-card,
.smc-nav-tab-circle {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}