/* ============================================
   文章内容图片自适应
   ============================================ */

/* 1. 核心：使文章内所有图片最大宽度为100%，高度自动，并居中 */
.article-content img {
    max-width: 100%; /* 关键：图片最大宽度不会超过其容器的100% */
    height: auto;    /* 保持宽高比 */
    display: block;  /* 将图片转为块级元素，便于居中控制 */
    margin: 10px auto; /* 上下留点边距，并水平居中 */
    border-radius: 0.25rem; /* 添加圆角 */
}

/* 图片标题样式 */
.article-content img + em,
.article-content .image-caption {
    display: block;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 5px;
    margin-bottom: 15px;
    font-style: normal;
}

.dark .article-content img + em,
.dark .article-content .image-caption {
    color: #9ca3af;
}

/* 2. 移动端特定优化（可选但推荐） */
@media (max-width: 768px) { /* 通常在平板/手机屏幕尺寸下生效 */
    .article-content img {
        max-width: 100% !important; /* 增加权重，确保覆盖其他样式 */
        height: auto !important;
    }
    
    /* 可选：防止因内联样式或编辑器设置的固定宽度导致失效 */
    .article-content img[width],
    .article-content img[style*="width"] {
        max-width: 100% !important;
        width: auto !important; /* 覆盖原有的固定宽度 */
        height: auto !important;
    }
    
    /* 小屏幕下减少图片边距 */
    .article-content img {
        margin: 5px auto;
    }
}

/* ============================================
   页面过渡动画
   ============================================ */

.page-transition {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
}

.page-exit {
    opacity: 1;
    transform: translateY(0);
}

.page-exit-active {
    opacity: 0;
    transform: translateY(-20px);
}

/* ============================================
   图片悬停放大效果
   ============================================ */

.image-container {
    overflow: hidden;
    border-radius: 0.5rem;
    position: relative;
    cursor: pointer;
}

.image-container img {
    transition: transform 0.5s ease, filter 0.3s ease;
    width: 100%;
    height: auto;
}

.image-container:hover img {
    transform: scale(1.1);
}

.image-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 0.5rem;
}

.image-container:hover::after {
    opacity: 1;
}

.dark .image-container::after {
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   按钮波纹效果
   ============================================ */

.ripple-button {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    cursor: pointer;
}

.ripple-button:active {
    transform: scale(0.98);
}

.ripple-button::after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.8) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.8s;
}

.ripple-button:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

.dark .ripple-button::after {
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.3) 10%, transparent 10.01%);
}

/* ============================================
   背景装饰
   ============================================ */

.bg-pattern {
    background-color: #f8f9fa;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%234361ee' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 60px 60px;
}

.dark .bg-pattern {
    background-color: #121212;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%235390d9' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ============================================
   文章内容样式
   ============================================ */

.article-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.8;
    color: #374151;
}

.dark .article-content {
    color: #e5e7eb;
}

/* 标题样式 */
.article-content h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    color: #111827;
}

.dark .article-content h1 {
    color: #f9fafb;
}

.article-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #1f2937;
    border-left: 4px solid #4361EE;
    padding-left: 1rem;
}

.dark .article-content h2 {
    color: #f3f4f6;
    border-left-color: #5390D9;
}

.article-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #374151;
}

.dark .article-content h3 {
    color: #e5e7eb;
}

.article-content h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    color: #4b5563;
}

.dark .article-content h4 {
    color: #d1d5db;
}

.article-content h5 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #6b7280;
}

.dark .article-content h5 {
    color: #9ca3af;
}

.article-content h6 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: #9ca3af;
}

.dark .article-content h6 {
    color: #6b7280;
}

/* 段落样式 */
.article-content p {
    margin-bottom: 1.25rem;
    line-height: 1.8;
    text-align: justify;
}

/* 链接样式 */
.article-content a {
    color: #4361EE;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.article-content a:hover {
    color: #3a56d4;
    text-decoration: none;
}

.dark .article-content a {
    color: #5390D9;
}

.dark .article-content a:hover {
    color: #4a80c9;
}

/* 列表样式 */
.article-content ul,
.article-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.article-content ul li,
.article-content ol li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.article-content ul li {
    list-style-type: disc;
}

.article-content ol li {
    list-style-type: decimal;
}

/* 引用块样式 */
.article-content blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: #6b7280;
    font-style: italic;
}

.dark .article-content blockquote {
    border-left-color: #4b5563;
    color: #9ca3af;
}

/* 代码样式 */
.article-content code {
    background-color: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    color: #dc2626;
}

.dark .article-content code {
    background-color: #1f2937;
    color: #f87171;
}

.article-content pre {
    background-color: #1f2937;
    color: #e5e7eb;
    padding: 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.article-content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* 表格样式 */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    overflow-x: auto;
    display: block;
}

