/* Products Page Styles - Vogue Magazine Inspired */

/* Products Hero */
.products-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    min-height: 70vh;
    margin-top: var(--nav-height);
    padding: var(--spacing-xl) 0;
    background: linear-gradient(135deg, var(--primary-light) 0%, #f5f3ef 100%);
}

.hero-content {
    padding: var(--spacing-xl);
    max-width: 500px;
    margin-right: auto;
}

.hero-tag {
    display: inline-block;
    background: var(--accent-green);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-md);
}

.hero-magazine {
    position: relative;
    height: 100%;
    min-height: 500px;
    overflow: hidden;
}

.magazine-cover {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    transform: rotate(-2deg);
    transition: transform var(--transition-medium);
}

    .magazine-cover:hover {
        transform: rotate(0deg) scale(1.02);
    }

    .magazine-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.magazine-label {
    position: absolute;
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* Category Navigation */
.category-nav {
    background: white;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: var(--nav-height);
    z-index: 100;
}

.nav-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    flex-wrap: wrap;
}

.category-btn {
    background: transparent;
    border: 2px solid var(--border-light);
    color: var(--text-secondary);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
    white-space: nowrap;
}

    .category-btn:hover,
    .category-btn.active {
        background: var(--accent-green);
        border-color: var(--accent-green);
        color: white;
    }

/* Featured Collection */
.featured-collection {
    background: var(--primary-light);
}

.collection-header {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    align-items: center;
}

.collection-season {
    display: inline-block;
    color: var(--accent-green);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: var(--spacing-xs);
}

.collection-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

.collection-description {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.header-visual {
    display: flex;
    align-items: center;
    justify-content: center;
}

.visual-text {
    font-size: 8rem;
    font-weight: 900;
    color: rgba(154, 205, 50, 0.1);
    text-transform: uppercase;
    letter-spacing: -0.05em;
    line-height: 1;
}

/* Featured Grid - Magazine Layout */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    grid-auto-rows: auto;
    position: relative;
}

.product-magazine-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-medium);
    display: flex;
    flex-direction: column;
}

    .product-magazine-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    }

    /* 不同的雜誌佈局變化 */
    .product-magazine-card:nth-child(4n+1) {
        grid-row: span 2;
    }

    .product-magazine-card:nth-child(6n+3) {
        transform: rotate(-0.8deg);
    }

    .product-magazine-card:nth-child(8n+5) {
        transform: rotate(0.6deg);
    }

    .product-magazine-card:nth-child(10n+7) {
        grid-column: span 2;
    }

    /* 第一張卡片特殊樣式 */
    .product-magazine-card:first-child {
        grid-column: span 2;
        grid-row: span 2;
    }

.card-image {
    position: relative;
    height: 280px;
    overflow: hidden;
    flex-shrink: 0;
}

/* 大卡片圖片高度調整 */
.product-magazine-card:nth-child(4n+1) .card-image {
    height: 350px;
}

.product-magazine-card:nth-child(10n+7) .card-image {
    height: 250px;
}

.product-magazine-card:first-child .card-image {
    height: 400px;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-medium);
}

.product-magazine-card:hover .card-image img {
    transform: scale(1.05);
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 100%);
    opacity: 0;
    transition: opacity var(--transition-medium);
    display: flex;
    align-items: flex-end;
    padding: var(--spacing-lg);
}

/* 移除懸停時的文字覆蓋效果 */
/* .product-magazine-card:hover .card-overlay { opacity: 1; } */

.overlay-content {
    color: white;
}

