/* ==========================================================
   Deepal PDF Viewer (catalog popup)
   Works with /Assets/Deepal/JS/PdfViewer.js
   ========================================================== */

.pdfv {
    --pdfv-ink: #141416;
    --pdfv-ink-soft: #5d5c61;
    --pdfv-line: rgba(20, 20, 22, .08);
    --pdfv-panel: rgba(246, 245, 247, .97);
    --pdfv-stage: #dedce0;
    --pdfv-pill: rgba(20, 20, 22, .06);
    --pdfv-pill-hover: rgba(20, 20, 22, .12);
    --pdfv-ease: cubic-bezier(.22, .8, .24, 1);

    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2.4vw, 32px);
    font-family: 'avatrfont-regular', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--pdfv-ink);
    -webkit-tap-highlight-color: transparent;
    visibility: hidden;
    pointer-events: none;
}

.pdfv[hidden] {
    display: none;
}

.pdfv.is-open {
    visibility: visible;
    pointer-events: auto;
}

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

/* ---------- Backdrop ---------- */
.pdfv__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 18, 22, .52);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    backdrop-filter: blur(16px) saturate(1.15);
    opacity: 0;
    transition: opacity .4s var(--pdfv-ease);
    touch-action: none;
}

.pdfv.is-open .pdfv__backdrop {
    opacity: 1;
}

/* ---------- Panel ---------- */
.pdfv__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(1080px, 100%);
    height: 100%;
    max-height: 100%;
    background: var(--pdfv-panel);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12), 0 40px 120px rgba(0, 0, 0, .38);
    opacity: 0;
    transform: translateY(26px) scale(.975);
    transition: opacity .38s var(--pdfv-ease), transform .5s var(--pdfv-ease);
    outline: none;
}

.pdfv.is-open .pdfv__panel {
    opacity: 1;
    transform: none;
}

/* ---------- Header ---------- */
.pdfv__bar {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px 14px 24px;
    background: rgba(250, 249, 251, .92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--pdfv-line);
}

.pdfv__heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pdfv__eyebrow {
    font-size: 11px;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--pdfv-ink-soft);
}

.pdfv__title {
    margin: 0;
    font-family: 'avatrfont-bold', system-ui, sans-serif;
    font-size: clamp(16px, 1.6vw, 20px);
    font-weight: normal;
    line-height: 1.25;
    color: var(--pdfv-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.pdfv__zoom {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: var(--pdfv-pill);
}

.pdfv__zoom-val {
    min-width: 46px;
    text-align: center;
    font-size: 13px;
    color: var(--pdfv-ink-soft);
    font-variant-numeric: tabular-nums;
    user-select: none;
}

.pdfv__btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--pdfv-pill);
    color: var(--pdfv-ink);
    font: inherit;
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease, opacity .2s ease;
}

.pdfv__btn:hover {
    background: var(--pdfv-pill-hover);
}

.pdfv__btn:active {
    transform: scale(.94);
}

.pdfv__btn:focus-visible {
    outline: 2px solid var(--pdfv-ink);
    outline-offset: 2px;
}

.pdfv__btn[disabled] {
    opacity: .35;
    pointer-events: none;
}

.pdfv__btn svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pdfv__zoom .pdfv__btn {
    height: 32px;
    min-width: 32px;
    background: transparent;
}

.pdfv__zoom .pdfv__btn:hover {
    background: var(--pdfv-pill-hover);
}

.pdfv__download {
    padding: 0 18px 0 14px;
    background: var(--pdfv-ink);
    color: #fff;
}

.pdfv__download:hover {
    background: #2c2c30;
}

.pdfv__download:focus-visible {
    outline-color: #8f8f96;
}

/* ---------- Progress hairline ---------- */
.pdfv__progress {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    z-index: 3;
    overflow: hidden;
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}

.pdfv.is-loading .pdfv__progress {
    opacity: 1;
}

.pdfv__progress i {
    display: block;
    height: 100%;
    width: 100%;
    background: var(--pdfv-ink);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .25s ease;
}

.pdfv__progress.is-indeterminate i {
    width: 40%;
    transform: none;
    animation: pdfv-slide 1.15s ease-in-out infinite;
}

@keyframes pdfv-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

/* ---------- Scroll stage ---------- */
.pdfv__scroller {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--pdfv-stage);
    outline: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(20, 20, 22, .28) transparent;
}

