/**
 * New Weng Seng - Projects Page Styles
 * 工程案例頁面樣式
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    opacity: 0;
    animation: fadeInPage 0.8s ease-out forwards;
}

@keyframes fadeInPage {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
header {
    background: rgba(255,255,255,0.95);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 60px;
    border-bottom: 1px solid #ddd;
}

.header-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo img {
    height: 41px;
    width: 100px;
    object-fit: contain;
}

.logo {
    display: flex;
    align-items: center;
    height: 100%;
}

#main-nav ul {
    list-style: none;
    display: flex;
    gap: 25px;
}

#main-nav a {
    color: #1d1d1f;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
}

#main-nav a.login-link {
    color: #b87333;
    font-weight: 600;
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 3px;
    background: #333;
    border-radius: 2px;
}

/* Hero Section */
.projects-hero {
    background: linear-gradient(135deg, rgba(184,149,106,0.4) 0%, rgba(154,123,90,0.4) 100%), url('/images/project/casino/hero.png');
    background-size: cover;
    background-position: center;
    padding: 40px 0;
    color: #fff;
    transition: background-image 0.5s ease-in-out;
}

.projects-hero-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

.category-title {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1.1;
}

/* Category Navigation */
.category-nav {
    background: #f8f8f8;
    padding: 20px 0;
    border-bottom: 1px solid #e0e0e0;
}

.category-nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    gap: 40px;
    overflow-x: auto;
    align-items: center;
}

.category-nav-item {
    font-size: 16px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    padding: 10px 0;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.category-nav-item:hover {
    color: #9A7B5A;
}

.category-nav-item.active {
    color: #9A7B5A;
    border-bottom-color: #9A7B5A;
}

.view-toggle {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.view-btn {
    padding: 12px 24px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    color: #666;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.view-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: #fff;
}

.view-btn.active {
    background: #fff;
    color: #9A7B5A;
    border-color: #fff;
}

/* Projects Section */
.projects-section {
    padding: 80px 0;
}

.projects-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

/* Grid View */
.projects-grid {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}

.projects-grid.active {
    display: grid;
}

.project-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.project-image {
    width: 100%;
    height: 250px;
    background: #e0e0e0;
    background-size: cover;
    background-position: center;
}

.project-info {
    padding: 24px;
}

.project-category {
    font-size: 12px;
    color: #9A7B5A;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.project-title {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 12px;
}

.project-location {
    font-size: 14px;
    color: #666;
}

/* List View */
.projects-list {
    display: none;
}

.projects-list.active {
    display: block;
}

.project-list-item {
    display: flex;
    gap: 30px;
    padding: 30px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.3s;
}

.project-list-item:hover {
    background: #f8f8f8;
}

.project-list-image {
    width: 300px;
    height: 200px;
    background: #e0e0e0;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border-radius: 8px;
}

.project-list-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.project-list-item .project-category {
    margin-bottom: 12px;
}

.project-list-item .project-title {
    font-size: 24px;
    margin-bottom: 16px;
}

.project-list-item .project-location {
    font-size: 16px;
}

/* ===== 分頁（2026-10-28 batch2 ⑤）：每頁 6 項、10 頁一組 ===== */
.ms-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 34px 0 12px;
}

.ms-pager-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    font-size: 15px;
    color: #4a4a4c;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.ms-pager-btn:hover:not(:disabled):not(.active) {
    border-color: #9A7B5A;
    color: #9A7B5A;
}

.ms-pager-btn.active {
    background: #9A7B5A;
    border-color: #9A7B5A;
    color: #fff;
    font-weight: 600;
    cursor: default;
}

.ms-pager-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ms-pager-info {
    font-size: 13px;
    color: #86868b;
    margin-left: 10px;
}

@media (max-width: 768px) {
    .ms-pager-btn { min-width: 36px; height: 36px; font-size: 14px; }
    .ms-pager-info { width: 100%; text-align: center; margin: 4px 0 0; }
}

