
.videoscreen-button {
    position: relative;
    width: 100%;          /* fill parent context box */
    aspect-ratio: 251 / 177;  /* preserve original ratio */
    overflow: hidden;
    border-radius: 16px;
    transition: transform 0.3s ease;
    transform-origin: center;
    cursor: pointer;
}

.videoscreen-wrapper:hover .videoscreen-button {
    transform: translateX(5px); /* shift right by 5px */
}

/* 3D border fills button */
.borderscrn {
    position: absolute;
    inset: 0;            /* top/right/bottom/left = 0 */
    background: linear-gradient(180deg, #D9D9D9 0%, #737373 100%);
    border: 1px solid rgba(0,0,0,0.5);
    box-shadow: 0px 4px 4px rgba(0,0,0,0.25), inset -4px -4px 4px rgba(0,0,0,0.5), inset 4px 4px 4px rgba(255,255,255,0.7);
    border-radius: 16px;
}

/* Thumbnail inside button */
.videothumbnail {
    position: absolute;
    top: 5%;   /* 11.38px / 251px ≈ 4.5% */
    left: 4.5%;
    width: 91%;  /* 228.24px / 251px ≈ 91% */
    height: 87%; /* 154.62px / 177px ≈ 87% */
    border-radius: 20px;
    overflow: hidden;
    box-shadow: inset 4px -4px 4px rgba(0,0,0,0.25), inset 3px 4px 4px rgba(0,0,0,0.5);
}

.videothumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Shine */
.shine {
    position: absolute;
    top: 0;
    left: -180%;
    width: 250%;
    height: 100%;
    pointer-events: none;
    transform: skewX(-20deg);
    border-radius: 0;
    background: linear-gradient(
        212.73deg,
        rgba(255,255,255,0) 20%,
        rgba(255,255,255,0.3) 40%,
        rgba(255,255,255,0.9) 50%,
        rgba(255,255,255,0.3) 60%,
        rgba(255,255,255,0) 70%
    );
    animation: none;
    opacity: 0;
}


/* Shine animation on hover */
.videoscreen-button .shine {
    animation: none;
    opacity: 0;
}

.videoscreen-wrapper:hover .shine {
    animation: shine-slide 2.5s linear forwards;
}

@keyframes shine-slide {
    0% {
        left: -180%;
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    40% {
        left: -60%;
        opacity: 1;
    }
    65% {
        left: 0%;
        opacity: .6;   /* fade out sooner */
    }
    100% {
        left: 10%;
        opacity: 0;
    }
}

.videothumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    box-shadow: inset 4px -4px 4px rgba(0,0,0,0.25), inset 3px 4px 4px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 2; /* above shine */
}

/* Play overlay scales with button */
.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    font-size: clamp(24px, 4vw, 36px); /* scales with viewport */
    color: rgba(255,255,255,0.9);
    text-shadow: 0 0 8px rgba(0,0,0,0.6);
    pointer-events: none;
    transition: transform 0.3s ease;
}

.videoscreen-wrapper:hover .play-overlay {
    transform: translate(-50%, -50%) scale(1.3); /* grow on hover */
}

body.video-open {
    overflow: hidden;
    touch-action: none;
}

.video-player-overlay {
    position: fixed;

    /* Use logical viewport units (iOS-safe) */
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    top: 0;
    left: 0;

    background: rgba(0,0,0,0.85);

    display: none;
    justify-content: center;
    align-items: center;

    z-index: 9999;

    overflow: hidden;
    overscroll-behavior: contain;
    padding:
        env(safe-area-inset-top)
        env(safe-area-inset-right)
        env(safe-area-inset-bottom)
        env(safe-area-inset-left);

}

.video-player {
    position: relative;

    /* iOS-safe sizing */
    width: min(90vw, 1128px);
    height: auto;
    aspect-ratio: 1128 / 880;

    max-width: 100vw;
    max-height: 90vh;

    box-sizing: border-box;
    overflow: hidden;

    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease, width 0.3s ease, height 0.3s ease;
}

.video-player * {
    max-width: 100%;
    box-sizing: border-box;
}

.video-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

