/* MasterBinder 0.0.9 — Binder viewport, grayscale, context menu e zoom navigation */

/* =========================================================
   DESKTOP: il binder deve stare interamente nello schermo
   ========================================================= */
@media (min-width: 901px) {
    body.binder-detail-view {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    body.binder-detail-view .page-shell {
        height: calc(100dvh - 137px);
        min-height: 0;
        padding: 8px 14px 7px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.binder-detail-view .flash {
        flex: 0 0 auto;
        margin-bottom: 6px;
    }

    body.binder-detail-view .binder-detail-shell {
        flex: 1 1 auto;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    body.binder-detail-view .binder-detail-toolbar {
        flex: 0 0 46px;
        min-height: 46px;
        padding: 5px 8px;
        align-items: center;
    }

    body.binder-detail-view .binder-title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.binder-detail-view .binder-spread-wrap {
        flex: 1 1 auto;
        min-height: 0;
        padding: 6px 4px 4px;
        align-items: stretch;
        justify-content: center;
        overflow: hidden;
    }

    body.binder-detail-view .binder-spread {
        width: min(100%, 1320px);
        height: 100%;
        min-width: 0;
        min-height: 0;
        max-height: 100%;
        grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
    }

    body.binder-detail-view .binder-page {
        min-width: 0;
        min-height: 0;
        padding: 8px;
        overflow: hidden;
    }

    body.binder-detail-view .binder-page-grid {
        min-width: 0;
        min-height: 0;
        gap: 7px;
    }

    body.binder-detail-view .binder-slot {
        min-width: 0;
        min-height: 0;
        border-radius: 6px;
    }

    body.binder-detail-view .binder-card-image-shell {
        min-width: 0;
        min-height: 0;
        padding: 3px !important;
    }

    body.binder-detail-view .binder-slot-caption {
        min-height: 31px;
        max-height: 31px;
        padding: 2px 5px;
        grid-template-columns: auto 1fr;
        gap: 0 4px;
        font-size: 9px;
        line-height: 1.05;
    }

    body.binder-detail-view .binder-slot-caption small {
        font-size: 8px;
    }

    body.binder-detail-view .binder-navigation {
        flex: 0 0 52px;
        min-height: 52px;
        padding: 5px 10px;
    }

    body.binder-detail-view .binder-nav-arrow {
        min-height: 34px;
        height: 34px;
    }

    body.binder-detail-view .binder-jump-form input {
        min-height: 31px;
    }

    body.binder-detail-view .binder-frontispiece h1 {
        margin: 8px 0 12px;
        font-size: clamp(24px, 2.4vw, 40px);
    }

    body.binder-detail-view .frontispiece-progress {
        margin-top: 18px;
    }
}

/* =========================================================
   CARTE MANCANTI: vero bianco e nero
   ========================================================= */
.binder-slot.missing {
    opacity: 1 !important;
    filter: none !important;
}

.binder-slot.missing .binder-card-image-shell img {
    filter: grayscale(1) brightness(.72) contrast(.96) !important;
}

.binder-slot.missing .binder-card-image-shell {
    background: #11151c !important;
}

.binder-slot.missing .binder-slot-caption {
    color: #a6adb8;
    background: #171a21;
}

.binder-slot.missing .binder-slot-caption strong,
.binder-slot.missing .binder-slot-caption span,
.binder-slot.missing .binder-slot-caption small {
    color: #9aa1aa !important;
}

.binder-missing-number {
    position: absolute;
    right: 6px;
    bottom: 35px;
    z-index: 3;
    padding: 2px 5px;
    color: #f2f2f2;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 4px;
    background: rgba(0,0,0,.72);
    font-size: 9px;
    font-weight: 800;
    pointer-events: none;
}

.binder-owned-mark[hidden],
.binder-missing-number[hidden] {
    display: none !important;
}

/* =========================================================
   TOOLBAR
   ========================================================= */
.binder-rightclick-help {
    color: #8090aa;
    font-size: 10px;
    font-weight: 650;
    white-space: nowrap;
}

/* =========================================================
   MENU TASTO DESTRO
   ========================================================= */
.binder-context-menu[hidden] {
    display: none !important;
}

.binder-context-menu {
    position: fixed;
    z-index: 12000;
    min-width: 238px;
    padding: 5px;
    border: 1px solid #4a5c7d;
    border-radius: 7px;
    background: #151e30;
    box-shadow: 0 14px 38px rgba(0,0,0,.58);
}

.binder-context-menu button {
    width: 100%;
    min-height: 38px;
    padding: 7px 10px;
    color: #edf3ff;
    text-align: left;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    border: 0;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.binder-context-menu button:hover {
    background: #263551;
}

.binder-context-menu button:disabled {
    opacity: .55;
    cursor: wait;
}

.binder-action-toast[hidden] {
    display: none !important;
}

.binder-action-toast {
    position: fixed;
    z-index: 12500;
    right: 18px;
    bottom: 18px;
    max-width: 360px;
    padding: 10px 13px;
    color: #dff8e8;
    border: 1px solid #3f7b59;
    border-radius: 7px;
    background: #173424;
    box-shadow: 0 12px 30px rgba(0,0,0,.46);
    font-size: 12px;
    font-weight: 700;
}

.binder-action-toast.error {
    color: #ffe3e3;
    border-color: #8a4b50;
    background: #3d1d22;
}

/* =========================================================
   ZOOM: grayscale coerente + precedente/successiva
   ========================================================= */
.card-zoom-dialog {
    width: min(92vw, 760px) !important;
    height: min(94vh, 980px) !important;
    padding: 46px 64px 52px !important;
}

.card-zoom-image-stage {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    display: grid;
    place-items: center;
}

.card-zoom-image-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.card-zoom-dialog.zoom-missing .card-zoom-image-stage img {
    filter: grayscale(1) brightness(.72) contrast(.96) drop-shadow(0 18px 28px rgba(0,0,0,.45)) !important;
}

.card-zoom-fallback[hidden] {
    display: none !important;
}

.card-zoom-fallback {
    width: min(340px, 100%);
    aspect-ratio: 63 / 88;
    display: grid;
    place-items: center;
    color: #8c99ae;
    border: 1px dashed #4a5870;
    border-radius: 10px;
    background: #111827;
    text-align: center;
}

.card-zoom-meta {
    width: 100%;
    min-height: 34px;
    padding-top: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #aab7cc;
    font-size: 12px;
}

.card-zoom-meta strong.owned {
    color: #6fe09d;
}

.card-zoom-meta strong.missing {
    color: #c3c7cf;
}

.card-zoom-nav {
    width: 46px;
    height: 74px;
    position: absolute;
    z-index: 3;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #eff5ff;
    border: 1px solid #536783;
    border-radius: 8px;
    background: rgba(21,31,49,.94);
    box-shadow: 0 8px 24px rgba(0,0,0,.38);
    cursor: pointer;
    font-size: 38px;
    line-height: 1;
}

.card-zoom-prev { left: 9px; }
.card-zoom-next { right: 9px; }

.card-zoom-nav:hover:not(:disabled) {
    background: #2a3b59;
}

.card-zoom-nav:disabled {
    opacity: .22;
    cursor: default;
}

@media (max-width: 1100px) and (min-width: 901px) {
    .binder-rightclick-help {
        display: none;
    }

    body.binder-detail-view .binder-detail-tools .hunter-button {
        padding-left: 9px;
        padding-right: 9px;
        font-size: 11px;
    }

    body.binder-detail-view .binder-spread {
        grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
    }

    body.binder-detail-view .binder-page {
        padding: 6px;
    }

    body.binder-detail-view .binder-page-grid {
        gap: 5px;
    }
}

@media (max-width: 900px) {
    body.binder-detail-view {
        overflow: auto;
    }

    body.binder-detail-view .page-shell {
        height: auto;
        min-height: calc(100vh - 137px);
        overflow: visible;
    }

    .binder-rightclick-help {
        display: none;
    }

    .card-zoom-dialog {
        padding-left: 52px !important;
        padding-right: 52px !important;
    }

    .card-zoom-nav {
        width: 38px;
        height: 62px;
        font-size: 32px;
    }
}

@media (max-width: 560px) {
    .card-zoom-dialog {
        padding-left: 42px !important;
        padding-right: 42px !important;
    }

    .card-zoom-nav {
        width: 32px;
        height: 54px;
        font-size: 28px;
    }

    .card-zoom-meta {
        gap: 7px;
        font-size: 10px;
    }
}
