/* Villa Compta - in-app document viewer (PDF via pdf.js, images natively)
   Overlay injected by js/pdf-viewer.js. Tokens from shell.css; the reading stage is a warm dark
   "light table" so the white page floats, the page counter wears the app's gold accent. */

.pdfv-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    flex-direction: column;
    background: #1F1D1A;
    color: var(--text);
}
.pdfv-overlay.open { display: flex; animation: pdfv-fade .12s ease-out; }
@keyframes pdfv-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pdfv-overlay.open { animation: none; } }

/* Bars */
.pdfv-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .25rem;
    min-height: 52px;
    padding: 0 .4rem;
    background: var(--surface);
}
.pdfv-bar--top { border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.pdfv-bar--bottom { border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }

.pdfv-title {
    flex: 1;
    min-width: 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 .25rem;
}

.pdfv-btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
}
.pdfv-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pdfv-btn:active { background: var(--surface-alt); }
.pdfv-btn:disabled { color: var(--border); cursor: default; }
.pdfv-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pdfv-btn--close { color: var(--text); }

/* Reading stage */
.pdfv-stage {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    touch-action: pan-x pan-y;
}
.pdfv-canvas {
    display: block;
    margin: 0 auto;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, .55);
    flex-shrink: 0;
    transform-origin: 0 0;
}
.pdfv-canvas[hidden] { display: none; }
.pdfv-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    margin: auto;
    border-radius: 4px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, .55);
}
.pdfv-loading {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--accent);
    font-size: .9rem;
    font-weight: 500;
    pointer-events: none;
}
.pdfv-loading[hidden] { display: none; }
.pdfv-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(184, 148, 95, .3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: pdfv-spin .8s linear infinite;
}
@keyframes pdfv-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pdfv-spinner { animation-duration: 2s; } }
.pdfv-error {
    margin: auto;
    padding: 1rem 1.25rem;
    max-width: 320px;
    text-align: center;
    color: #F0EDE8;
    font-size: .9rem;
    line-height: 1.45;
}
.pdfv-error[hidden] { display: none; }
.pdfv-error a { color: var(--accent); font-weight: 600; }

/* Bottom bar: pages left, counter centre, zoom right */
.pdfv-group { display: flex; align-items: center; gap: .1rem; }
.pdfv-counter {
    flex: 1;
    display: flex;
    justify-content: center;
}
.pdfv-pill {
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--accent-light);
    color: #7A5F2F;
    font-size: .82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.pdfv-pill[hidden] { display: none; }
