/* =================================================== */
/* 1. 全新斜行雙排交錯網格佈局 (Staggered Grid Layout) */
/* =================================================== */
.works-list {
  width: 100%;
  padding: 150px 5% 100px 5%; /* 避開 Header 的高度 */
  display: flex;
  justify-content: center;
  background-color: #000;
  position: relative;
  z-index: 10;
}

.works-grid-container {
  width: 100%;
  max-width: 1300px;
  display: flex;
  gap: 80px; /* 左右兩行的間距 */
  align-items: flex-start;
}

.grid-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 100px; /* 上下作品卡片的間距 */
}

/* ⚠️ 讓右邊那一排往下掉，製造交錯感 */
.right-col {
  margin-top: 100px; 
}

.page-large-title {
   font: 100px "NEW", sans-serif; 
  font-weight: 500;
  color: #ffffff;
  line-height: 1.1;
  margin-bottom: 80px;
  margin-top: 0;
  letter-spacing: 0.02em;
}

/* =================================================== */
/* 2. 圖片卡片樣式 */
/* =================================================== */
.project-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: #ffffff;
}

.card-img-wrapper {
  width: 100%;
  overflow: hidden;
  margin-bottom: 20px;
  background-color: #111; /* 圖片還沒載入時的底色 */
}

.card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  display: block;
  object-fit: cover;
  
  /* ⚠️ 魔法 1：預設加上模糊濾鏡 (數字越大越模糊) 及微微降暗 */
  filter: blur(5px) brightness(0.7); 
  
  /* ⚠️ 魔法 2：加上 filter 的漸變動畫設定 */
  transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
              filter 0.8s cubic-bezier(0.23, 1, 0.32, 1); 
}

/* 滑鼠移上去時，圖片放大、變清晰、變亮！ */
.project-card:hover .card-img {
  transform: scale(1.05);
  filter: blur(0px) brightness(1); /* 濾鏡歸零 */
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 8px; /* 用 gap 來控制間距，取代負數 margin */
  padding-top: 5px;
}

/* =================================================== */
/* 頂級文字遮罩滑動特效 (Text Mask Slider) */
/* =================================================== */

.card-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 1px;
  white-space: nowrap;
  color: transparent !important; 
  position: relative;
  overflow: hidden; 
  width: max-content; 
  min-width: max-content;
  /* ⚠️ 魔法 1：擴大隱形骨架的範圍，當作緩衝區！ */
  /* 上:5px, 右:20px, 下:15px, 左:0 */
  padding: 5px 20px 15px 0; 
  line-height: 1; /* 讓骨架高度更穩定 */
  margin-top: -20px;
  margin-bottom: -16px;
}

/* 舊文字 (預設顯示) */
.card-title::before {
  content: attr(data-title); 
  position: absolute;
  top: 50%;
  left: 0;
  
  /* ⚠️ 核心修復：強制寬度與外層骨架完全相同 */
  width: 100%; 
  
  color: #ffffff; 
  white-space: nowrap;
  
  transform: translate(0, -50%);
  transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 新文字 (預設躲在右邊) */
.card-title::after {
  content: attr(data-title);
  position: absolute;
  top: 50%;
  left: 0;
  
  /* ⚠️ 核心修復：強制寬度與外層骨架完全相同 */
  width: 100%; 
  
  color: #ffffff;
  white-space: nowrap;

  font-family: 'LUX', serif; 
  font-style: italic;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: capitalize; 
  font-size: 1rem; 

  /* 現在的 100% 是外層的寬度，保證能把字推到螢幕最右邊的界外！ */
  transform: translate(100%, -50%);
  transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 💡 滑鼠移入時的聯動觸發動畫 (記得加上 -50% 保持高度不變) */
.project-card:hover .card-title::before {
  transform: translate(-100%, -50%); /* 舊字往左邊滑走 */
}

.project-card:hover .card-title::after {
  transform: translate(0, -50%); /* 新字從右邊滑進來，完美停在中間 */
}

/* ⚠️ 新增：讓 Type 與 Year 並排，並把年份推到最右邊 */
.card-meta {
  display: flex;
  justify-content: space-between; /* 左右撐開 */
  align-items: center;
  width: 100%; /* 確保能撐滿外層 */
  margin-top: 0px; /* 與上方標題拉開一點距離 */
}

/* 保持字體與透明度效果 */
.card-type, .card-year {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 300;
  color: #cccccc;
  margin: 0;
  opacity: 0.3;
  transition: opacity 0.4s ease;
}

/* 確保滑鼠移入卡片時變亮 */
.project-card:hover .card-type,
.project-card:hover .card-year {
  opacity: 1;
}

.project-card:hover .card-type,
.project-card:hover .card-year {
  opacity: 1;
}

/* =================================================== */
/* 3. 手機版適配 (RWD) 升級版 */
/* =================================================== */
@media (max-width: 768px) {
  /* 標題與網格佈局變成單行排列 */
  .works-grid-container {
    flex-direction: column;
    gap: 60px;
  }
  .right-col {
    margin-top: 0; 
  }
  .grid-col {
    gap: 60px;
  }
  .page-large-title {
    font-size: 4rem;
    margin-bottom: 40px;
  }
  .card-title {
    font-size: 1.4rem;
  }
}

/* ⚠️ 下方的 B區設定： #project-detail-section 請保持不動！ */
/* =================================================== */
/* 5. 作品詳細介紹：全螢幕版頭佈局 (Fullscreen Detail View) */
/* =================================================== */
#project-detail-section {
    position: absolute; top: 0; left: 0; width: 100%; z-index: 50; 
    min-height: 100vh; overflow: visible; background-color: #000; 
}

.detail-bg-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
#detail-hero-img { width: 100%; height: 100%; object-fit: cover; }

.detail-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.8) 100%);
}

