/* ==========================================================================
   Unified Content Cards v2
   Standalone card system for all content types.
   ========================================================================== */

/* ── Section header (site-wide) ───────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.section-header h2 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary, #f0f0f0);
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.section-header h2::before {
    content: "";
    display: block;
    width: 4px;
    min-height: 1.2em;
    align-self: stretch;
    background: var(--accent-color);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Secondary variant — same red bar, medium text */
.section-header-sm {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header-sm h2,
.section-header-sm h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary, #f0f0f0);
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.section-header-sm h2::before,
.section-header-sm h3::before {
    content: "";
    display: block;
    width: 3px;
    min-height: 1em;
    align-self: stretch;
    background: var(--accent-color);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Tertiary variant — same red bar, smallest text */
.section-header-xs {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

.section-header-xs h3,
.section-header-xs h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
    display: flex;
    align-items: stretch;
    gap: 7px;
}

.section-header-xs h3::before,
.section-header-xs h4::before {
    content: "";
    display: block;
    width: 3px;
    min-height: 0.9em;
    align-self: stretch;
    background: var(--accent-color);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Grid ──────────────────────────────────────────────────────────────── */
/*
 * Single clamp() avoids breakpoint jitter — columns grow smoothly.
 * auto-fill adds columns only when there's room for a full new one.
 */
.ucard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 20vw, 460px), 1fr));
    gap: clamp(14px, 1.5vw, 28px);
}

/* ── Card wrapper ──────────────────────────────────────────────────────── */
.ucard {
    position: relative;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    aspect-ratio: 1;
    container-type: inline-size;
}

.ucard:hover {
    transform: translateY(-4px);
    box-shadow: 0 0 32px 10px rgba(255, 18, 18, 0.35),
        0 8px 24px rgba(0, 0, 0, 0.5);
    border-color: var(--accent-color, #ff1212);
}

.ucard:hover .ucard-title {
    color: var(--accent-color, #ff1212);
}

/* ── Thumbnail ─────────────────────────────────────────────────────────── */
.ucard-thumb {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

/* Video/article: 16:9 thumbnail within the square card */
.ucard--video .ucard-thumb,
.ucard--article .ucard-thumb {
    aspect-ratio: 16 / 9;
}

/* Video/article/audio cards: allow 2 lines for the title */
.ucard--video .ucard-title,
.ucard--article .ucard-title,
.ucard--audio .ucard-title {
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* Audio cards keep single-line titles */
/* Audio: cover fills the entire card */
.ucard--audio .ucard-thumb {
    position: absolute;
    inset: 0;
}

/* Channel: banner — top half */
.ucard--channel .ucard-thumb {
    flex: 0 0 50%;
    min-height: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.ucard-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ucard:hover .ucard-thumb img {
    transform: scale(1.05);
}

.ucard-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: rgba(255, 255, 255, 0.2);
}

/* ── Info area ─────────────────────────────────────────────────────────── */
.ucard-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 3cqi 4cqi;
    min-height: 0;
    gap: 1cqi;
    z-index: 1;
    overflow: hidden;
}

/* Audio: overlay info on top of cover */
.ucard--audio .ucard-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15cqi 4cqi 3cqi;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.88));
    z-index: 1;
}

/* Channel: avatar straddles the banner/info boundary */
.ucard--channel .ucard-info {
    position: relative;
    flex: 1;
    align-items: center;
    text-align: center;
    padding: 0 4cqi 3cqi;
    gap: 1cqi;
    margin-top: -20cqi;
    z-index: 2;
    overflow: visible;
}

/* ── Text — scales with container ──────────────────────────────────────── */
.ucard-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    font-size: 4.5cqi;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
    transition: color 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    line-height: 1.3;
    flex-shrink: 0;
}

/* Accent left border on titles (not on channel cards) */
.ucard--video .ucard-title,
.ucard--audio .ucard-title,
.ucard--article .ucard-title {
    border-left: 3px solid var(--accent-color, #ff1212);
    margin-left: -4cqi;
    padding-left: 3.5cqi;
}

/* Audio: darken behind title text for readability over cover art */
.ucard--audio .ucard-title {
    background: rgba(0, 0, 0, 0.2);
    padding-top: 0.5cqi;
    padding-bottom: 0.5cqi;
}

.ucard-meta {
    display: block;
    font-size: 3.5cqi;
    color: #bbb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Engagement row ────────────────────────────────────────────────────── */
.ucard-engagement {
    display: flex;
    align-items: center;
    gap: 3cqi;
    margin-top: auto;
    padding-top: 1cqi;
    font-size: 3.5cqi;
    color: #bbb;
    flex-shrink: 0;
}

.ucard-engagement .stat {
    display: flex;
    align-items: center;
    gap: 1cqi;
}

.ucard-engagement .stat svg {
    width: 5cqi;
    height: 5cqi;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ucard-engagement .stat.upvote {
    color: #4caf50;
}

.ucard-engagement .stat.downvote {
    color: #f44336;
}

.ucard-engagement .stat.comments {
    color: #90caf9;
}

.ucard-engagement .stat.views {
    color: #bbb;
}

/* ── Content Type Badge (top-left) ─────────────────────────────────────── */
.ucard-type-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    padding: 5px 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    line-height: 0;
}

.ucard-type-badge svg {
    width: 16px;
    height: 16px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
}

/* ── Seen Badge (top-right) ────────────────────────────────────────────── */
.ucard-seen-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 18, 18, 0.55);
    color: #fff;
    font-size: 3cqi;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 1cqi 2.5cqi;
    border-radius: 4px;
    z-index: 5;
}

