/* =============================================
   Design System - Global Unified Style
   cms_native - 2026-06-18
   ============================================= */

/* =============================================
   Base Styles
   ============================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

/* =============================================
   Unified Icon Style - Single Color SVG
   ALL icons must use stroke="currentColor"
   NO emojis, NO colored icons
   ============================================= */
.icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}


/* =============================================
   Unified Input Styles
   ============================================= */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 0px solid var(--line);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink);
    transition: border-color var(--transition-fast);
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
}

/* =============================================
   Unified Modal Styles
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

.toast {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-width: 300px;
    max-width:720px;
    animation: slideInRight 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* =============================================
   Unified Loading Spinner
   ============================================= */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   Unified Empty State
   ============================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
    color: var(--muted);
}

.empty-state .icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-lg);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--muted);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    font-size: 14px;
    max-width:720px;
}

/* =============================================
   Responsive Grid
   ============================================= */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

@media (max-width:1200px) {
    .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width:720px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width:720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.text-primary { color: var(--primary); }

.mt-sm { margin-top: var(--spacing-sm); }

.flex { display: flex; }

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* =============================================
   Dark Mode Overrides
   ============================================= */
[data-theme="dark"] body {
    background: var(--bg);
    color: var(--ink);
}

[data-theme="dark"] .card {
    background: var(--surface);
    border-color: var(--line);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

[data-theme="dark"] .modal {
    background: var(--surface);
}

[data-theme="dark"] .toast {
    background: var(--surface);
}

/* =============================================
   Facet Filter — 分面筛选侧边栏组件
   统一合入 design-system（原 themes/pages/facet.css）
   ============================================= */

/* 分面组（accordion） */
.facet-group {
    border-top: 1px solid var(--line);
    padding: 10px 0 4px;
}
.facet-group:first-of-type {
    border-top: none;
    padding-top: 4px;
}

.facet-group-head {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 4px 2px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    color: var(--ink-600);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: color 0.15s;
}
.facet-group-head:hover { color: var(--accent); }
.facet-group.is-collapsed .fg-caret {
    transform: rotate(-90deg);
}

/* 折叠时隐藏主体 */
.facet-group-body {
    padding: 8px 2px 4px;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}
.facet-group.is-collapsed .facet-group-body {
    display: none;
}
.facet-group-body::-webkit-scrollbar { width: 4px; }
.facet-group-body::-webkit-scrollbar-track { background: transparent; }
.facet-group-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* chip 容器 */
/* 旧三栏 .facet-chip 视觉块（术语 chip / is-selected / fc-* / is-collapsed）已废弃删除：全仓无 PHP/JS 输出该变体，frontend 改用 .chip；.facet-chips 容器由 core/facet.css 提供（后台"已选"标签） */
@media (max-width:720px) {
    .facet-group-body { max-height: none; overflow: visible; }
}
.facet-group-body.show-all .fs-more { display: none; }

/* 「展开全部 N 项」按钮 */
.fs-more {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    border: 1px dashed var(--line);
    background: transparent;
    border-radius: 14px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.fs-more:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-bg);
}

/* =============================================
   Detail Page — 详情页共用组件
   ============================================= */

.detail-meta-row .author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--hx-e5e0d6);
}
.detail-meta-row .author-name {
    font-weight: 600;
    color: var(--ink-600);
}
.social-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    transition: all 0.15s;
}
.social-btn:hover {
    border-color: var(--line);
    background: var(--bg-soft);
    color: var(--ink);
}

/* 相关推荐 */
.related-section {
    margin-bottom: 32px;
}
.related-section h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 14px;
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.related-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    border: 1px solid var(--line);
    transition: all 0.15s;
}
.related-card:hover {
    border-color: var(--line);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.related-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}
.related-card span {
    padding: 0 10px 10px;
    font-size: 13px;
    color: var(--ink-600);
    line-height: 1.3;
}

/* 评论区 */
.comments {
    margin-bottom: 40px;
}
.comments h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 16px;
}

/* TOC 目录项 */
.toc-item {
    display: block;
    padding: 5px 0;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--surface);
    transition: color 0.15s;
    line-height: 1.4;
}
.toc-item:last-child { border-bottom: none; }
.toc-item:hover { color: var(--accent); }
.toc-h2 { padding-left: 12px; font-size: 12.5px; }
.toc-h3 { padding-left: 24px; font-size: 12px; color: var(--muted); }

/* 详情页响应式——右侧栏适配 */
@media (max-width:980px) {
    .detail-layout { flex-direction: column; }
    .detail-sidebar { width: 100%; }
    .ds-related-item { width: 50%; display: inline-flex; box-sizing: border-box; padding: 8px; }
}

/* 详情页响应式 */
@media (max-width:720px) {
    .detail-title { font-size: 22px; }
    .detail-meta-row { gap: 10px; font-size: 12px; }
    .detail-content { font-size: 15px; }
    .related-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width:720px) {
    .detail-title { font-size: 18px; }
    .related-grid { grid-template-columns: 1fr; }
    .social-bar { gap: 6px; }
    .social-btn { padding: 6px 10px; font-size: 12px; }
}