.detail-content { position: relative; z-index: 2; width: 100%; height: 100%; pointer-events: none; }
.detail-content * { pointer-events: auto; }

/* 文字元素初始狀態與位置 */
.detail-back-btn, .detail-info-top-right, .detail-title {
    opacity: 0; transform: translateY(30px); transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1); position: absolute;
}

.detail-back-btn { top: 140px; left: 5%; color: #fff; text-decoration: none; font-family: 'Inter', sans-serif; font-size: 1.2rem; border-bottom: 1px solid #fff; padding-bottom: 4px; }
.detail-info-top-right { top: 140px; right: 5%; text-align: right; color: #fff; font-family: 'GEN', sans-serif; font-weight: 100; }
.detail-type { font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 300; color: #cccccc; margin: 0 0 5px 0;}
.detail-year { font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: 300; color: #cccccc; margin: 0;}

.detail-title {
    bottom: 8%; left: 5%; margin: 0;
    font-size: 5rem; font-weight: 700; color: #fff; font-family: 'LUX', sans-serif; text-transform: uppercase;
    width: 90%; word-wrap: break-word; 
}

/* 啟用狀態 (配合 JS 觸發階梯式進場動畫) */
#project-detail-section.active .detail-back-btn,
#project-detail-section.active .detail-info-top-right,
#project-detail-section.active .detail-title { opacity: 1; transform: translateY(0); }

#project-detail-section.active .detail-title { transition-delay: 0.1s; }
#project-detail-section.active .detail-info-top-right { transition-delay: 0.2s; }
#project-detail-section.active .detail-back-btn { transition-delay: 0.3s; }

/* =================================================== */
/* 6. 作品詳細介紹：額外圖文 (Case Study) */
/* =================================================== */
.detail-extra-content {
    width: 85%; 
    max-width: 1200px; 
    margin: 80px auto 150px auto; 
    text-align: left;
    position: relative; 
    z-index: 10; 
    opacity: 0; 
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* ⚠️ 讓影片的風格與圖片完全一致 (滿版、無圓角) */
.detail-extra-content video.portfolio-video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0 !important; /* 維持俐落的直角 */
    margin-bottom: 60px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3); /* 微微的陰影讓影片更有層次感 */
    margin-top: 60px;
}

.detail-extra-content.active { opacity: 1; transform: translateY(0); }

/* ⚠️ 核心修復 1：取消所有 B 區圖片的圓角 */
.detail-extra-content img { 
    width: 100%; 
    border-radius: 0 !important; /* 變回直角 */
    margin-bottom: 60px; 
}

/* ⚠️ 核心修復 2：新增內容分欄網格 */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 左右等寬 */
    gap: 80px; /* 左右間距 */
    align-items: start;
    margin-bottom: 60px;
}

.detail-extra-content h2 { 
    font-family: 'Inter', sans-serif; 
    font-size: 1.5rem; 
    font-weight: 600; 
    margin-top: 0; /* 在網格內頂端對齊 */
    margin-bottom: -5px; 
    color: #ffffff; 
    letter-spacing: 0.5px;
}

.detail-extra-content p { 
    font-family: 'Inter', sans-serif; 
    font-size: 1.1rem; 
    line-height: 1.2; 
    color: #cccccc; 
    margin-bottom: 0; /* 交由 grid gap 處理 */
}

/* --- 手機版 RWD：在小螢幕自動變回上下排版 --- */
@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}


/* =================================================== */
/* 7. 手機版響應式設計 (Media Queries 集中管理) */
/* =================================================== */
@media (max-width: 768px) {
  /* 標題與列表 */
  .page-large-title { font-size: 3.5rem; margin-bottom: 40px; }
  .row-col-1 { font-size: 1.3rem; } 
  .row-col-2, .row-col-3 { font-size: 0.85rem; }
  .header-col-1, .row-col-1 { flex: 45; padding-right: 15px; }
  .header-col-2, .row-col-2 { flex: 35; padding-right: 10px; }
  .header-col-3, .row-col-3 { flex: 20; padding-right: 0; }
  
  /* 詳細頁 */
  .detail-title { font-size: 3rem; bottom: 10%; }
  .detail-info-top-right { top: 200px; right: 5%; } 
  .detail-type, .detail-year { font-size: 1rem; }
}

/* =================================================== */
/* 8. 無限水平滾動跑馬燈 (Infinite Marquee) 雙向版 */
/* =================================================== */

.marquee-container {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    overflow: hidden; 
    margin-top: 60px; /* 整體上方留白稍微縮小 */
    display: flex;
}

.marquee-track {
    display: flex;
    width: max-content; 
    animation: marqueeScroll 20s linear infinite; 

    /* ⚠️ 新增：強制開啟 GPU 硬體加速 */
    will-change: transform; 
    transform: translateZ(0); 
}

/* ⚠️ 反向滾動魔法：只要加上 reverse，動畫就會倒著跑！ */
.marquee-track.reverse {
    animation-direction: reverse;
}


/* 圖片樣式設定 */
.detail-extra-content .marquee-track img {
    width: auto !important; 
    height: 320px; /* ⚠️ 尺寸縮小了！從 450px 改成 320px，比例更精緻 */
    object-fit: cover;
    margin-right: 30px; /* 圖片間距配合尺寸稍微縮小 */
    margin-bottom: 60px !important;
    border-radius: 0; 
    flex-shrink: 0; 
}

/* 當 track 同時擁有 no-gap 類別時，消除圖片間距 */
.marquee-track.no-gap img {
    margin-right: 0 !important;
}

/* 為了讓無間隔效果更完美，我們可以微調跑馬燈圖片的寬度或高度 */
.marquee-track.no-gap img {
    height: 350px; /* 你可以根據需求調整高度 */
    width: auto;
    display: block;
}

/* 跑馬燈動畫設定 */
@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); } 
}

