/**
 * Resource Gallery Styles
 * 
 * Styles for the [resource_gallery] shortcode.
 * Mobile-first responsive design with Bootstrap 5 integration.
 * 
 * @package Salisbury_Academy_Tools
 */

/* ==========================================================================
   Wrapper & Container
   ========================================================================== */

.sa-resource-gallery {
    position: relative;
    width: 100%;
    margin: 2rem 0;
}

/* ==========================================================================
   Filters
   ========================================================================== */

.sa-rg-filters {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #F2F6FC;
    border: none;
    border-radius: 0;
}

.sa-rg-filter-group {
    margin-bottom: 1.5rem;
}

.sa-rg-filter-group:last-child {
    margin-bottom: 0;
}

.sa-rg-filter-label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sa-rg-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sa-rg-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sa-rg-filter-btn:hover {
    color: #212529;
    background: #e9ecef;
    border-color: #adb5bd;
}

.sa-rg-filter-btn.active {
    color: #fff;
    background: #002678;
    border-color: #002678;
}

.sa-rg-filter-btn:focus {
    outline: 2px solid #002678;
    outline-offset: 2px;
}

.sa-rg-count {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* ==========================================================================
   Preference Toggle
   ========================================================================== */

.sa-rg-preference-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    padding: 0.25rem;
    background: #e9ecef;
    border-radius: 0;
    width: fit-content;
}

.sa-rg-pref-btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6c757d;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sa-rg-pref-btn:hover {
    color: #212529;
}

.sa-rg-pref-btn.active {
    color: #fff;
    background: #002678;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sa-rg-pref-btn:focus {
    outline: 2px solid #002678;
    outline-offset: 2px;
}

/* ==========================================================================
   Grid
   ========================================================================== */

.sa-rg-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

/* 2 columns for tablets */
@media (min-width: 576px) {
    .sa-resource-gallery.cols-2 .sa-rg-grid,
    .sa-resource-gallery.cols-3 .sa-rg-grid,
    .sa-resource-gallery.cols-4 .sa-rg-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 3 columns for desktop */
@media (min-width: 768px) {
    .sa-resource-gallery.cols-3 .sa-rg-grid,
    .sa-resource-gallery.cols-4 .sa-rg-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 4 columns for large desktop */
@media (min-width: 1200px) {
    .sa-resource-gallery.cols-4 .sa-rg-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.sa-rg-card {
    display: flex;
    flex-direction: column;
    background: #F2F6FC;
    border: none;
    border-radius: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: none;
}

.sa-rg-card:hover {
    transform: translateY(-4px);
    box-shadow: none;
}

.sa-rg-card.sa-rg-hidden {
    display: none;
}

/* Card Image */
.sa-rg-card-image {
    display: none;
}

.sa-rg-card-placeholder {
    display: none;
}

.sa-rg-icon {
    display: none;
}

/* Card Content */
.sa-rg-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 1.25rem;
}

.sa-rg-card-title {
    margin: 0 0 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #002678;
    line-height: 1.4;
}

.sa-rg-card-title a {
    color: #002678 !important;
    text-decoration: none !important;
}

.sa-rg-card-title a:hover {
    color: #001a5c !important;
    text-decoration: none !important;
}

.sa-rg-card-meta {
    margin-bottom: 0.75rem;
}

.sa-rg-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #3D87CC;
    background: #e7f1ff;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sa-rg-card-excerpt {
    flex: 1;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.6;
}

.sa-rg-card-excerpt p:last-child {
    margin-bottom: 0;
}

/* Card Actions */
.sa-rg-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.sa-rg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none !important;
    border-radius: 0;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none !important;
}

.sa-rg-btn-primary {
    color: #fff !important;
    background: #002678;
    border-color: transparent !important;
}

.sa-rg-btn-primary:hover {
    color: #fff !important;
    background: #001a5c;
    border-color: transparent !important;
    text-decoration: none !important;
}

.sa-rg-btn-secondary {
    color: #002678 !important;
    background: #fff;
    border-color: transparent !important;
}

.sa-rg-btn-secondary:hover {
    color: #001a5c !important;
    background: #f8f9fa;
    border-color: transparent !important;
    text-decoration: none !important;
}

.sa-rg-btn:focus {
    outline: 2px solid #002678;
    outline-offset: 2px;
}

/* ==========================================================================
   No Results
   ========================================================================== */

.sa-rg-no-results {
    padding: 3rem 1.5rem;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    margin-top: 2rem;
}

.sa-rg-no-results p {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: #6c757d;
}

.sa-rg-reset-filters {
    padding: 0.5rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: #002678;
    border: 1px solid #002678;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sa-rg-reset-filters:hover {
    background: #001a5c;
    border-color: #001a5c;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.sa-resource-gallery-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    color: #6c757d;
    font-size: 1rem;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes sa-rg-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sa-rg-card {
    animation: sa-rg-fade-in 0.3s ease;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile: Stack filters */
@media (max-width: 575.98px) {
    .sa-rg-filters {
        padding: 1rem;
    }

    .sa-rg-preference-toggle {
        width: 100%;
    }

    .sa-rg-pref-btn {
        flex: 1;
        text-align: center;
    }

    .sa-rg-filter-buttons {
        flex-direction: column;
    }

    .sa-rg-filter-btn {
        width: 100%;
        justify-content: center;
    }

    .sa-rg-card-actions {
        flex-direction: column;
    }

    .sa-rg-btn {
        width: 100%;
    }
}

/* Tablet */
@media (min-width: 576px) and (max-width: 767.98px) {
    .sa-rg-grid {
        gap: 1.25rem;
    }
}

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

@media print {
    .sa-rg-filters,
    .sa-rg-no-results {
        display: none !important;
    }

    .sa-rg-card {
        box-shadow: none;
        border: 1px solid #000;
        break-inside: avoid;
    }

    .sa-rg-card:hover {
        transform: none;
    }
}

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

/* Focus styles for keyboard navigation */
.sa-rg-card:focus-within {
    outline: 2px solid #002678;
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sa-rg-card,
    .sa-rg-card:hover,
    .sa-rg-btn,
    .sa-rg-filter-btn,
    .sa-rg-pref-btn {
        transition: none !important;
        animation: none !important;
    }

    .sa-rg-card:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sa-rg-card {
        border-width: 2px;
    }

    .sa-rg-filter-btn,
    .sa-rg-btn {
        border-width: 2px;
    }
}
