/*
 * Player section CSS
 *
 * Styles for the video player and thumbnail slider. Adjust the arrows and scrolling to your liking.
 */

.cpb-player-wrapper {
    margin-bottom: 20px;
}

/* Ensure a fixed 16:9 aspect ratio for the main player by using padding trick */
.cpb-main-player {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    border-radius: 8px;
}

.cpb-main-player video,
.cpb-main-player img.cpb-main-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Review badge overlay on the main player */
.cpb-review-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    /* Show only white text with a subtle shadow; no colored background or padding */
    background: transparent;
    color: #ffffff;
    padding: 0;
    border-radius: 0;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    z-index: 3;
    pointer-events: none;
}

/* Review summary overlay displayed at the bottom of the main player when a review video is active */
.cpb-player-review-summary {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    /* Transparent background with only text; text-shadow aids readability */
    background: transparent;
    color: #ffffff;
    padding: 0;
    border-radius: 0;
    font-size: 0.8rem;
    line-height: 1.3;
    z-index: 3;
    pointer-events: none;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Play icon overlay on thumbnails */
.cpb-thumb-item {
    position: relative;
    margin-right: 10px;
    cursor: pointer;
    flex: 0 0 22%; /* default width on desktop, may be overridden by media queries below */
    overflow: hidden; /* ensure overlay elements stay within thumbnail bounds */
}

.cpb-thumb-item .cpb-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0;
}

/* Use a CSS pseudo-element to draw the triangle of the play icon */
.cpb-thumb-item .cpb-play-icon::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #fff;
    margin-left: 2px;
}

/* Review label on thumbnails */
.cpb-thumb-review-label {
    /* Position the review label at the top of the thumbnail instead of the bottom */
    position: absolute;
    top: 4px;
    left: 4px;
    background-color: rgba(255, 64, 129, 0.9);
    color: #fff;
    padding: 2px 4px;
    border-radius: 3px;
    /* Increase the font size and weight to make the label more prominent */
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 2;
    pointer-events: none;
}

.cpb-player-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.cpb-player-nav button {
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    padding: 5px 10px;
    margin: 0 10px;
    cursor: pointer;
    pointer-events: all;
}

.cpb-thumbnails {
    margin-top: 10px;
}

.cpb-thumbnails-inner {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    /* Show a custom scrollbar by default (thin) */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #c1c1c1 transparent; /* Firefox colors */
}

/* Customize the horizontal scrollbar of the thumbnail slider (WebKit browsers) */
.cpb-thumbnails-inner::-webkit-scrollbar {
    height: 8px; /* slightly larger scrollbar height */
}
.cpb-thumbnails-inner::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

/* On small screens, ensure the scrollbar is still visible and retain size */
@media (max-width: 768px) {
    .cpb-thumbnails-inner {
        scrollbar-width: thin;
    }
    .cpb-thumbnails-inner::-webkit-scrollbar {
        height: 8px;
    }
    .cpb-thumbnails-inner::-webkit-scrollbar-thumb {
        background: #b0b0b0;
    }
}
}

/* Flex basis for thumbnail items so different numbers of items appear on mobile and desktop */
/* Adjust number of visible thumbnails based on screen size */
@media (max-width: 768px) {
    .cpb-thumb-item {
        flex: 0 0 28%; /* approximately 3.5 items on mobile */
    }
}

/*
 * Thumbnail image sizing
 *
 * Originally the thumbnails used a 4:3 aspect ratio (2 / 1.5) which produced
 * noticeably taller images when compared to the original WishToVideo design.
 * Merchants requested a 1.5:1 (3:2) ratio so that the thumbnails appear
 * wider and match the preview shown in the admin.  Setting the aspect-ratio
 * property to 3 / 2 achieves this.  We also set height:auto for browsers
 * that do not fully support aspect-ratio on images.  The object-fit
 * declaration ensures that thumbnails are cropped appropriately without
 * distortion.  See https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio
 * for details on browser support.
 */
.cpb-thumb-img {
    width: 100%;
    /* Maintain a 3:2 (1.5:1) aspect ratio */
    aspect-ratio: 3 / 2;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: block;
}

/*
 * Ensure the primary media always remains visible.  Some SEO and caching
 * plugins (e.g. lazy‑loaders) hide video and image elements until they
 * detect a YouTube or external embed.  Because the CPB player dynamically
 * inserts native <video> and <img> tags, those plugins may erroneously
 * apply display:none to our media.  The following rules force the main
 * player elements to display so that the player does not vanish after
 * initial load.
 */
.cpb-main-player video.cpb-video,
.cpb-main-player img.cpb-main-image {
    display: block !important;
}

/* Highlight the active thumbnail */
.cpb-thumb-item.cpb-active-thumb .cpb-thumb-img {
    border-color: #0073aa;
}

.cpb-product-title {
    font-size: 1.5rem;
    margin-top: 15px;
}