/* ==================== 手機版 RWD 修正 ==================== */
@media (max-width: 900px) {

    /* --- 導航觸控優化 --- */
    nav ul {
        justify-content: center;
        margin-left: 0;
        padding: 0 10px;
    }
    
    nav li {
        flex: 0 1 auto;
    }
    
    nav a {
        padding: 10px 8px;
        display: flex;
        font-size: 14px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
        touch-action: manipulation;
    }

    /* --- 背景修正 (固定背景避免跳動) --- */
    body::before {
        position: fixed;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }
    
    /* --- 防止橫向溢出 --- */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
        position: relative;
    }
    
    #container {
        background-image: none;
        background-attachment: scroll;
        overflow: visible;
    }
    
    #web {
        background: rgba(255,255,255,0.02);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        position: relative;
        z-index: 1;
        overflow: visible;
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    .page-content {
        overflow: visible;
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    .name-title {
        background-attachment: scroll;
    }
    
    /* --- 字體大小修正 --- */
    .section-title {
        font-size: clamp(28px, 8vw, 40px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ==================================================
        Skills 區塊（滿版滑動修正）
    ================================================== */
    
    /* 整區塊高度：4頁 x 100vh → 改成安全高度 */
    .skills-section {
        position: relative;
        margin-top: 50px;
        height: calc(var(--vh) * 400); /* 4 個滿版 */
        overflow: visible;
    }
    
    #skills .section-title {
        position: relative;
        margin-top: 20px;
        margin-bottom: 20px;
    }
    
    /* Sticky 容器固定在一個安全高度內 */
    .skills-container {
        position: sticky;
        top: 0;
        height: calc(var(--vh) * 100);
        margin-top: 0;
        padding-top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    
    .skills-content {
        position: relative;
        width: 100%;
        height: 100%;
    }
    
    .skill-item { 
        padding: 0 5%;
        justify-content: center;
        align-items: center;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: calc(var(--vh) * 100);
        flex-direction: column;
        display: flex;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.6s ease, visibility 0.6s ease;
    }
    
    .skill-item.active {
        opacity: 1;
        visibility: visible;
    }
    
    .skill-text {
        margin-bottom: 20px;
        margin-top: 0;
        width: 100%;
        text-align: center;
        flex: 0 0 auto;
    }
    
    /* 圖片高度：40vh → 安全高度 */
    .skill-image {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        height: calc(var(--vh) * 40);
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    }

    .skill-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* 右側導航指示點 */
    .skill-indicators { 
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 20;
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    /* ==================================================
        作品集詳細頁面
    ================================================== */
    
    .back-button {
        position: fixed;
        top: 20px;
        left: 20px;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        background: rgba(234, 255, 0, 0.9);
        border: none;
        border-radius: 25px;
        color: #000;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        transition: all 0.3s ease;
        transform: translateY(0);
    }
    
    .back-button:active {
        transform: translateY(2px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .back-icon {
        display: none;
    }
    
    /* 確保專案頁面從頂部開始 */
    .project-view {
        position: relative;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .project-content {
        padding: 80px 20px 40px;
        position: relative;
        min-height: calc(var(--vh) * 100);
    }
    
    .project-title {
        position: static;
        transform: none;
        width: 100%;
        text-align: center;
        margin-bottom: 30px;
        padding: 0;
    }
    
    .project-title h1 {
        font-size: clamp(32px, 8vw, 48px);
        margin-bottom: 10px;
    }
    
    .project-title h2 {
        font-size: clamp(16px, 4vw, 20px);
    }
    
    .project-description {
        position: static;
        transform: none;
        width: 100%;
        max-height: none;
        padding: 0;
    }
    
    .project-description h1 {
        font-size: clamp(20px, 5vw, 28px);
        margin-top: 20px;
        margin-bottom: 15px;
    }
    
    .project-description h2 {
        font-size: clamp(18px, 4.5vw, 24px);
        margin-top: 20px;
        margin-bottom: 12px;
    }
    
    .project-description p {
        font-size: clamp(14px, 3.5vw, 16px);
        line-height: 1.8;
        margin-bottom: 20px;
    }
    
    .project-description img {
        margin: 20px 0;
        border-radius: 10px;
    }
}
