/*
 * main_styles.css
 * Korjattu asettelu: Top 10 oikealle, Hero keskelle.
 */

/* --- PERUSNOLLAUS JA YLEISET TYYLIT --- */
*, *::before, *::after {
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    padding: 0; 
}
h1, h2, h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.2;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
p { margin-bottom: 1.5rem; color: #555; }
a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}
a:hover { color: #2980b9; }

/* --- KONTTI JA HEADERI --- */
.container {
    max-width: 1200px;
    margin: 20px auto;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    
    position: static; 
}
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
}
nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}
nav li {
    margin-left: 1.5rem;
}
.user-greeting {
    font-weight: 600;
    color: #2c3e50;
    margin-left: 1.5rem;
}

/* --- HERO-SEKTIO (KESKITYS) --- */
.hero {
    padding: 4rem 0;
    text-align: center;
    padding-left: 0; 
    
    background-image: url('/static/images/background.png'); 
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center; 
    min-height: 250px; 
}
.hero h1 {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}
.hero p {
    font-size: 1.2rem;
    color: #777;
    margin-bottom: 2rem;
}
.button {
    display: inline-block;
    padding: 12px 24px;
    background-color: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}
.button:hover {
    background-color: #2980b9;
}

/* --- FLASH-VIESTIT --- */
.flash-messages {
    position: static; 
    margin-top: 15px;
    max-width: 100%;
    margin-left: auto; 
    margin-right: auto;
    text-align: center;
}
.flash-messages .alert {
    display: inline-block; 
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    animation: fadeIn 0.5s ease-in-out;
    margin-bottom: 10px;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =======================================
   --- PÄÄSISÄLLÖN ASETTELU (TOP 10 SIVULLE) ---
   ======================================= */

.main-content-layout {
    display: flex; 
    gap: 30px; 
    padding: 20px 0; 
    margin: 20px 0 0 0; 
    align-items: flex-start;
}

/* Tietopankki-osio */
.features {
    flex-grow: 1;
    min-width: 0; 
    padding: 0; 
    margin: 0; 
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 2rem;
    margin-top: 3rem;
}

.card {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}

/* TOP 10 LISTAN TYYLIT (10cm ylös ja kapeampi) */
.top10-ranking {
    /* KRITIIKKI: Nosta 10cm ylöspäin (noin 100px) negatiivisella marginaalilla */
    margin-top: -400px;
    
    flex-grow: 0;
    flex-basis: auto; 
    flex-shrink: 0; 
    
    width: 200px; 
    min-width: 200px;
    
    position: static; 
    
    background-color: #f7f7f7; 
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 1; 
}

.top10-ranking h2 {
    color: #007bff; 
    margin-top: 0;
    font-size: 1.0em; 
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
}

.ranking-list {
    list-style: none;
    padding: 0;
}

.ranking-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 0; 
    border-bottom: 1px dashed #ccc;
    font-size: 0.7em; 
    align-items: center;
}

.ranking-list li:last-child {
    border-bottom: none;
}

.ranking-name {
    font-weight: bold;
}

.ranking-count {
    color: #28a745; 
    font-weight: 600;
    font-size: 0.9em;
}


/* --- FOOTER --- */
footer {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid #eee;
    background-color: #fff;
    color: #777;
    font-size: 0.9rem;
}

/* --- MEDIAKYSYELYT (RESPONSIIVISUUS) --- */
@media (max-width: 900px) {
    .main-content-layout {
        flex-direction: column; 
        gap: 20px;
    }
    .top10-ranking {
        /* Nollaa ylösnosto mobiilissa, jotta se pysyy normaalissa virrassa */
        margin-top: 0; 
        order: -1; 
        width: auto; 
        min-width: auto;
    }
    .features .grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px; 
    }
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    nav ul {
        margin-top: 1rem;
        flex-direction: column;
    }
    nav li {
        margin-left: 0;
        margin-bottom: 0.5rem;
    }
    .grid {
        grid-template-columns: 1fr;
    }
}