/* ------------------------------------
 * Modern International Typecho Theme
 * Design: Minimalist, Content-First, A11y
 * Font: Inter / System Sans
 * --------------------------------- */

/* ==========================================================================
   1. Variables & Reset (全局变量)
   ========================================================================== */
:root {
    /* --- 字体系统 --- */
    --font-sans: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, Menlo, monospace;

    /* --- 尺寸变量 --- */
    --header-height: 70px;
    --max-width: 1200px;
    /* 稍微加宽以适应现代屏幕 */

    /* --- 亮色模式 (Light - Default) --- */
    --bg-body: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.85);
    /* 头部毛玻璃背景 */
    --bg-card: #ffffff;
    --bg-code: #f5f5f7;
    --bg-quote: #f9f9f9;

    --text-main: #1a1a1a;
    /* 更柔和的深黑 */
    --text-secondary: #4a4a4a;
    --text-muted: #888888;

    --accent: #000000;
    --link-color: #000000;
    --primary-color: #4a90e2;

    --border-line: rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.06);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 4px 30px rgba(0, 0, 0, 0.03);

    --focus-ring: 0 0 0 2px rgba(0, 0, 0, 0.8);
    --selection-bg: rgba(0, 0, 0, 0.1);
    --hover-bg: rgba(0, 0, 0, 0.04);
}

/* --- 深色模式 (Dark) --- */
html.dark-mode {
    --bg-body: #050505;
    --bg-glass: rgba(10, 10, 10, 0.85);
    --bg-card: #111111;
    --bg-code: #1a1a1a;
    --bg-quote: #111111;

    --text-main: #ededed;
    --text-secondary: #a1a1a1;
    --text-muted: #666666;

    --accent: #ffffff;
    --link-color: #ffffff;
    --primary-color: #4a90e2;

    --border-line: rgba(255, 255, 255, 0.1);
    --border-subtle: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-soft: 0 4px 30px rgba(0, 0, 0, 0.2);

    --focus-ring: 0 0 0 2px rgba(255, 255, 255, 0.8);
    --selection-bg: rgba(255, 255, 255, 0.2);
    --hover-bg: rgba(255, 255, 255, 0.08);
}

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

body {
    /* 移除背景颜色，因为已由 header.php 中的 ::before/::after 接管，保留作为后备 */
    background-color: var(--bg-body);
    /* 确保文字始终在这个背景遮罩之上 */
    position: relative;
    z-index: 0;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

::selection {
    background: var(--selection-bg);
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
    font-weight: 500;
}

a:hover {
    opacity: 0.7;
}

/* ==========================================================================
   2. Header Styles (头部样式 - 从 PHP 移入)
   ========================================================================== */
.modern-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    height: var(--header-height);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background-color: var(--bg-glass);
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.modern-header.scrolled {
    border-bottom-color: var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    height: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 0 24px;
    gap: 20px;
}

.brand-area .logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-area img {
    height: 28px;
    width: auto;
    border-radius: 6px;
}

/* 导航条 */
.nav-center {
    display: flex;
    justify-content: center;
}

.desktop-nav {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.02);
    padding: 4px;
    border-radius: 99px;
    border: 1px solid var(--border-subtle);
}

.desktop-nav a {
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-radius: 99px;
}

.desktop-nav a:hover {
    color: var(--text-main);
    background: var(--hover-bg);
}

.desktop-nav a.current {
    color: var(--text-main);
    background: var(--bg-body);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* 工具栏 */
.utils-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.util-item {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.util-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-main);
}

.kbd-hint {
    display: none;
    font-size: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 0 4px;
    margin-left: 6px;
}

@media (min-width: 768px) {
    .kbd-hint {
        display: inline-block;
    }
}

/* 时钟与搜索 */
.digital-clock {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 6px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}

