/**
 * common.css — 公共基础样式
 * 茶文化主题 · 沉墨青绿 × 古铜金
 *
 * 包含：CSS Reset / 设计令牌（颜色、字号、间距、圆角、阴影、动效）/
 *       基础排版 / Flex 与 Grid 栅格 / 通用容器 / 实用工具类
 *
 * 颜色基调取自现有页面内联样式：
 *   - 深茶绿 #2d3e2e   - 中茶绿 #436546   - 浅茶绿 #b2d1b5
 *   - 古铜金 #d4a55e   - 暗金   #b8934c   - 米金   #f1e1b5
 *   - 米白纸 #f9f7f2   - 浅卡纸 #f1ede4   - 暖象牙 #f5f1e6
 *   - 文字棕 #6e5c48   - 边线灰 #e8e0d5   - 警示红 #d32f2f
 */

/* ========================================================================
   1. CSS Reset / Normalize
   ======================================================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: 1.6;
    color: var(--color-text);
    background: var(--bg-page);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* 全局背景柔光（与现有 index.php 一致） */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(178, 209, 181, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(212, 165, 94, 0.05) 0%, transparent 20%);
    z-index: -1;
    pointer-events: none;
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    user-select: none;
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color var(--t-fast) ease;
}

a:hover {
    color: var(--color-gold);
}

ul,
ol {
    list-style: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(232, 224, 213, 0.4);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--color-tea-mid), var(--color-tea-dark));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
}

/* 选区颜色 */
::selection {
    background: rgba(212, 165, 94, 0.35);
    color: var(--color-tea-dark);
}

/* ========================================================================
   2. 设计令牌（CSS Variables）
   ======================================================================== */
