/* ============================================================================
   EM ALTA HOJE — Trending Section (claude.css block)
   Prefixo: .trending-* | Não conflita com nenhum outro componente
   
  ÚLTIMA EDIÇÃO 01:39 01/08
   ============================================================================ */

/* ── Seção wrapper ──────────────────────────────────────────── */
.trending-section {
    margin-bottom: 0px !important;
    margin-top: -46px !important;
    position: relative;
}

/* ── Header: Título + Tabs + Ver Todos ──────────────────────── */
.trending-header {
    display: flex;
    flex-direction: column;
    margin-top: 32px;
    margin-bottom: 24px;
    padding: 0 4%;
}

.trending-footer {
    display: flex;
    justify-content: flex-end;
    padding: 16px 4%;
    margin-top: 8px;
}

.trending-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    flex-shrink: 0;
}

.trending-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: #e50914;
    border-radius: 2px;
    flex-shrink: 0;
    order: 0;
}

.trending-title i {
    font-size: 20px;
    color: var(--text-muted);
    order: -1;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.trending-tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    overflow-x: auto;
    scrollbar-width: none;
    position: relative;
    z-index: 10;
}
.trending-tabs::-webkit-scrollbar { display: none; }
.trending-tab {
    background: none;
    border: none;
    color: #888;
    font-size: 15px;
    font-weight: 500;
    padding: 12px 0;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color 0.3s;
}
.trending-tab:hover { color: #fff; }
.trending-tab.is-active {
    color: #fff;
    font-weight: 600;
}
.trending-tab::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e50914;
    border-radius: 2px 2px 0 0;
    transform: scaleX(0);
    transition: transform var(--dur-base) var(--ease-spring);
}
.trending-tab.is-active::after {
    transform: scaleX(1);
}

/* ── Link "Ver Todos" ──────────────────────────────────────── */
.trending-ver-todos {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    position: relative;
}
.trending-ver-todos::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e50914;
    border-radius: 2px;
}

/* ── Grid scroll horizontal (homepage) ──────────────────────── */
@keyframes trendingGridFadeIn {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.trending-grid {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 30px 4px 40px;
    /* Space for hover expansion top and bottom */
    margin: -22px -4px -24px;
    /* Offset to prevent massive gap */
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    animation: trendingGridFadeIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.trending-grid::-webkit-scrollbar {
    display: none;
}

.trending-grid::-webkit-scrollbar-track {
    background: transparent;
}

.trending-grid::-webkit-scrollbar-thumb {
    background: transparent;
}

.trending-grid--hidden {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

/* ── Card Wrapper ──────────────────────────────────────────── */
.trending-card-wrapper {
    position: relative;
    flex-shrink: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

@media (min-width: 769px) {

    /* Afasta os cards da esquerda e direita quando em hover (Desktop) */
    .trending-grid:hover .trending-card-wrapper {
        transform: translateX(-50px);
    }

    .trending-grid .trending-card-wrapper:hover {
        transform: translateX(0) !important;
    }

    .trending-grid .trending-card-wrapper:hover~.trending-card-wrapper {
        transform: translateX(50px);
    }

    /* Correção de borda */
    .trending-grid .trending-card-wrapper:first-child:hover~.trending-card-wrapper {
        transform: translateX(100px);
    }
}

/* ── Card Poster ───────────────────────────────────────────── */
.trending-card {
    display: block;
    width: 180px;
    min-width: 180px;
    aspect-ratio: 2/3;
    border-radius: var(--radius-m);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: var(--shadow-card);
    background: var(--bg-card);
    transition: transform var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow) var(--ease-out);
    will-change: transform;
    isolation: isolate;
    text-decoration: none;
}

.trending-card > img:not([class*="badge"]) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--dur-slow) var(--ease-out);
}

.trending-badge {
    position: absolute;
    top: 9px;
    left: 9px;
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.07em;
    padding: 3px 7px;
    border-radius: 5px;
    z-index: 3;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.60);
    color: rgba(255, 255, 255, 0.92);
}

