/* --- 通用基礎樣式 --- */
body {
    font-family: "Noto Sans TC", "微軟正黑體", Arial, sans-serif;
    margin: 0;
    line-height: 1.6;
    color: #333;
    overflow-x: hidden; /* 防止水平滾動條 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px; /* 左右內邊距 */
}

a {
    text-decoration: none;
    color: #c00;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

button {
    background-color: #c00;
    color: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #b00;
}

/* --- Header 佈局 --- */
header {
    background: #fff;
    padding: 10px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky; /* 讓 header 固定在頂部 */
    top: 0;
    z-index: 1000; /* 確保在其他內容之上 */
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

header .logo {
    height: 50px;
}

/* --- 導覽列 --- */
nav ul {
    display: flex;
}

nav ul li {
    margin-left: 20px;
}

nav ul li a {
    text-decoration: none;
    color: #333;
    font-weight: bold;
    padding: 5px 0;
    transition: color 0.3s;
}

nav ul li a:hover {
    color: #c00;
}

/* --- 漢堡按鈕 (手機版) --- */
.menu-toggle {
    display: none; /* 預設隱藏 */
    font-size: 30px;
    cursor: pointer;
    z-index: 1001; /* 確保在導航菜單之上 */
}

/* --- 手機版導覽 (Media Query) --- */
@media (max-width: 768px) {
    .menu-toggle {
        display: block; /* 在小螢幕顯示漢堡按鈕 */
    }

    nav {
        position: absolute;
        top: 70px; /* 位於 header 下方 */
        right: 20px;
        background: white;
        border: 1px solid #ccc;
        display: none; /* 預設隱藏 */
        width: 200px;
        z-index: 1000; /* 確保在內容之上 */
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        border-radius: 5px;
    }

    nav ul {
        flex-direction: column; /* 垂直排列 */
        align-items: center; /* 項目置中 */
        padding: 10px 0;
    }

    nav ul li {
        margin: 10px 0;
    }

    nav.active { /* 透過 JS 控制的 class */
        display: block;
    }
}

/* --- Hero 區塊 (輪播圖) --- */
.hero .carousel {
    position: relative;
    width: 100%;
    /* 使用 aspect-ratio 確保圖片比例在不同裝置下一致 */
    /* 這裡使用 16 / 5 比例，可根據實際圖片調整，例如 3 / 1 或 2.5 / 1 */
    aspect-ratio: 16 / 5;
    overflow: hidden;
}

.hero .carousel img {
    width: 100%;
    height: 100%; /* 確保圖片填滿容器 */
    object-fit: cover; /* 圖片等比例填充容器，超出部分裁剪 */
    display: none; /* 預設隱藏 */
    transition: opacity 0.5s ease; /* 淡入淡出效果 */
}

.hero .carousel img.active {
    display: block; /* 顯示當前活躍圖片 */
}

/* --- 歡迎介紹區塊 --- */
.intro {
    text-align: center;
    padding: 30px 20px;
    color: #990000;
}

.intro h1 {
    font-size: clamp(24px, 5vw, 36px); /* 響應式字體大小 */
    margin-bottom: 20px;
    white-space: nowrap; /* 確保標題保持在一行 */
    overflow: hidden; /* 隱藏超出部分 */
    text-overflow: ellipsis; /* 超出部分顯示省略號 */
}

.intro p {
    font-size: clamp(16px, 2vw, 18px); /* 響應式字體大小 */
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.6;
}

/* --- 精選商品區塊 --- */
.featured-products {
    padding: 20px;
    text-align: center;
}

.featured-products h2 {
    font-size: 30px;
    margin-bottom: 20px;
    color: #333;
}

.products-grid {
    display: grid;
    /* 使用 auto-fit 結合 minmax 創建響應式網格 */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px; /* 網格間距 */
    margin-top: 20px;
}

.product-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    cursor: pointer; /* 顯示可點擊 */
}

.product-card:hover {
    transform: translateY(-8px); /* 懸停上移 */
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.product-card img {
    width: 100%;
    aspect-ratio: 1 / 1; /* 保持圖片為正方形 */
    object-fit: cover; /* 圖片等比例填充，超出部分裁剪 */
    border-radius: 8px;
    transition: transform 0.3s ease; /* 放大效果過渡 */
}

.product-card img:hover {
    transform: scale(1.05); /* 圖片在卡片內放大 */
}

.product-card h3 {
    margin: 15px 0 8px;
    font-size: 20px;
    color: #333;
}

.product-card p {
    margin-bottom: 15px;
    font-size: 18px;
    color: #c00; /* 價格顏色 */
    font-weight: bold;
}

/* --- 商品燈箱 (Modal) 樣式 --- */

/* --- 商品燈箱 (Modal) 樣式 --- */
.modal {
    display: none; /* 保持這個 'none' 以預設隱藏它 */
    position: fixed; /* 確保它能固定在視窗上 */
    z-index: 2000; /* 確保它在其他內容之上 */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7); /* 半透明黑色背景 */
    /* *** 將 display: flex; 從這裡移除 *** */
    justify-content: center; /* 讓內容水平置中 */
    align-items: center;   /* 讓內容垂直置中 */
    padding: 10px; /* 內部邊距，防止內容頂到邊緣 */
    box-sizing: border-box; /* 確保 padding 不會增加寬度 */
}

/* 當 JavaScript 添加 'active' class 時才顯示燈箱 */
.modal.active { /* 這個 '.active' class 會由你的 JS 控制 */
    display: flex; /* 只有當這個 class 被添加時，燈箱才會顯示並置中 */
}

.modal-content {
    background-color: #fefefe;
    padding: 25px;
    border: 1px solid #888;
    border-radius: 12px;
    width: 90%; /* 預設寬度佔 90% */
    max-width: 800px; /* **關鍵：燈箱最大寬度** */
    max-height: 90vh; /* **關鍵：燈箱最大高度 (視口高度的 90%)** */
    overflow-y: auto; /* 內容超出時垂直滾動 */
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    /* **調整此處的 Flexbox 設置：預設為垂直排列（手機優先）** */
    display: flex;
    flex-direction: column; 
    gap: 20px; /* 元素間距，如圖片與文字間距 */
    box-sizing: border-box; /* 確保 padding 不會導致超出 */
}

.close-btn {
    color: #aaa;
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 32px; /* 稍大一點方便點擊 */
    font-weight: bold;
    cursor: pointer;
    z-index: 10; /* 確保在輪播按鈕之上 */
    background: white; /* 小背景圓圈，讓圖標更明顯 */
    padding: 0 10px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    line-height: 1; /* 調整行高讓 x 居中 */
}

.close-btn:hover,
.close-btn:focus {
    color: #c00;
}

.modal-carousel {
    position: relative;
    width: 100%;
    max-height: 450px; /* **關鍵：圖片輪播區塊最大高度 (手機/預設)** */
    overflow: hidden; /* 確保圖片不超出區域 */
    margin-bottom: 20px; /* 手機版圖片下方間距 */
    display: flex; /* 使用 flexbox 讓圖片居中 */
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* 防止此區域被壓縮 */
}

.modal-carousel img {
    width: 100%; /* 圖片寬度佔滿父容器 */
    height: auto; /* 高度自動調整 */
    display: block; /* 移除圖片底部的空白 */
    max-height: 450px; /* **關鍵：圖片本身最大高度 (手機/預設)** */
    object-fit: contain; /* 圖片等比例縮放以適應容器，可能留白邊 */
    border-radius: 8px;
}

.carousel-controls {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    padding: 0 10px;
    box-sizing: border-box;
    z-index: 5; /* 確保按鈕在點點下方，但仍在圖片上方 */
}

.carousel-controls button {
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 50%; /* 圓形按鈕 */
    font-size: 20px;
    line-height: 1;
    transition: background-color 0.3s;
}

.carousel-controls button:hover {
    background-color: rgba(0,0,0,0.8);
}

/* 燈箱內小點點的樣式修正 */
.carousel-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
    margin-top: 0;
}