/* --- 手機版適配 --- */
@media (max-width: 768px) {
    .detail-extra-content .marquee-track img {
        height: 200px; /* ⚠️ 手機版的圖片也跟著縮小 */
        margin-right: 15px;
    }
}

/* =================================================== */
/* 9. 滾動展開圖片庫特效 (A4 直式海報修復版) */
/* =================================================== */

.scroll-expand-gallery {
    position: relative;
    width: 100%;
    /* ⚠️ 修復 1：稍微加高外框，讓直式海報有足夠的空間顯示，不會撞到上下文字 */
    height: 65vh; 
    min-height: 500px;
    margin: 100px 0;
}

.detail-extra-content .scroll-expand-gallery .gallery-img {
    position: absolute;
    top: 50%;
    object-fit: cover;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
    border-radius: 0 !important; 
    margin-bottom: 0 !important; 
}

/* --- 初始疊合狀態 --- */

.detail-extra-content .gallery-center {
    z-index: 3;
    width: 28% !important; 
    /* ⚠️ 修復 2：高度設為 auto，解除高度限制 */
    height: auto !important; 
    /* ⚠️ 修復 3：強制套用 A4 比例 (寬1 : 高1.414) */
    aspect-ratio: 1 / 1.414 !important; 
    
    left: 50%;
    transform: translate(-50%, calc(-50% - 15px));
}

.detail-extra-content .gallery-left, 
.detail-extra-content .gallery-right {
    z-index: 1;
    width: 25% !important; /* 兩側圖片稍微小一點點製造層次 */
    height: auto !important; 
    aspect-ratio: 1 / 1.414 !important; /* 同樣鎖定 A4 比例 */
}

.detail-extra-content .gallery-left {
    left: 50%;
    transform: translate(-100%, calc(-50% + 10px));
}

.detail-extra-content .gallery-right {
    left: 50%;
    transform: translate(0%, calc(-50% + 10px));
}

