/* ============================================
   InkSpace — 现代极简博客样式
   ============================================ */

/* ========== CSS 变量 ========== */
:root {
    /* 颜色 */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --accent: #6366f1;
    --accent-light: #eef2ff;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --accent-gradient-subtle: linear-gradient(135deg, rgba(99,102,241,.08) 0%, rgba(139,92,246,.08) 100%);
    --hero-gradient: linear-gradient(180deg, #faf5ff 0%, #eef2ff 40%, #f8fafc 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.08), 0 4px 10px -6px rgba(0,0,0,.04);
    --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.15);
    /* 圆角 */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    /* 间距 */
    --nav-h: 64px;
    --max-w: 1200px;
    /* 过渡 */
    --ease: cubic-bezier(.4,0,.2,1);
    --ease-spring: cubic-bezier(.34,1.56,.64,1);
}

/* ========== 深色主题 ========== */
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --border-light: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --accent-light: #1e1b4b;
    --hero-gradient: linear-gradient(180deg, #0f0720 0%, #0c0a2a 40%, #0f172a 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.5);
    --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.6);
}

/* ========== 全局重置 ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color .3s var(--ease), color .3s var(--ease);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    font: inherit;
    border: none;
    background: none;
    color: inherit;
}

/* ========== 导航栏 ========== */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    border-bottom: 1px solid var(--border);
    transition: background .3s var(--ease), border-color .3s var(--ease);
}

.nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 24px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.02em;
    flex-shrink: 0;
    transition: opacity .2s var(--ease);
}

.nav-logo:hover {
    opacity: .8;
}

.nav-logo svg {
    flex-shrink: 0;
}

.nav-categories {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    justify-content: center;
}

.nav-categories::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 20px;
    color: var(--text-secondary);
    transition: all .2s var(--ease);
    white-space: nowrap;
    position: relative;
}

.cat-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.cat-btn.active {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(99,102,241,.35);
}

.theme-toggle {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all .2s var(--ease);
    flex-shrink: 0;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.sun-icon,
.moon-icon {
    transition: all .3s var(--ease);
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon,
:root:not([data-theme]) .moon-icon {
    display: none;
}

/* ========== Hero ========== */
.hero {
    position: relative;
    padding: 80px 24px 64px;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: var(--hero-gradient);
    z-index: -1;
}

.hero-bg::after {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(99,102,241,.12) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
    border-radius: 20px;
    margin-bottom: 28px;
    animation: fadeInUp .6s var(--ease) both;
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .5; transform: scale(1.3); }
}

.hero-title {
    font-size: clamp(36px, 6vw, 56px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.03em;
    color: var(--text);
    animation: fadeInUp .6s var(--ease) .1s both;
}

.hero-title-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-sub {
    margin-top: 20px;
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.7;
    animation: fadeInUp .6s var(--ease) .2s both;
}

.hero-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    margin-top: 40px;
    animation: fadeInUp .6s var(--ease) .3s both;
}

.hero-stat {
    text-align: center;
}

.hero-stat-num {
    display: block;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-stat-label {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.hero-stat-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

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

/* ========== 主体 ========== */
.main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px 80px;
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.section-sub {
    font-size: 15px;
    color: var(--text-tertiary);
}

/* ========== 文章网格 ========== */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .articles-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== 文章卡片 ========== */
.article-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all .3s var(--ease);
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity .3s var(--ease);
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.article-card:hover::before {
    opacity: 1;
}

.card-category {
    display: inline-block;
    align-self: flex-start;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    letter-spacing: .02em;
}

.cat-tech {
    background: #eef2ff;
    color: #4f46e5;
}

.cat-design {
    background: #fdf2f8;
    color: #be185d;
}

.cat-life {
    background: #ecfdf5;
    color: #047857;
}

[data-theme="dark"] .cat-tech {
    background: #1e1b4b;
    color: #a5b4fc;
}

[data-theme="dark"] .cat-design {
    background: #2d0a1e;
    color: #f9a8d4;
}

[data-theme="dark"] .cat-life {
    background: #022c22;
    color: #6ee7b7;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-tertiary);
    padding-top: 4px;
}

.card-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.card-read {
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-read svg {
    opacity: .5;
}

/* ========== 骨架屏 ========== */
.skeleton-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    height: 200px;
    position: relative;
    overflow: hidden;
}

.skeleton-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        color-mix(in srgb, var(--text) 5%, transparent) 50%,
        transparent 100%
    );
    animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ========== 空状态 & 错误状态 ========== */
.empty-state,
.error-state {
    text-align: center;
    padding: 80px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-title,
.error-title {
    font-size: 18px;
    font-weight: 600;
    margin-top: 8px;
}

.empty-desc,
.error-desc {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 320px;
}

.btn-retry {
    margin-top: 12px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: var(--accent);
    border-radius: var(--radius-sm);
    transition: all .2s var(--ease);
}

.btn-retry:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ========== 详情弹窗 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15,23,42,.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn .2s var(--ease);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    position: relative;
    animation: modalIn .35s var(--ease-spring);
    display: flex;
    flex-direction: column;
}

.modal-scroll {
    overflow-y: auto;
    padding: 40px 36px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    z-index: 10;
    transition: all .2s var(--ease);
}

.modal-close:hover {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--text-tertiary);
}

.modal-article {
    animation: fadeInUp .4s var(--ease) .1s both;
}

.modal-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-category {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    letter-spacing: .02em;
}

.modal-date {
    font-size: 13px;
    color: var(--text-tertiary);
}

.modal-title {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -.02em;
    margin-bottom: 20px;
}

.modal-author-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
}

.modal-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.modal-author {
    display: block;
    font-size: 15px;
    font-weight: 600;
}

.modal-read {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* 文章内容排版 */
.modal-content {
    font-size: 13px;
    line-height: 1.85;
    color: var(--text);
}

.modal-content h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 36px 0 14px;
    letter-spacing: -.01em;
}

.modal-content h2:first-child {
    margin-top: 0;
}

.modal-content p {
    margin-bottom: 14px;
}

.modal-content ul,
.modal-content ol {
    margin-bottom: 14px;
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 6px;
}

.modal-content strong {
    font-weight: 600;
}

.modal-content code {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: .88em;
    padding: 2px 6px;
    background: var(--accent-light);
    border-radius: 4px;
    color: var(--accent);
}

.modal-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px 24px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.6;
}

.modal-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* body 滚动锁定 */
body.modal-open {
    overflow: hidden;
}

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

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.94) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ========== 页脚 ========== */
.footer {
    border-top: 1px solid var(--border-light);
    padding: 32px 24px;
    text-align: center;
}

.footer-text {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ========== 工具类 ========== */
.hidden {
    display: none !important;
}

/* ========== 响应式微调 ========== */
@media (max-width: 768px) {
    .hero {
        padding: 56px 20px 48px;
    }

    .hero-stats {
        gap: 24px;
    }

    .hero-stat-num {
        font-size: 26px;
    }

    .nav-categories {
        justify-content: flex-start;
    }

    .modal-scroll {
        padding: 28px 20px;
    }

    .section-header {
        flex-direction: column;
    }
}
