/**
 * common.css —— 青莲居 · 水墨古风设计系统
 * 供全站页面共享：色彩令牌 / 宣纸纹理 / 墨按钮 / 印章 / 导航 / 标签 / Toast
 */

:root {
    /* 墨色与宣纸 */
    --ink: #1f1a17;
    --ink-2: #3b322c;
    --ink-soft: #6b5f55;
    --paper: #f6f0e2;
    --paper-2: #efe6d0;
    --paper-3: #e7dcc2;
    /* 竹青 */
    --bamboo: #3f6b35;
    --bamboo-light: #5c8a4e;
    --bamboo-dark: #2a4a24;
    /* 朱砂印章 */
    --cinnabar: #b03a2e;
    --cinnabar-dark: #8e2b21;
    /* 鎏金 */
    --gold: #c9a86a;
    /* 夜色 */
    --night: #0a0f25;
    --night-2: #1a2035;
    /* 月白 */
    --moonlight: #fdf6e3;

    /* 字体 */
    --font-display: 'STXingkai', '华文行楷', 'KaiTi', '楷体', serif;
    --font-serif: 'STKaiti', 'KaiTi', '华文楷体', 'Songti SC', 'SimSun', serif;

    /* 纸纹（SVG 噪点，淡墨颗粒） */
    --grain-light: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0.13 0 0 0 0 0.10 0 0 0 0 0.08 0 0 0 0.05 0'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
    --grain-dark: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.035 0'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
    /* 水墨远山（浅色页面用） */
    --mountains-ink: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1440' height='320' viewBox='0 0 1440 320' preserveAspectRatio='xMidYMax slice'><path d='M0 320 L0 210 L120 120 L260 230 L420 90 L560 240 L720 140 L860 250 L1010 110 L1180 235 L1320 150 L1440 240 L1440 320 Z' fill='%23423a30' opacity='0.10'/><path d='M0 320 L0 250 L180 160 L360 265 L540 180 L760 275 L940 190 L1160 270 L1320 200 L1440 255 L1440 320 Z' fill='%23312927' opacity='0.14'/><path d='M0 320 L0 285 L200 225 L420 290 L660 235 L920 295 L1180 240 L1440 285 L1440 320 Z' fill='%23211f1c' opacity='0.18'/></svg>");
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-serif);
    color: var(--ink);
    background-color: var(--paper);
    background-image: var(--grain-light);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(176, 58, 46, 0.18); }

/* 细卷轴滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(#b9a98c, #9a8a6d);
    border-radius: 6px;
    border: 2px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

a { color: var(--ink-2); text-decoration: none; transition: color 0.25s; }
a:hover { color: var(--cinnabar); }

/* 键盘焦点可见性（无障碍） */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- 顶部导航（浅色页面） ---------- */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.85rem 2rem;
    background: linear-gradient(rgba(246, 240, 226, 0.94), rgba(246, 240, 226, 0.86));
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(63, 107, 53, 0.28);
    box-shadow: 0 2px 14px rgba(31, 26, 23, 0.07);
}
.site-nav::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--bamboo), var(--gold), var(--bamboo), transparent);
    opacity: 0.6;
}

.nav-brand {
    font-family: var(--font-display);
    font-size: 1.55rem;
    letter-spacing: 4px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}
.nav-brand .brand-seal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--cinnabar);
    color: #f7ead6;
    font-size: 0.95rem;
    border-radius: 5px;
    border: 1.5px solid #f7ead6;
    transform: rotate(-4deg);
    box-shadow: 0 2px 6px rgba(142, 43, 33, 0.45);
}
.nav-brand:hover { color: var(--cinnabar); }

.nav-links { display: flex; gap: 1.6rem; margin-left: auto; }
.nav-links a {
    position: relative;
    font-size: 1.02rem;
    letter-spacing: 2px;
    padding: 2px 2px 6px;
    color: var(--ink-2);
}
.nav-links a::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 2px;
    background: var(--cinnabar);
    transform: translateX(-50%);
    transition: width 0.3s;
}
.nav-links a:hover::after,
.nav-links a.active::after { width: 100%; }
.nav-links a.active { color: var(--cinnabar); }

/* ---------- 页脚 ---------- */
.site-footer {
    margin-top: 4rem;
    padding: 2rem 1.5rem 2.5rem;
    text-align: center;
    color: var(--ink-soft);
    border-top: 1px solid rgba(63, 107, 53, 0.25);
    font-size: 0.92rem;
    letter-spacing: 1px;
    position: relative;
}
.site-footer::before {
    content: '❖';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--gold);
    background: var(--paper);
    padding: 0 14px;
    font-size: 1rem;
}
.site-footer .foot-links { display: flex; gap: 1.4rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.6rem; }

