/* Professional KJC Layout - Based on Next.js/Tailwind Design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    /* Safari/iOS compatibility */
    -moz-box-sizing: border-box;
    /* Firefox compatibility */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 50%, #f0fdfa 100%);
    min-height: 100vh;
    color: #1f2937;
    line-height: 1.5;
}

/* KJC Title Section */
.kjc-title {
    margin: 2rem 0;
    padding: 1rem;
}

.kjc-title-text {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
    display: inline-block;
}

.kjc-title-text span:nth-child(1) {
    color: #FF6A00;
    /* K - Orange */
}

.kjc-title-text span:nth-child(2) {
    color: #0095F9;
    /* J - Blue */
}

.kjc-title-text span:nth-child(3) {
    color: #009532;
    /* C - Green */
}

/* Main Container */
.main-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* gap: 1.5rem; */
    background-image: url('/assets/kjc-bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Logo Section */
.logo-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    padding: 2rem 0;
}

.logo-container {
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
}

.kjc-logo {
    width: 100%;
    height: auto;
    max-width: 686px;
    color: transparent;
}

/* Countries Backdrop Section */
.countries-backdrop {
    /* background-color: rgba(107, 114, 128, 0.3); */
    /* backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px); */
    padding: 1.25rem 0;
}

.countries-section {
    display: flex;
    overflow: hidden;
    position: relative;
    flex-direction: column;
    grid-column: span 1;
    gap: 2.5rem;
    justify-content: space-between;
    align-items: center;
}

.countries-container {
    display: flex;
    flex-direction: column;
    position: relative;
    justify-content: center;
    align-items: center;
}

/* Countries Grid */
.countries-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    /* Better support than space-evenly */
    align-items: center;
    /* Fallback for older browsers that don't support gap */
    margin: -6px -28px;
    /* Negative margin to offset padding */
}

/* Modern browsers with gap support */
@supports (gap: 1rem) {
    .countries-grid {
        gap: 0.75rem 3.5rem;
        margin: 0;
        /* Reset margin when gap is supported */
    }
}

.countries-grid article {
    flex: 0 0 auto;
    /* Fallback spacing for older browsers */
    padding: 6px 28px;
    /* Half of the gap values converted to px */
    margin-bottom: 12px;
    /* Additional vertical spacing */
}

.countries-grid a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.country-figure {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    width: 87px;
    height: 125px;
    margin: 0;
    transition: transform 0.3s ease;
    /* Fallback for browsers without gap support */
    padding: 0;
}

/* Fallback spacing for older browsers */
.country-figure>*+* {
    margin-top: 12px;
    /* 0.75rem fallback */
}

/* Modern browsers with gap support */
@supports (gap: 1rem) {
    .country-figure>*+* {
        margin-top: 0;
        /* Reset margin when gap is supported */
    }
}

.country-figure:hover {
    transform: scale(1.05);
}

.country-flag {
    width: 87px;
    height: 87px;
    border-radius: 50%;
    object-fit: cover;
    color: transparent;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); */
    transition: box-shadow 0.3s ease;
}

.country-flag:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.country-caption {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    color: #000000;
    margin: 0;
}

/* Footer Sections */
.footer-section {
    display: flex;
    position: relative;
    flex-direction: column;
    grid-column: span 1;
    align-items: center;
    padding-bottom: 1.25rem;
}

.footer-image-container {
    max-width: 48rem;
    margin: 0 auto;
}

.kjc-footer-image {
    width: 100%;
    height: auto;
    color: transparent;
}

/* Contact Section */
.contact-section {
    display: flex;
    position: relative;
    flex-direction: column;
    grid-column: span 1;
    align-items: center;
}

.contact-container {
    width: auto;
    max-width: 250px;
    margin: 0 auto;
}

.contact-container a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.kjc-title {
    font-size: 3rem;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
    margin-bottom: 1rem;
}


.contact-image {
    width: 100%;
    height: auto;
    color: transparent;
    transition: transform 0.3s ease;
}

.contact-image:hover {
    transform: translateY(-2px);
}

