/**
 * MW Magazine - Flipbook Frontend Styles
 * Layout: toolbar bawah saja, zero elemen di atas flipbook.
 */

/* ==============================
   IMPORT FONT
   ============================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==============================
   VARIABEL
   ============================== */
:root {
    --mwm-accent: #6c8fff;
    --mwm-accent2: #a78bfa;
    --mwm-accent-glow: rgba(108, 143, 255, 0.45);
    --mwm-toolbar-bg: rgba(12, 12, 22, 0.94);
    --mwm-toolbar-blur: blur(24px);
    --mwm-toolbar-border: rgba(255, 255, 255, 0.08);
    --mwm-btn-hover: rgba(255, 255, 255, 0.1);
    --mwm-radius-sm: 6px;
    --mwm-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --mwm-toolbar-height: 100px;
}

/* ==============================
   WRAPPER UTAMA
   ============================== */
.mwm-magazine-single {
    /* Tidak pakai 100vh — flipbook ada di dalam halaman WordPress yang punya header */
    display: flex;
    flex-direction: column;
    background: var(--mwm-bg-color, #1a1a2e);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    box-sizing: border-box;
}

.mwm-magazine-single * {
    box-sizing: border-box;
}

/* ==============================
   CONTAINER FLIPBOOK
   ============================== */
.mwm-flipbook-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Padding aman di semua sisi — flipbook tidak menyentuh tepi */
    padding: 20px;
    position: relative;
    /* Container = viewport/jendela yang meng-clip flipbook */
    /* height dikontrol via JS dari setting (dalam vh) */
    overflow: hidden;
    /* min-height CSS fallback: pastikan container punya tinggi minimum
       sebelum JS berjalan & set height:Xvh — mencegah collapse saat loader */
    min-height: 50vh;
}

.mwm-flipbook-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* TIDAK ada fixed height — ikuti ukuran natural canvas */
    overflow: visible;
    /* Zoom diaplikasikan via CSS zoom property (oleh JS) */
    /* Tidak pakai transition agar zoom-to-point smooth */
    transform-origin: top left;
}

/* ==============================
   FULLSCREEN
   ============================== */
.mwm-magazine-single.mwm-is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    overflow-y: auto;
}

/* ================================================
   CINEMATIC LOADER
   ================================================ */
.mwm-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0d0d1a 0%, #0f0f2e 50%, #0d0d1a 100%);
    z-index: 50;
    transition: opacity 0.5s ease;
}

.mwm-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.mwm-loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 40px 32px;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

/* --------- ANIMASI BUKU --------- */
.mwm-loader-book {
    width: 72px;
    height: 88px;
    position: relative;
    margin-bottom: 28px;
    perspective: 200px;
}

.mwm-book-cover {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--mwm-loader-accent, var(--mwm-accent)), var(--mwm-accent2, #a78bfa));
    border-radius: 3px 8px 8px 3px;
    box-shadow:
        -4px 4px 20px rgba(108, 143, 255, 0.5),
        0 0 40px rgba(108, 143, 255, 0.15);
}

.mwm-book-page {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 6px;
    right: 4px;
    background: rgba(255 255 255 / 0.92);
    border-radius: 1px 6px 6px 1px;
    transform-origin: left center;
    animation: mwmPageTurn 1.8s ease-in-out infinite;
}

.mwm-page-a {
    animation-delay: 0s;
    background: rgba(255, 255, 255, 0.85);
}

.mwm-page-b {
    animation-delay: 0.6s;
    background: rgba(255, 255, 255, 0.75);
}

.mwm-page-c {
    animation-delay: 1.2s;
    background: rgba(255, 255, 255, 0.65);
}

@keyframes mwmPageTurn {
    0% {
        transform: rotateY(0deg) scaleX(1);
        opacity: 0.9;
    }

    40% {
        transform: rotateY(-30deg) scaleX(0.85);
        opacity: 0.7;
    }

    60% {
        transform: rotateY(-30deg) scaleX(0.85);
        opacity: 0.7;
    }

    100% {
        transform: rotateY(0deg) scaleX(1);
        opacity: 0.9;
    }
}

/* --------- ANGKA PERSEN BESAR --------- */
.mwm-loader-percent {
    font-size: clamp(52px, 15vw, 72px);
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--mwm-loader-text, #fff) 30%, var(--mwm-loader-accent, var(--mwm-accent)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variant-numeric: tabular-nums;
    min-width: 4ch;
}

/* --------- JUDUL TAHAP --------- */
.mwm-loader-stage {
    font-size: var(--mwm-loader-font-size, 15px);
    font-weight: 600;
    color: var(--mwm-loader-text, rgba(255, 255, 255, 0.9));
    margin: 0 0 18px;
    letter-spacing: 0.01em;
    min-height: 22px;
    transition: all 0.3s ease;
}

/* --------- PROGRESS BAR --------- */
.mwm-loader-bar-wrap {
    width: 100%;
    margin-bottom: 14px;
}

.mwm-loader-bar-track {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
}

.mwm-loader-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--mwm-loader-accent, var(--mwm-accent)), var(--mwm-accent2, #a78bfa));
    border-radius: 100px;
    width: 0%;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Shimmer efek di progress bar */
.mwm-loader-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.35) 50%, transparent 100%);
    animation: mwmShimmer 1.4s ease-in-out infinite;
}

@keyframes mwmShimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(300%);
    }
}

