/* ============================================================
   导航网站 — 样式表
   浅色主题：清新绿色系  |  深色主题：#19192e
   中文字体：幼圆  |  西文字体：Comic Sans MS
   ============================================================ */

/* ---------- 字体定义 ---------- */
/* 幼圆 — Windows 系统字体，文件名为 SIMYOU.TTF */
@font-face {
    font-family: 'YouYuanLocal';
    src: local('幼圆'), local('YouYuan'), local('SimYou');
    font-weight: normal;
    font-style: normal;
}

/* ---------- CSS 变量：浅色主题（默认） ---------- */
:root {
    --bg: #f2f8f4;
    --bg-secondary: #e8f2eb;
    --card-bg: #ffffff;
    --text: #2c3e2d;
    --text-secondary: #5a7a5b;
    --accent: #66bb6a;
    --accent-hover: #4caf50;
    --tag-bg: #c8e6c9;
    --tag-text: #2e7d32;
    --search-bg: #ffffff;
    --search-border: #c8e6c9;
    --search-focus-border: #66bb6a;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    --card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.12);
    --flower-color: #f0b8c0;
    --flower-opacity: 0.55;
    --category-header-bg: #e8f5e9;
    --category-header-hover: #dcedc8;
    --toggle-bg: #e8f5e9;
    --border: rgba(0, 0, 0, 0.06);
}

/* ---------- CSS 变量：深色主题 ---------- */
[data-theme="dark"] {
    --bg: #19192e;
    --bg-secondary: #1f1f38;
    --card-bg: #252540;
    --text: #e0e0e0;
    --text-secondary: #a0a0b8;
    --accent: #8b8bf0;
    --accent-hover: #7676e0;
    --tag-bg: #2a2a50;
    --tag-text: #c0c0f0;
    --search-bg: #252540;
    --search-border: #3a3a60;
    --search-focus-border: #8b8bf0;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.4);
    --flower-color: #5a5a8a;
    --flower-opacity: 0.35;
    --category-header-bg: #1e1e38;
    --category-header-hover: #2a2a4a;
    --toggle-bg: #252540;
    --border: rgba(255, 255, 255, 0.08);
}

/* ============================================================
   基础重置 & 全局样式
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Comic Sans MS', 'YouYuanLocal', '幼圆', 'YouYuan', cursive, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
    position: relative;
    overflow-x: hidden;
    padding-bottom: 60px;
}

/* ============================================================
   主题切换按钮（右上角）
   ============================================================ */

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--toggle-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.3s, border-color 0.3s, transform 0.2s;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* 浅色模式显示月亮，深色模式显示太阳 */
.toggle-icon::before {
    content: '🌙';
}

[data-theme="dark"] .toggle-icon::before {
    content: '☀️';
}

/* ============================================================
   标题区域
   ============================================================ */

.header {
    text-align: center;
    padding: 50px 20px 0;
}

.title {
    font-size: 2.2rem;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--text);
}

/* ============================================================
   搜索区域
   ============================================================ */

.search-wrapper {
    display: flex;
    justify-content: center;
    padding: 28px 20px 16px;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    opacity: 0.5;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 14px 44px 14px 48px;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--search-border);
    border-radius: 28px;
    background: var(--search-bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.search-input:focus {
    border-color: var(--search-focus-border);
    box-shadow: 0 0 0 4px rgba(102, 187, 106, 0.15);
}

[data-theme="dark"] .search-input:focus {
    box-shadow: 0 0 0 4px rgba(139, 139, 240, 0.2);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.search-clear:hover {
    background: var(--tag-bg);
    color: var(--text);
}

/* ============================================================
   内容区域
   ============================================================ */

.content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 24px 40px;
}

/* 加载/空/错误状态 */
.loading,
.empty-message,
.error-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.error-message {
    color: #e57373;
}

/* ============================================================
   分类区块
   ============================================================ */

.category {
    margin-bottom: 36px;
}

/* 分类标题行 */
.category-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    margin-bottom: 14px;
    width: fit-content;
    min-width: 140px;
    background: var(--category-header-bg);
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border);
}

.category-header:hover {
    background: var(--category-header-hover);
    box-shadow: var(--shadow);
}

.category-name {
    font-size: 0.95rem;
    font-weight: 700;
}

.category-arrow {
    font-size: 0.75rem;
    transition: transform 0.35s ease;
    opacity: 0.5;
    line-height: 1;
}

.category.collapsed .category-arrow {
    transform: rotate(-90deg);
}

/* 卡片网格 */
.category-sites {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.35s ease, margin 0.35s ease;
    max-height: 3000px;
    opacity: 1;
}

.category.collapsed .category-sites {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    overflow: hidden;
}

/* 分类中无可见卡片时隐藏整个分类 */
.category.no-results {
    display: none;
}

/* ============================================================
   网站卡片
   ============================================================ */

.site-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s;
    cursor: pointer;
    border: 1px solid var(--border);
    text-decoration: none;
}

.site-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

/* 卡片主体信息 */
.card-body {
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
    justify-content: center;
}

.card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 描述 */
.card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 标签区域 */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.tag {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--tag-bg);
    color: var(--tag-text);
    transition: background 0.3s, color 0.3s;
    white-space: nowrap;
}

/* ============================================================
   花朵装饰
   ============================================================ */

.flowers {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.flower {
    position: absolute;
    width: 26px;
    height: 26px;
    opacity: var(--flower-opacity);
    transition: opacity 0.4s ease;
}

/* 五瓣花 SVG（内联 data URI） */
.flower::before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background-color: var(--flower-color);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='15' cy='15' r='3.5'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(0 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(72 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(144 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(216 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(288 15 15)'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='15' cy='15' r='3.5'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(0 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(72 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(144 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(216 15 15)'/%3E%3Cellipse cx='15' cy='5.5' rx='4' ry='6' transform='rotate(288 15 15)'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    transition: background-color 0.4s ease;
}

/* 每朵花的位置、大小、旋转（均匀分散，不密集） */
.flower-1 { top: 8%;  left: 4%;   width: 28px; height: 28px; transform: rotate(15deg);  }
.flower-2 { top: 22%; right: 5%;  width: 22px; height: 22px; transform: rotate(-25deg); }
.flower-3 { top: 48%; left: 2%;   width: 24px; height: 24px; transform: rotate(40deg);  }
.flower-4 { top: 65%; right: 4%;  width: 26px; height: 26px; transform: rotate(-10deg); }
.flower-5 { bottom: 12%; left: 8%; width: 20px; height: 20px; transform: rotate(55deg); }
.flower-6 { top: 10%; right: 12%; width: 22px; height: 22px; transform: rotate(-45deg); }
.flower-7 { bottom: 20%; right: 10%; width: 24px; height: 24px; transform: rotate(30deg); }
.flower-8 { top: 80%; left: 6%; width: 21px; height: 21px; transform: rotate(-20deg); }

/* ============================================================
   响应式适配
   ============================================================ */

@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    .category-sites {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 14px;
    }
    .search-box {
        max-width: 360px;
    }
}

@media (max-width: 480px) {
    .header {
        padding-top: 40px;
    }
    .title {
        font-size: 1.6rem;
    }
    .category-sites {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .card-body {
        padding: 10px 12px 10px;
    }
    .category-header {
        padding: 6px 14px;
    }
    .content {
        padding: 10px 12px 40px;
    }
}
