/* ========================================================
   Modal de leitura de PDF (inc/pdf-modal.php + assets/pdf-modal.js)
   ======================================================== */

/* ---- Enquanto o JS não está pronto: link de PDF desabilitado com tooltip ---- */
html:not(.pdf-ready) a[href*="/wp-content/uploads/"][href$=".pdf" i] {
    position: relative;
    opacity: 0.55;
    cursor: wait;
}

html:not(.pdf-ready) a[href*="/wp-content/uploads/"][href$=".pdf" i]:hover::after {
    content: "Carregando...";
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    height: auto;
    padding: 4px 10px;
    border-radius: 3px;
    background: #000;
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
}

html:lang(en):not(.pdf-ready) a[href*="/wp-content/uploads/"][href$=".pdf" i]:hover::after {
    content: "Loading...";
}

html:lang(es):not(.pdf-ready) a[href*="/wp-content/uploads/"][href$=".pdf" i]:hover::after {
    content: "Cargando...";
}

/* ---- Gatilho (o link perde o href, então precisa do cursor de link) ---- */
.pdf-modal-trigger {
    cursor: pointer;
}

/* ---- Modal ---- */
.pdf-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: rgba(0, 0, 0, 0.85);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pdf-modal.is-active {
    display: flex;
}

.pdf-modal.is-visible {
    opacity: 1;
}

.pdf-modal__dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1120px;
    height: 100%;
    max-height: 92vh;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.pdf-modal__header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
}

.pdf-modal__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-modal__download {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border: 0;
    border-radius: 0;
    background-color: #000;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.15em;
    line-height: 1.2;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pdf-modal__download:hover,
.pdf-modal__download:focus-visible {
    background-color: #333;
}

.pdf-modal__download.is-loading {
    background-color: #333;
    cursor: progress;
    pointer-events: none;
}

.pdf-modal__download.is-loading::before {
    content: "";
    flex: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pdf-modal-spin 0.8s linear infinite;
}

@keyframes pdf-modal-spin {
    to {
        transform: rotate(360deg);
    }
}

.pdf-modal__close {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #000;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

.pdf-modal__body {
    flex: 1;
    min-height: 0;
    background-color: #525659;
}

.pdf-modal__frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

@media (max-width: 600px) {
    .pdf-modal {
        padding: 0;
    }

    .pdf-modal__dialog {
        max-height: 100%;
        border-radius: 0;
    }

    .pdf-modal__download {
        padding: 8px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pdf-modal {
        transition: none;
    }

    .pdf-modal__download.is-loading::before {
        animation-duration: 2s;
    }
}
