/* =========================================================================
   BG Gallery – Stylesheet
   Version: 1.1.0
   Card layout mirrors BG Popular Posts for visual consistency.
   ========================================================================= */

/* -------------------------------------------------------------------------
   Container
   ---------------------------------------------------------------------- */
.bg-gallery-container {
    width: 100%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}

/* -------------------------------------------------------------------------
   Search bar
   ---------------------------------------------------------------------- */
.bg-gallery-search {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.bg-gallery-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.4;
    background: #fff;
    color: #333;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.bg-gallery-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.bg-gallery-search-input::placeholder {
    color: #999;
}

.bg-gallery-search-button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #333;
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    box-sizing: border-box;
}

.bg-gallery-search-button:hover {
    background: #555;
}

.bg-gallery-search-button:active {
    transform: scale(0.97);
}

/* -------------------------------------------------------------------------
   Grid
   ---------------------------------------------------------------------- */
.bg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* overridden inline by shortcode */
    gap: 30px;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    transition: opacity 0.15s ease;
}

/* -------------------------------------------------------------------------
   Card
   ---------------------------------------------------------------------- */
.bg-gallery-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.bg-gallery-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

/* -------------------------------------------------------------------------
   Card image (4:3 ratio) – the whole image is a link to Flickr
   ---------------------------------------------------------------------- */
.bg-gallery-card-image {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 */
    overflow: hidden;
    background: #f5f5f5;
    display: block;
    flex: 0 0 auto;
}

.bg-gallery-card-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    text-decoration: none;
}

.bg-gallery-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    padding: 0;
    transition: transform 0.3s ease;
}

.bg-gallery-card-image:hover img {
    transform: scale(1.05);
}

/* Fallback for missing images */
.bg-gallery-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    background: #f5f5f5;
    font-size: 16px;
    font-weight: 500;
}

/* -------------------------------------------------------------------------
   Card content
   ---------------------------------------------------------------------- */
.bg-gallery-card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
    box-sizing: border-box;
}

/* Title */
.bg-gallery-card-title {
    margin: 0 0 12px;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 600;
    color: #333;
}

.bg-gallery-card-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.bg-gallery-card-title a:hover {
    color: #0073aa;
    text-decoration: underline;
}

/* Excerpt / caption (now the alt text) */
.bg-gallery-card-excerpt {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    flex: 1;
}

/* -------------------------------------------------------------------------
   Download button (mirrors .bg-popular-card-button)
   ---------------------------------------------------------------------- */
.bg-gallery-card-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #0073aa;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    transition: background 0.2s ease, transform 0.15s ease;
    align-self: flex-start;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
}

.bg-gallery-card-button:hover {
    background: #005a87;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
}

.bg-gallery-card-button:active {
    transform: translateY(0);
}

/* Flickr icon (SVG mask – inherits button color) */
.bg-gallery-card-button::before {
    content: "";
    width: 14px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-3.5 6.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7zm7 0a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7z'/></svg>") center / contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-3.5 6.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7zm7 0a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7z'/></svg>") center / contain no-repeat;
    flex: 0 0 auto;
}

/* -------------------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------------- */
.bg-gallery-no-posts,
.bg-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    font-size: 18px;
    color: #666;
    background: #f9f9f9;
    border-radius: 12px;
    margin: 0;
    box-sizing: border-box;
}

/* -------------------------------------------------------------------------
   Responsive – matches BG Popular Posts breakpoints
   ---------------------------------------------------------------------- */
@media only screen and (max-width: 1200px) {
    .bg-gallery-grid { gap: 25px; }
}

@media only screen and (max-width: 992px) {
    .bg-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px;
    }

    .bg-gallery-card-title { font-size: 18px; }
    .bg-gallery-card-content { padding: 18px; }
}

@media only screen and (max-width: 767px) {
    .bg-gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 25px;
    }

    .bg-gallery-card-title { font-size: 18px; }
    .bg-gallery-card-content { padding: 16px; }
    .bg-gallery-card-excerpt { font-size: 14px; }

    .bg-gallery-search {
        flex-direction: column;
        gap: 10px;
    }

    .bg-gallery-search-button {
        width: 100%;
    }
}

@media only screen and (max-width: 480px) {
    .bg-gallery-grid { gap: 20px; }

    .bg-gallery-card-content { padding: 14px; }

    .bg-gallery-card-title {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .bg-gallery-card-excerpt {
        font-size: 13px;
        margin-bottom: 15px;
    }

    .bg-gallery-card-button {
        padding: 8px 16px;
        font-size: 13px;
    }

    .bg-gallery-search-input,
    .bg-gallery-search-button {
        font-size: 14px;
        padding: 9px 12px;
    }
}

@media only screen and (max-width: 767px) and (orientation: landscape) {
    .bg-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }
}

/* -------------------------------------------------------------------------
   Print
   ---------------------------------------------------------------------- */
@media print {
    .bg-gallery-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid !important;
    }

    .bg-gallery-card-button,
    .bg-gallery-search {
        display: none !important;
    }
}