/* =============================================================================
   MT - Video Popup Widget — mtfe-vp
   ============================================================================= */

:root {
    --vp-btn-size:    88px;
    --vp-anim-color:  #ffffff;
    --vp-backdrop:    rgba(0, 0, 0, 0.85);
    --vp-popup-width: 960px;
}

/* ── Wrapper ──────────────────────────────────────────────────────────────── */

.mtfe-vp {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* ── Thumbnail / Ratio ────────────────────────────────────────────────────── */

.mtfe-vp__thumb {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
}

/* Aspect-ratio padding trick */
.mtfe-vp__thumb::before {
    content: '';
    display: block;
}

.mtfe-vp--ratio-16-9 .mtfe-vp__thumb::before { padding-top: 56.25%; }
.mtfe-vp--ratio-4-3  .mtfe-vp__thumb::before { padding-top: 75%;     }
.mtfe-vp--ratio-21-9 .mtfe-vp__thumb::before { padding-top: 42.86%;  }
.mtfe-vp--ratio-1-1  .mtfe-vp__thumb::before { padding-top: 100%;    }

.mtfe-vp__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    will-change: transform;
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}


/* ── Parallax ─────────────────────────────────────────────────────────────── */

/*
 * Scale up so neither mouse-pan nor scroll-offset ever reveals an edge.
 * JS drives all movement via CSS custom properties — no CSS transitions
 * for translate (lerp in rAF is the easing).
 *   --vp-px / --vp-py  : mouse parallax offset  (normalised -1…+1)
 *   --vp-scroll-y      : scroll parallax offset  (px, set directly by JS)
 *   --vp-shift-x/y     : max mouse shift in px
 */
.mtfe-vp--parallax .mtfe-vp__img {
    scale: 1.22;
    translate:
        calc(var(--vp-px, 0) * var(--vp-shift-x, 14px))
        calc(var(--vp-py, 0) * var(--vp-shift-y, 8px) + var(--vp-scroll-y, 0px));
    /* No translate transition — JS lerp handles smoothing */
    transition: scale 0.55s ease;
    will-change: translate, scale;
}

/* ── Overlay ──────────────────────────────────────────────────────────────── */

.mtfe-vp__overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.28);
    transition: background-color 0.4s ease;
    pointer-events: none;
}

/* ── Play Button ──────────────────────────────────────────────────────────── */

.mtfe-vp__btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: var(--vp-btn-size, 88px);
    height: var(--vp-btn-size, 88px);
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.55);
    cursor: pointer;
    outline: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background-color 0.35s ease,
        border-color     0.35s ease,
        transform        0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    isolation: isolate;
}

.mtfe-vp__btn:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.mtfe-vp__btn-icon {
    width: 32px;
    height: 32px;
    fill: #ffffff;
    /* offset play icon optical center */
    margin-left: 4px;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mtfe-vp__btn:hover .mtfe-vp__btn-icon {
    transform: scale(1.15);
}

/* ── Rings (shared) ───────────────────────────────────────────────────────── */

.mtfe-vp__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--vp-anim-color, #ffffff);
    pointer-events: none;
    opacity: 0;
}

/* ── ANIMATION: pulse — rings expand outward continuously ─────────────────── */

@keyframes vp-pulse {
    0%   { transform: scale(1);    opacity: 0.7; }
    100% { transform: scale(2.4);  opacity: 0; }
}