:root {
    /* —— 字体 —— */
    --font-body: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Segoe UI', sans-serif;
    --font-display: 'TeaFont', 'KaiTi', 'STKaiti', 'SimKai', cursive;
    --font-mono: 'SF Mono', Consolas, Menlo, monospace;

    /* —— 字号阶梯 —— */
    --fs-xs:    0.75rem;  /* 12px */
    --fs-sm:    0.85rem;  /* 13.6px */
    --fs-base:  0.95rem;  /* 15.2px */
    --fs-md:    1rem;     /* 16px */
    --fs-lg:    1.15rem;  /* 18.4px */
    --fs-xl:    1.35rem;  /* 21.6px */
    --fs-2xl:   1.6rem;   /* 25.6px */
    --fs-3xl:   2rem;     /* 32px */
    --fs-4xl:   2.4rem;   /* 38.4px */

    /* —— 字重 —— */
    --fw-light:    300;
    --fw-normal:   400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;

    /* —— 主题色：茶绿 —— */
    --color-tea-dark:    #2d3e2e;
    --color-tea-mid:     #436546;
    --color-tea-light:   #b2d1b5;
    --color-tea-soft:    rgba(67, 101, 70, 0.1);

    /* —— 主题色：古铜金 —— */
    --color-gold:        #d4a55e;
    --color-gold-dark:   #b8934c;
    --color-gold-soft:   #f1e1b5;
    --color-gold-glow:   rgba(212, 165, 94, 0.2);

    /* —— 中性 / 米色系 —— */
    --color-paper:       #f9f7f2;
    --color-paper-2:     #f1ede4;
    --color-ivory:       #f5f1e6;
    --color-line:        #e8e0d5;
    --color-text:        #2d3e2e;
    --color-text-warm:   #6e5c48;
    --color-text-muted:  #8c6d46;

    /* —— 状态色 —— */
    --color-success:     #2e7d32;
    --color-warning:     #e8a33d;
    --color-danger:      #d32f2f;
    --color-danger-dark: #b71c1c;
    --color-info:        #4a90a4;

    /* —— 链接 —— */
    --color-link:        var(--color-tea-mid);

    /* —— 渐变 —— */
    --grad-tea:    linear-gradient(135deg, #2d3e2e, #436546);
    --grad-tea-95: linear-gradient(135deg, rgba(45, 62, 46, 0.95), rgba(67, 101, 70, 0.95));
    --grad-gold:   linear-gradient(135deg, #d4a55e, #b8934c);
    --grad-page:   linear-gradient(135deg, #f9f7f2 0%, #f1ede4 100%);
    --grad-line:   linear-gradient(to right, #2d3e2e, #436546, #d4a55e);

    /* —— 页面背景 —— */
    --bg-page:    var(--grad-page);
    --bg-card:    rgba(255, 255, 255, 0.95);
    --bg-soft:    rgba(249, 247, 242, 0.8);

    /* —— 间距 —— */
    --sp-1:  0.25rem;
    --sp-2:  0.5rem;
    --sp-3:  0.75rem;
    --sp-4:  1rem;
    --sp-5:  1.25rem;
    --sp-6:  1.5rem;
    --sp-8:  2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;
    --sp-16: 4rem;

    /* —— 圆角 —— */
    --r-xs:    4px;
    --r-sm:    6px;
    --r-md:    8px;
    --r-lg:    12px;
    --r-xl:    16px;
    --r-pill:  999px;
    --r-circle: 50%;

    /* —— 阴影：低饱和茶绿色阴影 —— */
    --sh-xs: 0 2px 6px rgba(45, 62, 46, 0.06);
    --sh-sm: 0 4px 12px rgba(45, 62, 46, 0.08);
    --sh-md: 0 5px 15px rgba(45, 62, 46, 0.1);
    --sh-lg: 0 8px 30px rgba(45, 62, 46, 0.15);
    --sh-xl: 0 15px 40px rgba(45, 62, 46, 0.2);
    --sh-gold: 0 4px 14px rgba(212, 165, 94, 0.35);

    /* —— 边框 —— */
    --bd-line:  1px solid var(--color-line);
    --bd-gold:  1px solid rgba(212, 165, 94, 0.3);

    /* —— 动效曲线/时长 —— */
    --t-fast:   0.2s;
    --t-base:   0.3s;
    --t-slow:   0.5s;
    --ease-out:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* —— 层级 —— */
    --z-dropdown: 100;
    --z-sticky:   500;
    --z-sidebar:  1000;
    --z-nav:      1001;
    --z-modal:    2000;
    --z-toast:    3000;

    /* —— 容器宽度 —— */
    --w-xs:  640px;
    --w-sm:  768px;
    --w-md:  960px;
    --w-lg:  1200px;
    --w-xl:  1300px;
}

/* ========================================================================
   3. 字体定义（保持与现有页面一致）
   ======================================================================== */
@font-face {
    font-family: 'TeaFont';
    src: local('KaiTi'), local('STKaiti'), local('SimKai');
    font-display: swap;
}

/* ========================================================================
   4. 基础排版
   ======================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--color-tea-dark);
    line-height: 1.3;
    font-weight: var(--fw-semibold);
    letter-spacing: 1px;
}

h1 { font-size: var(--fs-4xl); letter-spacing: 3px; }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }

p {
    margin: 0 0 var(--sp-4);
}

p:last-child { margin-bottom: 0; }

small {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

strong, b { font-weight: var(--fw-semibold); }
em, i { font-style: italic; color: var(--color-text-warm); }

code, kbd, pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: rgba(232, 224, 213, 0.5);
    padding: 0.1em 0.4em;
    border-radius: var(--r-xs);
}

pre {
    padding: var(--sp-4);
    overflow-x: auto;
    line-height: 1.5;
}

hr {
    border: none;
    border-top: 1px dashed var(--color-line);
    margin: var(--sp-6) 0;
}

blockquote {
    border-left: 4px solid var(--color-gold);
    padding: var(--sp-3) var(--sp-5);
    background: var(--bg-soft);
    color: var(--color-text-warm);
    font-style: italic;
    border-radius: 0 var(--r-md) var(--r-md) 0;
    margin: var(--sp-5) 0;
}

/* 顶部装饰分隔（茶文化页面常用的菱形装饰） */
.divider-tea {
    text-align: center;
    position: relative;
    margin: var(--sp-8) 0;
}

.divider-tea::before,
.divider-tea::after {
    content: "";
    position: absolute;
    top: 50%;
    width: calc(50% - 30px);
    height: 1px;
    background: linear-gradient(to right, transparent, var(--color-gold), transparent);
}

.divider-tea::before { left: 0; }
.divider-tea::after  { right: 0; }

.divider-tea span {
    display: inline-block;
    color: var(--color-gold);
    font-size: 1.4rem;
}

/* ========================================================================
   5. 通用容器
   ======================================================================== */
.container {
    width: 100%;
    max-width: var(--w-xl);
    margin: 0 auto;
    padding: 0 var(--sp-6);
}

.container-md { max-width: var(--w-md); }
.container-lg { max-width: var(--w-lg); }
.container-narrow { max-width: var(--w-xs); }

/* 卡片化的内容板（与现有 .product-detail 的玻璃质感一致） */
.panel {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    padding: var(--sp-8);
    box-shadow: var(--sh-lg);
    border: var(--bd-gold);
    backdrop-filter: blur(10px);
    position: relative;
}

/* 顶部三色装饰条 */
.panel--ribbon::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--grad-line);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.panel-soft {
    background: var(--bg-soft);
    border-radius: var(--r-lg);
    padding: var(--sp-6);
    border: var(--bd-gold);
    border-left: 4px solid var(--color-gold);
}

/* ========================================================================
   6. Flex 与 Grid 栅格
   ======================================================================== */
.flex          { display: flex; }
.inline-flex  { display: inline-flex; }
.flex-col      { flex-direction: column; }
.flex-row      { flex-direction: row; }
.flex-wrap     { flex-wrap: wrap; }
.flex-nowrap   { flex-wrap: nowrap; }
.flex-1        { flex: 1 1 0; }
.flex-auto     { flex: 1 1 auto; }
.flex-none     { flex: none; }

.items-start    { align-items: flex-start; }
.items-center   { align-items: center; }
.items-end      { align-items: flex-end; }
.items-stretch  { align-items: stretch; }

.justify-start    { justify-content: flex-start; }
.justify-center   { justify-content: center; }
.justify-end      { justify-content: flex-end; }
.justify-between  { justify-content: space-between; }
.justify-around   { justify-content: space-around; }

.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }

/* 12 栅格（基于 Grid，简洁） */
.grid          { display: grid; gap: var(--sp-6); }
.grid-cols-1   { grid-template-columns: 1fr; }
.grid-cols-2   { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3   { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4   { grid-template-columns: repeat(4, 1fr); }
.grid-cols-6   { grid-template-columns: repeat(6, 1fr); }
.grid-cols-12  { grid-template-columns: repeat(12, 1fr); }

/* 自适应栅格（产品列表常用） */
.grid-auto-fill {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.8rem;
}

.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-6);
}

/* 跨列 */
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.col-span-6 { grid-column: span 6; }
.col-span-12 { grid-column: span 12; }

/* ========================================================================
   7. 实用工具类
   ======================================================================== */
.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.text-xs   { font-size: var(--fs-xs); }
.text-sm   { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-lg   { font-size: var(--fs-lg); }
.text-xl   { font-size: var(--fs-xl); }

.text-tea       { color: var(--color-tea-dark); }
.text-gold      { color: var(--color-gold); }
.text-warm      { color: var(--color-text-warm); }
.text-muted     { color: var(--color-text-muted); }
.text-danger    { color: var(--color-danger); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }

.fw-light    { font-weight: var(--fw-light); }
.fw-normal   { font-weight: var(--fw-normal); }
.fw-medium   { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold     { font-weight: var(--fw-bold); }

.font-display { font-family: var(--font-display); }

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-clamp-2,
.text-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.text-clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.text-clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* 显示/隐藏 */
.hidden    { display: none !important; }
.invisible { visibility: hidden; }
.block     { display: block; }
.inline    { display: inline; }
.inline-block { display: inline-block; }

/* 间距工具（仅常用，避免膨胀） */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.my-4 { margin-top: var(--sp-4); margin-bottom: var(--sp-4); }
.my-6 { margin-top: var(--sp-6); margin-bottom: var(--sp-6); }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-2 { padding: var(--sp-2); }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }
.p-8 { padding: var(--sp-8); }

/* 圆角 */
.rounded     { border-radius: var(--r-md); }
.rounded-lg  { border-radius: var(--r-lg); }
.rounded-xl  { border-radius: var(--r-xl); }
.rounded-pill { border-radius: var(--r-pill); }
.rounded-circle { border-radius: var(--r-circle); }

/* 阴影 */
.shadow-sm { box-shadow: var(--sh-sm); }
.shadow    { box-shadow: var(--sh-md); }
.shadow-lg { box-shadow: var(--sh-lg); }

/* 定位 */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

/* 鼠标 */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* 禁止选中 / 触摸优化 */
.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* ========================================================================
   8. 全局动画
   ======================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}

@keyframes pulse-gold {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 165, 94, 0.5); }
    50%      { box-shadow: 0 0 0 12px rgba(212, 165, 94, 0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-fade      { animation: fadeIn var(--t-slow) ease both; }
.animate-fade-up   { animation: fadeInUp var(--t-slow) var(--ease-out) both; }
.animate-float     { animation: float 3s ease-in-out infinite; }
.animate-pulse     { animation: pulse-gold 2s ease-in-out infinite; }

/* 动效偏好：尊重系统设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
