/* assets/style.css */

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --border-color: #e9ecef;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --container-width: 1200px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; transition: color 0.2s; }
a:hover { color: var(--primary-color); }
ul { list-style: none; }
img { max-width: 100%; height: auto; }

/* --- Layout --- */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.main-layout {
    display: flex;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 50px;
    flex: 1;
}

.content-area { flex: 3; background: transparent; }
.sidebar { flex: 1; min-width: 300px; }

/* --- Header & Nav --- */
.site-header {
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}
.logo img { height: 60px; margin-right: 10px; }

.main-nav ul { display: flex; gap: 20px; }
.main-nav a { font-weight: 500; color: var(--text-main); }
.main-nav a:hover { color: var(--primary-color); }

/* 默认隐藏汉堡按钮 (桌面端) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
    padding: 5px; /* 增加点击区域 */
}

/* --- Ads Slots --- */
.ad-container {
    margin: 20px 0;
    text-align: center;
    background: #eee;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    border-radius: var(--radius);
    overflow: hidden;
}

/* --- Components: Buttons --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-outline { border-color: var(--primary-color); color: var(--primary-color); background: transparent; }
.btn-outline:hover { background: var(--primary-color); color: #fff; }
.btn-secondary { background: var(--secondary-color); color: #fff; }
.btn-large { padding: 15px 40px; font-size: 1.2rem; }

/* --- Home Page --- */
.page-header { margin-bottom: 30px; text-align: center; }
.page-header h1 { font-size: 2.5rem; margin-bottom: 10px; color: #222; }
.subtitle { color: var(--text-muted); font-size: 1.1rem; }

.category-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 40px;
}

