/* ==========================================================================
   Home Page — Livestreams Section
   ========================================================================== */

/* ── Section Header + Toggle ────────────────────────────────────────────── */

.hidden {
    display: none !important;
}

.home-container {
    padding: 20px 32px;
}

/* Break out of .container max-width when on the home page */
.container:has(.home-container) {
    max-width: none;
}

/* section-header styles moved to content_cards_v2.css (globally loaded) */

.live-pulse-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
    animation: livePulse 1.5s ease-in-out infinite;
    margin-left: 4px;
    align-self: center;
}

@keyframes livePulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(255, 18, 18, 0.6);
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 8px rgba(255, 18, 18, 0);
    }
}

.view-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.view-toggle button {
    background: none;
    border: none;
    color: #888;
    padding: 8px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    position: relative;
}

.view-toggle button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.view-toggle button.active {
    color: var(--accent-color);
    background: rgba(255, 18, 18, 0.12);
}

.view-toggle button:hover:not(.active) {
    color: #ccc;
    background: rgba(255, 255, 255, 0.04);
}

/* ── Shared Card Pieces ─────────────────────────────────────────────────── */

.stream-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.thumbnail-wrapper {
    aspect-ratio: 16 / 9;
    position: relative;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}

.stream-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.live-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--accent-color);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(255, 18, 18, 0.4);
}

.viewer-count-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #eee;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.viewer-count-badge .viewer-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-color);
    border-radius: 50%;
}

.avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.text-info {
    min-width: 0;
    flex: 1;
}

.text-info h3 {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.3;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-info .streamer-name {
    margin: 4px 0 0;
    font-size: 0.95rem;
    color: #999;
}

/* Grid description — hidden by default, shown on featured card */
.grid-description {
    display: none;
    margin: 8px 0 0;
    font-size: 0.92rem;
    color: #888;
    line-height: 1.4;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Grid View ──────────────────────────────────────────────────────────── */

/*
 * Use a SINGLE consistent minmax to avoid breakpoint jitter.
 * As the viewport widens the columns grow proportionally;
 * auto-fill adds columns only once there is room for a full new one.
 * We use CSS clamp() on --grid-card-min so it scales smoothly.
 */
.streams-grid {
    --grid-card-min: clamp(280px, 22vw, 600px);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--grid-card-min), 1fr));
    gap: 24px;
}

/* Featured card — first stream gets 2x2 unless viewport is too narrow */
.streams-grid .stream-card-link:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

.streams-grid .stream-card-link:first-child .stream-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.streams-grid .stream-card-link:first-child .thumbnail-wrapper {
    flex: 1 1 auto;
}

.streams-grid .stream-card-link:first-child .stream-card-info {
    padding: 18px 20px;
}

.streams-grid .stream-card-link:first-child .text-info h3 {
    font-size: 1.3rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.streams-grid .stream-card-link:first-child .grid-description {
    display: -webkit-box;
}

@media (max-width: 620px) {
    .streams-grid .stream-card-link:first-child {
        grid-column: span 1;
        grid-row: span 1;
    }

    .streams-grid .stream-card-link:first-child .stream-card {
        display: block;
        height: auto;
    }

    .streams-grid .stream-card-link:first-child .thumbnail-wrapper {
        flex: none;
    }

    .streams-grid .stream-card-link:first-child .stream-card-info {
        padding: 14px;
    }

    .streams-grid .stream-card-link:first-child .text-info h3 {
        font-size: 1.1rem;
        white-space: nowrap;
        display: block;
    }

    .streams-grid .stream-card-link:first-child .grid-description {
        display: none;
    }
}

.streams-grid .stream-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.streams-grid .stream-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(255, 18, 18, 0.15), 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 18, 18, 0.25);
}

.streams-grid .stream-card:hover .stream-thumbnail {
    transform: scale(1.05);
}

/* Grid card info row */
.stream-card-info {
    padding: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.grid-engagement {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
    color: #999;
    font-size: 0.85rem;
}

.grid-engagement .stat {
    display: flex;
    align-items: center;
    gap: 3px;
}

.grid-engagement .stat svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

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

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

/* ── Offline Message (no streams) ──────────────────────────────────────── */

.streams-offline {
    text-align: center;
    padding: 48px 20px;
    color: #666;
    font-size: 1.05rem;
    font-style: italic;
}

/* ==========================================================================
   3D Carousel
   ========================================================================== */

.carousel-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 16px;
}

/* Blurred background */
.carousel-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(40px) brightness(0.35) saturate(1.4);
    transform: scale(1.3);
    z-index: 0;
    transition: background-image 0.6s ease;
}