/* Gradiente escuro na parte inferior para destacar título e ano */
.trending-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(7, 11, 19, 0.95) 0%,
        rgba(7, 11, 19, 0.70) 35%,
        rgba(7, 11, 19, 0.20) 65%,
        transparent 100%
    );
    z-index: 2;
    pointer-events: none;
    border-radius: var(--radius-m, 16px);
    transition: opacity var(--dur-base, 240ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

/* Informações no rodapé interno do card */
.trending-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 12px 10px;
    z-index: 3;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.trending-card-title {
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: -0.1px;
    text-align: left;
}

.trending-card-year {
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 12px;
    font-weight: 500;
    color: #8E98A5;
    margin-top: 3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    text-align: left;
}

.trending-card-wrapper:hover .trending-card {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lift);
}

.trending-card-wrapper:hover .trending-card > img:not([class*="badge"]) {
    transform: scale(1.06);
}

/* ── Hover Card (popup) ────────────────────────────────────── */
.trending-hover-card {
    position: absolute;
    top: -25px;
    bottom: auto;
    left: -70px;
    width: 340px;
    height: auto;
    min-height: auto;
    background-color: #14141c;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(8px);
    transform-origin: center top;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 50;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.trending-card-wrapper.is-active .trending-hover-card,
.trending-card-wrapper:hover .trending-hover-card {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

@media (min-width: 769px) {
    .trending-card-wrapper:first-child .trending-hover-card {
        left: 0 !important;
    }

    .trending-card-wrapper:last-child .trending-hover-card {
        left: auto !important;
        right: 0 !important;
    }
}

.trending-card-wrapper:hover {
    z-index: 50;
}

.trending-card-wrapper.is-active {
    z-index: 50;
}

.trending-hover-img-wrap {
    height: 145px;
    width: 100%;
    position: relative;
    background: #000;
    flex-shrink: 0;
    flex: none;
}

.trending-hover-img-wrap>img:not(.trending-hover-logo) {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.trending-hover-logo {
    width: auto !important;
    height: auto !important;
}

.trending-hover-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: linear-gradient(to bottom, transparent, #14141c);
}

.trending-hover-content {
    padding: 10px 14px 14px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1 1 auto;
}

.trending-hover-title {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: white;
    margin: 0 0 6px 0;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.trending-hover-rating {
    font-size: 12px;
    color: white;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trending-imdb-icon {
    height: 18px;
    width: auto;
}

.trending-hover-year {
    font-family: 'Outfit', sans-serif;
    color: #a0a0a0;
    font-weight: 500;
}

.trending-age-chip {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 10px !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
    background: #333;
}

.trending-age-chip[data-age="L"] {
    background: #00a651;
}

.trending-age-chip[data-age="10"] {
    background: #00aef0;
}

.trending-age-chip[data-age="12"] {
    background: #fccc0a;
    color: #000;
}

.trending-age-chip[data-age="14"] {
    background: #f58220;
}

.trending-age-chip[data-age="16"] {
    background: #ed1c24;
}

.trending-age-chip[data-age="18"] {
    background: #000;
    border: 1px solid #ed1c24;
}

.trending-hover-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.trending-category-tag {
    font-size: 10px;
    color: #d4d4d8;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 500;
}

.trending-hover-synopsis {
    font-family: 'Outfit', sans-serif;
    font-size: 11.5px;
    color: #a0a0a0;
    line-height: 1.45;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.trending-hover-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}

.trending-hover-actions .btn-play {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: var(--primary, #e50914);
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.trending-hover-actions .btn-play:hover {
    filter: brightness(1.2);
}

.trending-hover-actions .btn-save {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-weight: 600;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.trending-hover-actions .btn-save:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.trending-hover-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {

    /* ── Fix: overflow-y: clip impede que o hover-card invisível crie scroll vertical ── */
    .trending-grid {
        padding: 12px 6px !important;
        margin: 0 16px !important;
        gap: 8px !important;
        overflow-y: clip !important;
        scroll-snap-type: x mandatory;
    }

    .trending-card,
    .trending-card-wrapper {
        width: calc((100vw - 40px) / 2) !important;
        min-width: calc((100vw - 40px) / 2) !important;
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    .trending-card-wrapper.is-active {
        width: 280px !important;
        /* Largura expandida do card clicado */
        min-width: 28px !important;
        /* Força os cards vizinhos a se afastarem */
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        /* Animação suave do afastamento */
        z-index: 50;
    }


    .trending-card-title {
        width: 100% !important;
        font-size: 11px;
        margin-top: 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Desabilita hover no mobile — só o clique (is-active) funciona */
    .trending-card-wrapper:hover .trending-hover-card {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: none !important;
    }

    .trending-card-wrapper.is-active {
        transform: none !important;
        z-index: 50;
    }

    /* Hover card invisível não deve ocupar espaço algum */
    .trending-hover-card {
        display: none !important;
    }

    .trending-card-wrapper.is-active .trending-hover-card {
        display: flex !important;
    }

    body.trending-modal-open .main::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(10, 10, 15, 0.6);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        z-index: 9998;
        cursor: pointer;
        display: block;
    }

    body.trending-modal-open .trending-section {
        position: relative;
        z-index: 9999 !important;
    }

    body.trending-modal-open .trending-carousel-container {
        position: relative;
        z-index: 9999 !important;
    }

    body.trending-modal-open .trending-card-wrapper:not(.is-active) {
        filter: blur(5px) brightness(0.5);
        opacity: 0.7;
        pointer-events: none;
        transition: filter 0.3s ease, opacity 0.3s ease;
    }

    .trending-card-wrapper.is-active .trending-hover-card {
        display: flex !important;
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        bottom: auto !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        width: min(330px, 88vw) !important;
        height: auto !important;
        min-height: auto !important;
        max-height: 85vh !important;
        z-index: 99999 !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        border-radius: 14px !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.12) !important;
        flex-direction: column !important;
        overflow-y: auto !important;
        animation: trendingModalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both !important;
    }

    /* Quando o popup abre, esconde a capa do card de trás para não vazar */
    .trending-card-wrapper.is-active .trending-card,
    .trending-card-wrapper.is-active .trending-card-title {
        opacity: 0 !important;
        pointer-events: none !important;
    }

    @keyframes trendingModalFadeIn {
        from {
            opacity: 0;
            transform: translate(-50%, -46%) scale(0.92);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }




    .trending-hover-close {
        display: flex;
        top: 8px;
        right: 8px;
        width: 24px;
        height: 24px;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── Título abaixo do card (legado - agora dentro do card-info) ── */
.trending-card-wrapper > .trending-card-title {
    display: none;
}

/* ── Página "Ver Todos" (?page=em-alta) ─────────────────────── */
.trending-page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    row-gap: 12px;
}

.trending-page-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: -0.6px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    flex-shrink: 0;
}

.trending-page-title i {
    font-size: 24px;
    color: var(--primary-red);
}

.trending-page-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-s);
}

.trending-page-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    background: transparent;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: calc(var(--radius-s) - 4px);
    transition: color var(--dur-base) var(--ease-out), background var(--dur-base), box-shadow var(--dur-base);
    white-space: nowrap;
}

.trending-page-tab i {
    font-size: 15px;
}

.trending-page-tab.is-active {
    background: #fff;
    color: var(--primary-red);
    box-shadow: var(--shadow-xs);
    font-weight: 700;
}

.trending-page-count {
    margin-left: auto;
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Grid da página Ver Todos */
.trending-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px 16px;
    align-items: start;
    padding-bottom: 24px;
}

.trending-page-grid--hidden {
    display: none;
}

.trending-page-grid .trending-card-wrapper {
    width: 100%;
    flex-shrink: unset;
}

.trending-page-grid .trending-card {
    width: 100%;
    min-width: unset;
}

.trending-page-grid .trending-card-title {
    width: 100%;
}

/* Hover card na página Ver Todos */
.trending-page-grid .trending-hover-card {
    top: -20px;
    left: 50%;
    transform: translateX(-50%) scale(0.95);
}

.trending-page-grid .trending-card-wrapper.is-left-edge .trending-hover-card {
    left: 0;
    transform: translateX(0) scale(0.95);
}

.trending-page-grid .trending-card-wrapper.is-right-edge .trending-hover-card {
    left: auto;
    right: 0;
    transform: translateX(0) scale(0.95);
}

.trending-page-grid .trending-card-wrapper:hover .trending-hover-card {
    transform: translateX(-50%) scale(1);
    top: -20px;
}

.trending-page-grid .trending-card-wrapper.is-left-edge:hover .trending-hover-card {
    transform: translateX(0) scale(1);
}

.trending-page-grid .trending-card-wrapper.is-right-edge:hover .trending-hover-card {
    transform: translateX(0) scale(1);
}

/* Último card da linha — abre à esquerda */
.trending-page-grid .trending-card-wrapper:last-child .trending-hover-card,
.trending-page-grid .trending-card-wrapper:nth-last-child(2) .trending-hover-card {
    left: auto;
    right: calc(100% + 10px);
}

.trending-page-grid .trending-card-wrapper:last-child:hover .trending-hover-card,
.trending-page-grid .trending-card-wrapper:nth-last-child(2):hover .trending-hover-card {
    transform: translateX(0) translateY(0);
    left: auto;
    right: calc(100% + 10px);
}

/* ── Estado vazio ──────────────────────────────────────────── */
.trending-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-muted);
    gap: 12px;
    text-align: center;
}

.trending-empty i {
    font-size: 36px;
    color: var(--text-light);
}

.trending-empty p {
    font-family: var(--font-body);
    font-size: 14px;
}

/* ── Responsividade Mobile ─────────────────────────────────── */
@media (max-width: 768px) {

    .trending-card,
    .trending-card-wrapper {
        min-width: 180px !important;
    }

    .trending-card {
        width: 180px !important;
        min-width: 180px !important;
    }

    .trending-card-wrapper:hover .trending-card {
        transform: none !important;
        box-shadow: none !important;
    }

    .trending-card-wrapper:hover .trending-card img {
        transform: none !important;
    }

    .trending-card-title {
        width: 120px;
        font-size: 11px;
    }

    /* NEUTRALIZADO: Regras antigas de hover card mobile removidas.
       O hover card no mobile agora é position:fixed (modal centralizado).
       Veja @media(max-width:768px) acima. */


    .trending-page-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 14px 12px;
    }

    .trending-page-grid .trending-hover-card {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-8px);
    }

    .trending-page-grid .trending-card-wrapper:hover .trending-hover-card {
        transform: translateX(-50%) translateY(0);
        left: 50%;
    }

    .trending-hover-backdrop {
        height: 90px;
    }

    .trending-page-title {
        font-size: 18px;
    }
}

@media (max-width: 480px) {

    .trending-card,
    .trending-card-wrapper {
        width: calc((100vw - 50px) / 2.5) !important;
        min-width: calc((100vw - 50px) / 2.5) !important;
    }

    .trending-card-title {
        width: 100% !important;
    }

}

.trending-rating-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 4px 8px;
    border-radius: 6px;
    color: #fff;
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 5;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    line-height: 1;
    pointer-events: none;
}

.trending-rating-badge img {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: 14px !important;
    max-height: 14px !important;
    object-fit: contain !important;
    display: inline-block !important;
    margin: 0 !important;
    margin-top: -1px !important;
    padding: 0 !important;
    transform: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    filter: none !important;
}