/* ================================================================
   Medialis — Floating Video v9 (Dual-Layer)
   Shell berpindah DOM, Iframe TIDAK PERNAH pindah → no reset.
   ================================================================ */

/* ─── Anchor: placeholder estetik di dalam artikel ─── */
#m-video-anchor {
    display: block;
    width: 100%;
    /* pointer-events aktif saat docked agar shell di dalamnya bisa diklik */
    pointer-events: none;
    margin: 12px 0;
    /* height dan overflow dikontrol JS:
       - float mode  : height auto, overflow visible (hanya 0 tinggi)
       - docked mode : height = tinggi shell, overflow visible
       Penting: JANGAN overflow:hidden — shell relative di dalamnya
       harus mendorong konten di bawahnya secara normal */
    box-sizing: content-box;
    /* Transisi tinggi agar tidak melompat */
    transition: height .22s ease;
}

/* Saat docked: anchor punya ruang, shell di dalamnya mengalir normal */
#m-video-anchor.is-docked {
    pointer-events: auto;
    overflow: visible;
}

/* ════════════════════════════════════════
   LAYER A — SHELL (berpindah DOM)
   ════════════════════════════════════════ */
.m-fv-shell {
    z-index: 9990;
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 28px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease, box-shadow .25s ease, border-radius .22s ease;
    will-change: opacity;
}

.m-fv-shell--visible {
    opacity: 1;
    pointer-events: auto;
}

/* State: melayang bebas */
.m-fv-shell--float {
    position: fixed;
    box-shadow: 0 8px 32px rgba(0,0,0,.60), 0 2px 8px rgba(0,0,0,.30);
    border-radius: 10px;
}

/* State: docked di anchor — mengalir dalam dokumen, mendorong konten ke bawah */
.m-fv-shell--docked {
    position: relative !important;   /* krusial: harus relative, bukan fixed */
    display: block;
    box-shadow: 0 2px 14px rgba(0,0,0,.25);
    border-radius: 8px;
    width: 100% !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    top: auto !important;
    margin: 0;                        /* anchor sudah punya margin */
}

/* Slot kosong — placeholder tinggi iframe di dalam shell */
.m-fv__player-slot {
    width: 100%;
    background: #000;
    /* aspect-ratio tidak kita pakai — tinggi diatur via JS (padding-top) */
}

/* ════════════════════════════════════════
   LAYER B — IFRAME (selalu body, fixed)
   ════════════════════════════════════════ */
.m-fv-iframe {
    position: fixed;
    z-index: 9991;          /* 1 level di atas shell */
    background: #000;
    overflow: hidden;
    pointer-events: none;   /* klik menembus ke shell di belakangnya */
    opacity: 0;
    transition: opacity .28s ease;
    /* Koordinat & ukuran diupdate JS setiap animFrame */
}

.m-fv-iframe--visible {
    opacity: 1;
    pointer-events: auto;
}

/* Iframe memenuhi parent */
.m-fv-iframe iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Saat shell closed: sembunyikan iframe juga */
.m-fv-iframe--hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ════════════════════════════════
   BAR ATAS
   ════════════════════════════════ */
.m-fv__bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(0,0,0,.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    user-select: none;
    cursor: default;
    min-height: 38px;
    box-sizing: border-box;
}

.m-fv__label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255,255,255,.80);
    white-space: nowrap;
    flex-shrink: 0;
}

.m-fv__mini-info {
    display: none;
    align-items: center;
    gap: 7px;
    flex: 1;
    min-width: 0;
}

.m-fv__mini-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,.80);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m-fv__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
}

.m-fv__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255,255,255,.60);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: color .12s, background .12s;
    -webkit-tap-highlight-color: transparent;
}
.m-fv__btn:hover,
.m-fv__btn:focus-visible {
    color: #fff;
    background: rgba(255,255,255,.13);
    outline: none;
}

.m-fv__btn .icon-mini    { display: block; }
.m-fv__btn .icon-restore { display: none; }

/* ════════════════════════════
   STATE: MINIMIZED
   ════════════════════════════ */
.m-fv-shell.is-minimized .m-fv__label     { display: none; }
.m-fv-shell.is-minimized .m-fv__mini-info { display: flex; }
.m-fv-shell.is-minimized .m-fv__btn .icon-mini    { display: none; }
.m-fv-shell.is-minimized .m-fv__btn .icon-restore { display: block; }
.m-fv-shell.is-minimized .m-fv__bar { cursor: pointer; }

.m-fv-shell.is-minimized .m-fv__player-slot {
    height: 0 !important;
    padding-top: 0 !important;
    overflow: hidden;
}
.m-fv-shell.is-minimized .m-fv__link { display: none; }

/* Saat minimized: sembunyikan iframe layer */
.m-fv-iframe.is-minimized {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ════════════════════════════
   AUDIO WAVE
   ════════════════════════════ */
.m-fv__wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 14px;
    flex-shrink: 0;
}
.m-fv__wave span {
    display: block;
    width: 2.5px;
    height: 8px;
    background: var(--cp, #e63737);
    border-radius: 2px;
    transform-origin: bottom center;
    animation: mfv-wave .75s ease-in-out infinite alternate;
}
.m-fv__wave span:nth-child(1) { animation-delay: 0s;    height: 6px;  }
.m-fv__wave span:nth-child(2) { animation-delay: .18s;  height: 12px; }
.m-fv__wave span:nth-child(3) { animation-delay: .35s;  height: 7px;  }

@keyframes mfv-wave {
    from { transform: scaleY(.35); opacity: .6; }
    to   { transform: scaleY(1);   opacity: 1;  }
}

/* ════════════════════════════
   LINK "BACA JUGA"
   ════════════════════════════ */
.m-fv__link {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px 9px;
    background: #1a1a1a;
    text-decoration: none;
    border-top: 1px solid rgba(255,255,255,.07);
    transition: background .13s;
}
.m-fv__link:hover { background: #222; }

.m-fv__link-badge {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--cp, #e63737);
    line-height: 1;
}
.m-fv__link-title {
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255,255,255,.82);
    line-height: 1.42;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ════════════════════════════
   MOBILE
   ════════════════════════════ */
@media (max-width: 520px) {
    .m-fv-shell--float { bottom: 72px !important; }
}

/* ════════════════════════════════════════
   MODE PORTRAIT — Instagram / Facebook / TikTok Reels
   Rasio 2:3, frame lebih sempit & tinggi
   ════════════════════════════════════════ */

/* Shell portrait: lebar lebih sempit saat float */
.m-fv-shell[data-portrait="1"].m-fv-shell--float {
    /* width dikontrol JS (240px default) — tidak perlu override CSS */
    border-radius: 12px;
}

/* Saat docked di anchor, biarkan lebar mengikuti kolom artikel */
.m-fv-shell[data-portrait="1"].m-fv-shell--docked {
    max-width: 280px;   /* jangan terlalu lebar saat docked di kolom sempit */
    margin: 0 auto;     /* tengahkan di dalam anchor */
}

/* Slot placeholder portrait: padding-top dikontrol JS (w*1.5) */
/* Tidak perlu CSS khusus karena JS yang menghitung */

/* Iframe layer portrait: border-radius lebih round */
.m-fv-iframe[data-portrait="1"] {
    border-radius: 10px;
    overflow: hidden;
}
