/* ============================================
   文章通用美化增强包
   说明: 为所有文章页面提供统一的美化效果
         低特异性，不破坏文章原有样式
   ============================================ */

/* 超链接美化 */
a {
    color: #6366f1;
    text-decoration: none;
    transition: color 0.25s ease;
}

a:hover {
    color: #4f46e5;
    text-decoration: underline;
    text-decoration-color: #8b5cf6;
    text-underline-offset: 3px;
}

/* 返回文章列表按钮 */
.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.back-link::before {
    content: '\f060';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.8em;
}

.back-link:hover {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.back-link:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .back-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* 全局字体优化 */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* 滚动条美化 */
::-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;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #6366f1 transparent;
}

/* 选中文字美化 */
::selection {
    background: rgba(99, 102, 241, 0.2);
    color: inherit;
}

/* 链接悬停增强 */
a {
    transition: color 0.25s ease, transform 0.25s ease;
}

a:hover {
    text-decoration: none;
}

/* 图片美化 */
img {
    image-rendering: -webkit-optimize-contrast;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

/* 代码块增强 */
pre {
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
    transition: box-shadow 0.3s ease;
}

pre:hover {
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12) !important;
}

code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace !important;
}

/* 复制按钮美化 */
.copy-button {
    border-radius: 6px !important;
    transition: all 0.25s ease !important;
    opacity: 0.7;
}

.copy-button:hover {
    opacity: 1;
    transform: scale(1.05);
}

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

th {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: #fff !important;
}

td {
    transition: background 0.2s ease;
}

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

/* 引用块美化 */
blockquote {
    border-left: 4px solid #6366f1 !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.03)) !important;
    border-radius: 0 8px 8px 0 !important;
    padding: 1em 1.5em !important;
}

/* 返回顶部按钮 */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
}

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

#back-to-top.show {
    display: flex;
}

/* ============================================
   页脚统一美化（文章页通用）
   ============================================ */
footer {
    position: relative;
    background: linear-gradient(180deg, #fafbff 0%, #f0f2ff 100%);
    border-top: none !important;
    padding: 2.5rem 1rem 1.5rem !important;
    margin-top: 3rem;
    overflow: hidden;
    text-align: center;
}

footer .footer-content {
    max-width: 800px;
    margin: 0 auto;
}

/* 顶部流光条 */
.footer-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #f59e0b, #3b82f6);
    background-size: 200% 100%;
    animation: footerGlow 4s linear infinite;
}

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

/* 兼容：无 .footer-glow 时用 ::before 伪元素 */
footer:not(:has(.footer-glow))::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #f59e0b, #3b82f6);
    background-size: 200% 100%;
    animation: footerGlow 4s linear infinite;
}

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

/* 品牌区域 */
.footer-brand {
    text-align: center;
    margin-bottom: 1.2rem;
}

.footer-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #4361ee;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.footer-desc {
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.8;
    max-width: 500px;
    margin: 0 auto;
}

/* 社交图标 */
.footer .social-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.footer .social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #9ca3af;
    border-radius: 50%;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.footer .social-icon[title="GitHub"] {
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.05);
}

.footer .social-icon[title="GitHub"]:hover {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}

.footer .social-icon[title="微博"] {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.footer .social-icon[title="微博"]:hover {
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.footer .social-icon[title="知乎"] {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.05);
}

.footer .social-icon[title="知乎"]:hover {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.footer .social-icon[title="邮箱"] {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.footer .social-icon[title="邮箱"]:hover {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

/* 底部信息区 */
.footer-bottom {
    margin-top: 1.5rem;
    padding: 1.2rem;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    position: relative;
}

.footer-bottom::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 15%;
    right: 15%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #6366f1, transparent);
    opacity: 0.4;
}

.footer-meta-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #6b7280;
}

.footer-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.footer-meta-item i {
    color: #6366f1;
    opacity: 0.7;
}

.footer-copyright {
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    font-weight: 500;
}

.footer-copyright i {
    color: #6366f1;
    margin-right: 4px;
}

/* 备案徽章 */
.footer-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    text-decoration: none;
    transition: all 0.25s ease;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #9ca3af;
}

.badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.badge i {
    font-size: 0.7rem;
}

.badge img {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.badge-icp:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.badge-police:hover {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.badge-nobug:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

/* 页脚链接增强 */
.footer-link {
    transition: color 0.25s ease, transform 0.25s ease;
    display: inline-block;
}

.footer-link:hover {
    color: #6366f1 !important;
    transform: translateY(-1px);
}

/* 技术标签美化 */
.tech {
    display: inline-block;
    padding: 0.1em 0.4em;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

/* 页脚响应式 */
@media (max-width: 768px) {
    footer {
        padding: 2rem 0.8rem 1.2rem !important;
    }

    .footer-logo {
        font-size: 1.1rem;
    }

    .footer-bottom {
        padding: 1rem 0.8rem;
    }

    .footer-meta-row {
        gap: 0.8rem;
        font-size: 0.8rem;
    }

    .footer-badges {
        gap: 0.4rem;
    }

    .badge {
        padding: 3px 10px;
        font-size: 0.75rem;
    }
}

/* 页面加载动画 */
body {
    animation: pageFadeIn 0.4s ease-out;
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 列表项增强 */
li::marker {
    color: #6366f1;
}

/* 输入框聚焦增强 */
input:focus, textarea:focus {
    outline: none;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

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

/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
