/* ============================================================
   MCRES 茶室 - 共享组件样式
   依赖：base.css 的 CSS 变量

   包含：
     · 话题档位徽章
     · 帖子类型徽章
     · 话题 chip / 用户 chip
     · 帖子卡片（横向紧凑布局）
     · 回复条目
     · 话题选择器
     · 话题页头部
     · 通用 section 头
     · 全局置顶徽章
     · 额度提示（D9.1）
   ============================================================ */


/* ============================================================
   1. 话题档位徽章
   ============================================================ */
.topic-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

.topic-level-counter {
    background: rgba(139, 148, 158, 0.15);
    color: var(--level-counter);
}

.topic-level-yajian {
    background: rgba(232, 164, 55, 0.15);
    color: var(--level-yajian);
    box-shadow: 0 0 0 1px rgba(232, 164, 55, 0.35);
}

.topic-level-chatai {
    background: var(--level-chatai);
    color: #1a1a1a;
    font-weight: 600;
}

.topic-level-sanzuo {
    background: rgba(139, 148, 158, 0.10);
    color: var(--level-sanzuo);
}

.topic-level-sealed {
    background: rgba(224, 82, 82, 0.15);
    color: var(--level-sealed);
}


/* ============================================================
   2. 帖子类型徽章（颜色从 JSON 配置注入 --type-color）
   ============================================================ */
.post-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 9px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    background: color-mix(in srgb, var(--type-color, #8b949e) 18%, transparent);
    color: var(--type-color, #8b949e);
    white-space: nowrap;
}


/* ============================================================
   3. 话题 chip（用于茶桌滚动条、帖子 meta）
   ============================================================ */
.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(232, 164, 55, 0.10);
    color: var(--accent-bright);
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.topic-chip:hover {
    background: rgba(232, 164, 55, 0.20);
    color: var(--accent);
}

.topic-chip .hash {
    opacity: 0.7;
    font-weight: 400;
}


/* ============================================================
   4. 用户 chip（头像 + 昵称）
   ============================================================ */
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
    text-decoration: none;
}

.user-chip:hover {
    color: var(--accent-bright);
}

.user-chip .avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    flex-shrink: 0;
}

.user-chip .avatar-text {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    font-size: 11px;
    font-weight: 700;
}


/* ============================================================
   5. 帖子卡片（横向紧凑布局）
   ------------------------------------------------------------
   左侧 main（flex:1）：徽章+话题 / 作者+时间 / 标题 / 摘要 / meta
   右侧 cover（180px）：高度贴合卡片（stretch + cover 裁切）

   ★ 从 <a> 改为 <div data-href>：
     - 需要 cursor / outline / focus-visible
     - 内部可安全嵌套 <a>（话题 chip / 用户 chip）

   ★ 由 components/post_card.html 组件统一渲染。
   ============================================================ */
.post-card {
    display: flex;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    outline: none;
}

.post-card:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.post-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(232, 164, 55, 0.35);
    transform: translateY(-1px);
}

/* 左侧主内容 */
.post-card-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 第一行：徽章 + 话题 chip */
.post-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
}

/* 第二行：作者 + 时间 */
.post-card-author {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--text-muted);
}

.post-card-author .user-chip {
    font-size: 12.5px;
    color: var(--text-secondary);
}

.post-card-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.post-card-time i {
    font-size: 10px;
    opacity: 0.7;
}

/* 标题 */
.post-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card:hover .post-card-title {
    color: var(--accent-bright);
}

/* 摘要（1 行，避免撑高卡片） */
.post-card-excerpt {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* meta */
.post-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.post-card-meta .item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.post-card-meta i {
    font-size: 11px;
    opacity: 0.7;
}

/* 右侧封面：高度贴合卡片 */
.post-card-cover {
    width: 180px;
    flex-shrink: 0;
    align-self: stretch;      /* ★ 高度 = 卡片高度 */
    min-height: 90px;         /* 卡片非常矮时保底 */
    border-radius: var(--radius);
    overflow: hidden;
    background: #0b0f14;
    border: 1px solid var(--border-light);
}

.post-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;        /* 裁切居中，不变形 */
    display: block;
}

/* 徽章 */
.post-flag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
}

.post-flag-solved  { background: rgba(85, 216, 139, 0.15); color: var(--success); }
.post-flag-pinned  { background: rgba(232, 164, 55, 0.15); color: var(--accent); }
.post-flag-essence { background: rgba(232, 164, 55, 0.20); color: var(--accent-bright); }
.post-flag-locked  { background: rgba(139, 148, 158, 0.15); color: var(--text-muted); }

/* 响应式 */
@media (max-width: 900px) {
    .post-card-cover {
        width: 150px;
    }
}

@media (max-width: 640px) {
    .post-card {
        flex-direction: column;
        gap: 8px;
    }
    .post-card-cover {
        width: 100%;
        min-height: 0;
        aspect-ratio: 16 / 9;   /* 手机端：宽度撑满，恢复比例 */
        align-self: stretch;
    }
}


/* ============================================================
   6. 全局置顶徽章（D9.2）
   ------------------------------------------------------------
   ⚠️ 唯一权威定义。index.css / post.css 里若有重复，请删除。
   ============================================================ */
.post-flag-global {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: rgba(232, 164, 55, 0.20);
    color: var(--accent);
    white-space: nowrap;
}

.post-flag-global i {
    font-size: 10px;
    opacity: 0.9;
}


/* ============================================================
   7. 回复条目
   ============================================================ */
.reply-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

.reply-item:last-child {
    border-bottom: none;
}

.reply-item:hover {
    background: rgba(255, 255, 255, 0.015);
}

