/* 自定义样式 */

:root {
    /* --- 全新色彩规范体系 (Light Mode) --- */
    --brand-primary: #6366f1;    /* Indigo 600 - 主色 */
    --brand-secondary: #10b981;  /* Emerald 500 - 辅助色 (成功/系统状态) */
    --brand-accent: #f43f5e;     /* Rose 500 - 强调色 (心跳/警示) */
    
    /* 中性色 */
    --bg-primary: #f8fafc;       /* Slate 50 - 页面底色 */
    --bg-secondary: #ffffff;     /* White - 卡片/导航底色 */
    --bg-tertiary: #f1f5f9;      /* Slate 100 - 输入框/非强调背景 */
    
    --text-primary: #0f172a;     /* Slate 900 - 标题/正文 */
    --text-secondary: #475569;   /* Slate 600 - 次要信息/摘要 */
    --text-muted: #94a3b8;       /* Slate 400 - 占位符/禁用态 */
    
    --border-color: #e2e8f0;     /* Slate 200 - 标准边框 */
    --border-light: #f1f5f9;     /* Slate 100 - 极浅边框 */
    
    /* 阴影规范 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* 动画配置 */
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* --- 暗色模式适配 --- */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --border-light: #1e293b;
    
    --brand-primary: #818cf8;    /* Indigo 400 */
    --brand-secondary: #34d399;  /* Emerald 400 */
}

* {
    /* 移除通用 transition，减少重绘负担 */
}

