

.categories-section {
    padding: 2rem 1rem;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

.categories-title {
    font-size: 1.8rem;
    color: var(--light-text);
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.categories-subtitle {
    font-size: 0.9rem;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 400;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.categories-filter {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--light-text);
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.filter-btn:hover, .filter-btn.active {
    background-color: var(--accent-color);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.category-icon-small {
    font-size: 0.8rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.category-card {
    perspective: 1000px;
    height: 300px;
}

.category-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
}

.category-card:hover .category-card-inner {
    transform: rotateY(180deg);
}

.category-header, .post-list {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.category-header {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: var(--light-text);
    text-align: center;
    justify-content: center;
}

.category-icon-wrapper {
    background-color: rgba(255, 255, 255, 0.15);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 0.8rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.category-icon {
    font-size: 1.8rem;
    color: var(--light-text);
}

.category-title {
    font-size: 1.4rem;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.post-list {
    background-color: var(--card-background);
    transform: rotateY(180deg);
    overflow-y: auto;
    padding: 1rem;
    justify-content: flex-start;
}

.post-item {
    margin-bottom: 0.8rem;
}

.post-item:last-child {
    margin-bottom: 0;
}

.post-link {
    display: flex;
    flex-direction: column;
    color: var(--light-text);
    text-decoration: none;
    padding: 0.8rem;
    border-radius: 6px;
    transition: var(--transition);
    background-color: rgba(255, 255, 255, 0.05);
}

.post-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.post-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    line-height: 1.3;
    color: var(--light-text);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.post-link:hover .post-title {
    color: var(--accent-color);
}

.post-meta {
    font-size: 0.7rem;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.post-date {
    opacity: 0.8;
}

.post-read-time {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 500;
}

.category-footer {
    position: absolute;
    bottom: 0.75rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.post-count {
    font-size: 0.8rem;
    color: var(--text-color);
    font-weight: 500;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.category-card {
    animation: fadeIn 0.4s ease-out forwards;
    animation-delay: calc(var(--animation-order) * 0.05s);
}

@keyframes titlePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.post-link:active .post-title {
    animation: titlePulse 0.3s ease;
}

/* Scrollbar styles */
.post-list::-webkit-scrollbar {
    width: 4px;
}

.post-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.post-list::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.post-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 480px) {
    .categories-title {
        font-size: 1.6rem;
    }

    .categories-subtitle {
        font-size: 0.85rem;
    }

    .filter-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .category-card {
        height: auto;
    }

    .category-card-inner {
        transform-style: flat;
    }

    .category-card:hover .category-card-inner {
        transform: none;
    }

    .category-header, .post-list {
        position: relative;
        height: auto;
        transform: none;
        backface-visibility: visible;
    }

    .post-list {
        display: none;
        margin-top: 1rem;
    }

    .category-card:hover .post-list {
        display: block;
    }

    .category-footer {
        position: static;
        margin-top: 1rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .categories-title {
        font-size: 1.8rem;
    }

    .category-card {
        height: 320px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .categories-title {
        font-size: 2rem;
    }

    .category-card {
        height: 350px;
    }
}

@media (min-width: 1025px) {
    .categories-title {
        font-size: 2.2rem;
    }

    .category-card {
        height: 380px;
    }

    .post-title {
        font-size: 1rem;
    }
}

/* Estilos para cards con pocos posts */
.category-card:only-child .post-list,
.category-card:first-child:nth-last-child(2) .post-list,
.category-card:first-child:nth-last-child(2) ~ .category-card .post-list {
    justify-content: center;
}

.category-card:only-child .post-item,
.category-card:first-child:nth-last-child(2) .post-item,
.category-card:first-child:nth-last-child(2) ~ .category-card .post-item {
    margin-bottom: 1rem;
}

.category-card:only-child .post-link,
.category-card:first-child:nth-last-child(2) .post-link,
.category-card:first-child:nth-last-child(2) ~ .category-card .post-link {
    padding: 1rem;
}

.category-card:only-child .post-title,
.category-card:first-child:nth-last-child(2) .post-title,
.category-card:first-child:nth-last-child(2) ~ .category-card .post-title {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
    -webkit-line-clamp: 3;
}

.category-card:only-child .post-meta,
.category-card:first-child:nth-last-child(2) .post-meta,
.category-card:first-child:nth-last-child(2) ~ .category-card .post-meta {
    font-size: 0.75rem;
}

/* Accesibilidad */
.post-link:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-color);
}

.post-link:focus .post-title {
    color: var(--accent-color);
}

/* Estilos para dispositivos de alta densidad de píxeles */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .category-icon-wrapper {
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Soporte para modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #121212;
        --secondary-color: #1e1e1e;
        --card-background: #2c2c2c;
    }
}