/* General Body Styling */
*, *::before, *::after { box-sizing: border-box; }
body, html {
    height: 100vh; /* Fallback */
    min-height: 100vh;
    height: 100dvh; /* Use dynamic viewport to avoid mobile URL bar jump */
    min-height: 100dvh;
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: #f0f8ff; /* Light blue background */
    padding: clamp(8px, 2vh, 16px);
}

/* Container to center content */
.container {
    max-width: 960px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    padding-bottom: 2rem; /* Added distance from bottom */
    gap: clamp(4px, 1vh, 12px);
}

/* Header section (title + description) - takes up ~40% */
.container > div:first-child,
.container h1,
.container p {
    flex-shrink: 0;
}

/* Cards section - takes up ~60% */
.container .row {
    flex-grow: 1;
    align-content: center;
    /* Ensure the grid consumes remaining height without forcing scroll */
    max-height: 100%;
}

/* Tighter, responsive gutters for the card grid */
.container .row.g-3 {
    --bs-gutter-x: clamp(8px, 2vw, 1rem);
    --bs-gutter-y: clamp(6px, 1.2vh, 1rem);
}

/* So the last row doesn't add too much bottom margin */
/* Compress bottom margin applied via .mb-3 on columns */
.container .row > [class*="col-"] {
    margin-bottom: clamp(6px, 1.2vh, 16px) !important;
}

/* Card Styling */
.card {
    border: none;
    border-radius: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    height: clamp(100px, 16vh, 150px); /* Slightly smaller height */
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

.card-link {
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.card-body {
    padding: clamp(0.5rem, 1.2vw, 1rem); /* Reduced padding */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center;
    text-align: center;
    height: 100%;
}

.card-title {
    font-weight: 700;
    color: #333;
    font-size: clamp(0.9rem, 1.7vw, 1.1rem); /* Smaller font */
    margin-bottom: 0.25rem;
}

.card-text.small {
    font-size: clamp(0.7rem, 1.5vw, 0.9rem); /* Smaller font */
    line-height: 1.2;
    color: #666;
}

/* Language Button Styling */
.btn-outline-primary {
    border-color: #0d6efd;
    color: #0d6efd;
}

.btn-outline-primary.active, .btn-outline-primary:hover {
    background-color: #0d6efd;
    color: white;
}

/* Title and description mobile optimization */
h1 {
    font-size: clamp(1.1rem, 3.5vw, 2rem) !important;
    font-weight: 700;
}

p.fs-6 {
    font-size: clamp(0.92rem, 2.6vw, 1.2rem) !important;
    line-height: 1.4;
    color: #666;
}

/* Trim language bar spacing to save vertical space */
.container > .d-flex.mb-4 {
    margin-bottom: clamp(6px, 1.5vh, 12px) !important;
}

/* Responsive adjustments for larger screens */
@media (min-width: 768px) {
    .container {
        justify-content: flex-start;
        padding-top: clamp(12px, 2vh, 2rem);
    }
    
    .container .row {
        margin-top: clamp(4px, 1vh, 0.5rem);
    }

    .card {
        height: clamp(130px, 20vh, 190px);
    }

    .card:hover {
        transform: translateY(-8px);
    }

    .card-body {
        padding: clamp(1rem, 2vw, 2rem);
        justify-content: center;
    }

    .card-title {
        font-size: clamp(1.05rem, 1.6vw, 1.3rem);
    }

    .card-text.small {
        font-size: clamp(0.85rem, 1.4vw, 1rem);
    }
    /* Headings already clamp; no overrides needed */
}

@media (min-width: 992px) {
    .container {
        padding-top: clamp(16px, 2.5vh, 2.5rem);
    }
    
    .container .row {
        margin-top: 0rem;
    }
    
    .card {
        height: clamp(140px, 22vh, 220px);
    }
}

@media (min-width: 1200px) {
    .container {
        padding-top: clamp(18px, 3vh, 3rem);
        max-height: 95dvh;
    }
}

/* Ensure no accidental page scrollbars due to 1px rounding */
body { overflow: hidden; }

@media (max-width: 576px) {
    /* Move the card grid slightly upward */
    .container {
        padding-top: 4px;
    }

    /* Make cards taller on mobile */
    .card {
        height: clamp(150px, 30vh, 240px);
    }

    /* Enlarge visuals and nudge content toward the top */
    .card-body {
        padding-top: 0.4rem;   /* less top padding to move content up */
        padding-bottom: 0.8rem;
    }

    .card-title {
        font-size: clamp(1.05rem, 4.2vw, 1.3rem);
        margin-bottom: clamp(0.35rem, 1.6vh, 0.6rem);
    }

    .card-text.small {
        font-size: clamp(0.9rem, 3.6vw, 1.1rem);
        line-height: 1.35;
    }
}