/* Copyright Footer */
.copyright-footer {
    padding: 1.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.copyright-text {
    text-align: center;
    color: #374151;
    font-size: 1.2rem;
    font-weight: 400;
    opacity: 0.8;
    font-family: math;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 639px) {
    .kjc-title-text {
        font-size: 2.2rem;
        font-size: 35px;
        /* Fallback for older browsers */
    }

    .kjc-title {
        margin: 1.5rem 0;
        margin: 24px 0;
        /* Fallback */
        padding: 0.5rem;
        padding: 8px;
        /* Fallback */
    }

    /* Ensure proper spacing on very small/old devices */
    .countries-grid {
        justify-content: center;
        /* Center items on small screens */
        margin: -3px -14px;
        /* Smaller negative margins */
    }

    .countries-grid article {
        padding: 3px 14px;
        /* Smaller padding */
        margin-bottom: 6px;
        /* Smaller vertical spacing */
    }

    /* Reset for modern browsers */
    @supports (gap: 1rem) {
        .countries-grid {
            gap: 0.5rem 3.5rem;
            /* Smaller gap on mobile */
            margin: 0;
        }

        .countries-grid article {
            padding: 0;
            margin-bottom: 0;
        }
    }
}

/* Specific fixes for very old mobile devices */
@media screen and (max-width: 480px) {
    .countries-grid {
        display: -webkit-box;
        /* Old flexbox syntax */
        display: -webkit-flex;
        /* Webkit flexbox */
        display: -ms-flexbox;
        /* IE10 flexbox */
        display: flex;
        /* Modern flexbox */
        -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
        -webkit-justify-content: center;
        -ms-flex-pack: center;
        justify-content: center;
        text-align: center;
        /* Additional centering for inline elements */
    }


    /* .country-flag {
        width: 72px;
        height: 72px;
    } */

    @supports (gap: 1rem) {
        .countries-grid {
            gap: 0.5rem 1.5rem;
            margin: 0;
        }
    }

    .countries-grid article {
        display: inline-block;
        /* Fallback for very old browsers */
        vertical-align: top;
        margin: 6px 8px;
        /* Simple margin-based spacing */
        text-align: center;
    }

    /* Ensure minimum spacing between items */
    .country-figure {
        margin: 8px auto;
        display: block;
        /* Fallback display */
        text-align: center;
    }

    .country-flag {
        display: block;
        margin: 0 auto 8px auto;
        /* Center and add bottom margin */
    }

    .country-caption {
        display: block;
        text-align: center;
        margin-top: 4px;
    }
}

/* Ultra small devices - 400px and below */
@media screen and (max-width: 400px) {
    .kjc-title-text {
        font-size: 1.8rem;
        font-size: 28px;
        /* Fallback for older browsers */
    }

    .kjc-title {
        margin: 1rem 0;
        margin: 16px 0;
        /* Fallback */
        padding: 0.25rem;
        padding: 4px;
        /* Fallback */
    }

    .countries-grid {
        display: -webkit-box;
        /* Old flexbox syntax */
        display: -webkit-flex;
        /* Webkit flexbox */
        display: -ms-flexbox;
        /* IE10 flexbox */
        display: flex;
        /* Modern flexbox */
        -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
        -webkit-justify-content: center;
        -ms-flex-pack: center;
        justify-content: center;
        text-align: center;
        margin: -2px -6px;
        /* Very small negative margins */
    }

    .countries-grid article {
        display: inline-block;
        /* Fallback for very old browsers */
        vertical-align: top;
        margin: 2px 6px;
        /* Minimal margin-based spacing */
        text-align: center;
        padding: 0;
        /* Remove padding to save space */
    }

    /* Smaller country figures for ultra small screens */
    .country-figure {
        width: 70px;
        height: 100px;
        margin: 4px auto;
        display: block;
        /* Fallback display */
        text-align: center;
    }

    .country-flag {
        width: 87px;
        height: 87px;
        display: block;
        margin: 0 auto 6px auto;
        /* Center and add bottom margin */
    }

    .main-container {
        padding: 8px;
        /* gap: 1.5rem; */
        /* Fallback */
    }

    .country-caption {
        font-size: 0.8rem;
        font-size: 12px;
        /* Fallback */
        display: block;
        text-align: center;
        margin-top: 2px;
        line-height: 1.2;
    }

    /* Reduce container padding */
    .countries-backdrop {
        padding: 0.75rem 0;
        padding: 12px 0;
        /* Fallback */
    }

    /* Ensure content fits in very small screens */
    .container {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Reset for modern browsers with gap support */
    @supports (gap: 1rem) {
        .countries-grid {
            gap: 0.25rem 2rem;
            /* Very small gap */
            margin: 0;
        }

        .countries-grid article {
            padding: 0;
            margin: 0;
        }
    }
}

@media (min-width: 640px) {
    .countries-backdrop {
        padding: 2.5rem 0;
    }

    .country-figure {
        width: 137px;
        height: 183px;
    }

    .country-flag {
        width: 137px;
        height: 137px;
    }

    .country-caption {
        font-size: 1.25rem;
    }

    .logo-container {
        width: auto;
    }
/* 
    .main-container {
        gap: 1.5rem;
    } */

    .footer-section {
        padding-bottom: 2rem;
    }

    .kjc-title-text {
        font-size: 4rem;
    }
}

@media (min-width: 768px) {
    .countries-section {
        grid-column: span 2;
    }
}

@media (min-width: 1280px) {
    .countries-section {
        grid-column: span 8;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus states for accessibility */
a:focus,
button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Loading animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.countries-grid article {
    animation: fadeIn 0.6s ease forwards;
}

.countries-grid article:nth-child(1) {
    animation-delay: 0.1s;
}

.countries-grid article:nth-child(2) {
    animation-delay: 0.2s;
}

.countries-grid article:nth-child(3) {
    animation-delay: 0.3s;
}

.countries-grid article:nth-child(4) {
    animation-delay: 0.4s;
}

.countries-grid article:nth-child(5) {
    animation-delay: 0.5s;
}