/* =============================================================
   Modern Image Viewer
   Drop-in replacement for FancyBox — intercepts data-fancybox links
   ============================================================= */

/* ── Lock body scroll when viewer is open ───────────────────── */
.mv-no-scroll {
    overflow: hidden;
}

/* ── Root overlay ────────────────────────────────────────────── */
#mv-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    opacity: 0;
    transition: opacity 0.32s ease;
}

#mv-overlay.mv-is-open {
    display: flex;
    align-items: stretch;
}

#mv-overlay.mv-visible {
    opacity: 1;
}

/* ── Dark backdrop ───────────────────────────────────────────── */
#mv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 8, 0.97);
}

/* ── Wrapper ─────────────────────────────────────────────────── */
#mv-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
#mv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem 0 1.25rem;
    height: 54px;
    flex-shrink: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72) 0%, transparent 100%);
}

#mv-counter {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.55);
    user-select: none;
}

#mv-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Toolbar buttons */
.mv-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.mv-btn:hover {
    color: #efd686;
    background: rgba(255, 255, 255, 0.08);
}

.mv-btn:focus-visible {
    outline: 2px solid #efd686;
    outline-offset: 2px;
}

.mv-btn svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    display: block;
}

/* ── Stage ───────────────────────────────────────────────────── */
#mv-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* ── Image frame ─────────────────────────────────────────────── */
#mv-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#mv-img {
    max-width: 92%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    border-radius: 2px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
    transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
}

#mv-frame.mv-frame--zoomed #mv-img {
    cursor: grab;
}

#mv-frame.mv-frame--zoomed #mv-img:active {
    cursor: grabbing;
}

/* ── Loading spinner ─────────────────────────────────────────── */
#mv-spinner {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.mv-spin-ring {
    width: 38px;
    height: 38px;
    border: 2.5px solid rgba(255, 255, 255, 0.12);
    border-top-color: #efd686;
    border-radius: 50%;
    animation: mv-spin 0.75s linear infinite;
}

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

/* ── Caption ─────────────────────────────────────────────────── */
#mv-caption {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.6rem 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    pointer-events: none;
}

/* ── Prev / Next nav ─────────────────────────────────────────── */
.mv-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    transition: border-color 0.25s, color 0.25s, background 0.25s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.mv-nav:hover {
    border-color: #efd686;
    color: #efd686;
    background: rgba(0, 0, 0, 0.55);
}

.mv-nav:focus-visible {
    outline: 2px solid #efd686;
    outline-offset: 2px;
}

.mv-nav svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

#mv-prev { left: 1rem; }
#mv-next { right: 1rem; }

/* ── Autoplay progress bar ───────────────────────────────────── */
#mv-progress {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 5;
    pointer-events: none;
}

#mv-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #c9a84c, #efd686);
}

/* ── Thumbnail strip ─────────────────────────────────────────── */
#mv-thumbs {
    flex-shrink: 0;
    height: 82px;
    background: rgba(0, 0, 0, 0.55);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    overflow: hidden;
}

#mv-thumb-track {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 100%;
    overflow-x: auto;
    padding: 8px 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#mv-thumb-track::-webkit-scrollbar {
    display: none;
}

.mv-thumb {
    flex-shrink: 0;
    width: 58px;
    height: 58px;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.45;
    border: 2px solid transparent;
    background: none;
    padding: 0;
    transition: opacity 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
}

.mv-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.mv-thumb:hover {
    opacity: 0.75;
    transform: scale(1.06);
}

.mv-thumb.mv-thumb--active {
    opacity: 1;
    border-color: #efd686;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    #mv-toolbar {
        padding: 0 0.4rem 0 0.8rem;
        height: 50px;
    }

    .mv-btn {
        width: 36px;
        height: 36px;
    }

    .mv-btn svg {
        width: 17px;
        height: 17px;
    }

    /* Hide zoom buttons on touch devices */
    #mv-zoom-in,
    #mv-zoom-out,
    #mv-zoom-fit {
        display: none;
    }

    .mv-nav {
        width: 42px;
        height: 42px;
    }

    .mv-nav svg {
        width: 18px;
        height: 18px;
    }

    #mv-prev { left: 0.4rem; }
    #mv-next { right: 0.4rem; }

    #mv-img {
        max-width: 96%;
    }

    #mv-thumbs {
        height: 66px;
    }

    .mv-thumb {
        width: 46px;
        height: 46px;
    }
}

@media (max-width: 480px) {
    #mv-actions .mv-btn:nth-child(n+4):not(#mv-play):not(#mv-close) {
        display: none;
    }
}