/* ===== 列表模式綠箭頭（2026-10-28 batch2 ⑤）：rollover 顯示 ===== */
.project-list-arrow {
    align-self: center;
    margin-left: auto;
    padding-left: 24px;
    font-size: 30px;
    line-height: 1;
    color: #2e9e4f;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    flex-shrink: 0;
    user-select: none;
}

.project-list-item:hover .project-list-arrow {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 768px) {
    .project-list-arrow { display: none; }
}

/* Section Container */
.section-container {
    display: none;
}

.section-container.active {
    display: block;
}

/* Footer */
footer {
    background: #f5f5f7;
    padding: 40px 0 20px;
    font-size: 12px;
    color: #86868b;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    max-width: 1000px;
    margin: 0 auto;
}

.footer-section h3 {
    font-size: 13px;
    color: #1d1d1f;
    margin-bottom: 12px;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section a {
    color: #86868b;
    text-decoration: none;
}

.footer-section a:hover {
    color: #9A7B5A;
}

.footer-bottom {
    max-width: 1000px;
    margin: 30px auto 0;
    padding-top: 20px;
    text-align: center;
    border-top: 1px solid #ddd;
}

/* 與 index 頁 footer 一致的輔助樣式 */
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 20px;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 0.8s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in-delay-4 {
    animation-delay: 0.4s;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background: #fff;
    width: min(92vw, 1100px);
    max-width: 1100px;
    max-height: 90vh;
    margin: auto;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.4s ease-out;
    transition: width 0.25s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.modal-header {
    background: linear-gradient(135deg, #B89566 0%, #9A7B5A 100%);
    color: #fff;
    padding: 14px 28px;
}

.modal-category {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 0;
}

.modal-location {
    font-size: 16px;
    opacity: 0.9;
}

/* 2026-11-21：padding 移去 legacy 子元素層，主圖可以全寬貼邊（對齊 story mode） */
.modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.modal-gallery {
    margin-bottom: 30px;
}

/* legacy 主圖：全寬 <img>，觀感同 .ms-hero 一致（2026-11-21） */
.modal-main-image {
    width: 100%;
    overflow: hidden;
    background: #111;
}

.modal-main-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 64vh;
    object-fit: cover;
}

.modal-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 20px 40px 10px;
}

.modal-thumbnails:empty {
    display: none;
}

.modal-thumbnail {
    width: 100px;
    height: 70px;
    background: #e0e0e0;
    background-size: cover;
    background-position: center;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
    flex-shrink: 0;
}

.modal-thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.modal-thumbnail.active {
    opacity: 1;
    border: 2px solid #9A7B5A;
}

.modal-description {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    margin-bottom: 20px;
    padding: 0 40px;
}

.modal-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 40px 40px;
    border-top: 1px solid #e0e0e0;
}

.modal-detail-item {
    font-size: 14px;
}

.modal-detail-label {
    color: #9A7B5A;
    font-weight: 600;
    margin-bottom: 4px;
}

.modal-detail-value {
    color: #333;
}

