/* ── PDF READER ────────────────────────────────────── */
#loader {
    text-align: center;
    padding: 40px 0;
    font-size: 14px;
    color: var(--muted, #888);
}

#loader.hidden { display: none; }

#pagination,
#canvas-wrapper {
    visibility: hidden;
}

/* ── BARRA DI NAVIGAZIONE ── */
#pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    row-gap: 10px;
    flex-wrap: wrap;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border, #e2e2e2);
    background: var(--color-white, #fff);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-group,
.zoom-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

/* CONTATORE MOBILE: nascosto su desktop */
#mobile-page-count {
    display: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #555);
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.page-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--muted, #555);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.page-btn:hover:not(:disabled) { background: var(--border, #eee); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.pagination-separator {
    width: 1px;
    height: 20px;
    background: var(--border, #ddd);
    margin: 0 4px;
}

#page-counter {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #555);
}

#page-input {
    width: 38px;
    text-align: center;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    font-size: 13px;
    padding: 3px 2px;
    font-family: inherit;
}

#page-input::-webkit-outer-spin-button,
#page-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

#zoom-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #555);
    padding: 4px 8px;
    min-width: 40px;
    text-align: center;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease;
}

#zoom-label:hover { background: var(--border, #eee); }

/* ── VISTA DESKTOP: libro ── */
#canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 18px;
    padding: 24px 16px 48px;
    overflow-x: auto;
    background: var(--color-cream);
}

.page-card {
    background: var(--color-white, #fff);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    overflow: hidden;
    flex: 0 0 auto;
}

.page-card canvas { display: block; max-width: 100%; height: auto; }

/* ── VISTA MOBILE: cascata nel flusso ── */
#cascade-main {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0 32px;
    visibility: hidden;
}

.cascade-card {
    width: 100%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.cascade-card canvas { display: block; width: 100%; height: auto; }

/*---TOOLTIP FULLSCREEN -----------*/
.fullscreen-wrap {
    position: relative;
    display: inline-flex;
}

.fullscreen-hint {
    display: none;
    position: absolute;
    top: 50%;
    max-width: 100px;
    left: calc(100% + 10px);
    transform: translateY(-50%);
    white-space: nowrap;
    background-color: var(--color-secondary);
    color: var(--color-white);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    pointer-events: none;
    opacity: 0;
}

/* freccetta che punta al bottone */
.fullscreen-hint::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--color-secondary);
}

@keyframes hintFade {
    0%   { opacity: 0; transform: translateY(-70%); }
    15%  { opacity: 1; transform: translateY(-50%); }
    70%  { opacity: 1; transform: translateY(-50%); }
    100% { opacity: 0; transform: translateY(-30%); }
}

@keyframes opacityFade {
    0%, 7.5% { opacity: 0; }
    21.25%   { opacity: 1; }
    73.75%   { opacity: 1; }
    100%     { opacity: 0; }
}

.fullscreen-hint {
    display: flex;
    animation: hintFade 2s ease-in-out forwards, opacityFade 2s ease-in-out forwards;
}

/* ── FULLSCREEN DESKTOP: pagina singola ── */
.fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--color-white, #fff);
    z-index: 1000;
    flex-direction: column;
}

.fullscreen-overlay.open { display: flex; }

.fullscreen-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #e2e2e2);
    flex-shrink: 0;
}

#fs-page-counter {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #555);
}

.fullscreen-canvas-wrapper {
    flex: 1 1 auto;
    overflow: auto;
    display: flex;
    justify-content: center;
    background: #f8f8f8;
    position: relative;
}

.fullscreen-canvas-wrapper canvas { display: block; max-width: 100%; }

.fs-tap-zone {
    position: absolute;
    top: 0; bottom: 0;
    width: 25%;
    z-index: 10;
    cursor: pointer;
}

#fs-tap-left  { left: 0; }
#fs-tap-right { right: 0; }

.fullscreen-navbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 12px;
    border-top: 1px solid var(--border, #e2e2e2);
    flex-shrink: 0;
}

.fullscreen-navbar .page-btn { width: 44px; height: 44px; }

.fullscreen-icon {
    width: 50px;
    height: 50px;
    display: flex;
}

/* ── FULLSCREEN MOBILE: cascata ── */
.cascade-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #f0f0f0;
    z-index: 1000;
    flex-direction: column;
}

.cascade-overlay.open { display: flex; }

.cascade-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #e2e2e2);
    background: var(--color-white, #fff);
    flex-shrink: 0;
}

#cascade-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted, #555);
}

.cascade-pages {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0 32px;
}

.cascade-pages .cascade-card { width: 100%; }

/* ── RESPONSIVE ── */
/* sotto i 768px */
@media (max-width: 768px) {
    /* desktop nascondo */
    #canvas-wrapper    { display: none !important; }
    #group-nav         { display: none; }
    #group-zoom        { display: none; }
    #sep-zoom          { display: none; }

    /* mobile mostra */
    #cascade-main      { display: flex; }
    #mobile-page-count { display: block; }

    #pagination { gap: 4px; padding: 8px 10px; }

    .fullscreen-icon { width: 30px; height: 30px; }
}