/* =================================================================
 * 组件样式 (Components)
 * 从所有页面提取的统一组件样式
 *
 * 包含:
 *   - FAB 系统 (floating-actions / fab / toast)
 *   - 智能搜索 (smart-search / search-box / search-input / search-results)
 *   - Footer 导航变体
 *   - 章节锚点动画 (#ch1-9 / #section-*)
 *   - 实用工具类 (.fade-in-up / .active / .visible / .focused / .show)
 *
 * 用法:
 *   <link href="assets/styles/design-system.css" rel="stylesheet">
 *   <link href="assets/styles/md3-enhance.css" rel="stylesheet">
 *   <link href="assets/styles/md3-readability.css" rel="stylesheet">
 *   <link href="assets/styles/components.css" rel="stylesheet">
 * ================================================================= */

/* ===== FAB 浮动操作按钮组 ===== */
.floating-actions {
    position: fixed;
    right: 24px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 998;
}

.fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-primary, #cc785c);
    color: var(--on-primary, #ffffff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(204, 120, 92, 0.4);
    transition: all 0.2s;
}
.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(204, 120, 92, 0.6);
}
.fab.active {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
}

/* ===== Toast 提示 ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-dark, #181715);
    color: var(--on-dark, #faf9f5);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--hairline, #e6dfd8);
    z-index: 9999;
    transition: transform 0.3s;
    font-size: 14px;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ===== 智能搜索 ===== */
.smart-search {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
.smart-search.active {
    display: flex;
}

.search-box {
    width: 90%;
    max-width: 600px;
    background: var(--surface-dark, #181715);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--hairline-soft, #ebe6df);
}

.search-input {
    width: 100%;
    padding: 14px 20px;
    background: var(--canvas, #faf9f5);
    border: 1px solid var(--hairline, #e6dfd8);
    border-radius: 12px;
    color: var(--ink, #141413);
    font-size: 16px;
    outline: none;
    font-family: inherit;
}
.search-input:focus {
    border-color: var(--brand-primary, #cc785c);
    box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.2);
}

.search-results {
    margin-top: 12px;
    max-height: 50vh;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--on-dark, #faf9f5);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
    text-decoration: none;
}
.search-result-item:hover,
.search-result-item.focused {
    background: rgba(204, 120, 92, 0.15);
    color: var(--on-dark, #faf9f5);
}

.cat-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(204, 120, 92, 0.2);
    color: var(--brand-primary, #cc785c);
    flex-shrink: 0;
}

.search-empty {
    padding: 32px;
    text-align: center;
    color: var(--muted-soft, #8e8b82);
    font-size: 14px;
}

/* ===== Footer 导航扩展 ===== */
.footer-nav-label {
    font-size: 0.75rem;
    color: var(--muted-soft, #8e8b82);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.footer-nav-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--on-dark, #faf9f5);
}

.footer-nav-arrow {
    color: var(--brand-primary, #cc785c);
    font-size: 1.5rem;
    transition: transform 0.3s;
}
.footer-nav-card:hover .footer-nav-arrow-left {
    transform: translateX(-4px);
}
.footer-nav-card:hover .footer-nav-arrow-right {
    transform: translateX(4px);
}

.footer-nav-icon {
    width: 2rem;
    height: 2rem;
    color: var(--brand-primary, #cc785c);
    margin-bottom: 0.5rem;
}

/* ===== 通用动画 ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 400ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* 章节锚点交错出现 */
section[id^="ch"],
section[id^="section-"] {
    animation: fadeInUp 500ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
section[id="ch1"], section[id="section-1"] { animation-delay: 0ms; }
section[id="ch2"], section[id="section-2"] { animation-delay: 100ms; }
section[id="ch3"], section[id="section-3"] { animation-delay: 200ms; }
section[id="ch4"], section[id="section-4"] { animation-delay: 300ms; }
section[id="ch5"], section[id="section-5"] { animation-delay: 400ms; }
section[id="ch6"], section[id="section-6"] { animation-delay: 500ms; }
section[id="ch7"], section[id="section-7"] { animation-delay: 600ms; }
section[id="ch8"], section[id="section-8"] { animation-delay: 700ms; }
section[id="ch9"], section[id="section-9"] { animation-delay: 800ms; }

/* 章节内卡片交错 */
.magic-card:nth-child(1) { animation-delay: 0ms; }
.magic-card:nth-child(2) { animation-delay: 80ms; }
.magic-card:nth-child(3) { animation-delay: 160ms; }
.magic-card:nth-child(4) { animation-delay: 240ms; }
.magic-card:nth-child(5) { animation-delay: 320ms; }

.principle-card:nth-child(1) { animation-delay: 0ms; }
.principle-card:nth-child(2) { animation-delay: 60ms; }
.principle-card:nth-child(3) { animation-delay: 120ms; }
.principle-card:nth-child(4) { animation-delay: 180ms; }
.principle-card:nth-child(5) { animation-delay: 240ms; }

/* ===== 工具类 ===== */
.active { /* 通用 active 状态 */ }
.visible { /* 通用可见性切换 */ }
.show { /* 通用显示状态 */ }
.focused { /* 通用聚焦状态 */ }

/* ===== 媒体查询偏好 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}