/* Responsive Design */
@media only screen and (max-width: 768px) {
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .mobile-menu-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
    .mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
    .mobile-menu-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }
    
    #main-nav {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: #ffffff;
        z-index: 999;
        overflow-y: auto;
        display: none;
    }
    
    #main-nav.open {
        display: block;
    }
    
    #main-nav ul {
        flex-direction: column;
        padding: 20px;
        gap: 0;
    }
    
    #main-nav li {
        border-bottom: 1px solid #eee;
        display: block;
    }
    
    #main-nav a {
        display: block;
        padding: 20px 0;
        font-size: 20px;
    }
    
    .projects-hero-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 30px;
    }
    
    .category-title {
        font-size: 21px;
    }
    
    .view-toggle {
        width: 100%;
        justify-content: flex-start;
    }
    
    .projects-hero {
        padding: 30px 0;
    }
    
    .category-nav-container {
        padding: 0 20px;
        gap: 20px;
    }
    
    .category-nav-item {
        font-size: 14px;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .project-list-item {
        flex-direction: column;
        gap: 20px;
    }
    
    .project-list-image {
        width: 100%;
        height: 200px;
    }
    
    .projects-container {
        padding: 0 20px;
    }
    
    .modal-container {
        width: min(92vw, 1100px);
        margin: 20px auto;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-title {
        font-size: 24px;
    }
    
    .modal-body {
        padding: 0;
    }
    
    .modal-main-image img {
        max-height: 42vh;
    }
    
    .modal-thumbnails {
        padding: 16px 20px 8px;
    }
    
    .modal-description {
        padding: 0 20px;
    }
    
    .modal-details {
        padding: 16px 20px 28px;
    }
    
    .modal-thumbnail {
        width: 80px;
        height: 60px;
    }
}

@media screen and (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}

/* ============================================================
   Story Mode — epic-style 項目模態框（2026-10-21）
   blocks 有資料時 .modal-container 加 .story-mode
   結構：全寬 hero 主圖 → .ms-content（兩側留白）→ header/content 區塊
   Desktop：圖文左右並排；Mobile：一律垂直單行
   ============================================================ */

.modal-container.story-mode {
    width: min(92vw, 1100px);
    max-width: 1100px;
}

.story-mode .modal-body {
    padding: 0;
}

/* legacy 元素喺 story mode 隱藏 */
.story-mode .modal-gallery,
.story-mode .modal-description {
    display: none;
}

.modal-story { display: none; }
.story-mode .modal-story { display: block; }

/* --- Hero：全寬貼到 layer 兩邊（同首頁 slide 一樣） --- */
.ms-hero {
    width: 100%;
    overflow: hidden;
    background: #111;
}
.ms-hero img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 64vh;
    object-fit: cover;
}

/* --- 內容區：按比例收窄、兩側留白 --- */
.ms-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 46px 52px 16px;
}

/* 引子（項目描述） */
.ms-intro {
    text-align: center;
    font-size: 15px;
    line-height: 2;
    color: #4a4a4c;
    max-width: 720px;
    margin: 0 auto 20px;
}

/* --- 大標題區塊（靠左/靠右 + 副標題） --- */
.ms-head {
    margin: 52px 0 30px;
}
.ms-head.align-right { text-align: right; }
.ms-head h3 {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #1d1d1f;
    margin: 0;
}
.ms-head p {
    margin-top: 12px;
    font-size: 15px;
    letter-spacing: 0.14em;
    color: #9A7B5A;
}

/* --- 圖文左右區塊 --- */
.ms-row {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 40px;
    align-items: center;
    margin-bottom: 44px;
}
.ms-row.img-right .ms-img { order: 2; }
.ms-row.img-right .ms-text { order: 1; }
.ms-img img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}
.ms-text-sub {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #9A7B5A;
    margin-bottom: 12px;
}
.ms-text-body {
    font-size: 14.5px;
    line-height: 2;
    color: #4a4a4c;
}

/* --- story mode 下詳細資料區 --- */
.story-mode .modal-details {
    max-width: 960px;
    margin: 0 auto;
    padding: 34px 52px 44px;
    border-top: 1px solid #ece8e2;
}

/* --- 手機版：一律垂直單行 --- */
@media screen and (max-width: 768px) {
    .ms-hero img {
        max-height: 42vh;
    }
    .ms-content {
        padding: 26px 20px 8px;
    }
    .ms-intro {
        font-size: 14px;
        text-align: left;
    }
    .ms-head {
        margin: 34px 0 20px;
    }
    .ms-head h3 {
        font-size: 23px;
    }
    .ms-row,
    .ms-row.img-right {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 34px;
    }
    .ms-row.img-right .ms-img { order: 0; }
    .ms-row.img-right .ms-text { order: 0; }
    .story-mode .modal-details {
        padding: 26px 20px 32px;
    }
}

