/* ==========================================================================
 * Banners laterales: Talleres Benalúa y Vendecaranuncios
 *
 * Dos «rascacielos» fijos en los huecos que quedan a izquierda y derecha del
 * contenido central. Solo aparecen cuando el hueco cabe entero (ancho del
 * contenedor + 2 × banner + márgenes). En móvil (hasta 767px) sale UN banner
 * horizontal flotante abajo; entre 768px y 1699px no se pintan. El HTML lo crea assets/js/banner-taller.js y
 * los dos archivos los encola inc/banner-taller.php (versión = fecha del
 * archivo, así que la caché del navegador se renueva sola al subirlos).
 *
 * Qué banners hay y sus reglas se gestionan en wp-admin › Banners. En cada
 * página cargada el JS sortea UNO (.vcb-anuncio, clase .is-activa) y lo pone
 * en los dos huecos (.vcb-banner).
 * En .vcb-cerrar se ve primero un contador (5 s) y luego la X blanca, que
 * cierra los dos banners durante la sesión.
 *
 * Fotos:
 *   - Benalúa: assets/img/banner-taller/taller-motor.webp de fondo, con un
 *     velo azul encima. Encuadre: «33% 100% / auto 86%».
 *   - Vendecaranuncios: assets/img/banner-vca/anuncio-vca.webp (el anuncio
 *     cuadrado) de fondo a todo el alto, encuadrado en la mano con el
 *     móvil que muestra la web. Encuadre: «9.6% 0% / auto 100%».
 * Si falta una foto, se ve solo el degradado de fondo.
 * ========================================================================== */

.vcb-banner {
    display: none;
}

/*
 * Ancho del contenedor central (el contenido más ancho del tema llega a
 * 1280px) y del banner. --vcb-top: alto de la cabecera fija (84px) + aire.
 */
:root {
    --vcb-c: 1280px;
    --vcb-w: 170px;
    --vcb-pad: 12px;
    --vcb-gap: 16px;
    --vcb-top: calc(84px + var(--vcb-gap));
    /* Colores del logo de Talleres Benalúa */
    --vcb-oro: #f5ad0f;
    --vcb-oro-claro: #ffc33a;
    --vcb-marino: #0b1d45;
    --vcb-azul: #13396e;
    /* Colores del anuncio de Vendecaranuncios */
    --vca-marino: #081a4d;
    --vca-azul: #0d3a8c;
    --vca-amarillo: #ffd21f;
    --vca-cian: #22c6ff;
    --vca-cian-claro: #6fdcff;
}

/* Barra de administración de WordPress (usuarios con sesión de editor). */
body.admin-bar .vcb-banner {
    top: calc(var(--vcb-top) + 32px);
}

/*
 * Escritorio ancho (1280 + 2 × (170 + 40) = 1700): dos rascacielos laterales.
 * Móvil (hasta 767px): los mismos estilos de base y, más abajo, un bloque que
 * los convierte en UN banner horizontal flotante abajo.
 */