.pdfv__scroller::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.pdfv__scroller::-webkit-scrollbar-thumb {
    background: rgba(20, 20, 22, .26);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.pdfv__sheet {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: max-content;
    min-width: 100%;
    padding: 28px 32px 96px;
}

.pdfv__page {
    position: relative;
    flex: 0 0 auto;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 14px 38px rgba(30, 30, 40, .16);
    overflow: hidden;
}

.pdfv__page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(0, 0, 0, .045) 50%, transparent 80%);
    background-size: 220% 100%;
    animation: pdfv-shimmer 1.6s linear infinite;
}

.pdfv__page.is-rendered::before {
    display: none;
}

.pdfv__page canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
    transition: opacity .35s ease;
}

.pdfv__page.is-rendered canvas {
    opacity: 1;
}

@keyframes pdfv-shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -120% 0; }
}

/* ---------- Floating page pill ---------- */
.pdfv__counter {
    position: absolute;
    left: 50%;
    bottom: 22px;
    z-index: 2;
    transform: translate(-50%, 8px);
    padding: 9px 18px;
    border-radius: 999px;
    background: rgba(20, 20, 22, .78);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 13px;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
}

.pdfv.is-ready .pdfv__counter {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- Loading / error state ---------- */
.pdfv__state {
    position: absolute;
    left: 0;
    right: 0;
    top: 62px;
    bottom: 0;
    z-index: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    pointer-events: none;
}

.pdfv.is-loading .pdfv__state,
.pdfv.is-error .pdfv__state {
    display: flex;
}

.pdfv.is-error .pdfv__state {
    background: var(--pdfv-stage);
    pointer-events: auto;
}

.pdfv__spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(20, 20, 22, .14);
    border-top-color: var(--pdfv-ink);
    animation: pdfv-spin .8s linear infinite;
}

.pdfv.is-error .pdfv__spinner,
.pdfv.is-error .pdfv__zoom,
.pdfv.is-error .pdfv__bar .pdfv__download {
    display: none;
}

.pdfv__msg {
    margin: 0;
    max-width: 34ch;
    font-size: 15px;
    line-height: 1.6;
    color: var(--pdfv-ink-soft);
}

.pdfv__state-actions {
    display: none;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.pdfv.is-error .pdfv__state-actions {
    display: flex;
}

.pdfv__state-actions .pdfv__btn {
    padding: 0 20px;
}

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

/* ---------- Tablet ---------- */
@media (max-width: 900px) {
    .pdfv__sheet {
        padding: 22px 20px 92px;
    }
}

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

    .pdfv__panel {
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform .5s var(--pdfv-ease), opacity .3s ease;
    }

    .pdfv.is-open .pdfv__panel {
        transform: none;
    }

    .pdfv__bar {
        padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 10px 16px;
        gap: 8px;
    }

    .pdfv__eyebrow {
        display: none;
    }

    .pdfv__title {
        font-size: 16px;
    }

    .pdfv__zoom-val,
    .pdfv__zoom-out,
    .pdfv__zoom-in {
        display: none;
    }

    .pdfv__zoom {
        padding: 0;
        background: transparent;
    }

    .pdfv__download {
        width: 38px;
        padding: 0;
    }

    .pdfv__download span {
        display: none;
    }

    .pdfv__sheet {
        gap: 12px;
        padding: 14px 10px calc(84px + env(safe-area-inset-bottom, 0px));
    }

    .pdfv__page {
        border-radius: 3px;
    }

    .pdfv__counter {
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .pdfv__state {
        top: calc(58px + env(safe-area-inset-top, 0px));
    }
}

/* Phone landscape: keep the header compact */
@media (max-height: 480px) and (orientation: landscape) {
    .pdfv {
        padding: 0;
    }

    .pdfv__panel {
        border-radius: 0;
    }

    .pdfv__bar {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .pdfv__eyebrow {
        display: none;
    }

    .pdfv__btn {
        height: 34px;
        min-width: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pdfv__backdrop,
    .pdfv__panel,
    .pdfv__page canvas,
    .pdfv__counter {
        transition-duration: .01ms !important;
    }

    .pdfv__page::before,
    .pdfv__spinner,
    .pdfv__progress.is-indeterminate i {
        animation-duration: 3s;
    }
}
