/*
 * Pau Lightbox — Frontend CSS v1.0.1
 * Custom properties inyectadas desde PHP.
 * Sin dependencias externas.
 */

/* ── Variables por defecto (sobreescritas por PHP) ──────────── */
:root {
    --pau-lb-speed:        .28s;
    --pau-lb-overlay:      rgba(0,0,0,.82);
    --pau-lb-frame:        none;
    --pau-lb-frame-shadow: 0 0 0 4px rgba(255,255,255,.08), 0 24px 80px rgba(0,0,0,.9), 0 8px 32px rgba(0,0,0,.6);
    --pau-lb-blur:         none;
}

/* ── Overlay ─────────────────────────────────────────────────── */
#pau-lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--pau-lb-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--pau-lb-speed) ease, visibility var(--pau-lb-speed) ease;
    -webkit-backdrop-filter: var(--pau-lb-blur);
    backdrop-filter: var(--pau-lb-blur);
    /* Evitar scroll del body */
    overscroll-behavior: contain;
}

#pau-lb-overlay.pau-lb-open {
    opacity: 1;
    visibility: visible;
}

/* ── Wrap centrado ───────────────────────────────────────────── */
#pau-lb-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 60px 80px;
    box-sizing: border-box;
}

/* ── Marco de imagen ─────────────────────────────────────────── */
#pau-lb-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: var(--pau-lb-frame);
    box-shadow: var(--pau-lb-frame-shadow);
    border-radius: 4px;
    transition: transform var(--pau-lb-speed) cubic-bezier(.4,0,.2,1),
                opacity  var(--pau-lb-speed) ease;
}

#pau-lb-frame.pau-lb-loading {
    opacity: 0;
    transform: scale(.97);
}

/* ── Imagen ──────────────────────────────────────────────────── */
#pau-lb-img {
    display: block;
    max-width: 90vw;
    max-height: 82vh;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    border-radius: 4px;
}

/* ── Caption ─────────────────────────────────────────────────── */
#pau-lb-caption {
    width: 100%;
    padding: 10px 16px;
    background: rgba(0,0,0,.55);
    color: rgba(255,255,255,.88);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    min-height: 0;
    box-sizing: border-box;
}

#pau-lb-caption:empty {
    display: none;
}

/* ── Botón cerrar ────────────────────────────────────────────── */
#pau-lb-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #cc2222;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s, transform .15s;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,.6);
}
#pau-lb-close svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: #ffffff !important;
    stroke-width: 3;
    flex-shrink: 0;
}
#pau-lb-close:hover { background: #aa1111; transform: scale(1.1); }
#pau-lb-close:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ── Flechas ─────────────────────────────────────────────────── */
#pau-lb-prev,
#pau-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.15);
    border: 1px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    transition: background var(--pau-lb-speed), transform .15s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#pau-lb-prev { left: 18px; }
#pau-lb-next { right: 18px; }
#pau-lb-prev svg,
#pau-lb-next svg { width: 22px; height: 22px; }
#pau-lb-prev:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }
#pau-lb-next:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }
#pau-lb-prev:focus-visible,
#pau-lb-next:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

#pau-lb-prev.pau-lb-hidden,
#pau-lb-next.pau-lb-hidden { display: none; }

/* ── Toolbar (contador + play) ───────────────────────────────── */
#pau-lb-toolbar {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(0,0,0,.45);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 30px;
    padding: 8px 18px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#pau-lb-counter {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,.8);
    letter-spacing: .04em;
    min-width: 48px;
    text-align: center;
}

#pau-lb-play {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.8);
    transition: color .15s, transform .15s;
    border-radius: 50%;
    padding: 0;
}
#pau-lb-play svg { width: 16px; height: 16px; }
#pau-lb-play:hover { color: #fff; transform: scale(1.15); }
#pau-lb-play:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
#pau-lb-play[aria-pressed="true"] { color: #6b9eff; }

#pau-lb-toolbar.pau-lb-hidden { display: none; }

/* ── Loader spinner mientras carga imagen ────────────────────── */
#pau-lb-wrap::after {
    content: '';
    position: absolute;
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: rgba(255,255,255,.7);
    border-radius: 50%;
    animation: pau-lb-spin .7s linear infinite;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
#pau-lb-wrap.pau-lb-loading::after { opacity: 1; }

@keyframes pau-lb-spin {
    to { transform: rotate(360deg); }
}

/* ── Cursor en imágenes con lightbox ─────────────────────────── */
a[data-pau-lightbox],
img[data-pau-lb-src] {
    cursor: zoom-in;
}

/* ── Scroll lock en body ─────────────────────────────────────── */
body.pau-lb-open {
    overflow: hidden;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    #pau-lb-wrap {
        padding: 56px 16px 72px;
    }

    #pau-lb-img {
        max-width: 96vw;
        max-height: 72vh;
    }

    #pau-lb-prev { left: 6px; width: 42px; height: 42px; }
    #pau-lb-next { right: 6px; width: 42px; height: 42px; }
    #pau-lb-prev svg,
    #pau-lb-next svg { width: 18px; height: 18px; }

    #pau-lb-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}

/* ── Reducir movimiento ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #pau-lb-overlay,
    #pau-lb-frame,
    #pau-lb-close,
    #pau-lb-prev,
    #pau-lb-next,
    #pau-lb-play {
        transition: none;
        animation: none;
    }
}
