﻿/**
 * CSS Migliorato per Card Oroscopi
 * File: static/css/horoscope-cards-improved.css
 * 
 * Risolve problemi di allineamento e crea layout uniforme
 */

/* ===== RESET E BASE ===== */

.horoscope-grid .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    align-items: stretch; /* Importante: forza tutte le card alla stessa altezza */
    padding: 2rem 0;
}

/* ===== CARD PRINCIPALE ===== */

.horoscope-card {
    background: white;
    border-radius: 20px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    transform: translateY(20px);
    position: relative;
    
    /* FLEXBOX per controllo perfetto del layout */
    display: flex;
    flex-direction: column;
    height: 100%; /* Forza altezza uniforme */
    min-height: 480px; /* Altezza minima garantita */
}

.horoscope-card.appear {
    opacity: 1;
    transform: translateY(0);
}

.horoscope-card:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.1);
}

/* ===== HEADER MIGLIORATO ===== */

.card-header {
    padding: 2rem 1.5rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    text-align: center;
    position: relative;
    flex-shrink: 0; /* Non si riduce mai */
    min-height: 160px; /* Altezza fissa per uniformità */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        transparent 50%, 
        rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
}

.sign-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.horoscope-card:hover .sign-icon {
    transform: scale(1.1) rotate(5deg);
}

.card-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
}

.date-range {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 500;
    position: relative;
    z-index: 2;
}


/* ===== BODY MIGLIORATO ===== */

.card-body {
    padding: 1.5rem;
    flex-grow: 1; /* Prende tutto lo spazio disponibile */
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
}

.horoscope-preview {
    flex-grow: 1; /* Prende tutto lo spazio rimanente */
    line-height: 1.7;
    font-size: 1rem;
    color: #444;
    margin-bottom: 1.5rem;
    
    /* Controllo uniforme del testo */
    display: -webkit-box;
    -webkit-line-clamp: 6; /* Massimo 6 righe */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Altezza minima per uniformità */
    min-height: 120px;
    max-height: 180px;
}

/* Stili markdown migliorati per preview */
.horoscope-preview .markdown-h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin: 1rem 0 0.75rem 0;
    font-weight: 600;
    font-family: 'Playfair Display', serif;
    text-align: center;
    padding: 0.5rem 0;
    border-bottom: 2px solid rgba(107, 63, 160, 0.2);
    background: linear-gradient(135deg, 
        rgba(107, 63, 160, 0.05), 
        rgba(107, 63, 160, 0.02));
    border-radius: 8px;
}

.horoscope-preview .markdown-h4 {
    color: var(--primary-dark);
    font-size: 1rem;
    margin: 0.75rem 0 0.5rem 0;
    font-weight: 600;
}

.horoscope-preview strong {
    color: var(--primary);
    font-weight: 600;
    background: linear-gradient(135deg, 
        rgba(107, 63, 160, 0.1), 
        rgba(107, 63, 160, 0.05));
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border-left: 3px solid var(--primary);
}

.horoscope-preview em {
    color: var(--primary-dark);
    font-style: italic;
    background: rgba(107, 63, 160, 0.05);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
}

.horoscope-preview ul {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.horoscope-preview li {
    margin-bottom: 0.5rem;
    color: #555;
    font-size: 0.95rem;
    position: relative;
    padding-left: 0.5rem;
}

.horoscope-preview li::marker {
    color: var(--primary);
    font-weight: bold;
}

.read-more {
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, 
        rgba(107, 63, 160, 0.1), 
        rgba(107, 63, 160, 0.05));
    border-radius: 20px;
    border: 1px solid rgba(107, 63, 160, 0.2);
    transition: all 0.3s ease;
    align-self: flex-start;
}

.read-more:hover {
    background: var(--primary);
    color: white;
    text-decoration: none;
    transform: translateX(5px);
}

.read-more::after {
    content: '→';
    transition: transform 0.3s ease;
}

.read-more:hover::after {
    transform: translateX(3px);
}

/* ===== FOOTER MIGLIORATO ===== */

.card-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(107, 63, 160, 0.1);
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    flex-shrink: 0; /* Mantiene altezza fissa */
    min-height: 140px; /* Altezza minima per uniformità */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* ===== META INFORMAZIONI ===== */