.article-content th,
.article-content td {
    border: 1px solid #e5e7eb;
    padding: 0.75rem;
    text-align: left;
}

.article-content th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.article-content tr:nth-child(even) {
    background-color: #f9fafb;
}

.dark .article-content th,
.dark .article-content td {
    border-color: #4b5563;
}

.dark .article-content th {
    background-color: #1f2937;
    color: #f3f4f6;
}

.dark .article-content tr:nth-child(even) {
    background-color: #1f2937;
}

/* 分割线样式 */
.article-content hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 2rem 0;
}

.dark .article-content hr {
    border-top-color: #4b5563;
}

/* ============================================
   标签样式
   ============================================ */

.article-tag {
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: rgba(67, 97, 238, 0.1);
    color: #4361EE;
    cursor: pointer;
    user-select: none;
}

.article-tag:hover {
    transform: scale(1.05);
    background-color: rgba(67, 97, 238, 0.2);
}

.dark .article-tag {
    background-color: rgba(83, 144, 217, 0.2);
    color: #5390D9;
}

.dark .article-tag:hover {
    background-color: rgba(83, 144, 217, 0.3);
}

/* ============================================
   相关文章卡片悬停效果
   ============================================ */

.related-article-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
}

.related-article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: rgba(67, 97, 238, 0.2);
}

.dark .related-article-card {
    border-color: rgba(255, 255, 255, 0.1);
}

.dark .related-article-card:hover {
    border-color: rgba(83, 144, 217, 0.3);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* 卡片边框动画 */
.related-article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    border: 2px solid transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.related-article-card:hover::before {
    opacity: 1;
    border-color: rgba(67, 97, 238, 0.2);
}

.dark .related-article-card:hover::before {
    border-color: rgba(83, 144, 217, 0.3);
}

/* ============================================
   上下篇文章链接样式
   ============================================ */

.prev-next-link {
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
    color: #374151;
    text-decoration: none;
}

.prev-next-link:hover {
    transform: translateX(5px);
    background-color: #e9ecef;
    color: #1f2937;
}

.dark .prev-next-link {
    background-color: #1f2937;
    color: #e5e7eb;
}

.dark .prev-next-link:hover {
    background-color: #374151;
    color: #f9fafb;
}

.prev-link::before {
    content: "←";
    margin-right: 0.5rem;
}

.next-link::after {
    content: "→";
    margin-left: 0.5rem;
}

/* ============================================
   文章元信息样式
   ============================================ */

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: #6b7280;
    font-size: 0.875rem;
}

.dark .article-meta {
    color: #9ca3af;
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.article-meta-item i {
    font-size: 0.75rem;
}

/* ============================================
   响应式调整
   ============================================ */

@media (max-width: 768px) {
    .article-content h1 {
        font-size: 1.75rem;
        margin-top: 2rem;
    }
    
    .article-content h2 {
        font-size: 1.5rem;
        margin-top: 1.75rem;
        padding-left: 0.75rem;
    }
    
    .article-content h3 {
        font-size: 1.25rem;
        margin-top: 1.5rem;
    }
    
    .article-content h4 {
        font-size: 1.125rem;
        margin-top: 1.25rem;
    }
    
    .article-content p {
        font-size: 0.9375rem;
    }
    
    .article-content ul,
    .article-content ol {
        padding-left: 1.25rem;
    }
    
    .related-article-card:hover {
        transform: translateY(-3px);
    }
    
    .article-tag:hover {
        transform: scale(1.03);
    }
}

@media (max-width: 480px) {
    .article-content h1 {
        font-size: 1.5rem;
    }
    
    .article-content h2 {
        font-size: 1.375rem;
        border-left-width: 3px;
    }
    
    .article-content p {
        text-align: left;
    }
    
    .article-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ============================================
   打印样式优化
   ============================================ */

@media print {
    .article-content {
        color: #000;
    }
    
    .article-content h1,
    .article-content h2,
    .article-content h3,
    .article-content h4,
    .article-content h5,
    .article-content h6 {
        color: #000;
        break-after: avoid;
    }
    
    .article-content a {
        color: #000;
        text-decoration: none;
    }
    
    .article-content a::after {
        content: " (" attr(href) ")";
        font-size: 0.875em;
        color: #666;
    }
    
    .article-content img {
        break-inside: avoid;
        max-width: 100% !important;
    }
    
    .article-content blockquote,
    .article-content pre,
    .article-content table {
        break-inside: avoid;
    }
    
    .article-content h2,
    .article-content h3 {
        page-break-after: avoid;
    }
    
    /* 隐藏不需要打印的元素 */
    .related-article-card,
    .article-tag,
    .prev-next-link,
    .image-container:hover img {
        display: none !important;
    }
}

/* ============================================
   工具类
   ============================================ */

.text-balance {
    text-wrap: balance;
}

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-soft {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.shadow-medium {
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

.blur-backdrop {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}