/* ========================================
   话题首页瀑布流样式 - 简洁清新设计
   使用本地思源黑体字体
   ======================================== */

/* 字体定义 - 使用本地思源黑体（优化：仅加载woff格式） */
@font-face {
    font-family: 'SourceHanSansCN';
    src: url('../../../public/mainpack/fonts/SOURCEHANSANSCN-NORMAL.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SourceHanSansCN';
    src: url('../../../public/mainpack/fonts/SOURCEHANSANSCN-MEDIUM.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'SourceHanSansCN';
    src: url('../../../public/mainpack/fonts/SOURCEHANSANSCN-BOLD.woff') format('woff');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* 基础设置 */
.topic-index-page {
    background: #fafbfc;
    min-height: 100vh;
    font-family: 'SourceHanSansCN', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

.topic-index-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* 页面头部 - 限定作用域 */
.topic-index-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 1rem;
}

.topic-index-page .header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}

.topic-index-page .page-title {
    font-size: 2rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.2;
    flex-shrink: 0;
}

/* 筛选标签 - 限定作用域 */
.topic-index-page .filter-tabs {
    display: flex;
    gap: 4px;
    background: #ffffff;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 快速发帖按钮 - 限定作用域 */
.topic-index-page .quick-post-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 8px 16px;
    background: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.topic-index-page .quick-post-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.topic-index-page .quick-post-btn i {
    font-size: 16px;
}

.topic-index-page .filter-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.topic-index-page .filter-tab:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    text-decoration: none;
}

.topic-index-page .filter-tab.active {
    color: #ffffff;
    background: #3b82f6;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* 瀑布流容器 - 使用绝对定位实现真正的紧密排列 */
.waterfall-container {
    position: relative;
    margin-bottom: 40px;
    min-height: 400px;
    /* 容器高度由JavaScript动态设置 */
}

/* 话题卡片 */
.topic-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
    overflow: hidden;
    position: absolute; /* 绝对定位实现瀑布流 */
    /* 初始状态：完全隐藏，避免堆叠显示 */
    opacity: 0;
    visibility: hidden;
    /* 宽度和位置由JavaScript动态设置 */
    /* 性能优化：启用硬件加速，减少闪烁 */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
    /* 平滑过渡 */
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                visibility 0s linear 0.3s,
                top 0.3s ease,
                left 0.3s ease;
}

/* JavaScript布局完成后显示卡片 */
.topic-card.positioned {
    opacity: 1;
    visibility: visible;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                visibility 0s,
                top 0.3s ease,
                left 0.3s ease;
}

.topic-card:hover {
    transform: translateY(-4px) translateZ(0);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    border-color: #e2e8f0;
    z-index: 1;
}

/* 封面图片 */
.card-cover {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    background: #f0f2f5;
}

.card-cover a {
    display: block;
    width: 100%;
    height: 100%;
}

.card-cover img,
.card-cover video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 性能优化：独立的transform层 */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* 初始透明，加载完成后显示 */
    opacity: 0;
}

.card-cover img.loaded {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.topic-card:hover .card-cover img {
    transform: scale(1.08) translateZ(0);
}

/* 图片加载占位符 - 骨架屏动画 */
.card-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #f0f2f5 25%,
        #e8eaed 50%,
        #f0f2f5 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    z-index: 1;
}

.card-cover img.loaded ~ .card-cover::before,
.card-cover.has-image::before {
    display: none;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 隐藏图片加载失败的默认图标 */
.card-cover img {
    font-size: 0;
    color: transparent;
}

.card-cover img::before {
    content: '';
    display: block;
}

/* 卡片内容 */
.card-content {
    padding: 20px;
}

/* 用户信息 - 限定作用域 */
.topic-card .user-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.topic-card .user-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #6b7280;
    transition: color 0.2s ease;
}

.topic-card .user-link:hover {
    color: #3b82f6;
    text-decoration: none;
}

.topic-card .user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    object-fit: cover;
}