.clock-dot {
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.search-wrapper {
    position: relative;
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 0;
    transition: width 0.3s ease;
    font-size: 0.9rem;
    padding: 0;
}

.search-wrapper.active .search-input {
    width: 160px;
    padding-left: 8px;
    border-bottom: 1px solid var(--text-main);
}

.search-input:focus {
    outline: none;
}

/* 移动端菜单开关 */
.mobile-toggle {
    display: none;
}

/* ==========================================================================
   3. Main Layout (布局系统)
   ========================================================================== */
.container {
    padding-top: 40px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* 简单的 Flex 布局，替代 grid.css */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
}

#main {
    flex: 1;
    /* 占据剩余空间 */
    min-width: 0;
    /* 防止 flex 子项溢出 */
    padding-bottom: 60px;
}

#secondary {
    width: 300px;
    /* 侧边栏固定宽度 */
    flex-shrink: 0;
}

/* 标题系统 */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2em;
    margin-bottom: 0.8em;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.75rem;
    border-bottom: 1px solid var(--border-line);
    padding-bottom: 0.3em;
}

h3 {
    font-size: 1.4rem;
}

/* ==========================================================================
   4. Post List (文章卡片)
   ========================================================================== */
.post {
    padding: 0 0 40px 0;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-line);
}

.post:last-child {
    border-bottom: none;
}

.post-title {
    margin: 0 0 12px 0;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.3;
}

.post-title a {
    color: var(--text-main);
    background-image: linear-gradient(var(--text-main), var(--text-main));
    background-position: 0% 100%;
    background-repeat: no-repeat;
    background-size: 0% 2px;
    transition: background-size 0.3s;
}

.post-title a:hover {
    opacity: 1;
    background-size: 100% 2px;
}

.post-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.post-meta li {
    display: inline-block;
}

.post-meta a {
    color: var(--text-secondary);
}

.post-content {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.8;
}

/* ==========================================================================
   5. Markdown Content (正文美化)
   ========================================================================== */
.post-content p {
    margin-bottom: 1.5em;
}

pre,
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

code {
    background: var(--bg-code);
    color: var(--text-main);
    padding: 3px 6px;
    border-radius: 4px;
}

pre {
    background: var(--bg-code);
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-line);
    margin: 2em 0;
}

pre code {
    background: none;
    padding: 0;
    color: var(--text-secondary);
    border: none;
}

blockquote {
    margin: 2em 0;
    padding: 1em 1.5em;
    border-left: 3px solid var(--accent);
    background: var(--bg-quote);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 2em auto;
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s;
}

.post-content img:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-hover);
}

.post-content img.zoomed {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    max-height: 90vh;
    max-width: 90vw;
    z-index: 9999;
    cursor: zoom-out;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

html.dark-mode .post-content img {
    filter: brightness(0.9);
}

html.dark-mode .post-content img.zoomed {
    filter: brightness(1);
}

.img-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.img-zoom-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.post-content ul,
.post-content ol {
    padding-left: 2em;
    margin-bottom: 1.5em;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.95em;
}

table th,
table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-line);
    text-align: left;
}

table th {
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 2px solid var(--border-line);
}

hr {
    border: 0;
    height: 1px;
    background: var(--border-line);
    margin: 4em auto;
    width: 30%;
}

/* ==========================================================================
   6. Comments (评论区)
   ========================================================================== */
#comments {
    padding-top: 40px;
    margin-top: 40px;
    border-top: 1px dashed var(--border-line);
}

.comment-list,
.comment-list ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.comment-list li {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-line);
}

.comment-list .children {
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid var(--border-line);
}

.comment-author .avatar {
    float: left;
    margin-right: 12px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.comment-author cite {
    font-style: normal;
    font-weight: 600;
    color: var(--text-main);
}

.comment-meta {
    margin-bottom: 8px;
}

.comment-meta a {
    font-size: 0.8em;
    color: var(--text-muted);
}

.comment-content {
    margin-left: 52px;
    font-size: 0.95rem;
}

#comment-form input[type="text"],
#comment-form input[type="email"],
#comment-form input[type="url"],
#comment-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-line);
    background: var(--bg-card);
    color: var(--text-main);
    border-radius: 6px;
    margin-bottom: 10px;
    font-family: var(--font-sans);
    transition: all 0.2s;
}