.product-era {
    display: inline-block;
    background: var(--accent-green);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.overlay-content .product-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.product-story {
    font-size: 0.95rem;
    opacity: 0.9;
    line-height: 1.5;
}

/* Card Content */
.card-content {
    padding: var(--spacing-lg);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

    .card-content.compact {
        padding: var(--spacing-md);
    }

    /* 價格區塊置底 */
    .card-content .product-price-range {
        margin-top: auto;
        padding-top: var(--spacing-md);
        position: relative;
    }

/* 雜誌風格裝飾線條 */
.product-magazine-card:nth-child(7n+2)::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    width: 30px;
    height: 30px;
    border: 2px solid var(--accent-green);
    border-radius: 50%;
    opacity: 0.3;
}

.product-magazine-card:nth-child(9n+4)::after {
    content: '';
    position: absolute;
    bottom: -15px;
    right: -15px;
    width: 40px;
    height: 2px;
    background: var(--accent-warm);
    opacity: 0.4;
}

/* 商品分類圓條樣式（靠左、右側貼齊文字） */
.product-category {
    display: inline-flex; /* 依內容決定寬度 */
    align-items: center;
    justify-content: flex-start; /* 文字靠左 */
    padding: var(--spacing-xs) 0 var(--spacing-xs) var(--spacing-sm); /* 左側保留、右側貼齊 */
    border-radius: 9999px; /* 完全膠囊圓角 */
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-sm);
    width: auto; /* 不撐滿整行 */
    background-clip: padding-box;
    line-height: 1.3;
    white-space: nowrap; /* 防止斷行 */
}

    /* 顏色樣式（維持原有色系） */
    .product-category.vintage {
        background: rgba(154,205,50,0.1);
        color: #3c5314;
    }

    .product-category.accessories {
        background: rgba(154,205,50,0.1);
        color: var(--accent-green);
    }

    .product-category.collectibles {
        background: rgba(255,193,7,0.1);
        color: #f57c00;
    }

    .product-category.local {
        background: rgba(76,175,80,0.1);
        color: #3c5314;
    }

/* 手機尺寸微調，讓圓條比例更自然 */
@media (max-width: 768px) {
    .product-category {
        padding-left: 10px;
        font-size: 0.85rem;
    }
}

/* 根據類別添加不同的裝飾元素 */
.product-magazine-card[data-category="vintage"] {
    border-top: 3px solid var(--accent-warm);
}

.product-magazine-card[data-category="accessories"] {
    border-top: 3px solid var(--accent-green);
}

.product-magazine-card[data-category="local"] {
    border-top: 3px solid #388e3c;
}

.product-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.3;
}

.card-content.compact .product-title {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-xs);
}

.product-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.card-content.compact .product-description {
    font-size: 0.9rem;
    margin-bottom: var(--spacing-sm);
}

.product-details {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.9rem;
    color: var(--text-light);
}

.product-price-range {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-green);
}

.card-content.compact .product-price-range {
    font-size: 1.1rem;
}

/* Magazine Sidebar */
.magazine-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}



/* Monthly Theme */
.monthly-theme {
    background: linear-gradient(135deg, var(--accent-green) 0%, #7cb342 100%);
    color: white;
}

.theme-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    align-items: center;
}

.theme-label {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-md);
}

.theme-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

.theme-description {
    font-size: 1.1rem;
    line-height: 1.8;
    opacity: 0.9;
    margin-bottom: var(--spacing-lg);
}

.theme-stats {
    display: flex;
    gap: var(--spacing-lg);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: var(--spacing-xs);
}

/* Theme Visual Collage */
.visual-collage {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--spacing-md);
    height: 400px;
}

.collage-image {
    border-radius: var(--border-radius);
    object-fit: cover;
    width: 100%;
    height: 100%;
}

    .collage-image.main {
        grid-row: span 2;
    }

/* Shopping Guide */
.shopping-guide {
    background: var(--primary-light);
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
}

.guide-item {
    background: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.guide-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-md);
}

.guide-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.guide-description {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 雜誌風格裝飾元素 */
.featured-grid::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(154, 205, 50, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
}

/* 添加紙張質感背景 */
.featured-collection {
    position: relative;
}

    .featured-collection::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: radial-gradient(circle at 20% 30%, rgba(139, 115, 85, 0.03) 0%, transparent 50%), radial-gradient(circle at 80% 70%, rgba(154, 205, 50, 0.02) 0%, transparent 50%);
        pointer-events: none;
        z-index: 0;
    }

    .featured-collection > * {
        position: relative;
        z-index: 1;
    }

