/*
 * CSS da seção "Populares" (template-parts/populares.php), exibida no fim
 * do post individual. Extraído de lá (onde vivia inline) para cá.
 * Enfileirado condicionalmente (is_single()) via functions.php
 * (temanovo_scripts) — só carrega em página de post.
 */

/* ============================================
   TRENDS - PREMIUM
   ============================================ */

.trends-wrapper {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto 32px;
    padding: 36px 40px 40px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
    /* Fora da dobra (fim do post) — o navegador pode pular o layout/
       renderização até o usuário rolar até aqui. A altura estimada
       evita pulo de layout quando o conteúdo real "aparece". */
    content-visibility: auto;
    contain-intrinsic-size: auto 700px;
}

.trends-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg,
        var(--tn-color-primary),
        var(--tn-color-secondary),
        var(--tn-color-extra),
        var(--tn-color-primary)
    );
    background-size: 300% 100%;
    animation: trendsGlow 6s ease-in-out infinite;
}

@keyframes trendsGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ================= HEADER ================= */
.trends-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.trends-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.trends-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--tn-color-primary), var(--tn-color-secondary));
    color: #fff;
    font-size: 22px;
    box-shadow: 0 6px 20px rgba(var(--tn-color-primary-rgb), 0.3);
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.trends-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, var(--tn-color-primary), var(--tn-color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.trends-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tn-color-primary);
    background: rgba(var(--tn-color-primary-rgb), 0.08);
    padding: 6px 16px;
    border-radius: 30px;
    border: 1px solid rgba(var(--tn-color-primary-rgb), 0.15);
}

.badge-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tn-color-primary);
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ================= GRID ================= */
.trends-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
}

/* ================= CARDS ================= */
.trend-card {
    position: relative;
    isolation: isolate;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    aspect-ratio: 16 / 9;
    background: #f5f5f5;
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    animation: cardFadeIn 0.6s ease forwards;
}

.trend-card:nth-child(1) { animation-delay: 0.05s; }
.trend-card:nth-child(2) { animation-delay: 0.10s; }
.trend-card:nth-child(3) { animation-delay: 0.15s; }
.trend-card:nth-child(4) { animation-delay: 0.20s; }
.trend-card:nth-child(5) { animation-delay: 0.25s; }
.trend-card:nth-child(6) { animation-delay: 0.30s; }
.trend-card:nth-child(7) { animation-delay: 0.35s; }

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.trend-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    z-index: 10;
}

.trend-card.hero {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    aspect-ratio: auto;
}

.trend-card.small {
    grid-column: auto;
    grid-row: auto;
}

.trend-card:nth-child(2) { grid-column: 2; grid-row: 1; }
.trend-card:nth-child(3) { grid-column: 3; grid-row: 1; }
.trend-card:nth-child(4) { grid-column: 2; grid-row: 2; }
.trend-card:nth-child(5) { grid-column: 3; grid-row: 2; }

.trend-card:nth-child(6) {
    grid-column: 1 / 2;
    grid-row: 3;
}

.trend-card:nth-child(7) {
    grid-column: 2 / 4;
    grid-row: 3;
}

/* ================= THUMBNAIL COM MOLDURA ================= */
.trend-thumb {
    position: relative;
    isolation: isolate;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f0f0f0;
}

.trend-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 1;
}

.trend-card:hover .trend-image {
    transform: scale(1.08);
}

/* ===== MOLDURA AUTOMÁTICA (sem opacity e mix-blend-mode) ===== */
.trend-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--tn-frame-image) center/cover no-repeat;
    pointer-events: none;
    z-index: 1;
}

/* No Image */
.trend-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #adb5bd;
    font-size: 48px;
}

/* ================= RANK ================= */
.trend-rank {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
}

.rank-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    height: 28px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: linear-gradient(135deg, var(--tn-color-primary), var(--tn-color-secondary));
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(var(--tn-color-primary-rgb), 0.3);
}

.hero .rank-number {
    min-width: 38px;
    height: 38px;
    font-size: 0.9rem;
}

/* ================= OVERLAY ================= */
.trend-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 4;
    align-items: flex-end;
    padding: 16px 18px 18px;
    background: linear-gradient(to top,
        rgba(0,0,0,0.85) 0%,
        rgba(0,0,0,0.4) 50%,
        rgba(0,0,0,0) 100%
    );
    transition: background 0.4s ease;
}