#comment-form textarea {
    min-height: 120px;
    resize: vertical;
}

#comment-form input:focus,
#comment-form textarea:focus {
    outline: none;
    border-color: var(--text-secondary);
    box-shadow: 0 0 0 2px var(--border-line);
}

#comment-form button {
    background: var(--text-main);
    color: var(--bg-body);
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

#comment-form button:hover {
    opacity: 0.9;
}

/* ==========================================================================
   7. Sidebar (侧边栏)
   ========================================================================== */
.widget {
    margin-bottom: 40px;
}

.widget-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 15px;
    font-weight: 700;
}

.widget-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-list li {
    margin-bottom: 10px;
}

.widget-list li a {
    color: var(--text-secondary);
    display: block;
    padding: 4px 0;
    transition: transform 0.2s, color 0.2s;
}

.widget-list li a:hover {
    color: var(--text-main);
    transform: translateX(4px);
}

/* ==========================================================================
   8. Footer (页脚 - 从 PHP 移入)
   ========================================================================== */
#footer {
    margin-top: 60px;
    padding: 40px 0;
    background-color: var(--bg-body);
    border-top: 1px solid var(--border-line);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.footer-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px 32px;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.metric-item:hover {
    opacity: 1;
    color: var(--text-main);
}

.metric-item i {
    font-size: 14px;
}

.mono {
    font-family: var(--font-mono);
    font-weight: 500;
}

.footer-divider {
    width: 60px;
    height: 2px;
    background-color: var(--border-line);
    border-radius: 2px;
}

.footer-legal {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.icp-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
}

/* ==========================================================================
   9. Page Navigator (翻页)
   ========================================================================== */
.page-navigator {
    list-style: none;
    padding: 0;
    margin: 40px 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.page-navigator li {
    display: inline-block;
}

.page-navigator a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    color: var(--text-secondary);
    border: 1px solid var(--border-line);
    transition: all 0.2s;
}

.page-navigator a:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

.page-navigator .current a {
    background: var(--text-main);
    color: var(--bg-body);
    border-color: var(--text-main);
}

/* ==========================================================================
   10. Like Button (点赞)
   ========================================================================== */
.post-like-wrapper {
    text-align: center;
    margin: 60px 0;
}

.post-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 30px;
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    color: var(--text-main);
    border-radius: 99px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.post-like-btn i {
    color: #ff4757;
    font-size: 1.1em;
    transition: transform 0.2s;
}

.post-like-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: var(--bg-body);
}

.post-like-btn:hover i {
    animation: heartPulse 0.8s infinite;
}

@keyframes heartPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.4);
    }

    100% {
        transform: scale(1);
    }
}

/* ==========================================================================
   11. Mobile / Responsive
   ========================================================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 768px) {

    /* 头部移动端适配 */
    .header-inner {
        grid-template-columns: 1fr auto;
        gap: 10px;
    }

    .nav-center,
    .desktop-nav {
        display: none;
    }

    .nav-mobile-active .nav-center {
        display: flex;
        position: absolute;
        top: var(--header-height);
        left: 0;
        width: 100%;
        background: var(--bg-body);
        border-bottom: 1px solid var(--border-subtle);
        padding: 20px;
        flex-direction: column;
    }

    .desktop-nav {
        flex-direction: column;
        width: 100%;
        background: transparent;
        border: none;
    }

    .mobile-toggle {
        display: flex;
        font-size: 1.2rem;
    }

    .digital-clock {
        display: none;
    }

    /* 布局堆叠 */
    .row {
        flex-direction: column;
    }

    #secondary {
        width: 100%;
        padding-left: 0;
        margin-top: 40px;
        border-top: 1px solid var(--border-line);
        padding-top: 40px;
    }

    /* 字体调整 */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .post-title {
        font-size: 1.5rem;
    }

    .comment-list .children {
        margin-left: 10px;
        padding-left: 10px;
    }
}