/**
 * Pixel Clusters - Frontend Styles
 * Version: 2.0.0
 * Modern responsive CSS for post clusters
 */

/* CSS Variables */
:root {
    --pc-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --pc-primary-color: #2271b1;
    --pc-text-color: #1d2327;
    --pc-text-secondary: #50575e;
    --pc-bg-light: #f6f7f7;
    --pc-border-color: #dcdcde;
    --pc-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --pc-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --pc-radius: 8px;
    --pc-transition: all 0.3s ease;
    --pc-btn-primary: #9bad3e;
    --pc-btn-cart: #e96656;
    --pc-btn-hover: #666666;
}

/* Base Cluster Container */
.cluster,
.pc-cluster {
    display: grid;
    gap: 24px;
    padding: 16px 0;
    width: 100%;
}

/* Legacy support */
.cluster {
    display: inline-block;
    padding: 10px 0;
    vertical-align: top;
    width: 100%;
}

/* Mode 1: Full articles with image, title, excerpt */
.cluster .category,
.pc-cluster .pc-item--full {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 20px;
    align-items: start;
    padding: 20px;
    background: var(--pc-bg-light);
    border-radius: var(--pc-radius);
    border: 1px solid var(--pc-border-color);
    transition: var(--pc-transition);
}

.cluster .category:hover,
.pc-cluster .pc-item--full:hover {
    box-shadow: var(--pc-shadow-hover);
    transform: translateY(-2px);
}

/* Legacy support for category */
.cluster .category {
    border-bottom: 1px dashed #CCC;
    display: inline-block;
    margin-bottom: 30px;
    padding-bottom: 10px;
    vertical-align: top;
    width: 100%;
}

.cluster .category .articles,
.pc-cluster .pc-item--full .pc-item__content {
    font-size: 1em;
    font-weight: 400;
    line-height: 1.6;
}

/* Legacy float support */
.cluster .category .articles {
    float: left;
    padding: 0 0 0 1%;
    width: 79%;
}

.cluster .category .articles .h2,
.pc-cluster .pc-item__title {
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 8px 0;
}

.cluster .category .articles .h2 a,
.pc-cluster .pc-item__title a {
    color: var(--pc-text-color);
    text-decoration: none;
    transition: var(--pc-transition);
}

.cluster .category .articles .h2 a:hover,
.pc-cluster .pc-item__title a:hover {
    color: var(--pc-primary-color);
}

.cluster .category .images,
.pc-cluster .pc-item--full .pc-item__image {
    border-radius: var(--pc-radius);
    overflow: hidden;
}

/* Legacy float support */
.cluster .category .images {
    float: left;
    padding: 0 2% 0 0;
    width: 18%;
}

.cluster .category .images img,
.pc-cluster .pc-item__img {
    height: auto;
    max-width: 100%;
    border-radius: var(--pc-radius);
    object-fit: cover;
    transition: var(--pc-transition);
}

.cluster .category .images a:hover img,
.pc-cluster .pc-item--full a:hover .pc-item__img {
    transform: scale(1.05);
}

.pc-cluster .pc-item__excerpt {
    color: var(--pc-text-secondary);
    font-size: 0.95em;
    line-height: 1.6;
}

/* Mode 2: Cards with image and title */
.cluster .column3,
.pc-cluster .pc-item--card {
    display: inline-block;
    width: calc(33.333% - 20px);
    margin: 0 10px 24px;
    vertical-align: top;
    background: #fff;
    border-radius: var(--pc-radius);
    overflow: hidden;
    box-shadow: var(--pc-shadow);
    transition: var(--pc-transition);
}

.cluster .column3:hover,
.pc-cluster .pc-item--card:hover {
    box-shadow: var(--pc-shadow-hover);
    transform: translateY(-4px);
}

.cluster .column3 .articles,
.pc-cluster .pc-item--card .pc-item__content {
    padding: 16px;
}

.cluster .column3 .articles .h2,
.pc-cluster .pc-item--card .pc-item__title {
    margin: 0;
}

.cluster .column3 .articles .h2 a,
.pc-cluster .pc-item--card .pc-item__title a {
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1.4;
    display: block;
    color: var(--pc-text-color);
    text-decoration: none;
}

.cluster .column3 .articles .h2 a:hover,
.pc-cluster .pc-item--card .pc-item__title a:hover {
    color: var(--pc-primary-color);
}

.cluster .column3 .images,
.pc-cluster .pc-item--card .pc-item__image-bg,
.pc-cluster .pc-item--card .images {
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    height: 180px;
    width: 100%;
    transition: var(--pc-transition);
}

.cluster .column3:hover .images,
.pc-cluster .pc-item--card:hover .pc-item__image-bg {
    transform: scale(1.05);
}

.cluster .column3 .articles .price,
.pc-cluster .pc-item--card .pc-item__price {
    margin: 10px 0;
    font-weight: 600;
    color: var(--pc-primary-color);
}

