/* =============================================
   Video Ratio Widget – Stylesheet v1.2
   Fix: mobile section stacking / overflow issue
   ============================================= */

/* ── Wrapper ────────────────────────────────────
   TIDAK pakai overflow:hidden di sini —
   biarkan parent section Elementor menghitung
   tinggi dengan benar.
   overflow hanya di ratio-box.
─────────────────────────────────────────────── */
.vrw-wrapper {
    position: relative;
    width: 100%;
    /* box-sizing supaya padding/border tidak
       menambah lebar di luar 100% */
    box-sizing: border-box;
    /* display block penting agar tidak collapse */
    display: block;
}

/* ── Ratio Box ──────────────────────────────────
   Gunakan aspect-ratio CSS modern (Chrome 88+,
   Firefox 89+, Safari 15+) dengan fallback
   padding-bottom untuk browser lama.

   Inline style padding-bottom dari PHP/JS tetap
   dirender sebagai fallback — browser modern
   akan override dengan aspect-ratio.
─────────────────────────────────────────────── */
.vrw-ratio-box {
    position: relative;
    width: 100%;
    overflow: hidden;          /* clip video/iframe di sini, bukan di wrapper */
    background: #000;

    /* Fallback lama: padding-bottom di-set via
       inline style dari PHP. Browser modern
       mengabaikan height:0 jika aspect-ratio ada */
    height: 0;
    box-sizing: content-box;   /* supaya padding-bottom bekerja sbg tinggi */
}

/* Support aspect-ratio modern — override padding trick */
@supports (aspect-ratio: 16 / 9) {
    .vrw-ratio-box {
        height: auto !important;   /* batalkan height:0 */
        padding-bottom: 0 !important; /* batalkan inline padding */
        /* aspect-ratio di-set via JS setelah load */
    }
}

/* ── Video element ──────────────────────────── */
.vrw-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: block;
    -webkit-tap-highlight-color: transparent;
}

/* ── iFrame (YouTube / Vimeo) ─────────────── */
.vrw-iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ── Placeholder ────────────────────────────── */
.vrw-placeholder {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: #888;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}
.vrw-placeholder span { display: block; max-width: 220px; line-height: 1.5; }

/* ── Custom Play / Pause Button ─────────────── */
.vrw-play-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    opacity: 1;
    transition: opacity 0.25s ease, transform 0.2s ease, background 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.vrw-wrapper.vrw-playing .vrw-play-btn {
    opacity: 0;
    pointer-events: none;
}
.vrw-wrapper.vrw-playing:hover .vrw-play-btn,
.vrw-wrapper.vrw-playing:focus-within .vrw-play-btn {
    opacity: 1;
    pointer-events: auto;
}
.vrw-play-btn:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: rgba(0, 0, 0, 0.75);
}

.vrw-play-btn svg {
    width: 45%;
    height: 45%;
    fill: #fff;
}
.vrw-icon-play  { display: block; }
.vrw-icon-pause { display: none; }
.vrw-wrapper.vrw-playing .vrw-play-btn .vrw-icon-play  { display: none; }
.vrw-wrapper.vrw-playing .vrw-play-btn .vrw-icon-pause { display: block; }

/* ── Ratio Badge ────────────────────────────── */
.vrw-ratio-badge {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    font-family: monospace;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s;
}
.vrw-wrapper.vrw-playing .vrw-ratio-badge { opacity: 0; }
.vrw-wrapper.vrw-playing:hover .vrw-ratio-badge { opacity: 1; }

/* ── Cursor ─────────────────────────────────── */
.vrw-wrapper[data-play-btn="true"] .vrw-video,
.vrw-wrapper[data-hover-play="true"] .vrw-video {
    cursor: pointer;
}

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 768px) {
    .vrw-ratio-badge { font-size: 10px; padding: 2px 6px; }
    .vrw-play-btn { min-width: 44px; min-height: 44px; }

    /* Di mobile tidak ada hover — tombol selalu visible saat playing */
    .vrw-wrapper.vrw-playing .vrw-play-btn {
        opacity: 0;
    }
    /* Tap untuk munculkan lagi ditangani JS */
}
