/**
 * Page Counters - Styles
 * Version: 1.0.0
 */

.page-counters-wrapper {
    width: 100%;
    margin: 30px 0;
    /* padding: 20px; */
}

.page-counters-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
}

/* Responsive: su mobile metti in colonna */
@media (max-width: 600px) {
    .page-counters-grid {
        grid-template-columns: 1fr;
        max-width: 200px;
    }
}

.counter-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
}

.counter-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.counter-item:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.counter-item:active {
    transform: translateY(-2px) scale(0.98);
}

/* Animazione click */
.counter-item.clicked {
    animation: pulse-animation 0.4s ease;
}

@keyframes pulse-animation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Immagine del contatore */
.counter-image-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.counter-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: filter 0.3s ease;
}

.counter-item:hover .counter-image {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* Effetto particelle quando si clicca */
.counter-item.clicked .counter-image-wrapper::after {
    content: '✨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    animation: sparkle 0.6s ease;
    pointer-events: none;
}

@keyframes sparkle {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -80%) scale(1.5);
    }
}

/* Contatore numerico */
.counter-count {
    margin-top: 8px;
}

.count-display {
    display: inline-block;
    font-size: 24px;
    font-weight: 700;
    color: #333;
    min-width: 40px;
    text-align: center;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Animazione incremento numero */
.count-display.incrementing {
    animation: count-increment 0.3s ease;
}

@keyframes count-increment {
    0% {
        transform: scale(1);
        color: #333;
    }
    50% {
        transform: scale(1.3);
        color: #4a90e2;
    }
    100% {
        transform: scale(1);
        color: #333;
    }
}

/* Loading state */
.counter-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.counter-item.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stili specifici per ogni tipo di contatore */
.counter-item[data-counter-type="counter_candle"]:hover {
    background: rgba(255, 245, 220, 0.8);
}

.counter-item[data-counter-type="counter_heart"]:hover {
    background: rgba(255, 240, 245, 0.8);
}

.counter-item[data-counter-type="counter_flower"]:hover {
    background: rgba(245, 255, 250, 0.8);
}

/* Accessibilità */
@media (prefers-reduced-motion: reduce) {
    .counter-item,
    .counter-image,
    .count-display {
        transition: none;
        animation: none;
    }
    
    .counter-item:hover {
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .counter-item {
        background: rgba(50, 50, 50, 0.5);
    }
    
    .counter-item:hover {
        background: rgba(70, 70, 70, 0.8);
    }
    
    .count-display {
        color: #f0f0f0;
    }
}

/* Contatore singolo */
.page-counters-single {
    /* display: inline-block; */
}

.page-counters-single .page-counters-grid {
    display: flex;
}

/* Label testo per contatori senza immagine (es. frase_1) */
.counter-label-text {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    text-align: center;
    padding: 8px 4px;
    word-break: break-word;
}
