/* =========================================
   CSS 變數系統 (支援雙模式切換)
   ========================================= */
:root {
    /* 預設：部落客模式 (Light Theme) */
    --bs-primary: #7ca38f;
    --bs-primary-rgb: 124, 163, 143;
    --bg-color: #fcfcfc;
    --card-bg: #ffffff;
    --card-light: #f9fbf9;
    --card-light-alt: #f4f7f5;
    --text-main: #333333;
    --text-secondary: #6c757d;
    --border-color: #f0f0f0;
    --border-subtle: #eef2f0;
    --header-bg: rgba(255, 255, 255, 0.95);
    --wave-1: rgba(252, 252, 252, 0.7);
    --wave-2: rgba(252, 252, 252, 0.5);
    --wave-3: rgba(252, 252, 252, 0.3);
    --wave-4: #fcfcfc;
    --font-main: 'Noto Sans TC', sans-serif;
    --font-code: 'Noto Sans TC', sans-serif; /* 預設不使用程式字體 */
    --shadow-color: rgba(0,0,0,0.08);
}

body.engineer-mode {
    /* 切換：工程師模式 (Dark Cyber Theme) */
    --bs-primary: #10b981; /* 螢光綠 / Emerald */
    --bs-primary-rgb: 16, 185, 129;
    --bg-color: #0f172a; /* Slate 900 */
    --card-bg: #1e293b; /* Slate 800 */
    --card-light: #334155; /* Slate 700 */
    --card-light-alt: #0f172a;
    --text-main: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --border-color: #334155;
    --border-subtle: #475569;
    --header-bg: rgba(30, 41, 59, 0.95);
    --wave-1: rgba(15, 23, 42, 0.7);
    --wave-2: rgba(15, 23, 42, 0.5);
    --wave-3: rgba(15, 23, 42, 0.3);
    --wave-4: #0f172a;
    --font-code: 'Fira Code', monospace; /* 啟用程式字體 */
    --shadow-color: rgba(0,0,0,0.3);
}

/* =========================================
   全域自動適應覆寫 (強制 Bootstrap 吃變數)
   新增平滑色彩漸變過渡 (0.8s)
   ========================================= */
body.profile-page {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    transition: background-color 0.8s ease, color 0.8s ease; 
}

/* 讓所有主要的版面元素都在切換時享有漸變效果 */
.profile-page .bg-white, .profile-page .bg-light, .profile-page .card, .profile-page .profile-content, .profile-page #header, .profile-page .dropdown-menu, .profile-page footer, .profile-page .portfolio-card, .profile-page .feature-box, .profile-page .portfolio-icon, .profile-page .feature-icon { 
    background-color: var(--card-bg) !important; 
    border-color: var(--border-color) !important;
    transition: background-color 0.8s ease, border-color 0.8s ease, box-shadow 0.8s ease !important;
}
.profile-page .bg-light, .profile-page .feature-box, .profile-page .portfolio-icon {
    background-color: var(--card-light) !important;
}

.profile-page .text-dark, .profile-page h1, .profile-page h2, .profile-page h3, .profile-page h4, .profile-page h5, .profile-page h6, .profile-page .font-code { 
    color: var(--text-main) !important; 
    transition: color 0.8s ease !important;
}
.profile-page .text-secondary, .profile-page .text-muted { 
    color: var(--text-secondary) !important; 
    transition: color 0.8s ease !important;
}
.profile-page .border-light { border-color: var(--border-color) !important; transition: border-color 0.8s ease !important; }
.profile-page .border-light-subtle { border-color: var(--border-subtle) !important; transition: border-color 0.8s ease !important; }
.profile-page .shadow-sm { box-shadow: 0 0.5rem 1rem var(--shadow-color) !important; }

/* 動態框線覆寫 */
.profile-page .dynamic-border { border-color: var(--card-bg) !important; transition: border-color 0.8s ease !important; }

/* 程式字體應用類別 */
.profile-page .font-code { font-family: var(--font-code); }

/* =========================================
   導覽列特效
   ========================================= */
