/* ============================================================
   Feed (Контент) page — video/stream grid, segment tabs
   ============================================================ */

/* ---------- Layout ---------- */
.feed-page {
    padding-block: var(--space-5) var(--space-9);
}

.feed-page .page-title {
    margin-bottom: var(--space-5);
}

/* ---------- Header row: tabs (left) + filters (right) ---------- */
.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.feed-tabs {
    display: inline-flex;
}

/* ---------- Feed content fade-in on htmx swap ---------- */
.feed-anim {
    animation: fade-up 200ms var(--ease-out);
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .feed-anim {
        animation: none;
    }
}

/* ---------- Video / Stream grid ---------- */
.feed-grid {
    /* align-items defaults to stretch so cards in a row match height */
}

/* ---------- Posts / Boosty masonry (row-major, variable heights) ----------
   CSS multi-column fills top-to-bottom (column order). To read left-to-right
   like the video grid while keeping variable card heights, we use a CSS grid
   whose rows are a fine 1px unit; app.js sets each card's grid-row span from
   its measured height (.is-masonry), packing cards in source (row) order. */
.feed-masonry {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: var(--space-5);
    align-items: start;
}
.feed-masonry.is-masonry {
    grid-auto-rows: 1px;
}
@media (max-width: 1024px) {
    .feed-masonry {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 640px) {
    .feed-masonry {
        grid-template-columns: 1fr;
    }
}

/* ---------- Video card ---------- */
.video-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.video-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), var(--glow-accent);
    border-color: var(--border-strong);
}

.video-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.video-card__thumbnail-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--surface-2);
    min-height: 120px;
}

.video-card__thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--dur) var(--ease-standard);
}

.video-card__thumbnail.img--broken {
    display: none;
}

.video-card:hover .video-card__thumbnail {
    transform: scale(1.03);
}

.video-card__duration {
    position: absolute;
    bottom: var(--space-2);
    right: var(--space-2);
    background: rgba(0, 0, 0, 0.82);
    color: var(--text);
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-variant-numeric: tabular-nums;
}

.video-card__info {
    flex: 1 1 auto;
    padding: var(--space-3) var(--space-4) var(--space-4);
}

.video-card__title {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: var(--lh-snug);
    color: var(--text);
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-card__author {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.video-card__date {
    font-size: var(--fs-xs);
    color: var(--text-faint);
}

/* ---------- Stream card ---------- */
.stream-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.stream-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--glow-live), var(--shadow-lg);
    border-color: var(--live);
}

.stream-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.stream-card__thumbnail-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--surface-2);
    border-bottom: 2px solid var(--live);
}

.stream-card__thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stream-card__live-badge {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
}

.stream-card__info {
    flex: 1 1 auto;
    padding: var(--space-3) var(--space-4) var(--space-4);
}

.stream-card__title {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: var(--lh-snug);
    color: var(--text);
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stream-card__author {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.stream-card__viewers {
    font-size: var(--fs-xs);
    color: var(--live);
    font-weight: 600;
}

.stream-card__thumbnail.img--broken {
    display: none;
}

/* ---------- Empty state ---------- */
.feed-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: var(--space-8) var(--space-4);
    text-align: center;
}

.feed-empty__icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    color: var(--text-faint);
    margin-bottom: var(--space-4);
    flex-shrink: 0;
}

.feed-empty__text {
    color: var(--text-muted);
    font-size: var(--fs-md);
    font-weight: 500;
    margin: 0;
}

/* ---------- Live strip (feed page) ---------- */
.live-strip {
    margin-bottom: var(--space-5);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-2);
    border-radius: var(--r-lg);
}

.live-strip__inner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.live-strip__label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--live);
    white-space: nowrap;
}

.live-strip__avatars {
    display: flex;
    gap: var(--space-2);
}

.live-strip__item {
    position: relative;
}

.live-strip__avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--r-full);
    object-fit: cover;
}

.live-strip__dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: var(--r-full);
    background: var(--live);
    border: 2px solid var(--surface-2);
}

@media (prefers-reduced-motion: reduce) {
    .video-card,
    .stream-card {
        transition: none;
    }
    .video-card__thumbnail {
        transition: none;
    }
}

/* ---------- Feed filters (in header row) ---------- */
.feed-filters {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: flex-start;
}

.feed-filter-select {
    padding: var(--space-2) var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: border-color var(--dur-fast);
}

.feed-filter-select:hover,
.feed-filter-select:focus {
    border-color: var(--border-strong);
    outline: none;
}

/* ---------- Member chip dropdown ---------- */
.feed-chip-dropdown {
    position: relative;
    display: inline-block;
}

.feed-chip-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: var(--fs-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color var(--dur-fast);
}

.feed-chip-trigger:hover,
.feed-chip-trigger:focus {
    border-color: var(--border-strong);
    outline: none;
}

.feed-chip-trigger--active {
    background: var(--accent-weak);
    border-color: var(--accent);
    color: var(--accent);
}

.feed-chip-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.feed-chip-panel {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    min-width: 260px;
    max-width: min(480px, 90vw);
}

/* chips inside the dropdown panel */
.feed-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px var(--space-2);
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    color: var(--text-muted);
    font: 500 var(--fs-xs) / 1 var(--font-ui);
    cursor: pointer;
    white-space: nowrap;
    transition:
        background var(--dur-fast),
        border-color var(--dur-fast),
        color var(--dur-fast);
}

.feed-chip:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.feed-chip--active {
    background: var(--accent-weak);
    border-color: var(--accent);
    color: var(--accent);
}

.feed-chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.feed-chip__face {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    image-rendering: pixelated;
    flex-shrink: 0;
    display: block;
}

/* ---------- Load more ---------- */
.feed-loadmore {
    display: flex;
    justify-content: center;
    margin-top: var(--space-6);
}

.feed-loadmore:empty {
    margin-top: 0;
}

/* ---------- Video card tags (overlay on thumbnail, top-left) ---------- */
.video-card__tags {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    max-width: calc(100% - var(--space-4));
    z-index: 1;
    pointer-events: none;
}

.video-card__tag {
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1;
    padding: 3px 8px;
    border-radius: var(--r-full);
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}