/* ---------- 墨按钮 ---------- */
.btn-ink {
    position: relative;
    display: inline-block;
    padding: 0.55rem 1.5rem;
    font-family: var(--font-serif);
    font-size: 1rem;
    letter-spacing: 3px;
    color: #f4ecd9;
    background: linear-gradient(160deg, #2b2622, #171310);
    border: 1px solid #050403;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 3px 8px rgba(31, 26, 23, 0.35);
    transition: transform 0.2s, box-shadow 0.25s;
}
.btn-ink::before {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 30%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.18), transparent);
    transform: skewX(-20deg);
    transition: left 0.5s;
}
.btn-ink:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(31, 26, 23, 0.45); }
.btn-ink:hover::before { left: 120%; }
.btn-ink:active { transform: translateY(0); }

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
    border: 1px solid var(--ink-soft);
    box-shadow: none;
}
.btn-ghost:hover { color: var(--cinnabar); border-color: var(--cinnabar); box-shadow: 0 3px 10px rgba(176, 58, 46, 0.15); }

.btn-cinnabar {
    background: linear-gradient(160deg, #c14a3a, #8e2b21);
    border-color: #6d1f17;
}

/* ---------- 印章 ---------- */
.seal-stamp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--cinnabar);
    color: #f7ead6;
    border: 1.5px solid #f7ead6;
    box-shadow: inset 0 0 0 3px var(--cinnabar), 0 2px 8px rgba(142, 43, 33, 0.4);
    border-radius: 4px;
    font-family: var(--font-display);
    transform: rotate(-5deg);
    user-select: none;
}

/* ---------- 标签 chips ---------- */
.chip {
    display: inline-block;
    padding: 0.25rem 0.9rem;
    border: 1px solid rgba(63, 107, 53, 0.5);
    border-radius: 999px;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: var(--bamboo-dark);
    cursor: pointer;
    background: rgba(246, 240, 226, 0.6);
    transition: all 0.25s;
    user-select: none;
}
.chip:hover { border-color: var(--cinnabar); color: var(--cinnabar); transform: translateY(-1px); }
.chip.active {
    background: var(--bamboo-dark);
    color: #eef3e2;
    border-color: var(--bamboo-dark);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 8%;
    transform: translate(-50%, 20px);
    z-index: 9999;
    padding: 0.6rem 1.6rem;
    background: linear-gradient(160deg, #2b2622, #171310);
    color: #f2e9d5;
    font-family: var(--font-serif);
    font-size: 1rem;
    letter-spacing: 2px;
    border-radius: 3px;
    border-left: 4px solid var(--gold);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s, transform 0.35s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 页面标题区 ---------- */
.page-hero {
    text-align: center;
    padding: 3.2rem 1.5rem 2.6rem;
    position: relative;
}
.page-hero::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 1.2rem;
    transform: translateX(-50%);
    width: 160px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.page-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    letter-spacing: 10px;
    color: var(--ink);
}
.page-hero .sub {
    margin-top: 0.7rem;
    color: var(--ink-soft);
    font-size: 1.05rem;
    letter-spacing: 3px;
}

/* ---------- 水墨动效 ---------- */
@keyframes inkFadeUp {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
}
.anim-up { animation: inkFadeUp 0.7s ease-out both; }
.anim-up-1 { animation-delay: 0.08s; }
.anim-up-2 { animation-delay: 0.18s; }
.anim-up-3 { animation-delay: 0.28s; }

/* 点击墨痕（浅色页面） */
.ink-splash {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(63, 107, 53, 0.28) 0%, rgba(31, 26, 23, 0.18) 40%, transparent 70%);
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%, -50%);
    animation: splashOut 0.7s ease-out forwards;
}
@keyframes splashOut {
    from { width: 0; height: 0; opacity: 0.75; }
    to { width: 130px; height: 130px; opacity: 0; }
}

/* ---------- 诗笺海报浮层 ---------- */
.poster-mask {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(8, 12, 22, 0.72);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;          /* 小屏/高图时可滚动，避免叉跑出视口 */
    animation: maskIn 0.35s ease both;
}
.poster-box {
    position: relative;
    max-height: 92vh;
    margin: auto;              /* 配合 overflow-y:auto 居中 */
    background: #f6f0e2;
    border-radius: 8px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    padding: 1.1rem;
    animation: readerIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.poster-img {
    display: block;
    max-width: min(92vw, 420px);
    max-height: 76vh;
    border-radius: 4px;
}
.poster-close {
    position: absolute;
    top: 10px;                 /* 位于盒子内部，任何视口都可达 */
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--ink-soft);
    background: rgba(246, 240, 226, 0.95);
    color: var(--ink-2);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s;
    z-index: 5;
}
.poster-close:hover { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); }
.poster-actions { margin-top: 0.8rem; display: flex; justify-content: center; }

@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes readerIn {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 动效降级（偏好减弱动态） ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
    .site-nav { padding: 0.65rem 1rem; gap: 0.8rem; flex-wrap: wrap; }
    .nav-links { gap: 0.9rem; font-size: 0.92rem; }
    .nav-brand { font-size: 1.25rem; letter-spacing: 2px; }
}
@media (max-width: 480px) {
    .site-nav { padding: 0.55rem 0.8rem; gap: 0.5rem; }
    .nav-links { gap: 0.7rem; }
    .nav-brand { font-size: 1.1rem; letter-spacing: 1px; }
    .nav-brand .brand-seal { width: 28px; height: 28px; font-size: 0.8rem; }
}