.topic-card .user-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.post-time {
    font-size: 12px;
    color: #9ca3af;
}

/* 标题 */
.card-title {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: #111827;
}

.card-title a {
    color: #111827;
    text-decoration: none;
    transition: color 0.2s ease;
}

.card-title a:hover {
    color: #3b82f6;
}

.topic-label {
    display: inline-block;
    background: #fef2f2;
    color: #dc2626;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
}

.pin-badge {
    display: inline-block;
    background: #fef3c7;
    color: #d97706;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* 摘要 */
.card-excerpt {
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #6b7280;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* 标准属性 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 统计信息 */
.card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #9ca3af;
}

.stats-left {
    flex: 1;
    min-width: 0;
}

.group-tag {
    display: inline-flex;
    align-items: center;
    color: #6b7280;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    background: #f8fafc;
    transition: all 0.2s ease;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-tag:hover {
    color: #3b82f6;
    background: #eff6ff;
    text-decoration: none;
}

.stats-right {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.topic-card .stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topic-card .stat-item i {
    font-size: 11px;
}

/* 无限滚动加载提示 */
.infinite-scroll-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    margin-top: 2rem;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* 没有更多内容提示 */
.infinite-scroll-end {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
}

.infinite-scroll-end span {
    font-size: 0.875rem;
    color: #9ca3af;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: #f8f9fa;
}

/* 分页（传统方式，默认隐藏） */
.pagination-section {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

/* 空状态 */
.topic-index-page .empty-state {
    text-align: center;
    padding: 80px 20px;
    max-width: 400px;
    margin: 0 auto;
}

.topic-index-page .empty-icon {
    font-size: 64px;
    color: #d1d5db;
    margin-bottom: 24px;
}

.topic-index-page .empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px 0;
}

.topic-index-page .empty-state p {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.topic-index-page .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #3b82f6;
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
}

.topic-index-page .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    text-decoration: none;
    color: #ffffff;
}

/* 响应式设计 */
@media (min-width: 768px) {
    .topic-index-page .container {
        padding: 32px 24px;
    }
    
    .topic-index-page .page-title {
        font-size: 2.25rem;
    }
    
    .card-cover {
        height: 220px;
    }
}

@media (max-width: 767px) {
    .topic-index-page .container {
        padding: 20px 16px;
    }
    
    .topic-index-page .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .topic-index-page .page-title {
        font-size: 1.75rem;
    }
    
    .topic-index-page .filter-tabs {
        width: 100%;
        justify-content: space-between;
    }
    
    .topic-index-page .filter-tab {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .card-content {
        padding: 16px;
    }
    
    .card-cover {
        height: 180px;
    }
}

@media (max-width: 480px) {
    .topic-index-page .container {
        padding: 16px 12px;
    }
    
    .topic-index-page .page-title {
        font-size: 1.5rem;
    }
    
    .topic-index-page .filter-tab {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .card-cover {
        height: 160px;
    }
    
    .card-content {
        padding: 12px;
    }
    
    .card-title {
        font-size: 15px;
    }
    
    .topic-card .user-section {
        margin-bottom: 10px;
    }
    
    .card-stats {
        font-size: 11px;
    }
    
    .stats-right {
        gap: 8px;
    }
}

/* 深色模式支持 */
/* ========================================
   暗色模式适配 - 系统夜间模式
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* 页面背景 */
    .topic-index-page {
        background: #0f172a;
    }
    
    /* 卡片背景 */
    .topic-card {
        background: #1e293b;
        border-color: #334155;
    }
    
    /* 页面标题 */
    .page-title {
        color: #f8fafc;
    }
    
    
    /* 卡片标题 */
    .card-title,
    .card-title a {
        color: #f8fafc;
    }
    
    .card-title a:hover {
        color: #60a5fa;
    }
    
    /* 筛选标签 */
    .filter-tabs {
        background: #1e293b;
        border-color: #334155;
    }
    
    .filter-tab {
        color: #94a3b8;
    }
    
    .filter-tab:hover {
        color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
    }
    
    .filter-tab.active {
        color: #ffffff;
        background: #3b82f6;
    }
    
    /* 用户信息 */
    .topic-card .user-name {
        color: #cbd5e1;
    }
    
    .post-time {
        color: #64748b;
    }
    
    /* 摘要文字 */
    .card-excerpt {
        color: #94a3b8;
    }
    
    /* 小组标签 */
    .group-tag {
        background: #334155;
        color: #cbd5e1;
    }
    
    .group-tag:hover {
        background: rgba(96, 165, 250, 0.1);
        color: #60a5fa;
    }
    
    /* 统计信息 */
    .card-stats {
        color: #64748b;
    }
    
    .stat-item {
        color: #64748b;
    }
    
    /* 标签徽章 */
    .topic-label {
        background: #7f1d1d;
        color: #fca5a5;
    }
    
    .pin-badge {
        background: #78350f;
        color: #fcd34d;
    }
    
    /* 封面占位背景 */
    .card-cover {
        background: #334155;
    }
    
    /* 空状态 */
    .topic-index-page .empty-state {
        color: #94a3b8;
    }
    
    .topic-index-page .empty-state h3 {
        color: #cbd5e1;
    }
    
    .topic-index-page .empty-state p {
        color: #64748b;
    }
    
    .topic-index-page .empty-icon {
        color: #475569;
    }
    
    /* 无限滚动加载提示 */
    .infinite-scroll-loading {
        color: #64748b;
    }
    
    .loading-spinner {
        border-color: #334155;
        border-top-color: #3b82f6;
    }
    
    .loading-text {
        color: #64748b;
    }
    
    .infinite-scroll-end span {
        color: #64748b;
        background: #1e293b;
    }
}

/* ========================================
   快速发帖弹窗
   ======================================== */

/* 弹窗容器 */
.quick-post-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

/* 遮罩层 */
.quick-post-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* 弹窗对话框 - 桌面端宽一些 */
.quick-post-dialog {
    position: relative;
    z-index: 2;
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* 弹窗头部 */
.quick-post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f3f5;
    flex-shrink: 0;
}

.quick-post-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.quick-post-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.quick-post-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* 弹窗主体 */
.quick-post-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* 表单组 */
.quick-post-modal .form-group {
    margin-bottom: 1.25rem;
}

.quick-post-modal .form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

/* 下拉选择框 */
.quick-post-modal .form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #374151;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.quick-post-modal .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 文本输入框 */
.quick-post-modal .form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
}

.quick-post-modal .form-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 文本域 */
.quick-post-modal .form-textarea {
    width: 100%;
    min-height: 180px;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
    outline: none;
}

.quick-post-modal .form-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 防止编辑器插件影响弹窗样式 */
.quick-post-modal .note-editor {
    display: none !important;
}

.quick-post-modal textarea {
    display: block !important;
}

/* 弹窗底部按钮 */
.quick-post-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f1f3f5;
}

.quick-post-modal .btn-submit,
.quick-post-modal .btn-cancel {
    padding: 0.625rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.quick-post-modal .btn-submit {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.quick-post-modal .btn-submit:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.quick-post-modal .btn-cancel {
    background: #ffffff;
    color: #6b7280;
    border: 1px solid #e1e4e8;
}

.quick-post-modal .btn-cancel:hover {
    background: #f6f8fa;
    border-color: #d0d7de;
}

/* 漂流描述区域 */
.drift-description {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #3b82f6;
}

.drift-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.6;
    margin: 0;
    font-style: italic;
}

/* 响应式 - 快速发帖弹窗 */
@media (max-width: 768px) {
    .quick-post-dialog {
        width: 95%;
        max-width: none;
        max-height: 90vh;
    }
    
    .quick-post-header,
    .quick-post-body {
        padding: 1rem;
    }
    
    .topic-index-page .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .quick-post-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .upload-preview {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

/* 性能优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