/* ── Duration Badge ────────────────────────────────────────────────────── */
.ucard-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 3.2cqi;
    font-weight: 600;
    padding: 0.6cqi 1.5cqi;
    border-radius: 4px;
    z-index: 10;
}

/* ── Channel-specific ──────────────────────────────────────────────────── */
.ucard-channel-avatar {
    width: 40cqi;
    aspect-ratio: 1;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 16px 4px rgba(0, 0, 0, 0.6);
    transition: box-shadow 0.3s ease;
}

.ucard--channel:hover .ucard-channel-avatar {
    box-shadow: 0 0 18px 6px rgba(255, 255, 255, 0.4);
}

.ucard-channel-avatar.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 700;
    font-size: 10cqi;
}

.ucard-avatar-wrap {
    position: relative;
    display: inline-block;
}

.ucard-live-badge {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 1.5cqi 4cqi;
    background: #e00;
    color: #fff;
    font-size: 4.5cqi;
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: 20px;
    line-height: 1.5;
    white-space: nowrap;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(200, 0, 0, 0.5);
    animation: liveBadgePulse 2s ease-in-out infinite;
}

@keyframes liveBadgePulse {
    0%, 100% { box-shadow: 0 2px 6px rgba(200, 0, 0, 0.5); }
    50% { box-shadow: 0 2px 12px rgba(255, 0, 0, 0.8); }
}

.ucard-channel-name {
    font-weight: 600;
    font-size: 5cqi;
    color: var(--text-primary, #eee);
    transition: color 0.3s ease;
}

.ucard--channel:hover .ucard-channel-name {
    color: var(--accent-color, #ff1212);
}

.ucard-channel-followers {
    font-size: 3.5cqi;
    color: #bbb;
}

/* Content-type counts overlay on channel banner */
.ucard-channel-counts {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 6px;
    font-size: 12px;
    color: #ddd;
    z-index: 5;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ucard-channel-counts .ccount {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ucard-channel-counts .ccount svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Follow / Unfollow button */
.ucard-follow-btn {
    margin-top: auto;
    padding: 1.5cqi 4cqi;
    border: none;
    border-radius: 6px;
    font-size: 3.2cqi;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s, opacity 0.2s;
    background: var(--accent-color, #ff1212);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.ucard-follow-btn:hover {
    filter: brightness(1.15);
    transform: scale(1.02);
}

.ucard-follow-btn:active {
    transform: scale(0.97);
}

.ucard-follow-btn.following {
    background: rgba(255, 255, 255, 0.08);
    color: #888;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ucard-follow-btn.following:hover {
    background: rgba(255, 60, 60, 0.15);
    color: #f66;
    border-color: rgba(255, 60, 60, 0.3);
}

.ucard-follow-btn.own-channel {
    background: rgba(255, 255, 255, 0.08);
    color: #aaa;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: none;
    letter-spacing: 0;
}

.ucard-follow-btn.own-channel:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ddd;
}

.ucard-follow-btn.login-to-follow {
    background: rgba(255, 255, 255, 0.06);
    color: #777;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-transform: none;
    letter-spacing: 0;
}

.ucard-follow-btn.login-to-follow:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #aaa;
}

.ucard-follow-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* "Going Live in …" badge on channel cards */
.ucard-upcoming-badge {
    position: absolute;
    bottom: 58%;
    left: 50%;
    transform: translateX(-50%);
    padding: 1.5cqi 4cqi;
    background: #f5c518;
    color: #111;
    border-radius: 20px;
    font-size: 4.5cqi;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    line-height: 1.4;
    z-index: 5;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    margin-right: 5px;
    vertical-align: middle;
    animation: liveDotPulse 1.5s ease-in-out infinite;
}

@keyframes liveDotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.ucard-channel-banner-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* ── Video preview ─────────────────────────────────────────────────────── */
.ucard .card-preview-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.ucard .card-preview-video.visible {
    opacity: 1;
}

/* ── User avatar row (video / article info area) ──────────────────────── */
.ucard-avatar-row {
    display: flex;
    align-items: center;
    gap: 3cqi;
    flex: 1;
    min-height: 0;
}

.ucard-avatar-row img {
    width: 14cqi;
    height: 14cqi;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.ucard-avatar-row .placeholder {
    width: 14cqi;
    height: 14cqi;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 700;
    font-size: 5cqi;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ucard-avatar-detail {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ucard-avatar-detail .username {
    font-size: 4cqi;
    font-weight: 600;
    color: #ddd;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ucard-avatar-detail .sub-label {
    font-size: 3.5cqi;
    color: #999;
}

/* ── Container breakout for test page ─────────────────────────────────── */
.container:has(.test-page) {
    max-width: none;
}

/* ── Narrowest: < 480px — single column ───────────────────────────────── */
@media (max-width: 479px) {
    .ucard-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}