/* =====================================================
   瀑布流布局样式 - 纯 CSS column-count 实现
   同时兼容 JS 智能瀑布流布局
   ===================================================== */

.waterfall-container {
    column-count: 4;
    column-gap: 25px;
    padding: 16px 0;
}

.grid-container {
    display: grid;
    gap: 25px;
    padding: 16px 0;
}

/* 单个内容卡片 */
.waterfall-item {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 25px;
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: none;
    display: block;
}

.waterfall-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* 卡片内链接样式 */
.waterfall-item .card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.waterfall-item .card-link:hover {
    color: inherit;
}

/* 卡片媒体区 */
.waterfall-item .card-media {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #f5f5f5;
    border-radius: 12px;
}

.waterfall-item .card-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 12px;
}

.grid-container .waterfall-item {
    break-inside: auto;
    margin-bottom: 0;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: none;
    overflow: hidden;
    transition: box-shadow 0.25s ease;
}

.grid-container .waterfall-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.grid-container .waterfall-item .card-media {
    overflow: hidden;
    aspect-ratio: 3 / 4;
    background-color: #f5f5f5;
    position: relative;
    width: 100%;
    height: auto;
    min-height: 200px;
}

.grid-container .waterfall-item .card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.grid-container .waterfall-item .card-content {
    padding: 12px 14px 14px;
}

.grid-container .waterfall-item .card-title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.45;
    color: #222;
    margin: 0 0 0 0;
    word-break: break-word;
}

.grid-container .waterfall-item .card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.grid-container .waterfall-item .author {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    font-size: 12px;
    color: #999;
}

.grid-container .waterfall-item:hover {
}

.waterfall-item .card-media--placeholder {
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waterfall-item .card-media--video {
    aspect-ratio: 9 / 16;
}

/* 视频标识图标 */
.video-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.55);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 3px;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.video-badge svg {
    width: 18px;
    height: 18px;
}

.video-badge--large {
    width: 52px;
    height: 52px;
    padding-left: 4px;
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%);
    background-color: rgba(255, 36, 66, 0.85);
}

.video-badge--large svg {
    width: 22px;
    height: 22px;
}

/* 卡片内容区 */
.waterfall-item .card-content {
    padding: 12px 14px 14px;
}

.waterfall-item .card-title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.45;
    color: #222;
    margin: 0 0 10px 0;
    word-break: break-word;
}

/* 卡片元信息区 (作者 + 点赞) */
.waterfall-item .card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.waterfall-item .card-meta .author {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.waterfall-item .card-meta .author img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.waterfall-item .card-meta .author-name {
    font-size: 12px;
    color: #999;
    font-weight: 400;
}

.waterfall-item .card-meta .stats {
    flex-shrink: 0;
}

.waterfall-item .card-meta .likes {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #999;
    font-size: 12px;
}

.waterfall-item .card-meta .likes svg {
    width: 14px;
    height: 14px;
}

.waterfall-item .card-meta .likes .count {
    font-variant-numeric: tabular-nums;
}

/* =====================================================
   JS 智能瀑布流 (fallback 布局样式)
   ===================================================== */

.waterfall-container.is-absolute-layout {
    position: relative;
    column-count: initial !important;
    column-gap: initial !important;
}

.waterfall-container.is-absolute-layout .waterfall-item {
    position: absolute;
    margin-bottom: 0;
}

/* 卡片加载动画 */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.waterfall-item.is-new {
    animation: fadeSlideUp 0.4s ease-out both;
}

/* 暗色主题兼容 - prefers-color-scheme */
@media (prefers-color-scheme: dark) {
    .waterfall-item {
        background-color: #1f1f1f;
    }

    .waterfall-item .card-title {
        color: #eaeaea;
    }

    .waterfall-item .card-media,
    .waterfall-item .card-media--placeholder {
        background-color: #2a2a2a;
    }

    .waterfall-item .card-meta .author-name,
    .waterfall-item .card-meta .likes {
        color: #999;
    }
}

/* 暗色主题兼容 - data-theme 属性 */
[data-theme="dark"] .waterfall-item {
    background-color: #1f1f1f;
}

[data-theme="dark"] .waterfall-item:hover,
[data-theme="dark"] .grid-container .waterfall-item:hover {
    box-shadow: none;
}

[data-theme="dark"] .waterfall-item .card-title {
    color: #eaeaea;
}

[data-theme="dark"] .waterfall-item .card-media,
[data-theme="dark"] .waterfall-item .card-media--placeholder {
    background-color: #2a2a2a;
}

[data-theme="dark"] .waterfall-item .card-meta .author-name,
[data-theme="dark"] .waterfall-item .card-meta .likes {
    color: #999;
}
