/*
Theme Name: Product Showcase
Theme URI: 
Description: 自适应拟态化产品展示主题，支持产品展示和公告功能
Version: 2.0
Author: Your Name
License: GPL v2
*/

/* 全局重置和变量定义 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #7209b7;
    --price-color: #e74c3c;
    --bg-color: #f8f9fa;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-color: #333;
    --text-secondary: #666;
    --border-radius: 20px;
    --border-radius-sm: 12px;
    --shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
    --shadow-hover: 12px 12px 24px #d1d9e6, -12px -12px 24px #ffffff;
    --shadow-inset: inset 8px 8px 16px #d1d9e6, inset -8px -8px 16px #ffffff;
    --gap-desktop: 2rem;
    --gap-tablet: 1.5rem;
    --gap-mobile: 1rem;
    --gap-small: 0.8rem;
    --transition: all 0.3s ease;
}

/* 深色模式变量 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4895ef;
        --secondary-color: #560bad;
        --accent-color: #b5179e;
        --price-color: #ff6b6b;
        --bg-color: #121212;
        --card-bg: rgba(30, 30, 30, 0.7);
        --text-color: #e0e0e0;
        --text-secondary: #b0b0b0;
        --shadow: 8px 8px 16px #0a0a0a, -8px -8px 16px #1a1a1a;
        --shadow-hover: 12px 12px 24px #0a0a0a, -12px -12px 24px #1a1a1a;
        --shadow-inset: inset 8px 8px 16px #0a0a0a, inset -8px -8px 16px #1a1a1a;
    }
}

/* 基础样式 */
html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器样式 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    animation: fadeIn 0.5s ease-out;
}

/* 加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 公告区域样式 */
.announcement-section {
    margin-bottom: 3rem;
    animation: fadeIn 0.8s ease-out 0.1s both;
}

.announcement-box {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 2.5px solid var(--primary-color);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    border-left: 6px solid var(--accent-color);
}

.announcement-box:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.announcement-box::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary-color) 0%, transparent 70%);
    opacity: 0.1;
    z-index: 0;
}

.announcement-box::after {
    content: '📢';
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.8rem;
    opacity: 0.15;
    z-index: 1;
}

.announcement-title {
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    font-size: 1.6rem;
    font-weight: 700;
    position: relative;
    display: inline-block;
    z-index: 2;
}

.announcement-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), transparent);
    border-radius: 2px;
}

.announcement-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    position: relative;
    z-index: 2;
}

.announcement-content p {
    margin-bottom: 1rem;
}

.announcement-content p:last-child {
    margin-bottom: 0;
}

/* 产品区域样式 */
.products-section {
    animation: fadeIn 1s ease-out 0.2s both;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    text-align: center;
    position: relative;
    padding-bottom: 0.8rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    border-radius: 2px;
}

/* 产品网格 - 桌面端4列 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap-desktop);
    margin-top: 2rem;
}

/* 产品卡片样式 */
.product-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.product-image-container {
    width: 100%;
    padding-top: 133.33%; /* 3:4 比例 */
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

@media (prefers-color-scheme: dark) {
    .product-image-container {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    }
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    opacity: 0;
    animation: fadeInImage 0.5s ease 0.3s forwards;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-image.loading {
    filter: blur(10px);
    transform: scale(1.1);
}

.product-info {
    padding: 1.8rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
    z-index: 1;
}

.product-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.8rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3.5em;
}

.product-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--price-color);
    margin-top: auto;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.price-currency {
    font-size: 1rem;
    opacity: 0.8;
    margin-right: 4px;
}

.price-amount {
    font-size: 1.4rem;
    font-weight: 700;
}

.product-price::before {
    content: '💰';
    font-size: 1.2rem;
    margin-right: 8px;
    opacity: 0.7;
}

