/* ========================================
   FIX CRÍTICO: Forçar imagens lazy-loaded a aparecer
   data-bgsrc usa background-image via CSS — fallback se JS não disparar
   ======================================== */
.img.lazyload[data-bgsrc],
.img.lazyloading[data-bgsrc] {
    background-image: var(--bg-image);
}
/* Fallback universal: qualquer elemento com data-bgsrc deve mostrar imagem */
[data-bgsrc] {
    background-image: var(--bg-image);
}
/* Garantir que imagens background-image tenham tamanho mínimo */
.img.bg-cover {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* BANNERS: Fundo Cinza Full-Width com label vertical na esquerda */
.pn-ad-master-container {
    background: linear-gradient(180deg, #f8f9fa 0%, #f1f3f5 100%) !important;
    border-top: 1px solid #ddd !important;
    border-bottom: 1px solid #ddd !important;
    padding: 12px 0 12px 28px !important;
    margin: 0 0 25px 0 !important;
    width: 100% !important;
    clear: both !important;
    display: flex;
    align-items: center;
    position: relative;
}

.pn-ad-label {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    transform-origin: left center;
    display: block;
    font-size: 8.5px;
    color: #aaa;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1.3px;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    width: auto;
}

@media (max-width: 768px) {
    .pn-ad-master-container {
        padding: 10px 0 10px 0 !important;
        flex-direction: column;
    }
    .pn-ad-label {
        position: static;
        transform: none;
        text-align: center;
        margin-bottom: 8px;
    }
}

.pn-ad-box {
    background: #f8f9fa !important;
    border: 1px solid #eee !important;
    border-radius: 12px !important;
    padding: 15px !important;
    margin: 25px auto !important;
    text-align: center !important;
}

/* FLEX PARA BANNERS LADO A LADO */
.pn-ad-flex {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
/* Proteção do Logo - PiraNOT Master */
.smart-head-main { overflow: visible !important; }
.ts-logo, .logo-link { flex-shrink: 0 !important; min-width: 180px !important; display: flex !important; align-items: center !important; }
.smart-head-mid .logo img { max-height: 75px !important; width: auto !important; }

/* =============================================
   BARRA DE COLUNISTAS — v10 (O Globo franja + Folha faixa)
   CSS Grid 2-col por card: foto circular | nome + titulo
   Desktop: 3 colunistas com label vertical; Mobile: scroll horizontal snap
   ============================================= */

/* Container — fundo dark elegante */
.pn-topbar-cols {
    background: #1a1f36;
    border-bottom: 2px solid #c5a35a;
    padding: 18px 0;
    position: relative;
    z-index: 90;
}

/* Wrapper interno */
.pn-topbar-cols__inner {
    width: 100%;
    max-width: 1236px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Lista horizontal — flex, 3 cards ocupam espaço igual */
.pn-topbar-cols__list {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    flex: 1;
}
.pn-topbar-cols__list::-webkit-scrollbar {
    display: none;
}

/* Card — CSS Grid 2-col (estilo O Globo franja-colunistas) */
.pn-topbar-cols__item {
    display: grid;
    grid-template-columns: 76px 1fr;
    grid-template-rows: auto 1fr;
    gap: 4px 16px;
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 0;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    padding-left: 24px;
    transition: background-color 0.2s ease;
}
.pn-topbar-cols__item:first-child {
    border-left: none;
    padding-left: 0;
}
.pn-topbar-cols__item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
}

/* Avatar — grid-row 1/3, foto circular */
.pn-topbar-cols__avatar-link {
    grid-row: 1 / 3;
    grid-column: 1 / 2;
    display: flex;
    align-items: flex-start;
    text-decoration: none;
}

.pn-topbar-cols__avatar {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    filter: grayscale(60%);
    transition: filter 0.3s ease, transform 0.2s ease;
    border: 2.5px solid rgba(197, 163, 90, 0.25);
}
.pn-topbar-cols__item:hover .pn-topbar-cols__avatar {
    filter: grayscale(0%);
    transform: scale(1.04);
    border-color: #c5a35a;
}

/* Content — grid-col 2, mais espaço pro título */
.pn-topbar-cols__content {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    justify-content: center;
}

/* Nome — bold, cor destaque, MAIÚSCULO */
.pn-topbar-cols__name {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #c5a35a;
    text-decoration: none;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}
.pn-topbar-cols__name:hover {
    color: #ddb96e;
    text-decoration: none;
}

/* Titulo — serif, claro, até 5 linhas, mais espaço */
.pn-topbar-cols__title {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 14.5px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
    transition: color 0.2s ease;
}
.pn-topbar-cols__title:hover {
    color: #fff;
    text-decoration: none;
}

/* Avatar fallback */
.pn-topbar-cols__avatar[src=""],
.pn-topbar-cols__avatar:not([src]) {
    display: none;
}

/* Pinned — borda mais visível */
.pn-topbar-cols__item.pn-col-pinned .pn-topbar-cols__avatar {
    border-color: rgba(197, 163, 90, 0.5);
}

/* =============================================
   MOBILE — Colunistas v10
   ============================================= */

/* Tablet */
@media (max-width: 991px) {
    .pn-topbar-cols__list {
        gap: 18px;
    }
    .pn-topbar-cols__item {
        grid-template-columns: 64px 1fr;
        gap: 4px 12px;
        padding-left: 18px;
    }
    .pn-topbar-cols__avatar {
        width: 64px;
        height: 64px;
    }
    .pn-topbar-cols__name {
        font-size: 14px;
    }
    .pn-topbar-cols__title {
        font-size: 13.5px;
        -webkit-line-clamp: 4;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .pn-topbar-cols {
        padding: 14px 0;
    }
    .pn-topbar-cols__inner {
        padding: 0 12px;
    }
    .pn-topbar-cols__list {
        gap: 0;
        scroll-snap-type: x mandatory;
    }
    .pn-topbar-cols__item {
        flex: 0 0 280px;
        min-width: 260px;
        max-width: 300px;
        scroll-snap-align: start;
        grid-template-columns: 60px 1fr;
        gap: 3px 10px;
        padding: 10px 14px;
        border-left: 1px solid rgba(255, 255, 255, 0.05);
    }
    .pn-topbar-cols__item:first-child {
        padding-left: 0;
    }
    .pn-topbar-cols__avatar {
        width: 60px;
        height: 60px;
    }
    .pn-topbar-cols__name {
        font-size: 13.5px;
        font-weight: 800;
    }
    .pn-topbar-cols__title {
        font-size: 12.5px;
        -webkit-line-clamp: 4;
        line-height: 1.4;
    }

    /* Fade edges */
    .pn-topbar-cols__list {
        mask-image: linear-gradient(to right, transparent 0, black 12px, black calc(100% - 24px), transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0, black 12px, black calc(100% - 24px), transparent 100%);
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .pn-topbar-cols__item {
        flex: 0 0 260px;
        min-width: 240px;
        grid-template-columns: 52px 1fr;
        gap: 3px 10px;
        padding: 8px 12px;
    }
    .pn-topbar-cols__avatar {
        width: 52px;
        height: 52px;
    }
}

/* Swipe animation hint (mobile) */
@keyframes pn-swipe-hint {
    0%, 100% { transform: translateX(0); opacity: 0.4; }
    50% { transform: translateX(4px); opacity: 0.85; }
}

/* ========================================
   SPACING MOBILE — Margens e Gaps (estilo NationalPress)
   Padding único via .main-wrap (10px), sem acúmulo de camadas.
   ======================================== */
@media (max-width: 768px) {
    /* === PADDING ÚNICO — só no .main-wrap ===
       Antes: padding duplicado em .main-wrap (16px) + .elementor-section (16px)
       + .elementor-column (18px) = 50px+ por lado → bordas brancas enormes.
       Agora: 10px no main-wrap, zero no resto. */
    .main-wrap {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Header e footer mantêm padding próprio */
    .smart-head-mid,
    .smart-head-bot,
    footer .wrap,
    .footer-wrap {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* === FULL-BLEED: elementos que devem ir de canto a canto ===
       .main-wrap tem padding 10px, então -10px de margin "escapa" o padding */
    .smart-head-mobile,
    .smart-head-main,
    .pn-topbar-cols,
    .main-footer {
        margin-left: -10px !important;
        margin-right: -10px !important;
    }

    /* ZERAR padding HORIZONTAL duplicado dos containers Elementor (vertical preservado) */
    .elementor-section,
    .elementor-section.elementor-top-section {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .elementor-section.elementor-top-section {
        margin-bottom: 18px !important;
    }
    .elementor-column,
    .elementor-column.elementor-col-100 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .elementor-column-gap-default > .elementor-row > .elementor-column > .elementor-element-populated,
    .elementor-column-gap-default > .elementor-column > .elementor-element-populated {
        padding: 0 5px !important;
    }
    /* Negative margins do Elementor container — zerar no mobile */
    .elementor-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    /* Espaçamento vertical entre widgets */
    .elementor-widget {
        margin-bottom: 16px !important;
    }
    .elementor-widget:last-child {
        margin-bottom: 0 !important;
    }
    .grid-post {
        margin-bottom: 16px !important;
    }

    /* .site-content não precisa de padding extra (main-wrap já tem) */
    .site-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* SmartMag .ts-contain — zerar padding duplicado */
    .ts-contain {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Gaps verticais entre blocos/seções */
    .block-heading,
    .widget-heading {
        margin-bottom: 14px !important;
        margin-top: 24px !important;
    }
    .loop-grid,
    .loop-list {
        margin-bottom: 20px !important;
    }

    /* Espaçamento entre artigos em listas */
    .small-post {
        margin-bottom: 14px !important;
        padding-bottom: 14px !important;
    }

    /* Ad containers — side padding + spacing */
    .pn-ad-master-container {
        margin: 16px 0 !important;
        padding: 10px 14px 10px 22px !important;
    }
    .pn-ad-label {
        font-size: 7px;
    }

    /* Sidebar no mobile — mais espaçamento */
    .right-sidebar {
        padding-left: 0 !important;
        margin-top: 24px !important;
    }

    /* Imagens — bordas arredondadas no mobile */
    .post-thumb img,
    .media img {
        border-radius: 6px !important;
    }

    /* Ad desktop-only — esconder no mobile */
    .pn-ad-desktop-only {
        display: none !important;
    }

    /* In-content ads — layout mobile (1 coluna) */
    .pn-incontent-ads .pn-ad-flex {
        flex-direction: column !important;
        align-items: center !important;
    }
}

/* ========================================
   FIXES GLOBAIS — Títulos, Descrições, Imagens
   ======================================== */

/* === FIX 1: TÍTULOS COMPLETOS — GLOBAL ===
   Títulos de posts NUNCA são cortados, em NENHUMA página.
   Regra universal que sobrepõe tudo do SmartMag (.limit-lines, 
   .small-post, .grid-post, sidebar, overlays, carousels, etc.) */

.post-title,
.post-title.limit-lines,
.is-title.post-title,
.home .is-title.post-title,
.archive .is-title.post-title,
h2.post-title,
h3.post-title,
.small-post .post-title,
.grid-post .post-title,
.list-post .post-title,
.large-post .post-title,
.overlay-post .post-title,
.feat-grid .post-title,
.main-featured .post-title,
.sidebar .post-title,
.loop-small .post-title,
.ts-posts .post-title,
.slick-slide .post-title,
article .post-title {
    --limit-lines: 99 !important;
    max-height: none !important;
    -webkit-line-clamp: unset !important;
    overflow: visible !important;
    display: block !important;
    text-overflow: unset !important;
    white-space: normal !important;
}

/* === FIX 1c: AJUSTES DE LAYOUT POR TIPO DE BLOCO ===
   Com títulos completos, o layout precisa se adaptar.
   Cada tipo de bloco tem uma estratégia para acomodar títulos longos. */

/* small-post (thumb + título lado a lado, muito compacto):
   Aumentar altura mínima e reduzir font-size levemente no mobile */
@media (max-width: 767px) {
    .small-post .post-title {
        font-size: 0.9rem !important;
        line-height: 1.35 !important;
    }
    .small-post.m-pos-left,
    .small-post.m-pos-right {
        min-height: auto !important;
        align-items: flex-start !important;
    }
}

/* list-post (horizontal: thumb + content):
   Permitir que o item cresça verticalmente para acomodar título */
.list-post {
    min-height: auto !important;
    height: auto !important;
}
.list-post .content {
    flex: 1 !important;
    min-height: auto !important;
}
@media (max-width: 767px) {
    .list-post .post-title {
        font-size: 0.95rem !important;
        line-height: 1.35 !important;
    }
}

/* grid-post (card): flex-grow natural, título expande o card */
.grid-post .content {
    flex: 1 !important;
}

/* overlay-post (texto sobre imagem): permitir título maior mas com fundo legível */
.overlay-post .post-title {
    text-shadow: 0 1px 3px rgba(0,0,0,0.5) !important;
}
@media (max-width: 767px) {
    .overlay-post .post-title {
        font-size: 1rem !important;
        line-height: 1.3 !important;
    }
}

/* === FIX 1b: FALLBACK — CONTAINER VAZIO SEM IMAGEM ===
   Esconde container .media vazio (sem <a> dentro) para não quebrar grid.
   O mu-plugin piranot-placeholder-image.php é a solução primária,
   este CSS é safety net. */
article.l-post .media:not(:has(a)) {
    display: none !important;
}
/* Em grid/overlay, quando .media some o conteúdo deve preencher */
.grid-post .media:not(:has(a)) + .content,
.overlay-post .media:not(:has(a)) + .content {
    flex: 1;
}

/* === FIX 2: EXCESSO DE DESCRIÇÃO ===
   Limitar excerpts/descriptions a 3 linhas máximo, elegante. */

.post-content-list .excerpt,
.grid-post .excerpt,
.list-post .excerpt,
.large-post .excerpt,
.ts-posts .excerpt,
.post-excerpt,
.grid-post .post-content p,
article .excerpt {
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    line-height: 1.55 !important;
    max-height: calc(1.55em * 3) !important;
}

/* Posts menores: 2 linhas de excerpt */
.small-post .excerpt,
.small-post .post-excerpt,
.sidebar .excerpt {
    -webkit-line-clamp: 2 !important;
    max-height: calc(1.55em * 2) !important;
}

/* === FIX 3: ESPAÇOS VAZIOS SEM IMAGEM ===
   Quando post não tem imagem, o SmartMag deixa espaço vazio.
   Colapsar o container de imagem e reorganizar layout. */

/* Imagem placeholder — esconder */
.no-feat-img .image-link,
.no-feat-img .post-thumb,
.no-feat-img .media,
article:not(:has(img)) .image-link:empty,
article:not(:has(img)) .post-thumb:empty {
    display: none !important;
}

/* Post sem imagem: conteúdo ocupa 100% */
.no-feat-img .content,
.no-feat-img .post-content-list {
    width: 100% !important;
    flex: 1 !important;
    max-width: 100% !important;
}

/* Grid post sem imagem: fundo sutil no lugar */
.grid-post .post-thumb:empty,
.grid-post .image-link:empty {
    display: none !important;
}

/* Para layouts de lista sem imagem (span[data-bgsrc] = SmartMag lazy bg images) */
.list-post:not(:has(.post-thumb img)):not(:has(.post-thumb span[data-bgsrc])) .post-thumb,
.list-post:not(:has(.media img)):not(:has(.media span[data-bgsrc])) .media {
    display: none !important;
}

.list-post:not(:has(.post-thumb img)):not(:has(.post-thumb span[data-bgsrc])) .content,
.list-post:not(:has(.media img)):not(:has(.media span[data-bgsrc])) .post-content-list {
    width: 100% !important;
    max-width: 100% !important;
}

/* Post com imagem quebrada (404) — placeholder cinza com ícone */
.post-thumb img[src=""],
.post-thumb img:not([src]),
.media img[src=""],
.media img:not([src]) {
    background: #f0f0f0;
    min-height: 120px;
    object-fit: contain;
}

/* ========================================
   REFINAMENTOS TIPOGRÁFICOS GLOBAIS
   ======================================== */

/* Títulos de seção/heading SmartMag — mais espaço */
.block-heading .h-text,
.block-heading .heading {
    letter-spacing: 0.02em;
}

/* Meta info (autor, data) — mais discreta */
.post-meta .author,
.post-meta .date,
.post-meta .humans-by,
.post-meta-a .time-link {
    font-size: 12px;
    color: #777;
}

/* ========================================
   REDESIGN SINGLES — ESTILO FOLHA
   Complementa CSS do piranot-core-final.php
   ======================================== */

/* Single: espaçamento do header (título + meta) */
.single .pn-single-main .the-post-header,
.single .pn-single-shell .the-post-header {
    margin-bottom: var(--pn-space-md, 16px);
}

/* Single: heading div refinamento */
.single .the-post-header .heading {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Single: comments link no heading — compacto */
.single .the-post-header .heading .comments {
    font-size: 0.8rem;
    color: var(--pn-text-tertiary, #888);
    margin-left: 8px;
    vertical-align: middle;
}

/* Single: featured image com cantos suaves */
.single .the-post-header .featured {
    margin-top: var(--pn-space-xs, 4px);
    border-radius: 2px;
    overflow: hidden;
}
.single .the-post-header .featured img {
    border-radius: 2px;
}

/* Single: sidebar ajuste quando meta-col presente */
@media (min-width: 992px) {
    .pn-single-folha > .main-sidebar {
        /* Sidebar já é col-4, sem mudanças necessárias */
    }
}

/* Single: author ribbon — harmonizado com design editorial */
.single .pn-author-ribbon--mu {
    border-top: 1px solid var(--pn-rule, #dcdcdc);
    padding-top: var(--pn-space-lg, 24px);
    margin-top: var(--pn-space-xl, 32px);
}
