/* ============================================================
   UNIFIED PUBLICATION VIEWER
   ============================================================ */

.hpub-viewer {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vw, 40px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .35s ease, visibility .35s ease;
}

.hpub-viewer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.hpub-viewer__backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, .1), transparent 55%),
        rgba(20, 3, 8, .94);
    backdrop-filter: blur(10px) saturate(1.2);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    cursor: zoom-out;
}

.hpub-viewer__inner {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto 1fr auto;
    width: 100%;
    max-width: 1400px;
    max-height: calc(100vh - 2 * clamp(12px, 3vw, 40px));
    background: linear-gradient(160deg,
        rgba(42, 5, 11, .95) 0%,
        rgba(58, 6, 13, .95) 50%,
        rgba(42, 5, 11, .98) 100%);
    border: 1px solid rgba(212, 175, 55, .38);
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(212, 175, 55, .08),
        0 30px 80px -20px rgba(0, 0, 0, .9),
        0 0 80px rgba(212, 175, 55, .18);
    transform: scale(.96);
    opacity: 0;
    transition: transform .35s cubic-bezier(.22, 1, .36, 1), opacity .35s ease;
}

.hpub-viewer.is-open .hpub-viewer__inner {
    transform: scale(1);
    opacity: 1;
}

.hpub-viewer__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(212, 175, 55, .22);
    background: linear-gradient(180deg, rgba(42, 5, 11, .6), transparent);
}

.hpub-viewer__title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 15px;
    font-weight: 600;
    color: #FFFDF5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    padding-right: 12px;
}

.hpub-viewer__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hpub-viewer__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(212, 175, 55, .08);
    border: 1px solid rgba(212, 175, 55, .38);
    color: #EBD07A;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition:
        background .3s ease, color .3s ease,
        border-color .3s ease, transform .3s ease;
}

.hpub-viewer__btn:hover,
.hpub-viewer__btn:focus-visible {
    background: linear-gradient(135deg, #E0C158, #B8860B);
    color: #2A050B;
    border-color: #D4AF37;
    transform: translateY(-1px);
    outline: none;
}

.hpub-viewer__stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    overflow: hidden;
    padding: 12px;
}

.hpub-viewer__img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 240px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow:
        0 0 0 1px rgba(212, 175, 55, .25),
        0 20px 60px -20px rgba(0, 0, 0, .9);
}

.hpub-viewer__pdf {
    width: 100%;
    height: calc(100vh - 240px);
    min-height: 400px;
    border: none;
    border-radius: 10px;
    background: #FFFDF5;
    box-shadow:
        0 0 0 1px rgba(212, 175, 55, .25),
        0 20px 60px -20px rgba(0, 0, 0, .9);
}

.hpub-viewer__spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(212, 175, 55, .25);
    border-top-color: #D4AF37;
    animation: hpubSpin .9s linear infinite;
}
@keyframes hpubSpin { to { transform: rotate(360deg); } }

.hpub-viewer__stage.is-loaded .hpub-viewer__spinner { display: none; }

.hpub-viewer__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
    border-top: 1px solid rgba(212, 175, 55, .22);
    background: linear-gradient(0deg, rgba(42, 5, 11, .6), transparent);
}

.hpub-viewer__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(212, 175, 55, .1);
    border: 1px solid rgba(212, 175, 55, .4);
    color: #EBD07A;
    font-size: 13px;
    cursor: pointer;
    transition:
        background .3s ease, color .3s ease,
        border-color .3s ease, transform .3s ease;
}

.hpub-viewer__nav:hover,
.hpub-viewer__nav:focus-visible {
    background: linear-gradient(135deg, #E0C158, #B8860B);
    color: #2A050B;
    border-color: #D4AF37;
    transform: scale(1.06);
    outline: none;
}

.hpub-viewer__nav:disabled {
    opacity: .3;
    pointer-events: none;
}

.hpub-viewer__counter {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    color: rgba(235, 208, 122, .85);
    font-family: 'Fraunces', Georgia, serif;
}

body.hpub-viewer-open { overflow: hidden; }

/* Trigger affordance */
[data-hpub-open] { cursor: zoom-in; }
.jr-journal-media[data-hpub-open],
.jr-brochure-media[data-hpub-open],
.pb-news-media[data-hpub-open],
.home-gallery-card[data-hpub-open] { cursor: pointer; }
[data-hpub-open]:focus-visible {
    outline: 2px solid #D4AF37;
    outline-offset: 3px;
}

@media (max-width: 720px) {
    .hpub-viewer { padding: 0; }
    .hpub-viewer__inner {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    .hpub-viewer__img { max-height: calc(100vh - 200px); }
    .hpub-viewer__pdf {
        height: calc(100vh - 200px);
        min-height: 0;
        border-radius: 6px;
    }
    .hpub-viewer__title { font-size: 14px; }
    .hpub-viewer__stage { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .hpub-viewer,
    .hpub-viewer__inner,
    .hpub-viewer__img,
    .hpub-viewer__pdf,
    .hpub-viewer__btn,
    .hpub-viewer__nav {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
    .hpub-viewer__spinner { animation-duration: .01ms !important; }
}