@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;700&family=Inter:wght@200;400;600&display=swap');

:root { 
    --bg: #fafaf8; 
    --text: #1a1a1a; 
    --accent: #555555; 
    --border: #eeeeee;
}
.dim { 
    --bg: #d5d5d0; 
    --text: #2a2a2a; 
    --accent: #666666; 
    --border: #b8b8b5;
}
.dark { 
    --bg: #1a1a18; 
    --text: #e5e5e5; 
    --accent: #a0a0a0; 
    --border: #222222;
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    margin: 0;
    will-change: background;
}

.serif { font-family: 'Noto Serif SC', serif; }

/* 左侧空间导航 */
#space-nav {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 100;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 80px 0 40px 0;
    overflow-y: auto;
}
#space-nav.show {
    left: 0;
}
.space-trigger {
    position: fixed;
    left: 0;
    top: 0;
    width: 20px;
    height: 100vh;
    z-index: 99;
    cursor: pointer;
}
.space-trigger:hover + #space-nav,
#space-nav:hover {
    left: 0;
}

/* 左侧切换提示标志 */
.space-hint {
    position: fixed;
    left: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    transform-origin: center;
    z-index: 98;
    pointer-events: none;
    opacity: 0.25;
    transition: opacity 0.3s ease;
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-weight: 400;
}
.space-hint::before {
    content: '◂';
    margin-right: 8px;
    display: inline-block;
    transform: rotate(90deg);
    font-size: 8px;
}
.space-trigger:hover ~ .space-hint,
#space-nav:hover ~ .space-hint {
    opacity: 0;
}
.space-item {
    padding: 16px 32px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.4;
    font-size: 18px;
    letter-spacing: 0.1em;
}
.space-item:hover {
    opacity: 0.8;
    padding-left: 40px;
}
.space-item.active {
    opacity: 1;
    font-weight: 600;
    border-left: 3px solid var(--text);
}

/* 空间切换诗句提示 */
#space-poem-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
#space-poem-overlay.show {
    opacity: 1;
    pointer-events: all;
}
#space-poem-text {
    font-size: 32px;
    letter-spacing: 0.2em;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
#space-poem-overlay.show #space-poem-text {
    opacity: 1;
    transform: translateY(0);
}

/* 天平加载动画 */
#loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 1.2s cubic-bezier(0.85, 0, 0.15, 1), opacity 0.8s ease;
}
#loader.fade-out {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.libra-container {
    width: 160px;
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.libra-svg {
    width: 96px;
    height: 96px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.libra-beam {
    transform-origin: 12px 10px;
    animation: beam-swing 4s infinite ease-in-out;
}

.libra-pan-l {
    transform-origin: 4px 10px;
    animation: pan-swing-l 4s infinite ease-in-out;
}

.libra-pan-r {
    transform-origin: 20px 10px;
    animation: pan-swing-r 4s infinite ease-in-out;
}

@keyframes beam-swing {
    0%, 100% { transform: rotate(-8deg); }
    50% { transform: rotate(8deg); }
}

@keyframes pan-swing-l {
    0%, 100% { transform: translateY(2px) rotate(8deg); }
    50% { transform: translateY(-2px) rotate(-8deg); }
}

@keyframes pan-swing-r {
    0%, 100% { transform: translateY(-2px) rotate(8deg); }
    50% { transform: translateY(2px) rotate(-8deg); }
}

#loader.stopped * {
    animation: none !important;
}

.glass { 
    background: rgba(255,255,255,0.8); 
    backdrop-filter: blur(15px); 
    -webkit-backdrop-filter: blur(15px); 
    border-bottom: 1px solid var(--border); 
}
.dark .glass { background: rgba(13,13,13,0.8); }

.post-card-inner {
    transition: all 0.4s ease;
    border: 1px solid var(--border);
    height: 100%;
    border-radius: 16px;
    animation: breathe 6s ease-in-out infinite;
}
.post-card:hover .post-card-inner {
    background: rgba(0,0,0,0.02);
    transform: translateY(-4px);
    animation: none;
}
.dark .post-card:hover .post-card-inner {
    background: rgba(255,255,255,0.03);
}

@keyframes breathe {
    0%, 100% { 
        transform: translateY(0px) scale(1);
        box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    }
    50% { 
        transform: translateY(-6px) scale(1.005);
        box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    }
}

#poem-display {
    transition: opacity 1s ease;
    opacity: 1;
}
.poem-fade { 
    opacity: 0 !important; 
}

.sync-active { animation: pulse 2s infinite; }
@keyframes pulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.8; }
    100% { opacity: 0.3; }
}

/* 心情选择器 */
.mood-selector {
    display: flex;
    gap: 12px;
    margin: 16px 0;
}
.mood-option {
    font-size: 28px;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.3s ease;
    filter: grayscale(1);
}
.mood-option:hover {
    opacity: 0.8;
    transform: scale(1.2);
    filter: grayscale(0);
}
.mood-option.selected {
    opacity: 1;
    transform: scale(1.3);
    filter: grayscale(0);
}

/* 点赞动画 */
.reaction-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}
.reaction-btn {
    font-size: 24px;
    cursor: pointer;
    opacity: 0.2;
    transition: all 0.3s ease;
    user-select: none;
}
.reaction-btn:hover {
    opacity: 0.6;
    transform: scale(1.2);
}
.reaction-btn.active {
    opacity: 1;
    animation: heartbeat 0.6s ease;
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1.1); }
    75% { transform: scale(1.25); }
}
.reaction-count {
    font-size: 14px;
    opacity: 0.5;
}

/* 首页图片预览 */
.post-preview-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 16px;
    background: var(--border);
    transition: opacity 0.3s ease;
}
.post-preview-image[loading="lazy"] {
    opacity: 0;
}
.post-preview-image.loaded {
    opacity: 1;
}

/* 页面切换动画 */
main > section {
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
}
main > section.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    position: absolute;
    width: 100%;
}
main > section:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    position: relative;
}

/* 预加载优化 */
main {
    position: relative;
    min-height: 100vh;
}

/* 卡片动画优化 - 添加硬件加速 */
.post-card-inner {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* 空间导航优化 */
#space-nav {
    will-change: left;
    backface-visibility: hidden;
}

/* 诗句切换优化 */
#poem-display {
    will-change: opacity;
}

/* 列表容器淡入效果 */
#list-container {
    transition: opacity 0.3s ease;
}

/* 主题切换光束动画 */
.theme-transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 9997;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
}

/* 暗到亮：光波扩散（优化版） */
.theme-transition-overlay.light-burst {
    background: radial-gradient(circle at var(--burst-x, 50%) var(--burst-y, 50%), 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.8) 15%,
        rgba(255, 255, 255, 0) 60%);
    animation: light-burst 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes light-burst {
    0% {
        opacity: 0;
        transform: translate3d(0, 0, 0) scale(0.3);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate3d(0, 0, 0) scale(2.5);
    }
}

/* 亮到暗：整体渐暗（优化版） */
.theme-transition-overlay.dark-fade {
    background: radial-gradient(circle at 50% 50%, 
        transparent 0%, 
        rgba(0, 0, 0, 0.2) 30%,
        rgba(0, 0, 0, 0.8) 100%);
    animation: dark-fade 0.8s ease-out forwards;
}

@keyframes dark-fade {
    0% {
        opacity: 0;
        transform: translate3d(0, 0, 0) scale(1.05);
    }
    50% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate3d(0, 0, 0) scale(0.98);
    }
}
