<?php
/**
 * Plugin Name: Fe Adulta - compact entry spacing
 * Description: Ajusta el aire vertical de la navegacion de entradas y la paginacion de archivos.
 */

add_action('wp_head', function() {
    if (is_admin()) return;
    if (!(is_single() || is_archive() || is_search() || is_home())) return;
    ?>
    <style>
    /* Issue #67: compactar el cierre del single post sin tocar el template FSE. */
    body.single-post .wp-block-group.alignwide:has(> nav[aria-label="Navegación de entradas"]) {
        margin-top: 1rem !important;
        margin-bottom: 0.75rem !important;
    }
    body.single-post nav[aria-label="Navegación de entradas"] {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        gap: 1rem !important;
    }
    body.single-post .wp-block-post-navigation-link {
        line-height: 1.35;
    }
    body.single-post .wp-block-post-navigation-link a {
        text-decoration-thickness: 1px;
        text-underline-offset: 3px;
    }
    body.single-post .wp-block-group.alignwide:has(> .wp-block-heading + .wp-block-query) {
        padding-top: 1rem !important;
        padding-bottom: 1.25rem !important;
    }
    body.single-post .wp-block-group.alignwide:has(> .wp-block-heading + .wp-block-query) > .wp-block-heading {
        margin-bottom: 0.65rem !important;
    }
    body.single-post .wp-block-group.alignwide:has(> .wp-block-heading + .wp-block-query) .wp-block-post-template > .wp-block-post {
        margin-block-start: 0 !important;
    }

    /* Issue #67: paginacion de archivos/categorias ("Mas entradas" / siguiente pagina). */
    body.archive .wp-block-query.alignwide > .wp-block-spacer,
    body.search .wp-block-query.alignwide > .wp-block-spacer,
    body.blog .wp-block-query.alignwide > .wp-block-spacer {
        height: 0.5rem !important;
    }
    body.archive .wp-block-query.alignwide > .wp-block-group.alignfull:has(> .wp-block-query-pagination),
    body.search .wp-block-query.alignwide > .wp-block-group.alignfull:has(> .wp-block-query-pagination),
    body.blog .wp-block-query.alignwide > .wp-block-group.alignfull:has(> .wp-block-query-pagination) {
        margin-top: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }
    body.archive .wp-block-query-pagination,
    body.search .wp-block-query-pagination,
    body.blog .wp-block-query-pagination {
        gap: 0.75rem 1.25rem !important;
        align-items: center;
    }
    body.archive .wp-block-query-pagination-numbers,
    body.search .wp-block-query-pagination-numbers,
    body.blog .wp-block-query-pagination-numbers {
        display: flex;
        gap: 0.45rem;
        align-items: center;
    }
    </style>
    <?php
}, 30);
