/* ==========================================================
   PDF viewer modal  (used by links with  data-pdf-modal)
   Soft glass look, responsive: centred card on desktop,
   full-height bottom sheet on phones.
   ========================================================== */
.pdfm {
    --pdfm-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --pdfm-ink: #14161a;
    --pdfm-muted: #6b6f76;
    --pdfm-line: rgba(20, 22, 26, 0.09);
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 3vh, 36px) clamp(10px, 3vw, 48px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
    font-family: avatrfont-regular, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.pdfm[hidden] { display: none; }

.pdfm.is-open {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.pdfm__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 14, 18, 0.55);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    backdrop-filter: blur(10px) saturate(120%);
}

/* ---------- card ---------- */
.pdfm__card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(1080px, 100%);
    height: min(92vh, 100%);
    height: min(92dvh, 100%);
    background: #f3f3f1;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    transform: translateY(26px) scale(0.975);
    opacity: 0;
    transition: transform 0.5s var(--pdfm-ease), opacity 0.4s ease;
}

.pdfm.is-open .pdfm__card {
    transform: none;
    opacity: 1;
}

/* ---------- top bar ---------- */
.pdfm__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px 12px 20px;
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--pdfm-line);
    flex: 0 0 auto;
}

.pdfm__title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pdfm__icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: #14161a;
    color: #fff;
}

.pdfm__icon svg { width: 18px; height: 18px; }

.pdfm__heading { min-width: 0; }

.pdfm__heading h2 {
    margin: 0;
    font-size: 16px;
    line-height: 1.25;
    font-weight: 400;
    color: var(--pdfm-ink);
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdfm__count {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--pdfm-muted);
    letter-spacing: 0.04em;
}

.pdfm__tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.pdfm__zoom {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: rgba(20, 22, 26, 0.06);
}

.pdfm__zoom span {
    min-width: 46px;
    text-align: center;
    font-size: 12.5px;
    color: var(--pdfm-ink);
    font-variant-numeric: tabular-nums;
}

.pdfm__icon-btn,
.pdfm__btn {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.pdfm__icon-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: transparent;
    color: var(--pdfm-ink);
}

.pdfm__icon-btn svg { width: 18px; height: 18px; }
.pdfm__icon-btn:hover { background: rgba(20, 22, 26, 0.08); }
.pdfm__icon-btn:active { transform: scale(0.94); }
.pdfm__icon-btn[disabled] { opacity: 0.35; cursor: default; pointer-events: none; }

.pdfm__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 14px;
    white-space: nowrap;
}

.pdfm__btn svg { width: 17px; height: 17px; }

.pdfm__btn--primary {
    background: #14161a;
    color: #fff;
}

.pdfm__btn--primary:hover {
    background: #2b2f36;
    box-shadow: 0 8px 20px rgba(20, 22, 26, 0.25);
    transform: translateY(-1px);
}

.pdfm__close {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(20, 22, 26, 0.06);
}

/* ---------- reading area ---------- */
.pdfm__body {
    position: relative;
    flex: 1 1 auto;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 22px clamp(10px, 3vw, 34px) 34px;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(255, 255, 255, 0.9), transparent 70%),
        #e8e8e5;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(20, 22, 26, 0.25) transparent;
}

.pdfm__body::-webkit-scrollbar { width: 10px; height: 10px; }
.pdfm__body::-webkit-scrollbar-thumb {
    background: rgba(20, 22, 26, 0.22);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

.pdfm__pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    min-width: min-content;
}

.pdfm__page {
    position: relative;
    flex: 0 0 auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 14px 34px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.pdfm__page canvas {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.45s ease;
}

.pdfm__page.is-ready canvas { opacity: 1; }

/* shimmer while a page is rendering */
.pdfm__page::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(0, 0, 0, 0.045) 50%, transparent 80%);
    background-size: 200% 100%;
    animation: pdfm-shimmer 1.4s linear infinite;
    transition: opacity 0.3s ease;
}

.pdfm__page.is-ready::before { opacity: 0; animation: none; }

@keyframes pdfm-shimmer {
    from { background-position: 120% 0; }
    to { background-position: -120% 0; }
}

/* ---------- loading / error ---------- */
.pdfm__state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
    color: var(--pdfm-muted);
    font-size: 14px;
    background: inherit;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.pdfm__state[hidden] { display: flex; opacity: 0; visibility: hidden; }

.pdfm__spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(20, 22, 26, 0.12);
    border-top-color: #14161a;
    animation: pdfm-spin 0.8s linear infinite;
}

.pdfm__state.is-error .pdfm__spinner { display: none; }

.pdfm__progress {
    width: min(220px, 60%);
    height: 3px;
    border-radius: 3px;
    background: rgba(20, 22, 26, 0.1);
    overflow: hidden;
}

.pdfm__progress i {
    display: block;
    height: 100%;
    width: 0;
    background: #14161a;
    transition: width 0.25s ease;
}

.pdfm__state.is-error .pdfm__progress { display: none; }

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

/* ---------- page-lock while open ---------- */
html.pdfm-lock,
html.pdfm-lock body { overflow: hidden !important; }

/* ---------- tablets ---------- */
@media (max-width: 900px) {
    .pdfm__bar { padding-left: 16px; }
    .pdfm__zoom span { min-width: 40px; }
}

/* ---------- phones: bottom sheet ---------- */
@media (max-width: 640px) {
    .pdfm {
        padding: 0;
        align-items: flex-end;
    }

    .pdfm__card {
        width: 100%;
        height: 94vh;
        height: 94dvh;
        border-radius: 22px 22px 0 0;
        transform: translateY(100%);
        opacity: 1;
        transition: transform 0.55s var(--pdfm-ease);
    }

    .pdfm.is-open .pdfm__card { transform: none; }

    .pdfm__card::before {          /* drag-handle look */
        content: "";
        position: absolute;
        top: 7px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: 4px;
        background: rgba(20, 22, 26, 0.18);
        z-index: 2;
    }

    .pdfm__bar { padding: 20px 10px 10px 14px; gap: 8px; }
    .pdfm__icon { display: none; }
    .pdfm__heading h2 { font-size: 15px; }
    .pdfm__zoom span { display: none; }
    .pdfm__btn { padding: 0 12px; height: 36px; font-size: 13px; }
    .pdfm__body { padding: 14px 8px 28px; }
    .pdfm__pages { gap: 12px; }
}

@media (max-width: 400px) {
    .pdfm__btn span { display: none; }       /* download becomes icon-only */
    .pdfm__btn { padding: 0 11px; }
}

@media (prefers-reduced-motion: reduce) {
    .pdfm, .pdfm__card, .pdfm__page canvas { transition-duration: 0.01s !important; }
    .pdfm__page::before, .pdfm__spinner { animation: none; }
    .pdfm__body { scroll-behavior: auto; }
}