.reply-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.reply-floor {
    font-size: 11px;
    color: var(--text-muted);
    padding: 1px 7px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
    flex-shrink: 0;
}

.reply-body {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    word-wrap: break-word;
}

.reply-body p {
    margin-bottom: 8px;
}

.reply-body p:last-child {
    margin-bottom: 0;
}

.reply-body a {
    color: var(--accent-bright);
    text-decoration: underline;
    text-decoration-color: rgba(245, 184, 85, 0.4);
    text-underline-offset: 3px;
}

.reply-body a:hover {
    color: var(--accent);
}

.reply-body img {
    max-width: 100%;
    max-height: 360px;
    border-radius: 6px;
    margin: 8px 0;
    display: block;
}

.reply-body blockquote {
    margin: 8px 0;
    padding: 8px 14px;
    background: rgba(232, 164, 55, 0.05);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.reply-body code {
    background: rgba(232, 164, 55, 0.10);
    color: var(--accent-bright);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.9em;
}

.reply-body pre {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
}

.reply-body pre code {
    background: none;
    color: var(--text-primary);
    padding: 0;
}

.reply-reply-to {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: rgba(232, 164, 55, 0.06);
    border-left: 2px solid var(--accent);
    border-radius: 4px;
    margin-bottom: 8px;
    display: inline-block;
}

.reply-reply-to a {
    color: var(--accent-bright);
}

.reply-actions {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.reply-actions button,
.reply-actions a {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    transition: var(--transition);
}

.reply-actions button:hover,
.reply-actions a:hover {
    color: var(--accent-bright);
}


/* ============================================================
   8. 话题选择器（下拉面板）
   ============================================================ */
.topic-selector {
    position: relative;
    width: 100%;
}

.topic-selector-trigger {
    width: 100%;
    padding: 9px 14px;
    background: rgba(11, 15, 20, 0.6);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.topic-selector-trigger:hover {
    border-color: var(--border-strong);
}

.topic-selector-trigger.open {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 164, 55, 0.15);
}

.topic-selector-trigger .placeholder {
    color: var(--text-muted);
}

.topic-selector-trigger .caret {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.topic-selector-trigger.open .caret {
    transform: rotate(180deg);
}

.topic-selector-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 380px;
    overflow-y: auto;
    background: rgba(18, 22, 30, 0.98);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    z-index: 60;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    display: none;
}

.topic-selector-panel.open {
    display: block;
}

.topic-selector-search {
    position: sticky;
    top: 0;
    padding: 10px 12px;
    background: rgba(18, 22, 30, 0.98);
    border-bottom: 1px solid var(--border-light);
    z-index: 1;
}

.topic-selector-search input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(11, 15, 20, 0.6);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.topic-selector-search input:focus {
    border-color: var(--accent);
}

.topic-selector-group {
    padding: 6px 0;
}

.topic-selector-group + .topic-selector-group {
    border-top: 1px solid var(--border-light);
}

.topic-selector-label {
    padding: 6px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.topic-selector-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13.5px;
    color: var(--text-secondary);
}

.topic-selector-item:hover,
.topic-selector-item.active {
    background: rgba(232, 164, 55, 0.08);
    color: var(--accent-bright);
}

.topic-selector-item .hash {
    color: var(--text-muted);
    font-weight: 400;
}

.topic-selector-item .name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.topic-selector-item .count {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.topic-selector-item .owner {
    font-size: 11px;
    color: var(--accent);
    opacity: 0.85;
    flex-shrink: 0;
}

.topic-selector-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.topic-selector-new {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13.5px;
    color: var(--accent-bright);
    border-top: 1px solid var(--border-light);
    background: rgba(232, 164, 55, 0.03);
}

.topic-selector-new:hover {
    background: rgba(232, 164, 55, 0.10);
}


/* ============================================================
   9. 话题页头部（hero）
   ============================================================ */
.topic-hero {
    padding: 24px 0 20px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 20px;
}

.topic-hero-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.topic-hero-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.topic-hero-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 14px;
    max-width: 800px;
}

.topic-hero-stats {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.topic-hero-stats .item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}


/* ============================================================
   10. 通用 section 头
   ============================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.section-header h2 i {
    color: var(--accent);
    font-size: 14px;
}

.section-more {
    font-size: 12.5px;
    color: var(--text-muted);
    transition: var(--transition);
}

.section-more:hover {
    color: var(--accent-bright);
}


/* ============================================================
   11. 额度提示（D9.1）
   ============================================================ */
.quota-hint {
    background: rgba(232, 164, 55, 0.05);
    border: 1px solid rgba(232, 164, 55, 0.18);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 14px;
    transition: var(--transition);
}

.quota-hint[hidden] {
    display: none !important;
}

.quota-hint.quota-hint-warning {
    background: rgba(230, 126, 34, 0.08);
    border-color: rgba(230, 126, 34, 0.30);
}

.quota-hint-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.quota-hint-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 0;
}

.quota-hint-info i {
    color: var(--accent);
    font-size: 12px;
    flex-shrink: 0;
}

.quota-hint-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quota-hint-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.quota-brick-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    color: var(--accent-bright);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.quota-brick-count i {
    font-size: 11px;
    opacity: 0.85;
}

.quota-brick-count[hidden] {
    display: none !important;
}

.quota-exchange-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #1a1a1a;
    border: none;
    border-radius: 16px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.quota-exchange-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 4px 12px rgba(232, 164, 55, 0.3);
}

.quota-exchange-btn:disabled {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    cursor: not-allowed;
}

.quota-exchange-btn i {
    font-size: 10px;
}

@media (max-width: 640px) {
    .quota-hint-inner {
        flex-direction: column;
        align-items: stretch;
    }
    .quota-hint-actions {
        justify-content: space-between;
    }
}