/* 针对性添加 transition */
.post-card, .category-pill, button, a, .heart-particle {
    transition: background-color var(--transition-base), color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] body {
    background-image: 
        radial-gradient(rgba(52, 211, 153, 0.05) 1px, transparent 1px),
        linear-gradient(to right, rgba(52, 211, 153, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(52, 211, 153, 0.02) 1px, transparent 1px);
    background-size: 32px 32px, 128px 128px, 128px 128px;
}

.glass-nav {
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

/* 覆盖 Tailwind 的一些默认颜色 */
[data-theme="dark"] .text-slate-900,
[data-theme="dark"] .text-slate-800,
[data-theme="dark"] .text-slate-700 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-slate-600,
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-400 {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-slate-50 {
    background-color: var(--bg-secondary) !important;
}

/* 图片加载状态 */
img {
    transition: opacity 0.5s ease-in-out;
}

/* 自定义动画 */
@keyframes bounce-slow {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-bounce-slow {
    animation: bounce-slow 3s ease-in-out infinite;
}

img:not([src]) {
    opacity: 0;
}

img[src] {
    opacity: 1;
}

.img-loading {
    background: var(--bg-tertiary) animate-pulse;
}

/* 骨架屏自定义动画 */
@keyframes skeleton-loading {
    0% { background-color: var(--bg-tertiary); }
    50% { background-color: var(--border-color); }
    100% { background-color: var(--bg-tertiary); }
}

.skeleton-card .animate-pulse {
    animation: skeleton-loading 1.5s ease-in-out infinite;
}
[data-theme="dark"] .bg-slate-100\/50 {
    background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] input::placeholder {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] input {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .modal-blur {
    backdrop-filter: blur(12px) brightness(0.5);
    -webkit-backdrop-filter: blur(12px) brightness(0.5);
}

[data-theme="dark"] .border-slate-100,
[data-theme="dark"] .border-slate-200 {
    border-color: var(--border-color) !important;
}

/* 按钮旋转动画 */
#theme-toggle .material-symbols-outlined {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#theme-toggle:hover .material-symbols-outlined {
    transform: rotate(45deg);
}

[data-theme="dark"] #theme-toggle .material-symbols-outlined {
    transform: rotate(360deg);
}

.post-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.post-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-shadow-hover);
}

/* 交互增强 */
a:focus-visible, 
button:focus-visible, 
input:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.category-pill {
    color: var(--text-secondary);
    background-color: transparent;
    border: none;
}

.category-pill.active {
    background-color: white;
    color: var(--brand-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .category-pill.active {
    background-color: var(--brand-primary);
    color: white;
}

.category-pill:not(.active):hover {
    color: var(--text-primary);
    background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .category-pill:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#postsGrid, #latestGrid, #moreGrid {
    transition: opacity 0.3s ease-in-out;
}

/* --- 全局进入动画 --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
    animation: fadeInUp var(--transition-slow) forwards;
}

/* 渐进式加载动画系统 (Sequential Reveal) */
.reveal-item {
    opacity: 0 !important;
    transform: translateY(20px) !important;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}

.reveal-item.is-revealed {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* 兼容性与无障碍降级 */
@media (prefers-reduced-motion: reduce) {
    .reveal-item {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    .animate-fade-in-up {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* 延迟出现效果 */
.delay-100 { transition-delay: 100ms !important; animation-delay: 100ms; }
.delay-200 { transition-delay: 200ms !important; animation-delay: 200ms; }
.delay-300 { transition-delay: 300ms !important; animation-delay: 300ms; }
.delay-400 { transition-delay: 400ms !important; animation-delay: 400ms; }
.delay-500 { transition-delay: 500ms !important; animation-delay: 500ms; }
.delay-600 { transition-delay: 600ms !important; animation-delay: 600ms; }
.delay-700 { transition-delay: 700ms !important; animation-delay: 700ms; }
.delay-800 { transition-delay: 800ms !important; animation-delay: 800ms; }
.delay-1000 { transition-delay: 1000ms !important; animation-delay: 1000ms; }

/* 卡片悬停提升感 */
.hover-lift {
    transition: var(--transition-base);
}
.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.skill-progress {
    transition: width 1.5s cubic-bezier(0.1, 0, 0.2, 1);
}

.modal-blur {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-color) 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 动态图片链接样式 */
.dyn-img-link-wrapper-di-script {
    anchor-scope: all;
    display: contents;
    position: relative;
    z-index: 1;
}

.dyn-img-link-wrapper-di-script img {
    anchor-name: --photo;
    display: block;
    max-width: 100%;
}

.dyn-img-link-di-script {
    z-index: 999999;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    color: white;
    height: clamp(13px, calc(max(anchor-size(width), anchor-size(height)) * 0.3), 21px);
    width: clamp(13px, calc(max(anchor-size(width), anchor-size(height)) * 0.3), 21px);
    padding: 4px;
    position: absolute;

    bottom: anchor(bottom);
    left: anchor(left);
    margin-left: 10px;
    margin-bottom: 10px;

    transition: background-color 0.2s ease-in-out;
}

.dyn-img-link-di-script:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.dyn-img-link-di-script span {
    font-size: 14px;
    vertical-align: top;
}

.dyn-img-attribution-button-di-script {
    z-index: 999999;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    color: white;
    width: clamp(13px, calc(max(anchor-size(width), anchor-size(height)) * 0.3), 21px);
    height: clamp(13px, calc(max(anchor-size(width), anchor-size(height)) * 0.3), 21px);
    padding: 4px;

    position: absolute;
    position-anchor: --photo;
    top: anchor(top);
    right: anchor(right);
    margin-top: 10px;
    margin-right: 10px;

    transition: background-color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dyn-img-attribution-button-di-script:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.dyn-img-attribution-button-di-script span {
    font-size: 14px;
    vertical-align: top;
}

.dyn-img-inline-attribution-di-script {
    z-index: 999999;
    font-size: 12px;
    padding: 4px;
    display: none;

    position: absolute;
    position-anchor: --photo;
    bottom: anchor(bottom);
    right: anchor(right);
    margin-bottom: 8px;
    margin-right: 8px;

    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;

    white-space: nowrap;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    color: white;
}

/* 交互动效与组件 */
.heart-particle {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    font-size: 1.5rem;
    user-select: none;
    animation: heart-burst 0.8s cubic-bezier(0.1, 0.6, 0.4, 1) forwards;
}

@keyframes heart-burst {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.5) rotate(var(--rot));
        opacity: 0;
    }
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #10b981;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.error-modal {
    background: white;
    padding: 2rem;
    border-radius: 2rem;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .error-modal {
    transform: scale(1);
}

[data-theme="dark"] .error-modal {
    background: #1e293b;
    color: white;
}