@media (min-width: 1700px), (max-width: 767px) {
    /* ---- Hueco fijo ---------------------------------------------------- */
    .vcb-banner {
        position: fixed;
        top: var(--vcb-top);
        bottom: var(--vcb-gap);
        z-index: 100;
        display: block;
        width: var(--vcb-w);
        overflow: hidden;
        border-radius: 18px;
        background: var(--vcb-marino);
        box-shadow: 0 18px 40px rgba(7, 12, 20, .28);
        transition: transform .2s ease, box-shadow .2s ease;
    }

    /* Centrado en el hueco lateral: (hueco - banner) / 2 */
    .vcb-banner--izq {
        left: calc((100vw - var(--vcb-c)) / 4 - var(--vcb-w) / 2);
    }

    .vcb-banner--der {
        right: calc((100vw - var(--vcb-c)) / 4 - var(--vcb-w) / 2);
    }

    .vcb-banner:hover {
        transform: translateY(-2px);
        box-shadow: 0 24px 48px rgba(7, 12, 20, .36);
    }

    /* Cerrado por el visitante (se recuerda durante la sesión). */
    .vcb-banner.is-cerrado {
        display: none;
    }

    /* Botón X para cerrar: fondo blanco, esquina superior izquierda. */
    .vcb-cerrar {
        position: absolute;
        top: 8px;
        left: 8px;
        z-index: 5;
        display: flex;
        width: 24px;
        height: 24px;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
        color: #0b1d45;
        cursor: pointer;
        opacity: .92;
        transition: opacity .15s ease, transform .15s ease;
    }

    .vcb-cerrar:hover,
    .vcb-cerrar:focus-visible {
        opacity: 1;
        transform: scale(1.1);
    }

    .vcb-cerrar:focus-visible {
        outline: 2px solid var(--vca-cian);
        outline-offset: 2px;
    }

    .vcb-cerrar svg {
        display: block;
        width: 12px;
        height: 12px;
    }

    /* Cuenta atrás antes de poder cerrar: número en el círculo blanco. */
    .vcb-cerrar.is-espera {
        cursor: default;
        opacity: .92;
        transform: none;
    }

    .vcb-cuenta {
        display: block;
        font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
        font-size: 13px;
        font-weight: 800;
        line-height: 1;
        font-variant-numeric: tabular-nums;
    }

    /* ---- Cada anuncio (apilados; solo se ve el activo) ----------------- */
    .vcb-anuncio {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        box-sizing: border-box;
        padding: 18px var(--vcb-pad) 14px;
        border-radius: inherit;
        color: #fff !important;
        font-family: "Montserrat", "Poppins", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
        line-height: 1.1;
        text-align: left;
        text-decoration: none !important;
        opacity: 0;
        visibility: hidden;
        transition: opacity .7s ease, visibility 0s linear .7s;
        -webkit-font-smoothing: antialiased;
    }

    .vcb-anuncio.is-activa {
        opacity: 1;
        visibility: visible;
        transition: opacity .7s ease, visibility 0s;
    }

    .vcb-anuncio *,
    .vcb-anuncio *::before,
    .vcb-anuncio *::after {
        box-sizing: border-box;
    }

    .vcb-anuncio:focus-visible {
        outline: 3px solid #fff;
        outline-offset: -5px;
    }

    /*
     * El botón de WhatsApp del tema (54px, z-index 1200) se pinta ENCIMA del
     * banner derecho, centrado en su parte baja. El banner reserva ese hueco
     * abajo para que el botón no tape el botón del anuncio. La flecha de
     * «volver arriba» de Astra se coloca sola a su izquierda.
     */
    html:root {
        --vcg-whatsapp-right: calc((100vw - var(--vcb-c)) / 4 - 27px);
    }

    .vcb-banner--der .vcb-anuncio {
        padding-bottom: calc(var(--vcg-whatsapp-bottom, 24px) - var(--vcb-gap) + 54px + 12px);
    }

    /* Hueco central flexible: absorbe el alto sobrante. */
    .vcb-foto {
        position: relative;
        display: flex;
        flex: 1 1 auto;
        min-height: 70px;
        align-items: center;
        justify-content: center;
        margin: 0 calc(var(--vcb-pad) * -1);
        overflow: hidden;
    }

    /* ==================================================================
     * Anuncio 1: Talleres Benalúa
     * ================================================================== */
    .vcb-anuncio--taller {
        background:
            /* Velo azul del logo: sólido tras el logo y el titular, casi
             * transparente sobre la cara y las manos, y algo más oscuro tras
             * los datos de abajo para leerlos. */
            linear-gradient(180deg,
                rgba(11, 29, 69, .97) 0%,
                rgba(11, 29, 69, .95) 16%,
                rgba(11, 29, 69, .25) 28%,
                rgba(11, 29, 69, .05) 42%,
                rgba(11, 29, 69, .08) 66%,
                rgba(11, 29, 69, .6) 78%,
                rgba(7, 19, 47, .85) 100%),
            /* Foto (1314 × 1920) desde debajo del titular hasta abajo,
             * centrada en la cabeza y las manos del mecánico. */
            url("../img/banner-taller/taller-motor.webp") 33% 100% / auto 86% no-repeat,
            linear-gradient(180deg, var(--vcb-azul) 0%, var(--vcb-marino) 48%, #07132f 100%);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 3px 0 var(--vcb-oro);
    }

    .vcb-anuncio--taller:hover {
        box-shadow: inset 0 0 0 1px rgba(245, 173, 15, .55), inset 0 3px 0 var(--vcb-oro);
    }

    .vcb-logo {
        display: block;
        flex: 0 0 auto;
        text-align: center;
    }

    .vcb-logo__sup {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-top: 4px;
        font-size: calc(var(--vcb-w) * .066);
        font-weight: 800;
        letter-spacing: .28em;
    }

    .vcb-logo__sup::before,
    .vcb-logo__sup::after {
        content: "";
        flex: 1 1 auto;
        height: 2px;
        border-radius: 2px;
        background: var(--vcb-oro);
    }

    .vcb-logo__sup::after {
        margin-left: -.28em; /* compensa el espaciado de la última letra */
    }

    .vcb-logo__nombre {
        display: block;
        margin-top: 2px;
        font-size: calc(var(--vcb-w) * .165);
        font-style: italic;
        font-weight: 900;
        letter-spacing: -.01em;
        line-height: 1;
        text-shadow: 2px 2px 0 var(--vcb-azul), 0 2px 10px rgba(4, 12, 32, .8);
    }

    .vcb-titular {
        display: block;
        flex: 0 0 auto;
        margin: 0;
        color: var(--vcb-oro);
        font-size: calc(var(--vcb-w) * .112);
        font-weight: 900;
        letter-spacing: -.01em;
        line-height: 1.02;
        text-transform: uppercase;
        text-shadow: 0 2px 6px rgba(4, 12, 32, .9), 0 0 18px rgba(4, 12, 32, .6);
    }

    .vcb-titular span {
        display: block;
        white-space: nowrap;
    }

    .vcb-tel {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 6px;
        border-radius: 999px;
        background: #fff;
        color: var(--vcb-marino);
        font-size: calc(var(--vcb-w) * .1);
        font-weight: 800;
        letter-spacing: -.01em;
        white-space: nowrap;
    }

    .vcb-ico {
        display: block;
        flex: 0 0 auto;
        width: 1.05em;
        height: 1.05em;
        color: var(--vcb-azul);
    }

    .vcb-dir {
        display: flex;
        flex: 0 0 auto;
        align-items: flex-start;
        gap: 6px;
        font-size: calc(var(--vcb-w) * .066);
        font-weight: 700;
        line-height: 1.25;
        white-space: nowrap;
        text-shadow: 0 1px 4px rgba(4, 12, 32, .95);
    }

    .vcb-dir .vcb-ico {
        width: 1.6em;
        height: 1.6em;
        color: var(--vcb-oro);
    }

    .vcb-dir span {
        display: block;
    }

    .vcb-cta {
        display: block;
        flex: 0 0 auto;
        padding: 11px 6px;
        border-radius: 999px;
        background: var(--vcb-oro);
        box-shadow: 0 8px 22px rgba(245, 173, 15, .32);
        color: var(--vcb-marino);
        font-size: calc(var(--vcb-w) * .088);
        font-weight: 800;
        text-align: center;
        white-space: nowrap;
        transition: background .2s ease;
    }

    .vcb-anuncio--taller:hover .vcb-cta,
    .vcb-anuncio--taller:focus-visible .vcb-cta {
        background: var(--vcb-oro-claro);
    }

    /* ==================================================================
     * Anuncio 2: Vendecaranuncios
     * ================================================================== */
    .vcb-anuncio--vca {
        gap: 12px;
        background:
            /* Velo azul: tapa arriba (logo, titular y etiqueta) y abajo
             * («Publica gratis», iconos y botón); en el centro se ve el móvil. */
            linear-gradient(180deg,
                rgba(8, 26, 77, .98) 0%,
                rgba(8, 26, 77, .96) 29%,
                rgba(8, 26, 77, .15) 36%,
                rgba(8, 26, 77, .05) 50%,
                rgba(8, 26, 77, .15) 64%,
                rgba(8, 26, 77, .82) 74%,
                rgba(5, 15, 48, .95) 100%),
            /* Mano con el móvil que enseña la web de Vendecaranuncios: el
             * anuncio cuadrado (1254 × 1254) a todo el alto del banner,
             * encuadrado en el móvil (x ≈ 90–380). */
            url("../img/banner-vca/anuncio-vca.webp") 9.6% 0% / auto 100% no-repeat,
            linear-gradient(180deg, var(--vca-azul) 0%, var(--vca-marino) 55%, #050f30 100%);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), inset 0 3px 0 var(--vca-amarillo);
    }

    .vcb-anuncio--vca:hover {
        box-shadow: inset 0 0 0 1px rgba(34, 198, 255, .6), inset 0 3px 0 var(--vca-amarillo);
    }

    /* Logo: techo de coche + «Vendecaranuncios.com» */
    .vca-logo {
        display: block;
        flex: 0 0 auto;
        text-align: center;
    }

    .vca-logo__techo {
        display: block;
        width: 62%;
        height: auto;
        margin: 0 auto -2px;
    }

    .vca-logo__texto {
        display: block;
        font-size: calc(var(--vcb-w) * .083);
        font-style: italic;
        font-weight: 800;
        letter-spacing: -.04em;
        line-height: 1;
        white-space: nowrap;
        text-shadow: 0 2px 6px rgba(0, 0, 0, .4);
    }

    .vca-logo__texto b {
        color: var(--vca-cian);
        font-weight: 800;
    }

    .vca-logo__texto small {
        font-size: .82em;
    }

    .vca-titular {
        display: block;
        flex: 0 0 auto;
        font-size: calc(var(--vcb-w) * .128);
        font-style: italic;
        font-weight: 900;
        letter-spacing: -.01em;
        line-height: .98;
        text-transform: uppercase;
        text-shadow: 0 3px 8px rgba(0, 0, 0, .45);
    }

    .vca-titular span {
        display: block;
        white-space: nowrap;
    }

    .vca-titular::after {
        content: "";
        display: block;
        width: 82%;
        height: 4px;
        margin-top: 7px;
        border-radius: 4px;
        background: var(--vca-amarillo);
        transform: skewX(-20deg);
    }

    /* Etiqueta amarilla inclinada */
    .vca-tipos {
        display: block;
        flex: 0 0 auto;
        margin: 0 -4px;
        padding: 6px 8px;
        background: var(--vca-amarillo);
        color: var(--vca-marino);
        font-size: calc(var(--vcb-w) * .066);
        font-style: italic;
        font-weight: 900;
        line-height: 1.15;
        text-align: center;
        text-transform: uppercase;
        transform: rotate(-3deg) skewX(-6deg);
        box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
    }

    .vca-tipos span {
        display: block;
        white-space: nowrap;
    }


    .vca-gratis {
        display: block;
        flex: 0 0 auto;
        font-style: italic;
        font-weight: 900;
        line-height: 1;
        text-align: center;
        text-transform: uppercase;
    }

    .vca-gratis__pub {
        display: block;
        margin: 0 -2px;
        padding: 5px 4px 4px;
        background: var(--vca-amarillo);
        color: var(--vca-marino);
        font-size: calc(var(--vcb-w) * .1);
        white-space: nowrap;
        transform: skewX(-8deg);
        box-shadow: 0 6px 18px rgba(255, 210, 31, .25);
    }

    .vca-gratis__veh {
        display: block;
        margin-top: 6px;
        font-size: calc(var(--vcb-w) * .112);
        white-space: nowrap;
        text-shadow: 0 3px 8px rgba(0, 0, 0, .45);
    }

    /* Iconos: coches, motos, furgonetas y más */
    .vca-iconos {
        display: flex;
        flex: 0 0 auto;
        justify-content: space-between;
        padding: 0 2px;
    }

    .vca-iconos svg {
        display: block;
        width: 22%;
        height: auto;
        padding: 0 4%;
        color: #fff;
    }

    .vca-iconos svg + svg {
        border-left: 1px solid rgba(255, 255, 255, .35);
    }

    .vca-cta {
        display: block;
        flex: 0 0 auto;
        padding: 10px 8px;
        border-radius: 999px;
        background: linear-gradient(180deg, var(--vca-cian-claro), var(--vca-cian));
        box-shadow: 0 0 0 2px rgba(255, 255, 255, .5), 0 8px 24px rgba(34, 198, 255, .45);
        color: var(--vca-marino);
        font-size: calc(var(--vcb-w) * .078);
        font-weight: 800;
        line-height: 1.15;
        text-align: center;
        transition: filter .2s ease;
    }

    .vcb-anuncio--vca:hover .vca-cta,
    .vcb-anuncio--vca:focus-visible .vca-cta {
        filter: brightness(1.12);
    }

    /* ==================================================================
     * Banners de imagen (wp-admin › Banners › Añadir banner de imagen):
     * la foto llena el banner. El JS pone en el propio enlace --vcb-img (la
     * de la posición 1 o 2 según el lado) y --vcb-img-movil (posición 3).
     * ================================================================== */
    .vcb-anuncio--img {
        display: block;
        padding: 0 !important;
        background: var(--vcb-img, none) center / cover no-repeat, var(--vcb-marino);
    }

    /* ---- Pantallas bajas: fuera las fotos y menos aire ----------------- */
    @media (max-height: 760px) {
        .vca-iconos {
            display: none;
        }
    }

    @media (max-height: 700px) {
        .vcb-anuncio {
            justify-content: space-between;
            gap: 10px;
            padding-top: 14px;
        }

        .vcb-foto {
            display: none;
        }
    }

    @media (max-height: 520px) {
        .vcb-banner {
            display: none;
        }
    }
}

/* Más hueco: banner más ancho. 1280 + 2 × (200 + 40) = 1760; con margen, 1840. */
@media (min-width: 1840px) {
    :root {
        --vcb-w: 200px;
        --vcb-pad: 14px;
    }

    .vcb-anuncio {
        padding-top: 22px;
        padding-bottom: 16px;
    }
}

/* ==========================================================================
 * Móvil (hasta 767px): un solo banner horizontal flotante, de 100px de alto,
 * pegado abajo justo encima del menú inferior del tema
 * (--vcg-bottom-nav-space) para no taparlo. Foto a la izquierda y textos a la
 * derecha en dos columnas. Mismo contador y misma X que en escritorio.
 * Mientras se ve (html.vcb-abierto), WhatsApp y «volver arriba» suben.
 * ========================================================================== */
@media (max-width: 767px) {
    :root {
        --vcb-w: 100px; /* escala de las letras */
        --vcb-movil-h: 100px;
        --vcb-movil-foto: 26%;
    }

    .vcb-banner {
        top: auto;
        right: calc(8px + env(safe-area-inset-right));
        bottom: calc(var(--vcg-bottom-nav-space, env(safe-area-inset-bottom)) + 8px);
        left: calc(8px + env(safe-area-inset-left));
        z-index: 9980;
        width: auto;
        height: var(--vcb-movil-h);
        border-radius: 14px;
        box-shadow: 0 8px 26px rgba(7, 12, 20, .38);
    }

    body.admin-bar .vcb-banner {
        top: auto;
    }

    .vcb-banner--der {
        display: none !important;
    }

    .vcb-banner:hover {
        transform: none;
    }

    .vcb-anuncio {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-content: center;
        align-items: center;
        justify-content: stretch;
        gap: 8px 10px;
        padding: 10px 12px 10px calc(var(--vcb-movil-foto) + 10px);
    }

    /* Foto recortada en la franja izquierda. */
    .vcb-anuncio::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: var(--vcb-movil-foto);
        -webkit-mask-image: linear-gradient(90deg, #000 72%, transparent);
        mask-image: linear-gradient(90deg, #000 72%, transparent);
    }

    .vcb-foto,
    .vcb-dir,
    .vca-tipos,
    .vca-iconos {
        display: none !important;
    }

    .vcb-cta,
    .vca-cta {
        padding: 7px 6px;
        white-space: normal;
    }

    /* ---- Benalúa: logo | teléfono  /  titular | botón ---- */
    .vcb-anuncio--taller {
        grid-template-areas:
            "logo tel"
            "tit  cta";
        background: linear-gradient(90deg, var(--vcb-azul) 0%, var(--vcb-marino) 55%, #07132f 100%);
    }

    .vcb-anuncio--taller::before {
        /* Cabeza y manos del mecánico: x 280–790, y 200–1050 de 1314 × 1920. */
        background: url("../img/banner-taller/taller-motor.webp") 34.8% 18.7% / 257.6% auto no-repeat;
    }

    .vcb-anuncio--taller .vcb-logo {
        grid-area: logo;
        text-align: left;
    }

    .vcb-anuncio--taller .vcb-logo__sup {
        margin-top: 2px;
    }

    .vcb-anuncio--taller .vcb-titular {
        grid-area: tit;
    }

    .vcb-anuncio--taller .vcb-tel {
        grid-area: tel;
        padding: 6px 4px;
    }

    .vcb-anuncio--taller .vcb-cta {
        grid-area: cta;
    }

    /* ---- Vendecaranuncios: logo | «Publica gratis»  /  titular | botón ---- */
    .vcb-anuncio--vca {
        grid-template-areas:
            "logo gratis"
            "tit  cta";
        background:
            radial-gradient(60% 90% at 70% 50%, rgba(34, 198, 255, .14), transparent 75%),
            linear-gradient(90deg, var(--vca-azul) 0%, var(--vca-marino) 55%, #050f30 100%);
    }

    .vcb-anuncio--vca::before {
        /* Mano con el móvil: x 15–415, y 385–1010 de 1254 × 1254. */
        background: url("../img/banner-vca/anuncio-vca.webp") 1.7% 61% / 350% auto no-repeat;
    }

    .vca-logo {
        grid-area: logo;
    }

    .vca-logo__techo {
        width: 55%;
    }

    .vca-titular {
        grid-area: tit;
    }

    .vca-titular::after {
        height: 3px;
        margin-top: 4px;
    }

    .vca-gratis {
        grid-area: gratis;
    }

    .vca-gratis__pub {
        font-size: calc(var(--vcb-w) * .078);
    }

    .vca-gratis__veh {
        margin-top: 4px;
        font-size: calc(var(--vcb-w) * .1);
    }

    .vca-cta {
        grid-area: cta;
        font-size: calc(var(--vcb-w) * .085);
    }

    /* Banner de imagen: la horizontal de móvil, a todo el banner. */
    .vcb-anuncio--img {
        display: block;
        padding: 0;
        background: var(--vcb-img-movil, none) center / cover no-repeat, var(--vcb-marino);
    }

    .vcb-anuncio--img::before {
        display: none;
    }

    /* WhatsApp y «volver arriba», por encima del banner mientras se ve. */
    html.vcb-abierto .vcg-whatsapp-float,
    html.vcb-abierto .vcg-whatsapp-float:visited {
        bottom: calc(var(--vcg-bottom-nav-space, env(safe-area-inset-bottom)) + 8px + var(--vcb-movil-h) + 12px) !important;
    }

    html.vcb-abierto #ast-scroll-top {
        bottom: calc(var(--vcg-bottom-nav-space, env(safe-area-inset-bottom)) + 8px + var(--vcb-movil-h) + 12px + 44px + 10px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .vcb-banner,
    .vcb-anuncio,
    .vcb-anuncio.is-activa,
    .vcb-cerrar,
    .vcb-cta,
    .vca-cta {
        transition: none;
    }

    .vcb-banner:hover {
        transform: none;
    }
}

@media print {
    .vcb-banner {
        display: none !important;
    }
}