.video-player.rotated {
    transform: rotate(90deg);
    transform-origin: center;
    /* Fill phone viewport */
    width: 100dvh;
    height: 100dvw;
    max-width: 100dvh;
    max-height: 100dvw;
}


/* YouTube video scales with parent */
#youtubePlayer {
    position: absolute;
    top: 11.6%;
    left: 14.5%;
    width: 70.8%;
    height: 66.4%;

    max-width: 100%;
}

@media (max-width: 480px) {
    .video-player {
        width: 92vw;
        max-width: 92vw;
        max-height: 85vh;
    }
}

/* Background TV effect scales with player */
.video_fortv {
    position: absolute;
    top: 11.6%;
    left: 14.5%;
    width: 70.8%;
    height: 66.4%;
    background: url('bggif3.png'), url('Checker.png');
    background-size: cover;
    box-shadow: inset 4px -4px 4px rgba(0,0,0,0.25), inset 0 4px 4px rgba(0,0,0,0.25);
    z-index: 2;
}

/* Old TV frame always fills parent */
.old_tv_frame {
    position: absolute;
    inset: 0;
    background: url('/assets/images/old_tv_frame.png') no-repeat center center;
    background-size: cover;
    z-index: 3;
}

/* Center button scales with video */
.center-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14%;             /* % of video-player width */
    aspect-ratio: 1 / 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.center-button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.close-btn {
    position: absolute;
    top: 0%;
    right: 0%;

    width: 48px;
    height: 48px;
    font-size: 30px;

    color: white;
    background: rgba(0,0,0,0.65);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: env(safe-area-inset-top);
}

.close-btn:hover {
  background: rgba(0,0,0,0.7);
}
/* Hide by default */
.rotate-btn {
    display: none;
    position: absolute;
    bottom: 22%;
    right: 10%;
    width: 48px;
    height: 48px;
    font-size: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    color: white;
    border: none;
    cursor: pointer;
    z-index: 20;
    margin-bottom: env(safe-area-inset-bottom);
}

.fullscreen-btn {
    display: none; /* hidden by default */
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 48px;
    height: 48px;
    font-size: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    color: white;
    border: none;
    cursor: pointer;
    z-index: 20;
    align-items: center;
    justify-content: center;
}

.fullscreen-btn:hover {
    background: rgba(0,0,0,0.8);
}
/* Fullscreen overlay removes all padding */
.video-player-overlay.fullscreen {
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
}

/* Video container fills overlay completely */
.video-player-overlay.fullscreen .video-player {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    aspect-ratio: auto !important;
    transform: none !important;
    border-radius: 0 !important;
}

/* YouTube iframe fills container fully, ignoring old offsets */
.video-player-overlay.fullscreen iframe#youtubePlayer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Hide all wrappers/TV frame/center button in fullscreen */
.video-player-overlay.fullscreen .video_fortv,
.video-player-overlay.fullscreen .old_tv_frame,
.video-player-overlay.fullscreen .center-button,
.video-player-overlay.fullscreen .rotate-btn {
    display: none !important;
}

/* Show close button */
.video-player-overlay.fullscreen .close-btn {
    display: flex !important;
    z-index: 99999;
}

body.fullscreen-active {
    overflow: hidden;       /* block scrollbars */
    touch-action: none;     /* block touch gestures */
    overscroll-behavior: none; /* prevent bounce / pull-to-refresh */
    position: fixed;        /* prevent viewport jump */
    width: 100vw;           /* lock width */
    height: 100vh;          /* lock height */
}

body.fullscreen-active {
    overflow: hidden;            /* block scrollbars */
    touch-action: none;          /* block touch gestures */
    overscroll-behavior: none;   /* prevent bounce / pull-to-refresh */
    position: fixed;             /* lock the page in place */
    width: 100vw;                /* lock width */
    height: 100vh;               /* lock height */
    top: 0;                      /* will be set dynamically in JS to scroll offset */
    left: 0;
}

@media (max-width: 768px) {
    .fullscreen-btn {
        display: flex;
    }
     .video-player-overlay:not(.fullscreen) .rotate-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .video-player-overlay.fullscreen .video-player {
        max-height: none !important;
        width: 100vw !important;
        height: 100vh !important;
    }
}