/* Category Cards Widget Styles */

.category-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

.category-card {
    flex: 1;
    min-width: 250px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.category-card a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
    position: relative;
    flex-grow: 1;
}

/* Background image overlay for better text readability */
.category-card.has-background-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.2) 100%);
    z-index: 1;
}

.category-card.has-background-image a {
    position: relative;
    z-index: 2;
    color: #ffffff;
}

.category-card.has-background-image .category-card-content h3 {
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.category-card.has-background-image .category-card-content p {
    color: #f0f0f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Icon styles */
.category-icon-wrapper {
    text-align: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.category-icon {
    max-width: 80px;
    max-height: 80px;
    width: auto;
    height: auto;
    border-radius: 8px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.category-card.has-background-image .category-icon {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* Content styles */
.category-card-content {
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.category-card-content h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #333333;
    line-height: 1.3;
}

.category-card-content p {
    margin: 0 0 15px 0;
    font-size: 0.9em;
    color: #666666;
    line-height: 1.4;
    flex-grow: 1;
}

/* Button styles */
.category-button-wrapper {
    margin-top: auto;
    text-align: center;
}

.category-button {
    display: inline-block;
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border-style: solid;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1.4;
}

.category-button:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* Background image adjustments for button */
.category-card.has-background-image .category-button {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #333333 !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
}

.category-card.has-background-image .category-button:hover {
    background-color: rgba(255, 255, 255, 1) !important;
}

/* Responsive grid layouts */
.cards-per-row-1 .category-card {
    flex: 0 0 100%;
}

.cards-per-row-2 .category-card {
    flex: 0 0 calc(50% - 10px);
}

.cards-per-row-3 .category-card {
    flex: 0 0 calc(33.333% - 14px);
}

.cards-per-row-4 .category-card {
    flex: 0 0 calc(25% - 15px);
}

.cards-per-row-5 .category-card {
    flex: 0 0 calc(20% - 16px);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .category-cards {
        gap: 15px;
    }
    
    .cards-per-row-3 .category-card,
    .cards-per-row-4 .category-card,
    .cards-per-row-5 .category-card {
        flex: 0 0 calc(50% - 8px);
    }
    
    .category-card {
        min-width: 150px;
    }
    
    .category-icon {
        max-width: 60px;
        max-height: 60px;
    }
    
    .category-card-content h3 {
        font-size: 1.1em;
    }
    
    .category-card-content p {
        font-size: 0.85em;
    }
    
    .category-button {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    .category-card {
        flex: 0 0 100% !important;
        min-width: auto;
    }
    
    .category-cards {
        gap: 10px;
    }
    
    .category-icon {
        max-width: 50px;
        max-height: 50px;
    }
    
    .category-card-content h3 {
        font-size: 1em;
    }
    
    .category-card-content p {
        font-size: 0.8em;
    }
    
    .category-button {
        font-size: 0.8em;
    }
}

/* Post cards styles (for when no subcategories exist) */
.post-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.post-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #007cba;
    transition: background-color 0.3s ease;
}

.post-card:hover {
    background: #e9ecef;
}

.post-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.post-card-content h3 {
    margin: 0;
    font-size: 1em;
    color: #333333;
    font-weight: 500;
}

/* Legacy image support (for backward compatibility) */
.category-card img:not(.category-icon) {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* Animation for loading states */
.category-card {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Accessibility improvements */
.category-card:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.category-button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .category-card {
        border: 2px solid #000000;
    }
    
    .category-card.has-background-image::before {
        background: rgba(0, 0, 0, 0.7);
    }
    
    .category-button {
        border-width: 2px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .category-card {
        animation: none;
        transition: none;
    }
    
    .category-card:hover {
        transform: none;
    }
    
    .category-button:hover {
        transform: none;
    }
}