.profile-page #header {
    background-color: var(--header-bg) !important;
    backdrop-filter: blur(5px);
}
.profile-page .custom-nav-link {
    position: relative;
    color: var(--text-main) !important;
    transition: color 0.3s ease;
}
.profile-page .custom-nav-link:hover { color: var(--bs-primary) !important; }
.profile-page .custom-nav-link::after {
    content: ''; position: absolute; width: 100%; height: 2px; bottom: 0; left: 0;
    background-color: var(--bs-primary);
    transform: scaleX(0); transform-origin: bottom right; transition: transform 0.3s ease-out, background-color 0.8s ease;
}
.profile-page .custom-nav-link:hover::after, .profile-page .custom-nav-link.active::after {
    transform: scaleX(1); transform-origin: bottom left;
}
.profile-page .navbar-brand svg { fill: var(--bs-primary); transition: fill 0.8s ease; }
.profile-page .navbar-toggler i { color: var(--text-main); transition: color 0.8s ease; }

.profile-page .dropdown-item { color: var(--text-main) !important; transition: all 0.2s; }
.profile-page .dropdown-item:hover { background-color: var(--card-light) !important; color: var(--bs-primary) !important; }

@media (max-width: 991.98px) {
    .profile-page .navbar-collapse { padding: 1rem 1.5rem; border-radius: 1rem; box-shadow: 0 10px 25px var(--shadow-color); margin-top: 15px; }
    .profile-page .nav-link { border-bottom: 1px solid var(--border-color); }
}

/* =========================================
   頁面頂部橫幅 (Page Header) 與圖片平滑漸變
   ========================================= */
.profile-page .page-header {
    position: relative;
    height: 40vh; 
    min-height: 350px;
    padding-top: 70px; 
    /* 底層為 Blogger 預設圖 */
    background-image: url('https://images.unsplash.com/photo-1499750310107-5fef28a66643?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
/* 上層為 Engineer 圖，利用 opacity 進行漸變切換 */
.profile-page .page-header-engineer-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('https://images.unsplash.com/photo-1555066931-4365d14bab8c?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 1;
}
body.engineer-mode .page-header-engineer-bg {
    opacity: 1;
}
.profile-page .page-header::after { /* 原本的 before 遮罩改為 after，並提高層級 */
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5); 
    z-index: 2;
}
.profile-page .page-header-content { position: relative; z-index: 10; animation: fadeInUp 0.8s ease-out forwards; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* 波浪效果 (動態顏色漸變) */
.profile-page .waves { position: absolute; bottom: 0; left: 0; width: 100%; height: 10vh; min-height: 50px; max-height: 100px; z-index: 12; }
.profile-page .parallax > use { 
    animation: move-forever 25s cubic-bezier(.55,.5,.45,.5) infinite; 
    transition: fill 0.8s ease; /* 波浪漸變 */
}
.profile-page .parallax > use:nth-child(1) { animation-delay: -2s; animation-duration: 7s; }
.profile-page .parallax > use:nth-child(2) { animation-delay: -3s; animation-duration: 10s; }
.profile-page .parallax > use:nth-child(3) { animation-delay: -4s; animation-duration: 13s; }
.profile-page .parallax > use:nth-child(4) { animation-delay: -5s; animation-duration: 20s; }
@keyframes move-forever { 0% { transform: translate3d(-90px,0,0); } 100% { transform: translate3d(85px,0,0); } }

/* =========================================
   關於我內容排版
   ========================================= */
.profile-page .profile-sticky { position: sticky; top: 100px; z-index: 10; }

.profile-page .profile-content {
    font-size: 1.05rem; line-height: 1.8;
    position: relative; overflow: hidden;
}
.profile-page .profile-content h3 {
    font-weight: 700; margin-top: 2.5rem; margin-bottom: 1.2rem; padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color); position: relative;
}
.profile-page .profile-content h3::after {
    content: ''; position: absolute; left: 0; bottom: -2px; width: 50px; height: 2px;
    background-color: var(--bs-primary); transition: background-color 0.8s ease;
}

/* 興趣/技能卡片互動保留 */
.profile-page .feature-box:hover, .profile-page .portfolio-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px var(--shadow-color) !important; border-color: var(--bs-primary) !important; }

.profile-page .feature-icon {
    display: flex; align-items: center; justify-content: center;
    color: var(--bs-primary); border-radius: 12px; font-size: 1.5rem; margin-bottom: 1rem;
    transition: color 0.8s ease, background-color 0.8s ease !important;
}