.carousel-dots span {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #ccc;
    border-radius: 50%;
    margin: 0 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.carousel-dots .active {
    background-color: #c00;
}

.modal-info {
    flex-grow: 1; /* 資訊區塊佔據剩餘空間 */
    overflow-y: auto; /* 內容過長時滾動 */
    padding-right: 0; /* 移除預設的 padding-right，由 media query 控制 */
    box-sizing: border-box; /* 確保 padding 不會導致超出 */
}

.modal-info h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 26px; /* 稍大一點 */
    color: #333;
}

.modal-info p {
    font-size: 16px; /* 預設字體大小 */
    line-height: 1.6;
    color: #555;
    margin-bottom: 10px; /* 段落間距 */
}

/* --- RWD (燈箱細部調整) --- */
/* 手機直式 (小於 768px) */
@media (max-width: 767px) {
    .modal-content {
        padding: 15px;
        width: 95%; /* 手機上可以更寬一點 */
        max-width: none; /* 移除最大寬度限制 */
        max-height: 95vh; /* 保持最大高度 */
        flex-direction: column; /* 再次明確手機版垂直排列 */
        gap: 15px; /* 手機版間距 */
    }

    .modal-carousel {
        max-height: 300px; /* 手機上圖片高度可以小一點 */
        margin-bottom: 15px; /* 調整手機版圖片下方間距 */
    }

    .modal-carousel img {
        max-height: 300px;
    }

    .carousel-controls button {
        padding: 8px 12px; /* 手機上按鈕小一點 */
        font-size: 18px;
    }

    .modal-info h3 {
        font-size: 22px;
    }

    .modal-info p {
        font-size: 14px;
    }
}

