* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #1F2937;
    background-color: #F8FAFC;
}


main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    width: 90%;
    max-width: 1000px;
    margin: 24px auto;
    text-align: left;
}

section {
    padding: 28px;
    background-color: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

section h2 {
    margin-top: 0;
    color: #B91C1C;
}

.intro{
    color: #B91C1C;
}

.intro h2 {
    margin-bottom: 12px;
    font-size: 2rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #B91C1C;
}

.intro p:last-child {
    margin: 0;
    line-height: 1.8;
    color: #374151;
    text-align: justify;
    font-family: Arial, Helvetica, sans-serif;
}

.gallery-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.gallery {
    display: flex;              
    flex-wrap: wrap;            
    justify-content: center;      
    align-items: stretch;      
    gap: 20px;  
}

.gallery-item {
    flex: 0 1 calc((100% - 40px) / 3);
    display: flex;
    flex-direction: column;
    background-color: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    text-align: center;
}

.gallery-item img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;           
    height: auto;
    object-fit: contain;         
    object-position: center;
    background-color: #F3F4F6;     
    text-align: center;
}

.gallery-caption {
    flex: 1;                      
    padding: 14px 16px 18px;
    border-top: 3px solid #B91C1C; 
    font-size: 0.92rem;
    line-height: 1.5;
    color: #4B5563;
    text-align: center;
}

.gallery-caption strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1.05rem;
    color: #1F2937;
    text-align: center;
}

footer {
    margin-top: 24px;
    padding: 24px 20px;
    background-color: #1F2937;
    color: #F8FAFC;
    text-align: center;
}

footer p {
    margin: 4px 0;
}

@media (min-width: 901px) {
    .gallery-item:nth-child(-n+4) {
        flex-basis: calc((100% - 20px) / 2);
    }
}

@media (max-width: 900px) {
    .gallery-item {
        flex-basis: calc((100% - 20px) / 2);
    }
}

@media (max-width: 560px) {
    section {
        padding: 20px;
    }

    .intro h2 {
        font-size: 1.5rem;
    }

    .gallery-item {
        flex-basis: 100%;
    }
}

@media (min-width: 768px) {

    .profile {
        flex-direction: row;
        text-align: left;
    }

    .content-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .profile,
    .about,
    #about,
    #academic,
    #contact {
        grid-column: 1 / -1;
    }
    
    @media (min-width: 768px) {
    .intro p:last-child {
        text-align: justify;
    }
}
}