/* 按鈕與社群客製化 */
.profile-page .btn-primary { background-color: var(--bs-primary); border-color: var(--bs-primary); color: #fff !important; transition: all 0.3s ease, background-color 0.8s ease, border-color 0.8s ease; }
.profile-page .btn-primary:hover, .profile-page .btn-primary:focus, .profile-page .btn-primary:active { opacity: 0.85; border-color: var(--bs-primary) !important; box-shadow: 0 0 15px rgba(var(--bs-primary-rgb), 0.4) !important; }
.profile-page .btn-outline-primary { color: var(--bs-primary); border-color: var(--bs-primary); transition: all 0.3s ease, color 0.8s ease, border-color 0.8s ease; }
.profile-page .btn-outline-primary:hover { background-color: var(--bs-primary); color: white !important; }

.profile-page .social-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; background-color: var(--card-light-alt); transition: transform 0.3s ease, background-color 0.8s ease, color 0.8s ease; color: var(--text-main); border-radius: 50%; text-decoration: none; border: 1px solid transparent; }
.profile-page .social-btn:hover { background-color: var(--bs-primary); color: white !important; transform: scale(1.1); border-color: var(--bs-primary); }
.profile-page .social-btn-large { width: 45px; height: 45px; font-size: 1.2rem; }

/* =========================================
   履歷與作品集專用樣式
   ========================================= */
.profile-page .timeline { border-left: 2px solid var(--border-color); padding-left: 1.5rem; position: relative; margin-top: 1.5rem; transition: border-color 0.8s ease; }
.profile-page .timeline-item { position: relative; margin-bottom: 2.5rem; }
.profile-page .timeline-item:last-child { margin-bottom: 0; }
.profile-page .timeline-item::before {
    content: ''; position: absolute; left: -1.5rem; top: 0.3rem; width: 14px; height: 14px;
    background-color: var(--bs-primary); border-radius: 3px;
    transform: translateX(-50%) rotate(45deg); border: 2px solid var(--card-bg);
    box-shadow: 0 0 8px rgba(var(--bs-primary-rgb), 0.5);
    transition: background-color 0.8s ease, border-color 0.8s ease, box-shadow 0.8s ease;
}

.profile-page .skill-badge {
    background-color: rgba(var(--bs-primary-rgb), 0.1); color: var(--bs-primary);
    border: 1px solid rgba(var(--bs-primary-rgb), 0.3); font-weight: 500;
    padding: 0.5rem 1rem; font-size: 0.9rem; transition: background-color 0.3s ease, color 0.3s ease, border-color 0.8s ease;
}
.profile-page .skill-badge:hover { background-color: var(--bs-primary); color: #fff !important; box-shadow: 0 0 10px rgba(var(--bs-primary-rgb), 0.4); }

.profile-page .portfolio-icon {
    display: flex; align-items: center; justify-content: center;
    color: var(--bs-primary); border-radius: 10px; font-size: 1.2rem; border: 1px solid var(--border-color);
    transition: color 0.8s ease, background-color 0.8s ease, border-color 0.8s ease !important;
}

/* =========================================
   大頭照 3D 翻轉動畫
   ========================================= */
.profile-page .profile-flip-container {
    perspective: 1000px; width: 160px; height: 160px; margin: 0 auto 1.5rem auto; cursor: pointer; position: relative;
}
.profile-page .profile-flip-inner {
    position: relative; width: 100%; height: 100%; transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1); transform-style: preserve-3d;
}
.profile-page .profile-flip-container.is-flipped .profile-flip-inner { transform: rotateY(180deg); }
.profile-page .profile-front, .profile-page .profile-back {
    position: absolute; width: 100%; height: 100%; backface-visibility: hidden;
    border-radius: 50%; border: 4px solid var(--card-bg); box-shadow: 0 0.5rem 1rem var(--shadow-color); overflow: hidden;
    transition: border-color 0.8s ease, box-shadow 0.8s ease;
}
.profile-page .profile-back { transform: rotateY(180deg); }

.profile-page .profile-flip-hint {
    position: absolute; bottom: 5px; right: 5px; background: var(--bs-primary); color: white !important;
    width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 3px solid var(--card-bg); z-index: 10; transition: transform 0.3s ease, background-color 0.8s ease, border-color 0.8s ease;
}
.profile-page .profile-flip-container:hover .profile-flip-hint { transform: scale(1.15) rotate(180deg); opacity: 0.9; }

/* 隱藏視圖 */
.profile-page .view-section { display: none; }

/* =========================================
   數位崩解特效 (Shatter)
   ========================================= */