/* --- 滾動觸發後的展開狀態 --- */

.scroll-expand-gallery.active .gallery-left {
    /* 調整展開距離，配合新的寬度比例 */
    transform: translate(-160%, calc(-50% + 10px)) !important;
}

.scroll-expand-gallery.active .gallery-right {
    transform: translate(60%, calc(-50% + 10px)) !important;
}

/* --- 手機版適配 --- */
@media (max-width: 768px) {
    .scroll-expand-gallery { height: 450px; }
    .detail-extra-content .gallery-center { width: 45% !important; }
    .detail-extra-content .gallery-left, 
    .detail-extra-content .gallery-right { width: 40% !important; }
    
    .scroll-expand-gallery.active .gallery-left {
        transform: translate(-120%, calc(-50% + 10px)) !important;
    }
    .scroll-expand-gallery.active .gallery-right {
        transform: translate(20%, calc(-50% + 10px)) !important;
    }
}

/* =================================================== */
/* 10. 詳細頁雙欄圖片網格 (2-Column Image Grid - 橫式 A4 版) */
/* =================================================== */

.image-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 30px; /* 調整間距，橫式圖片通常搭配稍微細一點的縫隙更有質感 */
    width: 100%;
    margin-top: 60px;
}

/* ⚠️ 核心修復：強制設定橫式 A4 比例，並加入動畫基礎設定 */
.detail-extra-content .image-grid-2col img {
    width: 100%;
    aspect-ratio: 1.414 / 1 !important; 
    height: auto !important; 
    object-fit: cover; 
    margin-bottom: 0 !important; 
    border-radius: 0 !important; 
    
    /* ⚠️ 動畫初始狀態：預設全透明 */
    opacity: 0; 
    /* 鋼琴般絲滑的 0.8 秒過渡動畫 */
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ⚠️ 左側圖片 (第1, 3, 5張)：預設往左偏移 100px */
.detail-extra-content .image-grid-2col img:nth-child(odd) {
    transform: translateX(-100px);
}

/* ⚠️ 右側圖片 (第2, 4, 6張)：預設往右偏移 100px */
.detail-extra-content .image-grid-2col img:nth-child(even) {
    transform: translateX(100px);
}

/* ⚠️ 觸發後的狀態 (透過 JS 加上 active 類別) */
.detail-extra-content .image-grid-2col img.slide-in-active {
    opacity: 1 !important;
    transform: translateX(0) !important; /* 回到原本最完美的位置 */
}

/* --- 手機版適配 --- */
@media (max-width: 768px) {
    .image-grid-2col {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* =================================================== */
/* 雙圖並排展示 (Two Images Row) */
/* =================================================== */

.two-img-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 完美平分成 2 欄 */
    gap: 40px; /* 兩張圖片中間的留白縫隙 */
    width: 100%;
    margin-bottom: 60px; /* 與下方內容維持原本的間距 */
}

/* 確保裡面的圖片乖乖貼齊，並消除預設的底部留白 */
.detail-extra-content .two-img-row img {
    width: 100%;
    height: auto;
    object-fit: cover;
    margin-bottom: 0 !important; 
    border-radius: 0 !important;
}

/* --- 手機版適配 (RWD) --- */
@media (max-width: 768px) {
    .two-img-row {
        grid-template-columns: 1fr; /* 手機版螢幕太小，自動變回上下 1 排 */
        gap: 20px; 
    }
}

/* =================================================== */
/* 11. 詳細頁底部導覽列 (Bottom Project Navigation) */
/* =================================================== */

.project-bottom-nav {
    width: 85%;
    max-width: 1200px;
    margin: 0 auto 100px auto;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.15); /* 微微的頂部分隔線 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    /* 配合詳細頁的階梯進場特效 */
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* 當詳細頁啟動時，底部按鈕最後才浮現 */
#project-detail-section.active .project-bottom-nav {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.8s; 
}

.project-bottom-nav a {
    color: #ffffff;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 1px;
    transition: color 0.4s ease, transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.bottom-back-btn:hover {
    color: #aaaaaa;
    transform: translateX(-8px); /* 往左滑動提示返回 */
}

.bottom-next-btn:hover {
    color: #aaaaaa;
    transform: translateX(8px); /* 往右滑動提示前進 */
}

/* --- 手機版適配 --- */
@media (max-width: 768px) {
    .project-bottom-nav {
        flex-direction: column;
        gap: 30px;
        text-align: center;
        padding-top: 30px;
        margin-bottom: 60px;
    }
}