.mtfe-vp--anim-pulse .mtfe-vp__ring--1 {
    animation: vp-pulse 2.2s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.mtfe-vp--anim-pulse .mtfe-vp__ring--2 {
    animation: vp-pulse 2.2s cubic-bezier(0.22, 1, 0.36, 1) 0.55s infinite;
}
.mtfe-vp--anim-pulse .mtfe-vp__ring--3 {
    animation: vp-pulse 2.2s cubic-bezier(0.22, 1, 0.36, 1) 1.1s infinite;
}

/* ── ANIMATION: spin — dashed ring rotates around button ──────────────────── */

.mtfe-vp__spin-ring {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px dashed var(--vp-anim-color, #ffffff);
    opacity: 0.55;
    pointer-events: none;
    animation: vp-spin 5s linear infinite;
}

@keyframes vp-spin {
    to { transform: rotate(360deg); }
}

/* Slow down spin on hover for a cool deceleration feel */
.mtfe-vp__btn:hover .mtfe-vp__spin-ring {
    animation-duration: 1.8s;
    opacity: 0.85;
}

/* Second dashed ring (counter-rotate) */
.mtfe-vp--anim-spin .mtfe-vp__btn::after {
    content: '';
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    border: 1px dashed var(--vp-anim-color, #ffffff);
    opacity: 0.28;
    pointer-events: none;
    animation: vp-spin-reverse 8s linear infinite;
}

@keyframes vp-spin-reverse {
    to { transform: rotate(-360deg); }
}

/* ── ANIMATION: ripple — single ring expands on hover only ───────────────── */

.mtfe-vp--anim-ripple .mtfe-vp__ring--1,
.mtfe-vp--anim-ripple .mtfe-vp__ring--2,
.mtfe-vp--anim-ripple .mtfe-vp__ring--3 {
    animation: none;
    opacity: 0;
    transform: scale(1);
    transition:
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        opacity   0.55s ease;
}

.mtfe-vp:hover .mtfe-vp--anim-ripple .mtfe-vp__ring--1,
.mtfe-vp__thumb:hover .mtfe-vp__ring--1 {
    transform: scale(1.8);
    opacity: 0;
    transition-duration: 0.55s;
}

/* Simpler: trigger via parent hover on the button */
.mtfe-vp--anim-ripple .mtfe-vp__btn:hover .mtfe-vp__ring--1 {
    transform: scale(1.8);
    opacity: 0;
    animation: vp-ripple 0.7s ease-out forwards;
}
.mtfe-vp--anim-ripple .mtfe-vp__btn:hover .mtfe-vp__ring--2 {
    animation: vp-ripple 0.7s ease-out 0.12s forwards;
}
.mtfe-vp--anim-ripple .mtfe-vp__btn:hover .mtfe-vp__ring--3 {
    animation: vp-ripple 0.7s ease-out 0.24s forwards;
}

@keyframes vp-ripple {
    0%   { transform: scale(1);   opacity: 0.65; }
    100% { transform: scale(2.0); opacity: 0; }
}

/* ── No-background (transparent) mode ────────────────────────────────────── */

.mtfe-vp--no-bg .mtfe-vp__thumb {
    background: transparent;
    overflow: visible;
    min-height: calc(var(--vp-btn-size, 88px) * 2.4);
}

.mtfe-vp--no-bg .mtfe-vp__thumb::before {
    display: none;
}

/* ── ANIMATION: bounce ────────────────────────────────────────────────────── */

@keyframes vp-bounce {
    0%,  100% { transform: translate(-50%, -50%) scale(1); }
    30%        { transform: translate(-50%, -50%) scale(1.12); }
    60%        { transform: translate(-50%, -50%) scale(0.96); }
    80%        { transform: translate(-50%, -50%) scale(1.05); }
}

.mtfe-vp--anim-bounce .mtfe-vp__btn {
    animation: vp-bounce 2.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}

/* Pause bounce on hover for a more intentional feel */
.mtfe-vp--anim-bounce .mtfe-vp__btn:hover {
    animation-play-state: paused;
    transform: translate(-50%, -50%) scale(1.08);
}

/* =============================================================================
   POPUP / MODAL
   ============================================================================= */

.mtfe-vp-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mtfe-vp-modal--open {
    opacity: 1;
    pointer-events: all;
}

/* Backdrop */
.mtfe-vp-modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--vp-backdrop, rgba(0, 0, 0, 0.85));
    cursor: pointer;
}

/* Inner container */
.mtfe-vp-modal__inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: var(--vp-popup-width, 960px);

    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mtfe-vp-modal--open .mtfe-vp-modal__inner {
    transform: scale(1) translateY(0);
}

/* 16:9 iframe wrapper */
.mtfe-vp-modal__video {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
}

.mtfe-vp-modal__video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Close button */
.mtfe-vp-modal__close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: background 0.25s ease, transform 0.25s ease;
}

.mtfe-vp-modal__close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1) rotate(90deg);
}

.mtfe-vp-modal__close svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2;
    stroke-linecap: round;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 767px) {
    .mtfe-vp-modal {
        padding: 16px;
    }

    .mtfe-vp-modal__close {
        top: -40px;
    }
}
