/**
 * RD Smart SEO Pro — apresentação profissional da imagem destacada.
 * Escopo deliberadamente restrito ao single de notícias.
 */
body.single-post img.rdseo-featured-cover {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 1200px !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    background: #fff !important;
    object-fit: contain !important;
    object-position: center center !important;
}

/* Foxiz usa rb-iwrap em diferentes composições de imagem. Aqui o quadro
   continua responsivo, mas a fotografia deixa de ser recortada/esticada. */
body.single-post .rb-iwrap:has(img.rdseo-featured-cover) {
    position: relative !important;
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 1200px !important;
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    aspect-ratio: 16 / 9 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    overflow: hidden !important;
    background: #fff !important;
}

body.single-post .rb-iwrap img.rdseo-featured-cover {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    margin: 0 !important;
    object-fit: contain !important;
    object-position: center center !important;
    background: #fff !important;
}

/* Mantém links, picture e figure que envolvem diretamente a capa sem
   impor largura acima do conteúdo editorial. */
body.single-post :is(a, picture, figure):has(> img.rdseo-featured-cover) {
    box-sizing: border-box;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    background: #fff;
}

@media (max-width: 767px) {
    body.single-post img.rdseo-featured-cover,
    body.single-post .rb-iwrap:has(img.rdseo-featured-cover) {
        max-width: 100% !important;
    }
}

/**
 * Lightbox Foxiz / Magnific Popup — ajuste à área realmente visível.
 *
 * A regra é intencionalmente mais forte que a do tema. O Foxiz pode atribuir
 * largura baseada no arquivo original ao abrir a imagem; para panfletos 2:3
 * isso faz a altura ultrapassar a tela. O CSS abaixo neutraliza dimensões
 * forçadas. O JS complementar calcula a altura real via visualViewport.
 */
html body.single-post .mfp-wrap,
html body.single-post .mfp-bg {
    box-sizing: border-box !important;
}

html body.single-post .mfp-wrap {
    overflow: hidden !important;
}

html body.single-post .mfp-wrap .mfp-container,
html body.single-post .mfp-container.mfp-image-holder {
    box-sizing: border-box !important;
    width: 100% !important;
    height: 100% !important;
    padding: 16px 20px !important;
}

html body.single-post .mfp-wrap .mfp-content,
html body.single-post .mfp-wrap .mfp-figure,
html body.single-post .mfp-container.mfp-image-holder .mfp-content,
html body.single-post .mfp-container.mfp-image-holder .mfp-figure {
    box-sizing: border-box !important;
    width: auto !important;
    height: auto !important;
    max-width: calc(100vw - 40px) !important;
    max-height: var(--rdseo-lightbox-content-max-h, calc(100vh - 96px)) !important;
    margin: auto !important;
}

/* O seletor sem .mfp-image-holder é proposital: algumas versões/configurações
   do Foxiz alteram a classe do container durante a animação de abertura. */
html body.single-post .mfp-wrap img.mfp-img,
html body.single-post .mfp-container img.mfp-img,
html body.single-post img.mfp-img {
    display: block !important;
    box-sizing: border-box !important;
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: var(--rdseo-lightbox-img-max-w, calc(100vw - 40px)) !important;
    max-height: var(--rdseo-lightbox-img-max-h, calc(100vh - 112px)) !important;
    margin: 0 auto !important;
    padding: 0 !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform: none !important;
    background: #fff !important;
}

/* Mantém legenda e botão de fechar dentro do quadro útil. */
html body.single-post .mfp-wrap .mfp-bottom-bar {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
}

html body.single-post .mfp-wrap .mfp-close {
    z-index: 2 !important;
}

@supports (height: 100dvh) {
    html body.single-post .mfp-wrap .mfp-content,
    html body.single-post .mfp-wrap .mfp-figure {
        max-height: var(--rdseo-lightbox-content-max-h, calc(100dvh - 96px)) !important;
    }

    html body.single-post .mfp-wrap img.mfp-img,
    html body.single-post .mfp-container img.mfp-img,
    html body.single-post img.mfp-img {
        max-height: var(--rdseo-lightbox-img-max-h, calc(100dvh - 112px)) !important;
    }
}

@media (max-width: 767px) {
    html body.single-post .mfp-wrap .mfp-container,
    html body.single-post .mfp-container.mfp-image-holder {
        padding: 10px !important;
    }

    html body.single-post .mfp-wrap .mfp-content,
    html body.single-post .mfp-wrap .mfp-figure,
    html body.single-post .mfp-wrap img.mfp-img,
    html body.single-post .mfp-container img.mfp-img,
    html body.single-post img.mfp-img {
        max-width: var(--rdseo-lightbox-img-max-w, calc(100vw - 20px)) !important;
    }
}

/**
 * 7.2.14 — Foxiz featured lightbox (estrutura inline própria do tema).
 *
 * A imagem destacada não recebe a classe img.mfp-img: o Foxiz injeta um <img>
 * normal dentro de .featured-popup-image > .mfp-source. Estas regras impedem
 * que o flex-grow e o overflow do popup façam o arquivo vertical ocupar a
 * largura e ser cortado em cima/baixo.
 */
html body.single-post .rb-popup-center.popup-no-overflow .mfp-content:has(.featured-popup-image) {
    display: flex !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: visible !important;
}

html body.single-post .mfp-wrap .featured-popup-image {
    display: flex !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 1 auto !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: var(--rdseo-lightbox-img-max-w, calc(100vw - 48px)) !important;
    max-height: var(--rdseo-lightbox-img-max-h, calc(100vh - 80px)) !important;
    margin: auto !important;
    overflow: visible !important;
}

html body.single-post .mfp-wrap .featured-popup-image .mfp-source {
    display: flex !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 1 auto !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    overflow: visible !important;
}

html body.single-post .mfp-wrap .featured-popup-image img,
html body.single-post .mfp-container .featured-popup-image img,
html body.single-post .featured-popup-image img {
    display: block !important;
    box-sizing: border-box !important;
    position: static !important;
    flex: 0 0 auto !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: var(--rdseo-lightbox-img-max-w, calc(100vw - 48px)) !important;
    max-height: var(--rdseo-lightbox-img-max-h, calc(100vh - 80px)) !important;
    margin: 0 auto !important;
    padding: 0 !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform: none !important;
}

@supports (height: 100dvh) {
    html body.single-post .mfp-wrap .featured-popup-image,
    html body.single-post .mfp-wrap .featured-popup-image img,
    html body.single-post .featured-popup-image img {
        max-height: var(--rdseo-lightbox-img-max-h, calc(100dvh - 80px)) !important;
    }
}

@media (max-width: 767px) {
    html body.single-post .mfp-wrap .featured-popup-image,
    html body.single-post .mfp-wrap .featured-popup-image img,
    html body.single-post .featured-popup-image img {
        max-width: var(--rdseo-lightbox-img-max-w, calc(100vw - 24px)) !important;
        max-height: var(--rdseo-lightbox-img-max-h, calc(100dvh - 56px)) !important;
    }
}