.trend-card:hover .trend-overlay {
    background: linear-gradient(to top,
        rgba(0,0,0,0.92) 0%,
        rgba(0,0,0,0.5) 50%,
        rgba(0,0,0,0.05) 100%
    );
}

/* ================= CONTENT ================= */
.trend-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hero .trend-content {
    gap: 10px;
}

.trend-category {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tn-color-secondary);
    background: rgba(0,0,0,0.3);
    padding: 2px 12px;
    border-radius: 30px;
    align-self: flex-start;
    backdrop-filter: blur(4px);
}

.trend-post-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero .trend-post-title {
    font-size: 1.1rem;
    font-weight: 700;
    -webkit-line-clamp: 3;
}

.trend-excerpt {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ================= META ================= */
.trend-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 4px;
}

.trend-views,
.trend-date {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
}

.trend-views i,
.trend-date i {
    font-size: 12px;
}

.hero .trend-views,
.hero .trend-date {
    font-size: 0.8rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .trends-wrapper {
        padding: 28px 24px 32px;
        width: 95%;
    }

    .trends-title {
        font-size: 1.5rem;
    }

    .trends-grid {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .trend-card {
        grid-column: auto !important;
        grid-row: auto !important;
        aspect-ratio: 16 / 9;
    }

    .trend-card.hero {
        grid-column: 1 / 2;
        grid-row: 1 / 3;
        aspect-ratio: auto;
    }

    .trend-card:nth-child(2) { grid-column: 2; grid-row: 1; }
    .trend-card:nth-child(3) { grid-column: 2; grid-row: 2; }
    .trend-card:nth-child(4) { grid-column: 1; grid-row: 3; }
    .trend-card:nth-child(5) { grid-column: 2; grid-row: 3; }
    .trend-card:nth-child(6) { grid-column: 1; grid-row: 4; }
    .trend-card:nth-child(7) { grid-column: 2; grid-row: 4; }

    .hero .trend-post-title {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .trends-wrapper {
        padding: 20px 16px 24px;
        width: 100%;
        border-radius: 16px;
        margin-bottom: 20px;
    }

    .trends-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .trends-title {
        font-size: 1.3rem;
    }

    .trends-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .trends-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .trend-card {
        aspect-ratio: 16 / 10;
    }

    .trend-card.hero {
        grid-column: 1 / -1;
        grid-row: auto;
        aspect-ratio: 16 / 9;
    }

    .trend-card:nth-child(2),
    .trend-card:nth-child(3),
    .trend-card:nth-child(4),
    .trend-card:nth-child(5),
    .trend-card:nth-child(6),
    .trend-card:nth-child(7) {
        grid-column: auto;
        grid-row: auto;
    }

    .hero .trend-post-title {
        font-size: 1.2rem;
        -webkit-line-clamp: 2;
    }

    .trend-post-title {
        font-size: 0.85rem;
    }

    .trend-overlay {
        padding: 12px 14px 14px;
    }

    .rank-number {
        min-width: 26px;
        height: 26px;
        font-size: 0.65rem;
        padding: 0 8px;
    }

    .hero .rank-number {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .trend-views,
    .trend-date {
        font-size: 0.6rem;
    }

    .trend-excerpt {
        display: none;
    }
}

@media (max-width: 480px) {
    .trends-wrapper {
        padding: 16px 12px 20px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .trends-title {
        font-size: 1.1rem;
    }

    .trends-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .trends-badge {
        font-size: 0.6rem;
        padding: 4px 12px;
    }

    .trends-grid {
        gap: 10px;
    }

    .hero .trend-post-title {
        font-size: 1rem;
    }

    .trend-post-title {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
    }

    .trend-overlay {
        padding: 10px 12px 12px;
    }

    .trend-rank {
        top: 8px;
        right: 8px;
    }

    .rank-number {
        min-width: 22px;
        height: 22px;
        font-size: 0.55rem;
        padding: 0 6px;
    }

    .rank-badge {
        display: none;
    }

    .trend-meta {
        gap: 10px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .trends-wrapper::before,
    .trends-icon,
    .badge-pulse {
        animation: none !important;
    }

    .trend-card,
    .trend-image {
        transition: none !important;
        animation: none !important;
    }

    .trend-card {
        opacity: 1;
        transform: none;
    }

    .trend-card:hover {
        transform: none;
    }

    .trend-card:hover .trend-image {
        transform: none;
    }
}