/* Mode 3: List style */
.pc-cluster--mode-3 {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pc-cluster .pc-item--list,
.cluster li {
    padding: 12px 16px;
    border-bottom: 1px solid var(--pc-border-color);
    transition: var(--pc-transition);
}

.pc-cluster .pc-item--list:last-child,
.cluster li:last-child {
    border-bottom: none;
}

.pc-cluster .pc-item--list:hover,
.cluster li:hover {
    background: var(--pc-bg-light);
    padding-left: 24px;
}

.pc-cluster .pc-item--list a,
.cluster li a {
    color: var(--pc-text-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--pc-transition);
}

.pc-cluster .pc-item--list a:hover,
.cluster li a:hover {
    color: var(--pc-primary-color);
}

/* Mode 4: Products (Flex layout) */
.cluster.flex,
.pc-cluster--flex {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.cluster.flex .columns,
.pc-cluster .pc-item--product {
    flex: 1 1 calc(33.333% - 24px);
    min-width: 280px;
    max-width: calc(33.333% - 16px);
    background: #fff;
    border-radius: var(--pc-radius);
    overflow: hidden;
    box-shadow: var(--pc-shadow);
    transition: var(--pc-transition);
}

.cluster.flex .columns:hover,
.pc-cluster .pc-item--product:hover {
    box-shadow: var(--pc-shadow-hover);
    transform: translateY(-4px);
}

.cluster.flex .columns .articles,
.pc-cluster .pc-item--product .pc-item__content {
    padding: 16px;
}

.cluster.flex .columns .articles .h2,
.pc-cluster .pc-item--product .pc-item__title {
    margin: 0 0 8px 0;
}

.cluster.flex .columns .articles .h2 a,
.pc-cluster .pc-item--product .pc-item__title a {
    font-size: 1em;
    font-weight: 600;
    line-height: 1.4;
    color: var(--pc-text-color);
    text-decoration: none;
}

.cluster.flex .columns .articles .h2 a:hover,
.pc-cluster .pc-item--product .pc-item__title a:hover {
    color: var(--pc-primary-color);
}

.cluster.flex .columns .articles .price,
.pc-cluster .pc-item--product .pc-item__price {
    margin: 12px 0;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--pc-primary-color);
}

.cluster.flex .columns .buttons,
.pc-cluster .pc-item--product .pc-item__buttons {
    display: flex;
    gap: 8px;
    width: 100%;
}

.cluster.flex .columns .buttons a,
.cluster.flex .columns .buttons button,
.pc-cluster .pc-item--product .pc-btn {
    flex: 1;
    background: var(--pc-btn-primary);
    border: none;
    border-radius: var(--pc-radius);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85em;
    padding: 12px 8px;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: var(--pc-transition);
}

.cluster.flex .columns .buttons a.carrito,
.cluster.flex .columns .buttons button.carrito,
.pc-cluster .pc-item--product .pc-btn--cart {
    background: var(--pc-btn-cart);
}

.cluster.flex .columns .buttons a:hover,
.cluster.flex .columns .buttons button:hover,
.pc-cluster .pc-item--product .pc-btn:hover {
    background: var(--pc-btn-hover);
    transform: translateY(-2px);
}

.cluster.flex .columns .images,
.pc-cluster .pc-item--product .pc-item__image-bg,
.pc-cluster .pc-item--product .images {
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    height: 200px;
    width: 100%;
    transition: var(--pc-transition);
}

.cluster.flex .columns:hover .images,
.pc-cluster .pc-item--product:hover .pc-item__image-bg {
    transform: scale(1.05);
}

/* Image link wrapper */
.pc-item__image-link {
    display: block;
    overflow: hidden;
}

/* Loading state for buttons */
.pc-btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.pc-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Placeholder for missing images */
.pc-item__placeholder {
    display: block;
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    border-radius: var(--pc-radius);
}

/* Price formatting */
.pc-price {
    font-weight: 700;
    color: var(--pc-primary-color);
}

/* Responsive Design */
@media screen and (max-width: 1024px) {
    .cluster .column3,
    .pc-cluster .pc-item--card {
        width: calc(50% - 20px);
    }
    
    .cluster.flex .columns,
    .pc-cluster .pc-item--product {
        flex: 1 1 calc(50% - 12px);
        max-width: calc(50% - 12px);
    }
}

@media screen and (max-width: 768px) {
    .cluster .category,
    .pc-cluster .pc-item--full {
        grid-template-columns: 100px 1fr;
        gap: 16px;
        padding: 16px;
    }
    
    /* Legacy float override for mobile */
    .cluster .category .images {
        float: none;
        width: 100px;
        padding: 0;
    }
    
    .cluster .category .articles {
        float: none;
        width: 100%;
        padding: 0;
    }
    
    .cluster .column3,
    .pc-cluster .pc-item--card {
        width: 100%;
        margin: 0 0 16px 0;
    }
    
    .cluster.flex,
    .pc-cluster--flex {
        gap: 16px;
    }
    
    .cluster.flex .columns,
    .pc-cluster .pc-item--product {
        flex: 1 1 100%;
        max-width: 100%;
        min-width: auto;
    }
}

@media screen and (max-width: 480px) {
    .cluster .category,
    .pc-cluster .pc-item--full {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .cluster .category .images,
    .pc-cluster .pc-item--full .pc-item__image {
        margin: 0 auto;
        max-width: 150px;
    }
    
    .cluster.flex .columns .buttons,
    .pc-cluster .pc-item--product .pc-item__buttons {
        flex-direction: column;
    }
    
    .cluster.flex .columns .buttons a,
    .cluster.flex .columns .buttons button,
    .pc-cluster .pc-item--product .pc-btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .cluster,
    .pc-cluster {
        display: block;
    }
    
    .cluster .column3,
    .cluster.flex .columns,
    .pc-cluster .pc-item--card,
    .pc-cluster .pc-item--product {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
    
    .cluster.flex .columns .buttons,
    .pc-cluster .pc-item--product .pc-item__buttons {
        display: none;
    }
}

/* Accessibility */
.cluster a:focus,
.pc-cluster a:focus,
.cluster button:focus,
.pc-cluster button:focus {
    outline: 2px solid var(--pc-primary-color);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cluster *,
    .pc-cluster * {
        transition: none !important;
        animation: none !important;
    }
}