/* DGM Video Plugin Frontend Styles */

.dgm-video-gallery {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.dgm-video-gallery[data-columns="1"] { grid-template-columns: 1fr; }
.dgm-video-gallery[data-columns="2"] { grid-template-columns: repeat(2, 1fr); }
.dgm-video-gallery[data-columns="3"] { grid-template-columns: repeat(3, 1fr); }
.dgm-video-gallery[data-columns="4"] { grid-template-columns: repeat(4, 1fr); }
.dgm-video-gallery[data-columns="5"] { grid-template-columns: repeat(5, 1fr); }
.dgm-video-gallery[data-columns="6"] { grid-template-columns: repeat(6, 1fr); }

.dgm-video-item {
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: #333;
    /* Height and padding-bottom are removed to let content define size */
}

.dgm-video-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.dgm-video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.dgm-video-thumbnail img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.3s ease;
    /* object-fit is controlled by inline styles from settings */
}

.dgm-video-thumbnail:hover img {
    transform: scale(1.05);
}

.dgm-video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dgm-video-thumbnail:hover .dgm-video-play-overlay {
    opacity: 1;
}

.dgm-play-button {
    transition: transform 0.3s ease;
}

.dgm-play-button:hover {
    transform: scale(1.1);
}

/* UPDATED: Title style to be an overlay with gradient */
.dgm-video-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 15px 15px; /* More padding at the top for the gradient */
    background: linear-gradient(to top, rgba(0,0,0,0.85) 10%, transparent 100%);
    pointer-events: none; /* Allows clicks to pass through */
}

.dgm-video-title h3 {
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
    color: #FFFFFF; /* Default color, can be overridden by settings */
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    /* Font size, color, and text-align are controlled by inline styles from settings */
}

/* Single Video Item */
.dgm-video-single-item {
    max-width: 800px;
    margin: 20px auto;
    position: relative;
    overflow: hidden;
}

.dgm-video-single-item .dgm-video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Fullscreen Video Modal */
.dgm-video-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dgm-video-modal-content {
    position: relative;
    margin: auto;
    padding: 0;
    width: 90%;
    max-width: 1200px;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 50%;
    transform: translateY(-50%);
}

.dgm-video-close {
    position: absolute;
    top: -5px;
    right: 5px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
}

.dgm-video-close:hover,
.dgm-video-close:focus {
    color: #bbb;
    text-decoration: none;
}

.dgm-video-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dgm-video-container video,
.dgm-video-container iframe {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    background: #000;
    border: none;
}

.dgm-video-container iframe {
    width: 100%;
    height: 56.25vw; /* 16:9 aspect ratio */
    max-height: 90vh;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dgm-video-gallery[data-columns="5"],
    .dgm-video-gallery[data-columns="6"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .dgm-video-gallery[data-columns="3"],
    .dgm-video-gallery[data-columns="4"],
    .dgm-video-gallery[data-columns="5"],
    .dgm-video-gallery[data-columns="6"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dgm-video-modal-content {
        width: 95%;
        height: 95%;
    }
    
    .dgm-video-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    .dgm-video-gallery,
    .dgm-video-gallery[data-columns="2"],
    .dgm-video-gallery[data-columns="3"],
    .dgm-video-gallery[data-columns="4"],
    .dgm-video-gallery[data-columns="5"],
    .dgm-video-gallery[data-columns="6"] {
        grid-template-columns: 1fr;
    }
    
    .dgm-video-title {
        padding: 20px 10px 10px;
    }
}