/* =========================================
   全站共用樣式表 (style.css)
========================================= */

/* --- 1. 基礎重設 --- */
* { box-sizing: border-box; }
html, body {
    width: 100%; max-width: 100vw; overflow-x: hidden;
    font-family: 'Microsoft JhengHei', Arial, sans-serif; 
    margin: 0; padding: 0; color: #333; min-height: 100vh;
}

/* --- 2. 首頁專屬外觀 (.page-home) --- */
body.page-home {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); 
    text-align: center; 
    display: flex; flex-direction: column; align-items: center;
    padding-top: 0 !important;
}

/* --- 3. 商品頁專屬外觀 (.page-product-list) --- */
body.page-product-list {
    background-color: #f8fafc; padding-top: 20px; user-select: none;
    display: block; /* 避免 flex 導致網格壓縮 */
}

/* =========================================
   首頁元件 (top.php & index.php)
========================================= */
.top-header { 
    width: 100%; position: sticky; top: 0; left: 0; z-index: 1500; 
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%); 
    box-shadow: 0 4px 20px rgba(0,0,0,0.15); transition: transform 0.4s; 
}
.header-inner-container { width: 100%; max-width: 1000px; margin: 0 auto; }
.header-row-top { width: 100%; padding: 10px 0; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.4); display: flex; justify-content: center; align-items: center; }
.site-title { font-size: 24px; font-weight: 900; color: #0369a1; text-decoration: none; letter-spacing: 2px; display: inline-block; text-indent: 2px; margin: 0 auto; width: fit-content; }
.header-row-bottom { height: 35px; background: rgba(255,255,255,0.5); display: flex; align-items: center; overflow: hidden; }
.marquee-track { display: flex; white-space: nowrap; animation: marquee 30s linear infinite; }
.marquee-item { margin-right: 50px; font-size: 13px; color: #1d3557; font-weight: bold; display: flex; align-items: center; }
@keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

.activity-badge {
    background-color: #ffeb3b; color: #d32f2f; padding: 4px 15px; border-radius: 20px; font-size: 14px; 
    font-weight: 900; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: 0.2s; display: inline-block;
}
.activity-badge:hover { transform: scale(1.05); }

/* 🟢 [補回] 首頁主內容區塊與懸浮按鈕 */
.main-content { 
    width: 95%; max-width: 1000px; background: rgba(255, 255, 255, 0.95); 
    border-top-left-radius: 0; border-top-right-radius: 0;
    border-bottom-left-radius: 15px; border-bottom-right-radius: 15px;
    padding: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); 
    margin-bottom: 40px; position: relative; min-height: 500px; margin-top: 0; 
}
#side-cart-btn { 
    position: fixed; bottom: 100px; right: 0; 
    background: #e63946; color: white; padding: 15px 8px; 
    border-radius: 8px 0 0 8px; writing-mode: vertical-rl; font-weight: bold; 
    z-index: 999; text-decoration: none; box-shadow: -2px 2px 10px rgba(0,0,0,0.1); 
}
#chat-widget-container { position: fixed; bottom: 30px; right: 30px; z-index: 10000; display: flex; flex-direction: column; align-items: flex-end; }
#chat-window { display: none; width: 330px; height: 450px; background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); flex-direction: column; overflow: hidden; margin-bottom: 15px; }
#chat-toggle-btn { width: 60px; height: 60px; border-radius: 50%; background: #1d3557; color: white; border: none; font-size: 28px; cursor: pointer; box-shadow: 0 6px 15px rgba(0,0,0,0.2); transition: 0.3s; }
#chat-toggle-btn:hover { transform: rotate(15deg) scale(1.1); }
.back-btn { display: inline-block; background: #e0f2fe; color: #0369a1; padding: 6px 20px; border-radius: 20px; text-decoration: none; font-weight: bold; margin-bottom: 15px; transition: 0.2s; }
.back-btn:hover { transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; justify-content: center; align-items: center; }

/* =========================================
   商品頁元件 (product_list.php)
========================================= */
.sticky-navbar { position: fixed; top: 0; left: 0; width: 100%; height: 75px; background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%); z-index: 1500; box-shadow: 0 2px 15px rgba(0,0,0,0.1); border-bottom: 1px solid #7dd3fc; transition: transform 0.4s ease-in-out; overflow: hidden; }
.navbar-hidden { transform: translateY(-100%); }
.navbar-bg-pattern { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; background-repeat: repeat; background-position: center center; }
.nav-container { max-width: 1200px; margin: 0 auto; height: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; box-sizing: border-box; position: relative; z-index: 10; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 10px; }
.nav-filters { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: center; }
.nav-filters select, .nav-filters input { padding: 9px 12px; border-radius: 20px; border: 1px solid #7dd3fc; background: rgba(255,255,255,0.85); font-size: 13px; outline: none; color: #0369a1; font-weight: bold; transition: 0.2s; backdrop-filter: blur(4px); }
.nav-filters select:hover, .nav-filters input:focus { border-color: #0ea5e9; background: #fff; }
#search-input { width: 150px; }
.nav-btn { background: #0ea5e9; color: white; text-decoration: none; padding: 9px 16px; border-radius: 20px; font-size: 13px; font-weight: bold; transition: 0.2s; display: flex; align-items: center; gap: 5px; border: none; cursor: pointer; }
.nav-btn:hover { background: #0284c7; }
.nav-btn.secondary { background: white; color: #0ea5e9; border: 1px solid #0ea5e9; }
.nav-btn.cart { background: #e63946; }

.gallery-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; width: 100%; max-width: 1600px; padding: 95px 10px 40px 10px; box-sizing: border-box; margin: 0 auto; }
.gallery-item { position: relative; overflow: hidden; cursor: pointer; background: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); aspect-ratio: 1 / 1.1; transition: transform 0.3s; }
.gallery-item:hover { transform: translateY(-3px); z-index: 10; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.gallery-item img.main-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-top, .note-bottom { position: absolute; left: 0; width: 100%; background: rgba(0, 0, 0, 0.7); color: #fff; text-align: center; font-weight: bold; transition: transform 0.3s ease, opacity 0.3s ease; z-index: 20; }
.note-top { top: 0; padding: 8px 5px; font-size: 14px; transform: translateY(-100%); }
.note-bottom { bottom: 0; padding: 10px 5px; font-size: 15px; transform: translateY(100%); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-item:hover .note-top, .gallery-item:hover .note-bottom { transform: translateY(0); }
.gallery-item.has-video-playing:hover .note-top, .gallery-item.has-video-playing:hover .note-bottom { opacity: 0; transform: translateY(0); pointer-events: none; }

.hover-video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s; z-index: 15; background: #000; pointer-events: none; }
.gallery-item.has-video-playing .hover-video { opacity: 1; }
.gallery-item.has-video-playing .video-indicator { opacity: 0; }
.video-indicator { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.5); color: white; padding: 2px 6px; border-radius: 4px; font-size: 11px; z-index: 15; pointer-events: none; transition: opacity 0.3s; }
.rarity-badge { position: absolute; top: 10px; left: 10px; padding: 4px 10px; font-size: 12px; font-weight: 900; border-radius: 4px; z-index: 25; box-shadow: 0 2px 5px rgba(0,0,0,0.3); background: #333; color: #fff; transition: opacity 0.3s; }
.gallery-item:hover .rarity-badge { opacity: 0; }
.rarity-badge[data-r="UR"], .rarity-badge[data-r="MUR"] { background: linear-gradient(135deg, #ffd700, #b8860b); color: #000; }
.rarity-badge[data-r="SAR"] { background: linear-gradient(135deg, #ff9a9e, #fecfef, #a1c4fd); color: #333; }
.rarity-badge[data-r="SSR"], .rarity-badge[data-r="SR"] { background: linear-gradient(135deg, #11998e, #38ef7d); }
.rarity-badge[data-r="AR"], .rarity-badge[data-r="CHR"] { background: linear-gradient(135deg, #ff7e5f, #feb47b); }
.rarity-badge[data-r="yugioh_red"] { background: linear-gradient(135deg, #ff0844, #ffb199); }
.rarity-badge[data-r="yugioh_gold_secret"] { background: linear-gradient(135deg, #f6d365, #fda085); color:#000; }
.featured-badge { position: absolute; top: 10px; left: 10px; background: #d4af37; color: #fff; padding: 4px 10px; font-size: 12px; font-weight: bold; border-radius: 4px; z-index: 25; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
.platform-icons { position: absolute; bottom: 8px; right: 8px; display: flex; gap: 5px; z-index: 15; transition: opacity 0.3s; }
.gallery-item:hover .platform-icons { opacity: 0; }
.p-icon { width: 24px; height: 24px; border-radius: 50%; background: #fff; padding: 2px; box-shadow: 0 2px 5px rgba(0,0,0,0.3); border: 1px solid #ccc; }
.sold-out-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.7); z-index: 30; display: flex; justify-content: center; align-items: center; font-weight: 900; font-size: 24px; color: #555; transform: rotate(-15deg); border: 5px solid #555; border-radius: 12px; margin: 10px; width: calc(100% - 20px); height: calc(100% - 20px); }

/* =========================================
   全站共用彈窗與手持裝置
========================================= */
.iframe-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.75); z-index: 99999; display: none; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.iframe-modal-box { background: white; width: 95%; max-width: 650px; height: 85vh; border-radius: 12px; position: relative; overflow: hidden; box-shadow: 0 15px 40px rgba(0,0,0,0.4); animation: popIn 0.3s ease-out forwards; }
@keyframes popIn { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.iframe-close-btn { position: absolute; top: -12px; right: -12px; font-size: 28px; color: #333; background: #f0f0f0; border-radius: 50%; width: 45px; height: 45px; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.2); z-index: 10; padding-top: 8px; padding-right: 8px; font-weight: bold; }
.iframe-close-btn:hover { background: #e63946; color: white; }

.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); justify-content: center; align-items: flex-start; backdrop-filter: blur(8px); overflow-y: auto; padding: 40px 0; }
.modal.show { display: flex; }
.modal-content-wrapper { display: flex; flex-direction: column; align-items: center; width: 95%; max-width: 480px; margin: auto; }
.zoom-container { position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 20px; cursor: crosshair; display: inline-block; max-width: 100%; max-height: 50vh; }
.zoom-container img { display: block; width: auto; max-width: 100%; max-height: 50vh; object-fit: contain; transition: transform 0.1s ease-out; }
@media (hover: hover) { .zoom-container:hover img { transform: scale(2.5); } }
#modal-thumbnails { display: flex; gap: 10px; margin-bottom: 15px; justify-content: center; flex-wrap: wrap; width: 100%; }
.modal-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; opacity: 0.6; transition: 0.2s; }
.modal-thumb.active, .modal-thumb:hover { border-color: #0ea5e9; opacity: 1; }
#share-btn { background: #e2e8f0; color: #1e293b; width: 100%; padding: 16px; border-radius: 12px; border: none; font-weight: bold; cursor: pointer; font-size: 16px; margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s; }
#share-btn:hover { background: #cbd5e1; }

@media (max-width: 768px) {
    .site-title { font-size: 20px !important; letter-spacing: 1px; text-indent: 1px; }
    .header-inner-container { padding: 0; }
    .nav-container { height: auto; flex-direction: column; padding: 10px; gap: 8px; }
    .sticky-navbar { height: auto; }
    .gallery-container { grid-template-columns: repeat(2, 1fr); gap: 8px; padding-top: 155px; padding-left: 8px; padding-right: 8px; }
    #search-input { width: 100%; }
    .zoom-container { cursor: default; } 
    
    /* 🟢 首頁手機版修正 */
    .main-content { margin-top: 0; }
    #side-cart-btn { bottom: 160px; right: 0; padding: 12px 6px; font-size: 14px; }
    #chat-widget-container { bottom: 20px; right: 15px; }
    #chat-toggle-btn { width: 50px; height: 50px; font-size: 24px; }
}

/* =========================================
   UI/UX 進階質感提升特效
========================================= */

/* 1. Q彈按鈕微動效 */
.nav-btn {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}
.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(3, 105, 161, 0.3);
}

/* 2. 卡片高級懸浮效果 */
.gallery-item {
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}
.gallery-item:hover {
    transform: translateY(-6px) scale(1.01) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15) !important;
}

/* 3. 骨架屏 (圖片載入中的閃爍動畫) */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
img.main-img {
    background: linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    color: transparent; /* 隱藏載入前醜醜的 alt 文字 */
    opacity: 0; 
    transition: opacity 0.5s ease-in-out;
}
img.main-img.loaded {
    background: none;
    animation: none;
    opacity: 1; /* 載入完成後優雅淡入 */
}

/* 4. 滾動淡入 (Scroll Reveal) 初始狀態 */
.reveal-item {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.reveal-item.visible {
    opacity: 1;
    transform: translateY(0);
}