/* ============================================================
   Story Mode 新區塊（2026-10-21 下午；2026-11-22 加單圖／單區塊）
   text = 純文區塊(雙區塊)（兩欄文章＋可選中間漸變幼線）
   text_single = 純文區塊(單區塊)（一段文章佔滿內容欄全寬）
   images = 純圖區塊(雙圖)（兩圖並排）
   image = 純圖區塊(單圖)（一張圖佔滿內容欄全寬）
   gallery = 圖片排區塊（網格＋lightbox 彈出）
   ============================================================ */

/* --- 純文區塊(雙區塊) --- */
.ms-text2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 44px;
    margin-bottom: 44px;
}
.ms-text2.with-divider {
    grid-template-columns: 1fr auto 1fr;
    gap: 40px;
}
.ms-text2-col {
    font-size: 14.5px;
    line-height: 2;
    color: #4a4a4c;
}
.ms-text2-divider {
    width: 1px;
    align-self: stretch;
    background: linear-gradient(180deg,
        rgba(154,123,90,0) 0%,
        rgba(154,123,90,0.45) 15%,
        rgba(154,123,90,0.45) 85%,
        rgba(154,123,90,0) 100%);
}

/* --- 純圖區塊(雙圖) --- */
.ms-img2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 44px;
}
.ms-img2 .ms-img img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* --- 純圖區塊(單圖)：一張圖佔滿內容欄全寬（2026-11-22）
   .ms-content 係 block flow（唔係 grid），全寬＝預設；
   單欄結構喺 ≤768px 自動成立，唔使額外 mobile override --- */
.ms-img-full {
    margin-bottom: 44px;
}
.ms-img-full img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* --- 純文區塊(單區塊)：一段文章佔滿內容欄全寬（2026-11-22） --- */
.ms-text-full {
    font-size: 14.5px;
    line-height: 2;
    color: #4a4a4c;
    margin-bottom: 44px;
}

/* --- 圖片排區塊 --- */
.ms-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 44px;
}
.ms-gallery-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.25s, filter 0.25s;
}
.ms-gallery-thumb:hover {
    transform: scale(1.03);
    filter: brightness(1.05);
}

/* --- Lightbox（彈出大圖） --- */
.ms-lightbox {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(10, 10, 10, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
}
.ms-lightbox.open {
    display: flex;
}
.ms-lb-img {
    max-width: 90vw;
    max-height: 84vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.6);
}
.ms-lb-close,
.ms-lb-prev,
.ms-lb-next {
    position: absolute;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-family: inherit;
}
.ms-lb-close:hover,
.ms-lb-prev:hover,
.ms-lb-next:hover {
    background: rgba(255,255,255,0.25);
}
.ms-lb-close {
    top: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    font-size: 18px;
}
.ms-lb-prev,
.ms-lb-next {
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    font-size: 26px;
    line-height: 1;
}
.ms-lb-prev { left: 20px; }
.ms-lb-next { right: 20px; }
.ms-lb-count {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    letter-spacing: 0.12em;
}

/* --- 手機版：新區塊一律垂直單行 --- */
@media screen and (max-width: 768px) {
    .ms-text2,
    .ms-text2.with-divider {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .ms-text2-divider {
        width: 60%;
        height: 1px;
        justify-self: center;
        background: linear-gradient(90deg,
            rgba(154,123,90,0) 0%,
            rgba(154,123,90,0.45) 20%,
            rgba(154,123,90,0.45) 80%,
            rgba(154,123,90,0) 100%);
    }
    .ms-img2 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .ms-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .ms-lb-prev, .ms-lb-next {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }
    .ms-lb-prev { left: 10px; }
    .ms-lb-next { right: 10px; }
    .ms-lb-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
    }
}
