/**
 * GB Media Embeds - Frontend Styles
 */

/* ==========================================================================
   Gallery Styles
   ========================================================================== */

.gb-gallery {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

/* Column variations */
.gb-gallery-columns-1 {
    grid-template-columns: 1fr;
}

.gb-gallery-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gb-gallery-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.gb-gallery-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.gb-gallery-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.gb-gallery-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Gallery items */
.gb-gallery-item {
    margin: 0;
    overflow: hidden;
    border-radius: 4px;
    background: #f5f5f5;
}

.gb-gallery-item a {
    display: block;
    line-height: 0;
}

.gb-gallery-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.gb-gallery-item a:hover .gb-gallery-image,
.gb-gallery-item a:focus .gb-gallery-image {
    transform: scale(1.05);
    opacity: 0.9;
}

.gb-gallery-caption {
    padding: 10px;
    font-size: 13px;
    color: #666;
    text-align: center;
    background: #f9f9f9;
    line-height: 1.4;
}

/* ==========================================================================
   Image Embed Styles
   ========================================================================== */

.gb-image-embed {
    margin: 20px 0;
    line-height: 0;
}

.gb-image-embed a {
    display: inline-block;
    line-height: 0;
}

.gb-embedded-image {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.gb-image-embed a:hover .gb-embedded-image,
.gb-image-embed a:focus .gb-embedded-image {
    opacity: 0.9;
}

.gb-image-caption {
    padding: 10px 0;
    font-size: 13px;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

/* Image alignment */
.gb-image-align-left {
    float: left;
    margin-right: 20px;
    margin-bottom: 10px;
}

.gb-image-align-right {
    float: right;
    margin-left: 20px;
    margin-bottom: 10px;
}

.gb-image-align-center {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.gb-image-align-none {
    float: none;
}

/* ==========================================================================
   Video Embed Styles
   ========================================================================== */

.gb-video-embed {
    margin: 20px 0;
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: #000;
}

/* Responsive video container */
.gb-video-embed iframe,
.gb-video-embed video,
.gb-video-embed embed,
.gb-video-embed object {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Aspect ratios */
.gb-video-ratio-16x9 {
    padding-bottom: 56.25%; /* 16:9 */
}

.gb-video-ratio-4x3 {
    padding-bottom: 75%; /* 4:3 */
}

.gb-video-ratio-21x9 {
    padding-bottom: 42.86%; /* 21:9 */
}

.gb-video-ratio-1x1 {
    padding-bottom: 100%; /* 1:1 */
}

/* Video link fallback */
.gb-video-link {
    padding: 40px 20px;
    text-align: center;
    background: #f5f5f5;
}

.gb-video-link a {
    color: #0073aa;
    text-decoration: none;
    word-break: break-all;
}

.gb-video-link a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Magazine Embed Styles
   ========================================================================== */

.gb-magazine-embed {
    margin: 20px 0;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gb-magazine-embed iframe {
    display: block;
    border: 0;
}

/* ==========================================================================
   Tweet Embed Styles
   ========================================================================== */

.gb-tweet-embed {
    margin: 20px 0;
    max-width: 550px;
}

.gb-tweet-embed .twitter-tweet {
    margin: 0 !important;
}

/* ==========================================================================
   Facebook Post Embed Styles
   ========================================================================== */

.gb-fb-post-embed {
    margin: 20px 0;
    overflow: hidden;
}

/* ==========================================================================
   Error Message (Admin Only)
   ========================================================================== */

.gb-media-embed-error {
    padding: 12px 15px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 15px 0;
    font-size: 14px;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.gb-gallery-item a:focus,
.gb-image-embed a:focus,
.gb-lightbox-trigger:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Screen reader text */
.gb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media screen and (max-width: 1024px) {
    .gb-gallery-columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }

    .gb-gallery-columns-5 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .gb-gallery-columns-6,
    .gb-gallery-columns-5,
    .gb-gallery-columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }

    .gb-image-align-left,
    .gb-image-align-right {
        float: none;
        margin: 20px auto;
        display: block;
    }
}

@media screen and (max-width: 480px) {
    .gb-gallery-columns-6,
    .gb-gallery-columns-5,
    .gb-gallery-columns-4,
    .gb-gallery-columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .gb-gallery {
        gap: 8px;
    }

    .gb-gallery-caption {
        padding: 8px;
        font-size: 12px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .gb-gallery {
        display: block;
    }

    .gb-gallery-item {
        display: inline-block;
        width: 30%;
        margin: 1%;
        page-break-inside: avoid;
    }

    .gb-video-embed {
        display: none;
    }

    .gb-video-embed::after {
        content: '[Video embed - not available in print]';
        display: block;
        padding: 20px;
        background: #f5f5f5;
        text-align: center;
    }
}

/* ==========================================================================
   Animation Utilities
   ========================================================================== */

@keyframes gb-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.gb-fade-in {
    animation: gb-fade-in 0.3s ease;
}

/* Lazy loading placeholder */
.gb-gallery-image[loading="lazy"],
.gb-embedded-image[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: gb-shimmer 1.5s infinite;
}

@keyframes gb-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