.horoscope-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(107, 63, 160, 0.1);
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 8px;
    transition: transform 0.3s ease;
    position: relative;
}

.meta-item:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, 
        rgba(107, 63, 160, 0.05), 
        rgba(107, 63, 160, 0.02));
}

.meta-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-weight: 700;
    font-size: 1.1rem;
    position: relative;
}

.lucky-number {
    color: #28a745;
    background: linear-gradient(135deg, #28a745, #20c997);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.mood {
    color: #17a2b8;
    text-transform: capitalize;
}

.color-indicator {
    font-weight: 600;
    text-transform: capitalize;
    position: relative;
}

.color-indicator::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===== AZIONI ===== */

.card-actions {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: center;
}

.btn-small {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary.btn-small {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(107, 63, 160, 0.3);
}

.btn-primary.btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(107, 63, 160, 0.4);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-outline.btn-small {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline.btn-small:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(107, 63, 160, 0.3);
}

/* Effetto ripple sui bottoni */
.btn-small::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: width 0.6s, height 0.6s;
    transform: translate(-50%, -50%);
    z-index: 0;
}

.btn-small:active::before {
    width: 300px;
    height: 300px;
}

.btn-small span,
.btn-small .btn-text {
    position: relative;
    z-index: 1;
}

/* ===== RESPONSIVE MIGLIORATO ===== */

@media (max-width: 1200px) {
    .horoscope-grid .grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 1.5rem;
    }
    
    .horoscope-card {
        min-height: 450px;
    }
}

@media (max-width: 768px) {
    .horoscope-grid .grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem 0;
    }
    
    .horoscope-card {
        min-height: 420px;
        margin: 0 0.5rem;
    }
    
    .card-header {
        padding: 1.5rem 1rem 1rem;
        min-height: 140px;
    }
    
    .card-header h2 {
        font-size: 1.5rem;
    }
    
    .sign-icon {
        width: 50px;
        height: 50px;
    }
    
    .horoscope-meta {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .meta-item {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
        padding: 0.75rem;
    }
    
    .card-actions {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .horoscope-preview {
        -webkit-line-clamp: 5;
        min-height: 100px;
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .horoscope-card {
        margin: 0;
        min-height: 400px;
    }
    
    .card-body,
    .card-footer {
        padding: 1rem;
    }
    
    .horoscope-preview {
        -webkit-line-clamp: 4;
        min-height: 80px;
        max-height: 120px;
        font-size: 0.95rem;
    }
    
    .meta-value {
        font-size: 1rem;
    }
    
    .btn-small {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}

/* ===== ANIMAZIONI EXTRA ===== */

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.horoscope-card.appear {
    animation: cardSlideIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Ritardo progressivo per effetto cascata */
.horoscope-card:nth-child(1) { animation-delay: 0ms; }
.horoscope-card:nth-child(2) { animation-delay: 100ms; }
.horoscope-card:nth-child(3) { animation-delay: 200ms; }
.horoscope-card:nth-child(4) { animation-delay: 300ms; }
.horoscope-card:nth-child(5) { animation-delay: 400ms; }
.horoscope-card:nth-child(6) { animation-delay: 500ms; }
.horoscope-card:nth-child(7) { animation-delay: 600ms; }
.horoscope-card:nth-child(8) { animation-delay: 700ms; }
.horoscope-card:nth-child(9) { animation-delay: 800ms; }
.horoscope-card:nth-child(10) { animation-delay: 900ms; }
.horoscope-card:nth-child(11) { animation-delay: 1000ms; }
.horoscope-card:nth-child(12) { animation-delay: 1100ms; }

/* ===== MIGLIORAMENTI ACCESSIBILITÀ ===== */

.horoscope-card:focus-within {
    outline: 3px solid rgba(107, 63, 160, 0.5);
    outline-offset: 2px;
}

.btn-small:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Riduce animazioni per utenti che preferiscono meno movimento */
@media (prefers-reduced-motion: reduce) {
    .horoscope-card,
    .btn-small,
    .meta-item,
    .sign-icon {
        transition: none;
        animation: none;
    }
    
    .horoscope-card.appear {
        opacity: 1;
        transform: none;
    }
}
