/* Reddit Community Gallery - Scoped Styles */
/* All classes prefixed with .rcg- to avoid Elementor/theme conflicts */

.rcg-gallery-wrapper {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #ffffff;
    color: #09090b;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

.rcg-gallery-wrapper *,
.rcg-gallery-wrapper *::before,
.rcg-gallery-wrapper *::after {
    box-sizing: inherit;
}

/* Header */
.rcg-header {
    text-align: center;
    padding: 60px 20px 40px 20px;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.rcg-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 100%;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.5;
    z-index: 0;
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    pointer-events: none;
}

.rcg-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: white;
    border: 1px solid #e4e4e7;
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #09090b;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.rcg-pulsing-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    position: relative;
}

.rcg-pulsing-dot::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: #22c55e;
    border-radius: 50%;
    animation: rcg-pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes rcg-pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

.rcg-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0 0 16px 0;
    color: #09090b;
    position: relative;
    z-index: 1;
}

.rcg-subtitle {
    color: #71717a;
    font-size: 1.125rem;
    line-height: 1.6;
    margin: 0 auto;
    max-width: 600px;
    position: relative;
    z-index: 1;
}

/* Grid */
/* Grid */
.rcg-grid {
    display: grid;
    /* Use auto-fill with standard minmax for desktop */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
    /* Ensure left alignment of orphan items */
    justify-content: start;
    justify-items: start;
}

@media (max-width: 640px) {
    .rcg-header {
        padding: 40px 16px 30px 16px;
    }

    .rcg-title {
        font-size: 1.75rem;
    }

    .rcg-subtitle {
        font-size: 1rem;
    }

    .rcg-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: flex-start !important;
        padding: 0 10px 24px 10px !important;
    }

    /* Force 2-column layout on mobile */
    .rcg-card {
        width: calc(50% - 5px) !important;
        min-width: 0 !important;
        flex-grow: 0 !important;
    }
}

/* Cards */
.rcg-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    /* Default for desktop grid */
    width: 100%;
}

.rcg-card-image {
    position: relative !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background-color: #f4f4f5 !important;
    margin-bottom: 12px !important;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.03) !important;
    padding: 0 !important;
    max-height: none !important;
    height: auto !important;
    width: 100% !important;
    display: block !important;
}

.rcg-card-image img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
    /* Natural aspect ratio */
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    /* Reset transform to avoid scaling issues */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.rcg-card-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rcg-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    color: #09090b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.rcg-card-footer {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    color: #71717a;
}

.rcg-source-tag {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rcg-icon-reddit {
    width: 16px;
    height: 16px;
    fill: #FF4500;
}

/* Error State */
.rcg-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #71717a;
    font-size: 1rem;
}

/* Skeleton Loading */
.rcg-skeleton {
    background: linear-gradient(90deg, #f4f4f5 25%, #e4e4e7 50%, #f4f4f5 75%);
    background-size: 200% 100%;
    animation: rcg-shimmer 1.5s infinite;
}

.rcg-skeleton-title {
    height: 16px;
    width: 85%;
    border-radius: 4px;
}

.rcg-skeleton-meta {
    height: 12px;
    width: 40%;
    border-radius: 4px;
}

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

    100% {
        background-position: -200% 0;
    }
}