/* === CSS Variables: Kid-Friendly Palette === */
:root {
    --color-primary: #4A90D9;
    --color-secondary: #F5A623;
    --color-accent: #7ED321;
    --color-bg: #FFF8F0;
    --color-card-bg: #FFFFFF;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-border: #E8E8E8;
    --color-header-bg: #4A90D9;
    --color-header-text: #FFFFFF;
    --color-shadow: rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: 0.3s ease;
    --font-main: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Header === */
.site-header {
    background: linear-gradient(135deg, #4A90D9, #6BB9F0, #48C9B0);
    color: var(--color-header-text);
    text-align: center;
    padding: 2.5rem 1rem;
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: headerShimmer 8s ease-in-out infinite;
}

@keyframes headerShimmer {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(20px, 10px); }
}

.site-header h1 {
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
    position: relative;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.site-header .subtitle {
    font-size: 1.3rem;
    opacity: 0.9;
    position: relative;
}

/* === Main Content === */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* === Filters === */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #ffffff, #f8faff);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(74, 144, 217, 0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-light);
}

.filter-group select,
.filter-group input {
    padding: 0.6rem 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-main);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

/* === Age Buttons === */
.age-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.age-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 20px;
    background: #fff;
    font-size: 0.9rem;
    font-family: var(--font-main);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--color-text-light);
}

.age-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.age-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

/* === Results Info === */
.results-info {
    text-align: right;
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
    padding-right: 0.25rem;
}

/* === Flags Grid === */
.flags-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.flag-card {
    background: var(--color-card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
    color: var(--color-text);
    animation: cardFadeIn 0.5s ease forwards;
    opacity: 0;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flag-card:hover {
    transform: scale(1.05) translateY(-6px);
    box-shadow: 0 16px 40px rgba(74, 144, 217, 0.2), 0 8px 16px rgba(0, 0, 0, 0.1);
}

.flag-card:active {
    transform: scale(1.02);
}

.flag-card img {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    display: block;
    border-bottom: 3px solid var(--color-border);
    transition: filter var(--transition);
}

.flag-card:hover img {
    filter: brightness(1.05);
}

.flag-card .card-info {
    padding: 0.75rem;
    text-align: center;
}

.flag-card .card-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.15rem;
}

.flag-card .card-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

/* === No Results === */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-light);
}

.no-results-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.75rem;
}

.no-results p {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.no-results .no-results-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* === Footer === */
.site-footer {
    text-align: center;
    padding: 2.5rem 1rem;
    margin-top: 2rem;
    color: var(--color-text-light);
    font-size: 0.9rem;
    background: linear-gradient(180deg, transparent, rgba(74, 144, 217, 0.05));
    border-top: 1px solid var(--color-border);
}

.site-footer p {
    margin-bottom: 0.3rem;
}

.site-footer .footer-sub {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* === Country Page === */
.country-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, #4A90D9, #6BB9F0, #48C9B0);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.country-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: headerShimmer 8s ease-in-out infinite;
}

.country-flag {
    width: 120px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

.country-title-block {
    position: relative;
    z-index: 1;
}

.country-title-block h1 {
    font-size: 2.2rem;
    margin-bottom: 0.25rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.country-title-block .country-name-en {
    font-size: 1.1rem;
    opacity: 0.85;
    margin-bottom: 0.5rem;
}

.btn-sound {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 20px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-main);
}

.btn-sound:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.8);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    color: #fff;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all var(--transition);
    position: relative;
    z-index: 1;
}

.btn-back:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.8);
}

/* Photo Gallery */
.photo-gallery {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--color-card-bg);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px var(--color-shadow);
}

.photo-gallery h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--color-text);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.photo-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    cursor: pointer;
    transition: transform var(--transition);
}

.photo-item:hover {
    transform: scale(1.03);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-item .photo-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.4rem 0.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
}

/* Country Content Sections */
.country-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.country-age-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.country-age-selector label {
    font-weight: 600;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.content-section {
    background: var(--color-card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--color-primary);
    animation: sectionSlideIn 0.4s ease forwards;
    opacity: 0;
}

.content-section:nth-child(1) { animation-delay: 0s; }
.content-section:nth-child(2) { animation-delay: 0.08s; }
.content-section:nth-child(3) { animation-delay: 0.16s; }
.content-section:nth-child(4) { animation-delay: 0.24s; }
.content-section:nth-child(5) { animation-delay: 0.32s; }

@keyframes sectionSlideIn {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.content-section .section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.content-section .section-emoji {
    font-size: 1.5rem;
}

.content-section .section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-primary);
}

.content-section .section-text {
    line-height: 1.8;
    color: var(--color-text);
    font-size: 1rem;
}

/* === Age Group Transition === */
#sections-container {
    transition: opacity 0.3s ease;
}

#sections-container.fade-out {
    opacity: 0;
}

/* === Custom Audio Player === */
.section-audio-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #f0f4ff, #e8f0fe);
    border-radius: 24px;
    max-width: 400px;
}

.audio-play-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}

.audio-play-btn:hover {
    background: #3a7bc8;
    transform: scale(1.1);
}

.audio-play-btn.playing {
    background: var(--color-secondary);
}

.audio-progress-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.audio-progress-bar {
    width: 100%;
    height: 6px;
    background: #d0d8e8;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.audio-progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.audio-time {
    font-size: 0.7rem;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}

/* Name pronunciation button active state */
.btn-sound.playing {
    background: rgba(255,255,255,0.4);
    border-color: #fff;
}

/* Photo gallery enhancements */
.photo-gallery {
    animation: sectionSlideIn 0.4s ease forwards;
}

.photo-item {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.photo-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Country Footer */
.country-footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 1rem;
}

/* === Responsive === */
@media (max-width: 900px) {
    .flags-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .site-header h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 500px) {
    .flags-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .site-header h1 {
        font-size: 1.8rem;
    }

    .site-header {
        padding: 1.5rem 1rem;
    }

    .filters {
        flex-direction: column;
    }

    .age-buttons {
        justify-content: center;
    }

    .results-info {
        text-align: center;
    }

    .country-header {
        flex-direction: column;
        text-align: center;
    }

    .country-flag {
        width: 100px;
    }

    .country-title-block h1 {
        font-size: 1.6rem;
    }

    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
