/* --- 全局变量与主题 --- */
:root {
    --bg: #FDFCFB;
    --surface: #FFFFFF;
    --text: #1A1A1A;
    --text-muted: #777;
    --accent: #B08968;
    --border: rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    --card-hover: #F9F7F2;
    --noise: 0.03;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 深色模式变量 */
[data-theme="dark"] {
    --bg: #0C0E12;
    --surface: #14171C;
    --text: #DDD;
    --text-muted: #888;
    --accent: #D4A373;
    --border: rgba(255, 255, 255, 0.05);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --card-hover: #1E222B;
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Bricolage Grotesque', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.2;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 5rem;
}

/* 噪点纹理背景 */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3BaseFilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/baseFilter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: var(--noise);
    pointer-events: none;
    z-index: 9999;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- 紧凑型页眉 --- */
.site-header {
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    background: rgba(var(--bg), 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
}

.site-logo {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.6rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text);
    text-decoration: none;
}

/* 搜索框样式 */
.search-wrapper {
    width: 350px;
    position: relative;
}

.search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 4px;
    color: var(--text);
    outline: none;
}

/* --- 栏目样式 --- */
section {
    margin-bottom: 1.5rem;
    scroll-margin-top: 5rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.section-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-weight: 700;
    font-style: italic;
    color: var(--accent);
    white-space: nowrap;
}

.section-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* --- 超紧凑网格布局 --- */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
}

/* 工具卡片样式 */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.8rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    transition: all 0.2s, opacity 0.6s var(--ease), transform 0.6s var(--ease);
    border-radius: 6px;
    min-height: 60px;
    justify-content: center;

    /* 进场动画初始状态 */
    opacity: 0;
    transform: translateY(20px);
}

.card.visible {
    opacity: 1;
    transform: translateY(0);
}

.card:hover {
    border-color: var(--accent);
    background: var(--card-hover);
    transform: translateY(-2px);
    /* 注意：这里可能会覆盖 visible 的 transform，需要确保优先级或逻辑 */
    box-shadow: var(--shadow);
    z-index: 2;
    /* 保持 hover 时的不透明度 */
    opacity: 1;
}

.card-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 顶部导航 --- */
.header-nav {
    margin-left: 2rem;
    flex: 1;
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--accent);
}

/* --- 紧凑型页脚 --- */
.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 4rem 1.5rem 0;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-link {
    text-decoration: none;
    color: inherit;
}

.footer-link:hover {
    color: var(--text);
}

/* --- 控制按钮 --- */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: var(--border);
}

/* --- 返回顶部按钮 --- */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s var(--ease);
    opacity: 0;
    visibility: hidden;
    z-index: 99;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-4px);
}

/* --- 响应式设计 --- */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
    }

    .tool-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .site-header {
        padding: 0.8rem 0;
    }

    .search-wrapper {
        width: 280px;
    }

    .section-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 600px) {
    .site-header {
        flex-wrap: wrap;
        padding: 0.8rem 0;
    }

    .site-logo {
        font-size: 1.4rem;
        order: 1;
    }

    .theme-toggle {
        order: 2;
    }

    .header-nav {
        display: flex;
        order: 4;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        padding: 0.5rem 0;
        margin-left: 0;
        gap: 1.2rem;
        -webkit-overflow-scrolling: touch;
        /* create scrollbar hiding */
        scrollbar-width: none;
    }

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

    .search-wrapper {
        width: 100%;
        order: 3;
        margin-top: 0.8rem;
    }

    .search-input {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }

    .tool-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem;
    }

    .card {
        padding: 0.7rem;
        min-height: 55px;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-desc {
        font-size: 0.7rem;
    }

    .site-footer {
        flex-direction: column;
        text-align: center;
        padding-right: 0;
    }
}