/* ============================================
   平平的小破站 - 全局美化增强包
   版本: 1.0
   说明: 跨所有页面通用，通过 main.css @import 引入
   使用低特异性选择器，不破坏各页面独立样式
   ============================================ */

/* ============================================
   1. 全局字体优化 - 统一字体渲染
   ============================================ */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: 0.02em;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.01em;
    line-height: 1.3;
}

/* ============================================
   2. 滚动条美化增强
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4f46e5, #7c3aed);
    background-clip: padding-box;
}

/* Firefox 滚动条 */
* {
    scrollbar-width: thin;
    scrollbar-color: #6366f1 transparent;
}

/* ============================================
   3. 选中文字美化
   ============================================ */
::selection {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
    color: inherit;
}

/* ============================================
   4. 链接悬停通用增强
   ============================================ */
a {
    transition: color 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}

/* ============================================
   5. 图片通用美化
   ============================================ */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.4s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"][src]:not([src=""]) {
    opacity: 1;
}

/* ============================================
   6. 页面入场动画
   ============================================ */
body {
    animation: pageEnter 0.5s ease-out;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   7. 所有卡片类通用悬浮增强
   ============================================ */
.blog-card,
.card,
.category-item,
.category-card,
.article-item,
.contact-item,
.hobby-item,
.skill-category,
.friend-card,
.link-card {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.35s ease;
}

.blog-card:hover,
.card:hover,
.category-item:hover,
.category-card:hover,
.article-item:hover,
.contact-item:hover,
.hobby-item:hover,
.skill-category:hover,
.friend-card:hover,
.link-card:hover {
    box-shadow: 0 20px 40px -12px rgba(99, 102, 241, 0.15),
                0 8px 20px -8px rgba(0, 0, 0, 0.08);
}

/* ============================================
   8. 按钮通用美化 - 光泽扫过效果
   ============================================ */
.btn,
button,
.blog-link,
input[type="submit"] {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::after,
button::after,
.blog-link::after,
input[type="submit"]::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transform: skewX(-15deg);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn:hover::after,
button:hover::after,
.blog-link:hover::after,
input[type="submit"]:hover::after {
    left: 120%;
}

/* ============================================
   9. 输入框聚焦增强
   ============================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15),
                0 0 12px rgba(99, 102, 241, 0.08);
}

/* ============================================
   10. Section 标题装饰增强
   ============================================ */
.section-title,
h2,
h3 {
    position: relative;
}

/* 渐变下划线增强 */
.section-title::after,
h2::after {
    background: linear-gradient(90deg, #6366f1, #ec4899, #06b6d4) !important;
    border-radius: 2px;
}

/* ============================================
   11. Header 导航栏玻璃拟态增强
   ============================================ */
header,
.main-header {
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
}

/* ============================================
   12. Footer 渐变分隔条
   ============================================ */
footer,
.main-footer {
    position: relative;
}

footer::before,
.main-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #ec4899, #06b6d4, #6366f1);
    background-size: 300% 100%;
    animation: footerGradient 6s ease infinite;
}

@keyframes footerGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ============================================
   13. 标签云美化
   ============================================ */
.tag,
.blog-category {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tag:hover,
.blog-category:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: #fff !important;
    border-color: transparent !important;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

/* ============================================
   14. 技能进度条动画增强
   ============================================ */
.skill-progress-bar,
.progress-bar-inner {
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899) !important;
    background-size: 200% 100% !important;
    animation: progressShimmer 2s ease-in-out infinite !important;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   15. 社交图标悬浮增强
   ============================================ */
.social-icon,
.social-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.social-icon:hover,
.social-link:hover {
    transform: translateY(-4px) scale(1.1) !important;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.35);
}

/* ============================================
   16. 返回顶部按钮美化
   ============================================ */
#back-to-top,
.back-to-top {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#back-to-top:hover,
.back-to-top:hover {
    transform: translateY(-4px) scale(1.08) !important;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5),
                0 0 20px rgba(99, 102, 241, 0.2);
}

/* ============================================
   17. 文章内容排版美化
   ============================================ */
.article-content,
.blog-content,
.bio-text,
.content,
.post-content {
    line-height: 1.9 !important;
}

.article-content p,
.blog-content p,
.bio-text p,
.content p,
.post-content p {
    margin-bottom: 1.2em;
}

.article-content h2,
.blog-content h2,
.content h2,
.post-content h2 {
    margin-top: 2em;
    margin-bottom: 0.8em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid rgba(99, 102, 241, 0.1);
}

.article-content h3,
.blog-content h3,
.content h3,
.post-content h3 {
    margin-top: 1.8em;
    margin-bottom: 0.6em;
}

.article-content code,
.content code,
.post-content code {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.article-content pre,
.content pre,
.post-content pre {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.article-content pre code,
.content pre code,
.post-content pre code {
    background: none;
    color: #24292e;
    padding: 0;
}

[data-theme="dark"] .article-content pre code,
[data-theme="dark"] .content pre code,
[data-theme="dark"] .post-content pre code {
    color: #cdd6f4;
}

.article-content blockquote,
.content blockquote,
.post-content blockquote {
    border-left: 4px solid #6366f1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.03));
    padding: 1em 1.5em;
    margin: 1.5em 0;
    border-radius: 0 8px 8px 0;
}

.article-content ul,
.article-content ol,
.content ul,
.content ol,
.post-content ul,
.post-content ol {
    padding-left: 1.8em;
    margin-bottom: 1.2em;
}

.article-content li,
.content li,
.post-content li {
    margin-bottom: 0.5em;
}

.article-content img,
.content img,
.post-content img {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin: 1.5em auto;
    max-width: 100%;
}

/* ============================================
   18. 表格美化
   ============================================ */
table {
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    width: 100%;
}

thead th {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    padding: 14px 20px;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.03em;
}

tbody td {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background 0.2s ease;
}

tbody tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   19. 暗色模式专属增强
   ============================================ */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #818cf8, #a78bfa);
    background-clip: padding-box;
}

[data-theme="dark"] ::selection {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.4), rgba(167, 139, 250, 0.4));
}

[data-theme="dark"] table {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] tbody td {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] tbody tr:hover td {
    background: rgba(129, 140, 248, 0.08);
}

[data-theme="dark"] .article-content code,
[data-theme="dark"] .content code,
[data-theme="dark"] .post-content code {
    background: rgba(129, 140, 248, 0.15);
    color: #a5b4fc;
}

[data-theme="dark"] .article-content blockquote,
[data-theme="dark"] .content blockquote,
[data-theme="dark"] .post-content blockquote {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.08), rgba(167, 139, 250, 0.05));
    border-left-color: #818cf8;
}

[data-theme="dark"] .article-content h2,
[data-theme="dark"] .content h2,
[data-theme="dark"] .post-content h2 {
    border-bottom-color: rgba(129, 140, 248, 0.15);
}

/* ============================================
   20. Focus-visible 可访问性增强
   ============================================ */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-radius: 4px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ============================================
   21. 响应式减弱动画 (尊重用户偏好)
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    body {
        animation: none !important;
    }
}

/* ============================================
   22. 移动端微调
   ============================================ */
@media (max-width: 768px) {
    .blog-card:hover,
    .card:hover,
    .category-item:hover,
    .article-item:hover {
        transform: none;
    }

    .social-icon:hover,
    .social-link:hover {
        transform: translateY(-2px) scale(1.05) !important;
    }
}