/* --------- DETAIL SUBSTEP --------- */
.mwm-loader-detail {
    font-size: 12px;
    color: color-mix(in srgb, var(--mwm-loader-text, #ffffff) 40%, transparent);
    margin: 0;
    min-height: 18px;
    transition: all 0.25s ease;
    line-height: 1.5;
}

/* Fade in animasi global */
@keyframes mwmFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==============================
   ERROR STATE
   ============================== */
.mwm-no-pdf {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 60px 20px;
}

.mwm-no-pdf-icon {
    margin-bottom: 20px;
    opacity: 0.35;
}

.mwm-no-pdf-icon svg {
    stroke: rgba(255, 255, 255, 0.8);
}

.mwm-no-pdf h2 {
    color: #fff;
    font-size: 20px;
    margin: 0 0 12px;
    font-weight: 600;
}

.mwm-no-pdf p {
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 24px;
}

.mwm-error-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--mwm-accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--mwm-transition);
    font-family: inherit;
}

.mwm-error-back-btn:hover {
    background: #5a78ee;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--mwm-accent-glow);
}

/* ================================================
   TOOLBAR BAWAH — DUA BARIS
   ================================================ */
.mwm-flipbook-toolbar {
    position: sticky;
    bottom: 0;
    /* z-index harus lebih tinggi dari bottom nav website (9999)
       agar toolbar tidak tertindih elemen floating website */
    z-index: 10001;
    background: var(--mwm-toolbar-bg);
    backdrop-filter: var(--mwm-toolbar-blur);
    -webkit-backdrop-filter: var(--mwm-toolbar-blur);
    border-top: 1px solid var(--mwm-toolbar-border);
    padding: 0 12px;
    /* Safe area untuk iPhone X+ notch/home bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    flex-direction: column;
}

.mwm-toolbar-row {
    display: flex;
    align-items: center;
    height: 50px;
    gap: 4px;
    width: 100%;
}

.mwm-toolbar-top-row {
    border-bottom: 1px solid var(--mwm-toolbar-border);
}

.mwm-toolbar-title {
    flex: 1;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    padding: 0 8px;
}

.mwm-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mwm-toolbar-nav-row {
    justify-content: center;
}

.mwm-toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--mwm-toolbar-border);
    margin: 0 8px;
    flex-shrink: 0;
}

.mwm-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* --------- TOMBOL --------- */
.mwm-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 36px;
    height: 36px;
    border-radius: var(--mwm-radius-sm);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: var(--mwm-transition);
    text-decoration: none;
    font-family: inherit;
    font-size: 12px;
    padding: 0 8px;
    flex-shrink: 0;
}

/* ── TOMBOL PREV / NEXT — Tampil menonjol, mudah dijangkau ── */
#mwm-btn-prev,
#mwm-btn-next {
    min-width: 48px;
    height: 42px;
    border-radius: 21px;
    /* pill shape */
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 14px;
    padding: 0 12px;
    gap: 6px;
}

#mwm-btn-prev:hover,
#mwm-btn-next:hover {
    background: var(--mwm-accent);
    border-color: var(--mwm-accent);
    color: #fff;
    box-shadow: 0 0 12px rgba(99, 179, 237, 0.4);
}

#mwm-btn-next:not(:disabled) {
    background: linear-gradient(135deg, rgba(99, 179, 237, 0.25), rgba(99, 179, 237, 0.1));
    border-color: rgba(99, 179, 237, 0.4);
    color: #fff;
}

.mwm-toolbar-btn:hover {
    background: var(--mwm-btn-hover);
    color: #fff;
}

.mwm-toolbar-btn:active {
    transform: scale(0.88);
}

.mwm-toolbar-btn:disabled {
    opacity: 0.2;
    pointer-events: none;
}

/* Tombol Close (×) */
.mwm-close-btn {
    color: rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
    width: 36px;
    min-width: 36px;
}

.mwm-close-btn:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.12);
}

/* Teks label di tombol */
.mwm-btn-text {
    font-size: 11px;
    font-weight: 500;
}

/* Indikator halaman */
.mwm-page-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    padding: 0 8px;
    min-width: 72px;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

.mwm-page-sep {
    color: rgba(255, 255, 255, 0.3);
    font-weight: 300;
}

.mwm-zoom-level {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Fullscreen active state */
.mwm-toolbar-btn.is-fullscreen {
    color: var(--mwm-accent);
}

/* ==============================
   SWIPE HINT (Mobile)
   ============================== */
.mwm-swipe-hint {
    position: absolute;
    bottom: calc(var(--mwm-toolbar-height) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    animation: mwmSwipeHintFade 5s forwards 2s;
}

@keyframes mwmSwipeHintFade {
    0% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 480px) {
    .mwm-toolbar-btn {
        min-width: 32px;
        height: 34px;
        padding: 0 6px;
    }

    /* Prev/Next tetap besar di mobile — mudah dicapai dengan jempol */
    #mwm-btn-prev,
    #mwm-btn-next {
        min-width: 54px;
        height: 44px;
        font-size: 15px;
    }

    #mwm-btn-first,
    #mwm-btn-last {
        display: none;
    }

    .mwm-btn-text {
        display: none;
    }

    .mwm-loader-inner {
        padding: 32px 24px;
        max-width: 300px;
    }
}

@media (min-width: 769px) {
    :root {
        --mwm-toolbar-height: 104px;
    }
}

@media print {

    .mwm-flipbook-toolbar,
    .mwm-loading-overlay {
        display: none;
    }
}