body {
    margin: 0;
    font-family: Georgia, serif;
    background: #ffffff;
    color: #333;
    line-height: 1.6;
}

/* Header */
header {
    text-align: center;
    padding: 60px 20px 30px;
    background: #f5ecff;
}

header h1 {
    font-size: 42px;
    margin-bottom: 5px;
    color: #5a2ea6;
}

header h2 {
    font-weight: 300;
    color: #7a4ac9;
    font-size: 20px;
}

/* Container */
.container {
    max-width: 1200px;  /* 3 cards (315px) + 2 gaps (25px each) = 680 + 50 = 995px; 1025 for padding */
    margin: 0 auto;     /* center container */
    padding: 20px;
}

/* SEARCH + CATEGORY FILTER SECTION */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
}
.controls input {
    flex: 0 0 600px; /* increase width */
}

/* Make category filter smaller */
.controls select {
    flex: 0 0 180px; /* smaller width */
}
input, select {
    padding: 10px;
    border: 2px solid #c8a9ff;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    background: white;
    color: #3b0a57;
}

input::placeholder {
    color: #9a7bbf;
}

/* Desktop / default styles */
.articles-grid {
    display: grid;
    gap: 35px; /* keep space between cards */
    grid-template-columns: repeat(3, 315px); /* fixed width */
    justify-content: center; /* center cards in container */
}
.article-card {
    width: 315px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 580px;       /* fixed card height */
    padding: 20px;
    border: 1px solid #e4d6ff;
    border-radius: 8px;
    background: #faf5ff;
    transition: 0.3s ease;
    position: relative;
}
.article-card .category-badge {
    position: absolute;
    top: 15px;     /* aligns with card padding */
    left: 15px;
    background-color: #e6d6ff;  /* light purple */
    color: #5a2ea6;
    font-size: 12px;
    font-weight: 600;
    padding: 0.5px 3px;
    border-radius: 4px;
    text-transform: uppercase;
}
.article-card:hover { 
    background: #f1e6ff; 
    border-color: #b38bff; 
}
.article-card h3 {
    font-size: 22px;
    line-height: 1.3;
    margin-bottom: 10px;
    font-family: "Merriweather", serif;
    color: #5a2ea6;

    flex-shrink: 0;        /* never shrink — title always visible */
}

.article-card h4 {
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 20px;
    color: #444;
    font-weight: normal;

    flex-shrink: 1;        /* allow shrinking if title takes more space */
    flex-grow: 1;          /* fill remaining space */
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6; /* max lines of abstract — adjust as needed */
    text-overflow: ellipsis;
}

.article-card p {
    margin-top: auto;      /* pushes button to bottom */
    margin-bottom: 20px;
    font-size: 16px;
    color: #555;
}

.btn {
    display: inline-block;      /* natural width */
    width: auto;                /* don't stretch */
    max-width: fit-content;     /* ensure it fits text + padding */
    padding: 10px 20px;         /* purple area around text */
    background-color: #7b3fe4;  
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 16px;
    white-space: nowrap;        /* prevent wrapping */
    box-sizing: border-box;
    align-self: flex-start;     /* only affects flex parents */
}

.btn:hover {
    background: #5a2ea6;
}

/* Footer */
footer {
    text-align: center;
    padding: 25px 0;
    margin-top: 40px;
    border-top: 1px solid #e4d6ff;
    color: #6b44b8;
    font-size: 15px;
    background: #faf5ff;
}
/* Tablet / medium screens: 2 cards per row */
@media (max-width: 800px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
        justify-items: center;
    }
    .article-card {
        width: 90%;
    }
    #searchBar {
        width: 90%;
    }
}

/* Mobile / small screens: 1 card per row */
@media (max-width: 480px) {
    .articles-grid {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .article-card {
        width: 95%;
    }
    #searchBar {
        width: 95%;
    }
}

/* Tablet (≤ 800px): stack neatly but keep good spacing */
@media (max-width: 800px) {
    .controls {
        justify-content: center;
        gap: 10px;
    }

    .controls input {
        flex: 1 1 100%;
        max-width: 600px;
    }

    .controls select {
        flex: 0 0 40%;
        max-width: 200px;
    }
}

/* Mobile (≤ 480px): full width */
@media (max-width: 480px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls input {
        width: 100%;
        flex: none;
    }

    .controls select {
        width: 100%;
        flex: none;
    }
}