.profile-page .shatter-overlay {
    position: absolute; top: -2%; left: -2%; width: 104%; height: 104%; display: flex; flex-wrap: wrap; z-index: 100; pointer-events: none;
}
.profile-page .shatter-box {
    transform: scale(0) translateY(20px) rotate(10deg); opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease; border-radius: 4px;
}
.profile-page .shatter-box.active { transform: scale(1.05) translateY(0) rotate(0); opacity: 1; border-radius: 0; }
.profile-page .shatter-box.leaving { transform: scale(0) translateY(-20px) rotate(-10deg); opacity: 0; border-radius: 4px; transition: transform 0.3s ease-in, opacity 0.2s ease-in; }

/* =========================================
   作品集列表分頁專用 (Portfolio List)
   ========================================= */

/* 橫向輪播模組 */
.profile-page .category-section { margin-bottom: 4rem; }
.profile-page .category-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--border-color);
}
.profile-page .category-title { font-weight: 700; margin: 0; }

/* 左右切換按鈕 */
.profile-page .carousel-nav-group { display: flex; gap: 0.5rem; }
.profile-page .carousel-nav-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background-color: var(--card-bg); border: 1px solid var(--border-color);
    color: var(--bs-primary); display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease; cursor: pointer;
}
.profile-page .carousel-nav-btn:hover {
    background-color: var(--bs-primary); color: #fff; border-color: var(--bs-primary);
    box-shadow: 0 4px 10px rgba(var(--bs-primary-rgb), 0.3);
}

/* 拖曳軌道 (核心) */
.profile-page .carousel-track-wrapper { position: relative; margin: 0 -15px; }
.profile-page .carousel-track {
    display: flex; gap: 1.5rem; overflow-x: auto; scroll-snap-type: x mandatory;
    scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
    padding: 1rem 15px 2rem 15px; cursor: grab;
}
.profile-page .carousel-track.dragging { scroll-behavior: auto; cursor: grabbing; scroll-snap-type: none; }
.profile-page .carousel-track::-webkit-scrollbar { display: none; }
.profile-page .carousel-track { -ms-overflow-style: none; scrollbar-width: none; }

.profile-page .carousel-item-card { scroll-snap-align: start; flex: 0 0 auto; width: 360px; }
@media (max-width: 768px) { .profile-page .carousel-item-card { width: 85vw; max-width: 360px; } }

/* 統一比例卡片補充 */
.profile-page .portfolio-card { overflow: hidden; height: 100%; display: flex; flex-direction: column; }
.profile-page .card-visual { width: 100%; aspect-ratio: 16 / 9; position: relative; overflow: hidden; background-color: var(--card-light); }
.profile-page .card-visual img { width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: none; }
.profile-page .portfolio-card:hover .card-visual img { transform: scale(1.05); }

.profile-page .card-visual.api-type {
    background: linear-gradient(135deg, #2b3238, #434e56);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.8);
}
.profile-page .api-icon {
    font-size: 3rem; color: var(--bs-primary); margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(var(--bs-primary-rgb), 0.5));
}
.profile-page .visual-badge {
    position: absolute; top: 15px; left: 15px;
    background: rgba(252,252,252,0.9); color: #333;
    padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
    backdrop-filter: blur(4px); z-index: 2;
}
body.engineer-mode .visual-badge { background: rgba(15, 23, 42, 0.8); color: #eee; }

.profile-page .card-body-custom { padding: 24px; display: flex; flex-direction: column; flex-grow: 1; }
.profile-page .card-desc {
    color: var(--text-secondary); font-size: 0.95rem; line-height: 1.6; margin-bottom: 20px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.profile-page .tech-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; margin-bottom: 20px; }
.profile-page .tech-badge {
    font-family: var(--font-code); font-size: 0.75rem;
    background-color: var(--card-light); color: var(--bs-primary); padding: 4px 10px; border-radius: 6px;
}

.profile-page .card-footer-custom { border-top: 1px solid var(--border-color); padding-top: 15px; display: flex; justify-content: space-between; align-items: center; }
.profile-page .action-link {
    color: var(--bs-primary); text-decoration: none; font-weight: 500; font-size: 0.95rem;
    display: inline-flex; align-items: center; gap: 5px; transition: gap 0.3s;
}
.profile-page .action-link:hover { color: var(--bs-primary); gap: 8px; opacity: 0.8; }