.category-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.category-head h2 { font-size: 1.8rem; }
.category-head a { color: var(--text-main); }
.count-badge { background: #eef2f7; color: var(--primary-color); padding: 4px 10px; border-radius: 20px; font-size: 0.9rem; font-weight: bold; }

.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.quiz-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.quiz-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--primary-color); }
.quiz-card h3 { font-size: 1.2rem; margin-bottom: 10px; line-height: 1.4; }
.card-tags { margin-bottom: 15px; }
.card-tags span { background: #f1f3f5; color: #555; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; margin-right: 5px; }
.card-meta { font-size: 0.85rem; color: #999; margin-top: auto; padding-top: 10px; border-top: 1px solid #eee; }
.card-action { margin-top: 15px; text-align: right; }

.category-footer { margin-top: 20px; text-align: right; }
.view-all-link { color: var(--primary-color); font-weight: 600; }

/* --- Category Page --- */
.breadcrumb { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 15px; }
.quiz-list-layout { display: flex; flex-direction: column; gap: 15px; }
.quiz-list-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}
.quiz-list-item h2 { font-size: 1.4rem; margin-bottom: 5px; }
.item-meta { font-size: 0.9rem; color: var(--text-muted); text-align: center; }
.item-meta .tags { margin-left: 10px; font-style: italic; }
.item-action { margin: 20px 0 20px; text-align: center; }

/* --- Quiz Intro & Play --- */
.quiz-intro-page, .quiz-player-page {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.quiz-meta-bar {
    display: flex;
    gap: 20px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: var(--radius);
    margin: 20px 0;
    font-size: 0.95rem;
}
.quiz-start-area { text-align: center; margin-top: 40px; padding: 30px; background: #f0f7ff; border-radius: var(--radius); }
.start-box p { margin-bottom: 20px; font-size: 1.2rem; }
.small-note { font-size: 0.85rem; color: #888; margin-top: 10px; }

/* Search */
.search-box-container { text-align: center; margin-bottom: 30px; }
.search-form-large { display: flex; max-width: 600px; margin: 0 auto; gap: 10px; }
.search-form-large input { flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: var(--radius); font-size: 1rem; }
.search-result-item { background: #fff; padding: 20px; margin-bottom: 15px; border-radius: var(--radius); border: 1px solid var(--border-color); }
.search-result-item mark { background: #fff3cd; color: #856404; padding: 0 2px; }

/* Static Pages */
.static-content-page { background: var(--card-bg); padding: 40px; border-radius: var(--radius); }
.content-body h3 { margin-top: 25px; margin-bottom: 10px; color: #444; }

/* Sidebar Widgets */
/* Sidebar Widgets - Tag Cloud / Capsule Style */
.widget { 
    background: var(--card-bg); 
    padding: 20px; 
    border-radius: var(--radius); 
    margin-bottom: 30px; 
    box-shadow: var(--shadow-sm); 
}

.widget h3 { 
    font-size: 1.2rem; 
    margin-bottom: 15px; 
    border-bottom: 2px solid var(--primary-color); 
    padding-bottom: 10px; 
    display: inline-block; 
    color: var(--text-color);
}

/* 关键：设置 Flex 布局并允许换行 */
.widget ul { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex; 
    flex-wrap: wrap; /* 核心：溢出自动换行 */
    gap: 10px; /* 按钮之间的间距 (水平和垂直) */
}

/* 列表项重置 */
.widget ul li { 
    margin: 0; 
    padding: 0; 
    border: none; 
}

/* 按钮样式 */
.widget ul li a { 
    display: inline-block; /* 适应内容宽度，不占满整行 */
    padding: 8px 16px; /* 上下8px，左右16px */
    background-color: #f0f2f5; /* 浅灰背景 */
    color: var(--text-color); 
    text-decoration: none; 
    border-radius: 20px; /* 大圆角，形成胶囊形状 */
    font-size: 0.9rem; 
    font-weight: 500; 
    transition: all 0.2s ease; 
    border: 1px solid transparent; 
    white-space: nowrap; /* 防止文字在按钮内换行 */
}

/* 悬停效果 */
.widget ul li a:hover { 
    background-color: var(--primary-color); 
    color: #ffffff; 
    transform: translateY(-2px); /* 轻微上浮 */
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); 
}

/* 可选：如果是当前页面分类，高亮显示 (需要 PHP 配合添加 class="active") */
.widget ul li a.active {
    background-color: var(--primary-color);
    color: #fff;
}

/* Footer */
.site-footer {
    background: #222;
    color: #ccc;
    padding: 40px 0;
    margin-top: auto;
}
.site-footer .container { text-align: center; }
.footer-links { margin: 20px 0; }
.footer-links a { color: #fff; margin: 0 15px; }
.footer-links a:hover { text-decoration: underline; }

/*ad*/
.ad-unit {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f6f6;
}

/* =========================================
   Responsive Mobile Styles (< 768px)
   ========================================= */
@media (max-width: 768px) {
    /* 1. 显示汉堡按钮 */
    .mobile-menu-toggle {
        display: block; 
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-main);
        z-index: 1001;
        position: relative;
        padding: 5px;
    }

    /* 2. 默认隐藏导航菜单 */
    .main-nav {
        display: none; 
        position: absolute; 
        top: 70px;
        left: 0;
        width: 100%;
        background: var(--card-bg); 
        box-shadow: var(--shadow-md);
        padding: 20px;
        z-index: 999; 
        border-top: 1px solid var(--border-color);
    }

    /* 3. 激活状态：显示菜单 */
    .main-nav.active {
        display: block; 
        animation: slideDown 0.3s ease-out;
    }

    /* 4. 菜单项垂直排列 + 居中 */
    .main-nav ul {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .main-nav ul li {
        border-bottom: 1px solid #f1f1f1;
        padding-bottom: 10px;
    }
    .main-nav ul li:last-child {
        border-bottom: none;
    }

    /* 5. 【关键】隐藏侧边栏 —— 手机端不要双栏！ */
    .sidebar {
        display: none !important;
    }

    /* 6. 【关键】主内容区占满宽度 */
    .content-area {
        flex: 1;
        width: 100%;
    }

    /* 7. 【关键】主布局改为单列 */
    .main-layout {
        /*flex-direction: column;*/
        gap: 20px;
        margin-top: 76px;
        margin-bottom: 30px;
    }

    /* 8. Header 内元素垂直居中对齐 */
    .header-inner {
        padding: 0 15px;
        height: 60px; /* 稍微降低高度适应手机 */
    }

    .logo {
        font-size: 1.3rem;
    }
    .logo img {
        height: 45px;
        margin-right: 8px;
    }

    /* 9. 其他组件适配 */
    .share-buttons {
        /*flex-direction: column; */
        gap: 10px;
        align-items: center;
    }
    
    .share-btn {
        width: 45px; 
        height: 45px;
    }

    .quiz-meta-bar {
        flex-direction: column;
        gap: 10px;
        align-items: center;
        text-align: center;
    }
    
    h1 {
        font-size: 1.5rem; 
        word-wrap: break-word; 
    }
    
    .btn-start {
        width: 100%; 
        max-width: 300px;
        padding: 12px 30px;
        font-size: 1.1rem;
    }
    
    .quiz-intro-page, .quiz-player-page, .static-content-page, .category-section {
        padding: 20px 15px; 
    }

    /* 10. 广告位也调整为全宽 */
    .ad-container {
        margin: 15px 0;
        min-height: 70px;
    }
}
/* =========================================
   移动端底部固定分类栏 (Mobile Sticky Category Bar)
   功能：仅手机端显示，底部固定，可左右拖动，不遮挡内容
   ========================================= */

/* 1. 容器基础样式 (默认隐藏，仅在媒体查询中开启) */
.mobile-category-bar {
    display: none; /* 核心：PC 端默认隐藏，不影响任何布局 */
    position: fixed; /* 核心：固定在视口底部 */
    top: 60px;
    left: 0;
    width: 100%;
    height: 56px; /* 适合手机操作的高度 */
    background: rgba(255, 255, 255, 0.98); /* 接近不透明的白色背景 */
    backdrop-filter: blur(10px); /* 磨砂玻璃特效 (iOS/现代安卓) */
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #eaeaea;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 990; /* 层级：高于内容，低于弹窗/汉堡菜单 */
    
    /* 弹性布局，让内部内容横向排列 */
    display: flex; 
    align-items: center;
    justify-content: flex-start;
}

/* 2. 内部滚动容器 (实现左右拖动) */
.category-scroll-container {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    
    /* 核心：允许横向滚动，隐藏纵向滚动 */
    overflow-x: auto; 
    overflow-y: hidden;
    
    /* 内边距，防止第一个和最后一个按钮贴边 */
    padding: 0 15px; 
    
    /* 按钮之间的间距 */
    gap: 10px; 
    
    /* 平滑滚动体验 */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
    
    /* 核心：隐藏滚动条 (视觉更干净，但保留拖动功能) */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* 隐藏 Chrome/Safari/Edge 的滚动条 */
.category-scroll-container::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* 3. 分类按钮样式 (胶囊状) */
.cat-pill {
    flex-shrink: 0; /* 核心：防止按钮被压缩，保持完整宽度 */
    white-space: nowrap; /* 防止文字换行 */
    
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    background-color: #f0f2f5;
    border-radius: 20px; /* 圆角胶囊 */
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    
    /* 优化点击体验 */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* 按钮悬停/按压效果 */
.cat-pill:active {
    transform: scale(0.95);
    background-color: #e4e6eb;
}

/* 当前激活状态 (由 PHP 添加 .active 类) */
.cat-pill.active {
    background-color: var(--primary-color); /* 使用你的主题色 #007bff */
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* 4. 响应式控制：仅在屏幕宽度 <= 768px 时生效 */
@media (max-width: 768px) {
    .mobile-category-bar {
        display: flex; /* 手机端开启显示 */
    }

    /* 关键：给 body 底部留白，防止内容被菜单栏遮挡 */
    body {
        padding-bottom: 60px; 
    }
    
    /* 如果 footer 有 margin-top，可能需要微调，通常 padding-bottom 足够 */
}

/* PC 端强制隐藏 (双重保险) */
@media (min-width: 769px) {
    .mobile-category-bar {
        display: none !important;
    }
    body {
        padding-bottom: 0; /* PC 端不需要底部留白 */
    }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}