/* ===== 资源分类页面样式（由 Category.cshtml 整理而来，首页分类块共用） ===== */

/* 与首页/搜索页的 .home-container 保持完全一致的盒模型：
   max-width 1080 + border-box + 左右 16px 内边距 => 内容区 1048px，
   与 .home-container 在每个视口下都相同，避免页面跳转时横向抖动 */
.uf-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    box-sizing: border-box;
}

/* ---- 顶部横排分类卡：分类标签横向排列、自动换行，与首页分类块同一套视觉 ---- */
.uf-cat-bar {
    background: var(--theme-surface, #fff);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;
}

.uf-cat-bar .category-chips {
    margin-top: 10px;
}

/* 分类卡标题与内容区标题共用同一套文字样式，并统一为主题色 5px 装饰线 */
.uf-cat-bar-head,
.uf-content-head {
    display: inline-block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--theme-text, #222);
    padding: 0 0 6px;
    border-bottom: 5px solid var(--theme-primary, #ff6b6b);
    border-radius: 0 0 3px 3px;
}

/* ---- 横排分类标签：首页分类块与"资源分类"页共用 ---- */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 14px;
    font-size: 13px;
    color: var(--theme-text-secondary, #999);
    text-decoration: none;
    border: 1px solid var(--theme-border, #f0f0f0);
    transition: all 0.2s ease;
}

/* 分类数量徽标：横排标签下的小圆角标签，配色跟随主题 */
.cat-chip > .uf-cat-count {
    flex: 0 0 auto;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 16px;
    color: var(--theme-primary, #ff6b6b);
    background: color-mix(in srgb, var(--theme-primary, #ff6b6b) 12%, transparent);
}

.cat-chip:hover {
    color: var(--theme-primary, #ff6b6b);
    border-color: var(--theme-primary, #ff6b6b);
}

.cat-chip.active {
    color: #fff;
    background: var(--theme-primary-gradient, linear-gradient(135deg, #ff6b6b, #ff8e53));
    border-color: transparent;
}

/* 选中态徽标反白，保证渐变底上的可读性 */
.cat-chip.active > .uf-cat-count {
    color: #fff;
    background: rgba(255, 255, 255, 0.28);
}

.uf-content {
    background: var(--theme-surface, #fff);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 内容区标题：样式与 .uf-cat-bar-head 共用；
   只额外覆盖圆角（直角）与文字到装饰线的间距（更紧凑） */
.uf-content-head {
    margin: 0 0 16px;
    padding-bottom: 3px;
    border-radius: 0;
}

/* ---- 列表：多列瀑布流排版 ----
   缩略图高度随原图比例变化很大，若用 grid 会被强行按行对齐，
   矮卡片下方必然出现空白；改用 CSS 多列后卡片在列内顺序堆叠，
   高度互不影响，行内不再有空洞（顺序为列优先） */
.uf-list {
    display: block;
    columns: 3;
    column-gap: 16px;
}

.uf-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 128px;
    /* 禁止卡片被拆到相邻两列 */
    -webkit-column-break-inside: avoid;
    break-inside: avoid;
    page-break-inside: avoid;
    /* 纵向间距：多列布局不认 gap，改用外边距 */
    margin-bottom: 16px;
    padding: 14px 16px 16px;
    background: var(--theme-surface, #fff);
    border: 1px solid var(--theme-border, #f0f0f0);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* 最后一列末项收掉尾部多余外边距，避免多出一段空白 */
.uf-list > .uf-item:last-child {
    margin-bottom: 0;
}

.uf-item:hover {
    transform: translateY(-3px);
    border-color: var(--theme-primary, #ff6b6b);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--theme-primary, #ff6b6b) 16%, transparent);
}

/* 标题：两行截断，卡片高度随内容自适应（瀑布流不要求等高） */
.uf-item .t {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--theme-text, #222);
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 分类标签：标题下方，展示 source_category_id 对应的分类名称 */
.uf-item .uf-cat {
    align-self: flex-start;
    max-width: 100%;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--theme-primary, #ff6b6b);
    background: color-mix(in srgb, var(--theme-primary, #ff6b6b) 10%, transparent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 资源介绍（vod_content）：标题下方完整显示，不截断 */
.uf-item .uf-desc {
    font-size: 12px;
    line-height: 1.6;
    color: var(--theme-text-secondary, #999);
    word-break: break-all;
    white-space: pre-wrap;
}

/* 预览图：满铺卡片顶部（抵消卡片内边距），有图显示图片，无图显示主题色渐变占位 */
.uf-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 左右与卡片内边距对齐，不再出血满铺 */
    width: 100%;
    /* 高度由图片原始比例决定，保证完整展示不被裁切 */
    height: auto;
    /* 上下边距归零，由卡片 gap 统一控制与上下内容的间距 */
    margin: 0;
    overflow: hidden;
    border-radius: 10px;
    background: linear-gradient(145deg,
        color-mix(in srgb, var(--theme-primary, #ff6b6b) 16%, var(--theme-surface, #fff)),
        color-mix(in srgb, var(--theme-primary, #ff6b6b) 4%, var(--theme-surface, #fff)));
}

.uf-thumb-img {
    display: block;
    width: 100%;
    /* 等比完整显示整张图片，高度随原图自适应，不裁切 */
    height: auto;
    min-height: 120px;
    max-height: 520px;
    object-fit: contain;
    background: var(--theme-surface, #fff);
    transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: transform;
}

.uf-item:hover .uf-thumb-img {
    transform: scale(1.02);
}

.uf-thumb-ph {
    /* 无图时用内边距撑起占位区高度 */
    padding: 70px 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 3px;
    color: color-mix(in srgb, var(--theme-primary, #ff6b6b) 45%, transparent);
    user-select: none;
}

/* 卡片底部：查看 */
.uf-item-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px dashed var(--theme-border, #f0f0f0);
}

.uf-item .act {
    flex-shrink: 0;
    /* 无论父容器对齐方式如何，都固定在底栏最右侧 */
    margin-left: auto;
    padding: 4px 12px;
    border-radius: 999px;
    color: #fff;
    background: var(--theme-primary-gradient, linear-gradient(135deg, #ff6b6b, #ff8e53));
    font-size: 12px;
    transition: opacity 0.2s ease;
}

.uf-item:hover .act {
    opacity: 0.88;
}

/* 分页：数字页码条（首页与"资源分类"页共用，视图见 Views/Shared/_Pager.cshtml） */
.uf-pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--theme-border, #eee);
}

.uf-pager .pg {
    min-width: 34px;
    padding: 6px 12px;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid var(--theme-border, #eee);
    border-radius: 6px;
    background: var(--theme-surface, #fff);
    color: var(--theme-text, #222);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
    transition: color .2s ease, border-color .2s ease, background .2s ease;
}

.uf-pager a.pg:hover {
    color: var(--theme-primary, #ff6b6b);
    border-color: var(--theme-primary, #ff6b6b);
}

/* 当前页：主题色实心高亮，不参与跳转 */
.uf-pager .pg.active {
    color: #fff;
    background: var(--theme-primary, #ff6b6b);
    border-color: var(--theme-primary, #ff6b6b);
    font-weight: 600;
    cursor: default;
}

/* 首页/上一页/下一页/末页在首尾页的禁用态 */
.uf-pager .pg.disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* 页码过多时的省略号 */
.uf-pager .pg-dots {
    padding: 0 2px;
    color: var(--theme-text-secondary, #999);
    font-size: 13px;
}

.uf-empty {
    text-align: center;
    padding: 60px 0;
    color: var(--theme-text-secondary, #999);
}

/* 响应式：平板两列，手机单列 */
@media (max-width: 992px) {
    .uf-list {
        columns: 2;
    }
}

@media (max-width: 768px) {
    /* 手机上收紧分类卡内边距，把宽度让给分类标签 */
    .uf-cat-bar {
        padding: 14px;
    }

    .uf-cat-bar .category-chips {
        gap: 6px;
        margin-top: 8px;
    }

    /* 分类标签在窄屏下略收紧，标签名过长不换行、不撑破卡片 */
    .cat-chip {
        max-width: 100%;
        padding: 6px 12px;
        font-size: 12px;
    }

    .uf-cat-bar-head {
        font-size: 14px;
    }

    /* 分页：窄屏收紧按钮间距与内边距，超长时自动换行不溢出 */
    .uf-pager {
        gap: 6px;
        margin-top: 16px;
        padding-top: 12px;
    }

    .uf-pager .pg {
        min-width: 30px;
        padding: 5px 9px;
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .uf-list {
        columns: 1;
        column-gap: 0;
    }

    .uf-item {
        min-height: 0;
        margin-bottom: 12px;
    }
}