/* 无产品时的提示 */
.no-products {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.no-products p {
    margin-bottom: 1rem;
}

/* 页脚样式 */
.site-footer {
    text-align: center;
    padding: 3rem 0;
    margin-top: 4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
    position: relative;
}

.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.site-footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.site-footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* ==================== 响应式设计 ==================== */

/* 平板设备 (768px-1024px) */
@media (max-width: 1024px) {
    :root {
        --border-radius: 18px;
    }
    
    .container {
        padding: 0 1.5rem;
    }
    
    body {
        padding: 1.5rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: var(--gap-tablet);
    }
    
    .announcement-box {
        padding: 2rem;
    }
    
    .announcement-title {
        font-size: 1.5rem;
    }
    
    .announcement-content {
        font-size: 1.05rem;
    }
    
    .product-info {
        padding: 1.5rem;
    }
    
    .product-name {
        font-size: 1.2rem;
        min-height: 3.2em;
    }
    
    .product-price {
        font-size: 1.3rem;
    }
}

/* 手机设备 (480px-768px) - 关键修改：两列显示 */
@media (max-width: 768px) {
    :root {
        --border-radius: 16px;
    }
    
    html {
        font-size: 15px;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    body {
        padding: 1rem;
    }
    
    .announcement-section {
        margin-bottom: 2.5rem;
    }
    
    .announcement-box {
        padding: 1.8rem;
        border-width: 2px;
        border-left-width: 5px;
    }
    
    .announcement-box::after {
        font-size: 1.5rem;
        top: 1.2rem;
        right: 1.2rem;
    }
    
    .announcement-title {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }
    
    .announcement-content {
        font-size: 1rem;
        line-height: 1.7;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 1.2rem;
    }
    
    /* 核心修改：移动端显示两列 */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--gap-mobile);
    }
    
    .product-card {
        border-radius: var(--border-radius-sm);
    }
    
    .product-info {
        padding: 1.2rem;
    }
    
    .product-name {
        font-size: 1.1rem;
        min-height: 3em;
        -webkit-line-clamp: 2;
        line-height: 1.4;
    }
    
    .product-price {
        font-size: 1.2rem;
        padding-top: 1rem;
    }
    
    .price-amount {
        font-size: 1.2rem;
    }
}

/* 小手机设备 (小于480px) */
@media (max-width: 480px) {
    :root {
        --border-radius: 14px;
    }
    
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 0 0.8rem;
    }
    
    body {
        padding: 0.8rem;
    }
    
    .announcement-section {
        margin-bottom: 2rem;
    }
    
    .announcement-box {
        padding: 1.5rem;
    }
    
    .announcement-box::after {
        display: none; /* 小屏幕上隐藏图标节省空间 */
    }
    
    .announcement-title {
        font-size: 1.3rem;
    }
    
    .announcement-content {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .section-title {
        font-size: 1.3rem;
    }
    
    /* 保持两列显示，但减小间距 */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.8rem;
    }
    
    .product-image-container {
        padding-top: 133.33%; /* 保持3:4比例 */
    }
    
    .product-info {
        padding: 1rem 0.8rem;
    }
    
    .product-name {
        font-size: 1rem;
        min-height: 2.8em;
        -webkit-line-clamp: 2;
        line-height: 1.3;
    }
    
    .product-price {
        font-size: 1.1rem;
        padding-top: 0.8rem;
    }
    
    .price-amount {
        font-size: 1.1rem;
    }
    
    .price-currency {
        font-size: 0.9rem;
    }
    
    .product-price::before {
        font-size: 1rem;
    }
}

/* 超小手机设备 (小于360px) */
@media (max-width: 360px) {
    /* 超小屏幕切换为一列显示 */
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 0.8rem;
    }
    
    .product-name {
        min-height: auto;
        -webkit-line-clamp: 2;
    }
    
    .announcement-box {
        padding: 1.2rem;
    }
    
    .announcement-title {
        font-size: 1.2rem;
    }
    
    .announcement-content {
        font-size: 0.9rem;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 横屏显示三列 */
        gap: var(--gap-mobile);
    }
    
    .announcement-box {
        padding: 1.5rem;
    }
    
    .product-name {
        min-height: 2.5em;
        -webkit-line-clamp: 2;
    }
}

/* 超高手机设备优化 */
@media (min-width: 481px) and (max-width: 768px) and (min-height: 800px) {
    .products-grid {
        gap: 1.2rem;
    }
    
    .product-card {
        border-radius: 18px;
    }
    
    .product-info {
        padding: 1.5rem;
    }
    
    .product-name {
        font-size: 1.15rem;
        min-height: 3.2em;
    }
}

/* 触摸优化 */
@media (max-width: 768px) {
    /* 提高触摸目标尺寸 */
    .product-card {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        touch-action: manipulation;
    }
    
    .product-card:active {
        transform: scale(0.98) translateY(0);
        transition: transform 0.1s ease;
    }
    
    /* 防止双击缩放 */
    .product-card,
    .announcement-box {
        touch-action: manipulation;
    }
    
    /* 提高按钮区域 */
    a, button, [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 优化滚动性能 */
    .products-grid {
        will-change: transform;
    }
}

/* 打印样式 */
@media print {
    .announcement-box,
    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .container {
        max-width: none;
    }
    
    .products-grid {
        display: block;
    }
    
    .product-card {
        margin-bottom: 1cm;
    }
}