.carousel-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(18, 18, 18, 0.85) 100%);
}

/* Stage */
.carousel-stage {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 20px 40px;
    min-height: 560px;
    perspective: 1200px;
}

/* Track — holds all items, shifted via translateX */
.carousel-track {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

/* Individual carousel item */
.carousel-item {
    position: absolute;
    width: 520px;
    max-width: 70vw;
    transition: all 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
}

.carousel-item .card-inner {
    background: rgba(30, 30, 30, 0.85);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Active (center) card */
.carousel-item.active .card-inner {
    border-color: rgba(255, 18, 18, 0.4);
    box-shadow: 0 16px 48px rgba(255, 18, 18, 0.2), 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* Center card info */
.carousel-item .carousel-card-info {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.carousel-item .carousel-card-info .carousel-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.carousel-item .carousel-card-info .carousel-streamer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.carousel-item .carousel-card-info .carousel-streamer .avatar-medium {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.carousel-item .carousel-card-info .carousel-streamer .streamer-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-color);
    margin: 0;
}

.carousel-item .carousel-card-info .stream-description {
    font-size: 0.95rem;
    color: #888;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Engagement stats (upvotes, downvotes, comments) */
.carousel-item .carousel-card-info .carousel-engagement {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: auto;
    padding-top: 6px;
    font-size: 0.95rem;
    color: #aaa;
}

.carousel-engagement .stat {
    display: flex;
    align-items: center;
    gap: 5px;
}

.carousel-engagement .stat svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

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

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

/* Dot indicators */
.carousel-dots {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding-bottom: 24px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.carousel-dot.active {
    background: var(--accent-color);
    box-shadow: 0 0 8px rgba(255, 18, 18, 0.5);
    transform: scale(1.3);
}

.carousel-dot:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* Ultrawide: ≥ 1800px — YouTube-like big cards */
@media (min-width: 1800px) {
    .home-container {
        padding: 28px 48px;
    }

    .streams-grid .stream-card-info {
        padding: 16px 18px;
    }

    .streams-grid .text-info h3 {
        font-size: 1.25rem;
    }

    .streams-grid .text-info .streamer-name {
        font-size: 1.05rem;
    }

    /* Carousel: larger & taller center card, fit within viewport */
    .carousel-stage {
        min-height: 0;
        height: calc(100vh - var(--header-height) - 160px);
        max-height: 940px;
        perspective: 1600px;
        padding: 40px 60px;
    }

    .carousel-item {
        width: 1560px;
        max-width: 65vw;
    }

    .carousel-item.active .card-inner {
        display: flex;
        flex-direction: row;
        min-height: 656px;
    }

    .carousel-item.active .card-inner>.thumbnail-wrapper {
        flex: 0 0 60%;
        aspect-ratio: auto;
        min-height: 0;
    }

    .carousel-item.active .card-inner>.carousel-card-info {
        flex: 1 1 40%;
        padding: 24px;
        justify-content: flex-start;
        min-width: 0;
    }

    .carousel-item.active .card-inner>.carousel-card-info .carousel-title {
        font-size: 1.5rem;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .carousel-item.active .card-inner>.carousel-card-info .carousel-streamer .streamer-name {
        font-size: 1.3rem;
    }

    .carousel-item.active .card-inner>.carousel-card-info .carousel-streamer .avatar-medium {
        width: 56px;
        height: 56px;
    }

    .carousel-item.active .card-inner>.carousel-card-info .stream-description {
        -webkit-line-clamp: 4;
        line-clamp: 4;
        font-size: 1.05rem;
    }

    .carousel-item.active .card-inner>.carousel-card-info .carousel-engagement {
        margin-top: auto;
        padding-top: 12px;
        font-size: 1.1rem;
    }
}

/* Large desktop: 1200 – 1799px */
@media (min-width: 1200px) and (max-width: 1799px) {
    .carousel-item {
        width: 600px;
    }

    .carousel-stage {
        min-height: 520px;
        perspective: 1400px;
    }
}

@media (max-width: 768px) {
    .home-container {
        padding: 16px;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    .streams-grid {
        --grid-card-min: 260px;
        gap: 14px;
    }

    .carousel-stage {
        min-height: 320px;
        padding: 32px 10px 28px;
        perspective: 800px;
    }

    .carousel-item {
        width: 380px;
        max-width: 85vw;
    }
}

@media (max-width: 480px) {
    .home-container {
        padding: 12px;
    }

    .streams-grid {
        --grid-card-min: 200px;
    }

    .carousel-item {
        width: 300px;
        max-width: 90vw;
    }

    .carousel-stage {
        min-height: 280px;
        perspective: 600px;
    }
}