/* Responsive Design */
@media (max-width: 1024px) {
    .guide-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .products-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-content {
        order: 2;
        padding: var(--spacing-lg) var(--spacing-md);
        margin: 0;
    }

    .hero-magazine {
        order: 1;
        min-height: 300px;
    }

    .collection-header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .featured-grid {
        grid-template-columns: 1fr;
    }
    /* 手機版重置特殊排版 */
    .product-magazine-card:nth-child(4n+1),
    .product-magazine-card:nth-child(10n+7),
    .product-magazine-card:first-child {
        grid-row: auto;
        grid-column: auto;
    }

    .product-magazine-card:nth-child(6n+3),
    .product-magazine-card:nth-child(8n+5) {
        transform: none;
    }

    .magazine-sidebar {
        grid-template-columns: 1fr 1fr;
        display: grid;
    }

    .theme-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .theme-stats {
        justify-content: center;
    }

    .visual-collage {
        height: 250px;
    }
    /* Center category buttons on mobile and allow wrapping */
    .nav-wrapper {
        justify-content: center;
        overflow-x: visible;
        padding-bottom: var(--spacing-xs);
        flex-wrap: wrap;
    }

    .category-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .guide-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .hero-magazine {
        min-height: 250px;
        margin: 0 var(--spacing-md);
    }

    .theme-stats {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .visual-text {
        font-size: 4rem;
    }

    .catalog-header {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: stretch;
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================== No-Flicker Transitions ===================== */
/* 1) View Transitions：指定轉場區塊（新瀏覽器使用） */
.featured-grid {
    view-transition-name: featuredGrid;
}

/* 統一轉場節奏（可依品牌節奏調整） */
::view-transition-old(featuredGrid),
::view-transition-new(featuredGrid) {
    animation-duration: 220ms;
    animation-timing-function: ease;
}

/* 僅對指定區塊轉場，避免整頁閃爍 */
:root {
    view-transition-name: none;
}

/* 2) Fallback：舊瀏覽器的平滑過場（搭配 JS 的 is-updating / is-showing / is-hiding） */
.featured-grid.is-updating {
    opacity: 0.001; /* 非 0 可避免子元素 transition 被跳過 */
    transition: opacity 160ms ease;
    will-change: opacity;
}

.product-magazine-card {
    backface-visibility: hidden;
    transform: translateZ(0);
    transition: opacity 180ms ease, transform 220ms ease;
    will-change: opacity, transform;
    contain: content;
}

    /* 顯示過場 */
    .product-magazine-card.is-showing {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

    /* 隱藏過場（transitionend 後由 JS 設 display:none） */
    .product-magazine-card.is-hiding {
        opacity: 0;
        transform: translateY(6px) scale(0.995);
        pointer-events: none;
    }

    /* 兼容舊 class：.showing / .hiding */
    .product-magazine-card.showing {
        opacity: 1;
        transform: none;
    }

    .product-magazine-card.hiding {
        opacity: 0;
        transform: translateY(6px) scale(0.995);
        pointer-events: none;
    }

    /* 初載時確保可見 */
    .product-magazine-card:not(.is-hiding) {
        opacity: 1;
        transform: none;
    }



/* 使用者偏好：減少動態時直接切換 */
@media (prefers-reduced-motion: reduce) {
    .featured-grid.is-updating {
        transition: none;
        opacity: 1;
    }

    .product-magazine-card {
        transition: none;
    }
}
/* ---- Fix: 讓分類膠囊只跟文字寬度、右側貼齊 ---- */
.card-content .product-category {
    display: inline-flex !important; /* 依內容寬度 */
    align-items: center !important;
    align-self: flex-start !important; /* 取消被 flex 橫向撐滿 */
    width: -moz-fit-content !important; /* Firefox */
    width: fit-content !important; /* 其他瀏覽器 */
    max-width: 100% !important;
    white-space: nowrap !important;
    border-radius: 9999px !important;
    padding: var(--spacing-xs) 14px var(--spacing-xs) var(--spacing-sm) !important;
    background-clip: padding-box !important;
}