/* 平板橫式及桌機 (大於等於 768px) */
@media (min-width: 768px) {
    .modal-content {
        flex-direction: row; /* **關鍵：桌機版水平排列** */
        max-width: 900px; /* 可以適度增加桌機燈箱最大寬度 */
        max-height: 80vh; /* 調整桌機燈箱最大高度 */
        padding: 30px; /* 桌機版內邊距 */
        align-items: flex-start; /* 確保內容從頂部對齊 */
        gap: 30px; /* 桌機版圖片與文字間距 */
    }

    .modal-carousel {
        width: 50%; /* 圖片區塊佔一半寬度 */
        max-width: 450px; /* 限制圖片區塊最大寬度 */
        flex-shrink: 0; /* 防止圖片區塊被壓縮 */
        margin-bottom: 0; /* 移除底部間距 */
    }

    .modal-carousel img {
        max-height: 450px; /* 配合燈箱高度調整圖片最大高度 */
        object-fit: contain; /* 確保圖片完全顯示 */
    }

    .modal-info {
        width: 50%; /* 文字區塊佔一半寬度 */
        padding-right: 10px; /* 避免滾動條擋住文字 */
        flex-grow: 1; /* 確保佔滿剩餘空間 */
    }
}
/* --- 浮動社群按鈕 --- */
.floating-buttons {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.floating-buttons a {
    width: 50px;
    height: 50px;
    background-color: #c00;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 24px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: background-color 0.3s, transform 0.2s ease; /* 添加 transform 過渡 */
}

.floating-buttons a:hover {
    background-color: #a00;
    transform: scale(1.15); /* 懸停放大效果 */
}

.floating-buttons i {
    font-size: 24px; /* 確保圖標尺寸一致 */
}

/* 手機版浮動按鈕縮小 */
@media (max-width: 768px) {
    .floating-buttons a {
        width: 45px; /* 稍小一點 */
        height: 45px;
        padding: 0; /* 移除 padding 避免影響大小 */
    }
    .floating-buttons i {
        font-size: 22px; /* 圖標也相應縮小 */
    }
}

/* --- Footer 樣式 --- */
footer {
    background: #f2f2f2;
    padding: 15px 20px; /* 增加上下 padding */
    text-align: center;
    color: #666;
    font-size: 14px;
}