/* 
   UPSC Articles (ua.php) – Smart Reading Zone
   Designed for CarpeDiem IAS | High Readability | Fully Responsive
*/

/* === Base Reset & Body === */
body {
    background-color: #ffffff;
    margin: 0;
    padding: 0;
    font-family: "Poppins", "Inter", "Segoe UI", system-ui, sans-serif;
    color: #222222;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Main Content Container === */
main.content-container {
    max-width: 880px;
    min-height: 350px;
    margin: 90px auto 70px;
    padding: 0 20px;
    position: relative;
    top: -80px;
}

/* === Page Title === */
h1.page-title {
    font-weight: 800;
    font-size: 2.1rem;
    text-align: center;
    margin: 120px 0 24px;
    letter-spacing: 0.08em;
    background: linear-gradient(90deg, #4a6fa5, #3b8d99);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    user-select: none;
    text-transform: uppercase;
    line-height: 1.2;
}

h1.page-title span {
    color: #950e47;
    background: none !important;
    -webkit-text-fill-color: initial !important;
    font-weight: 800;
}

/* === Filter Wrapper: Topic Selector + Search === */
.filter-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 24px 0 36px;
    justify-content: center;
    align-items: center;
}

#topicSelector,
#articleSearch {
    padding: 11px 16px;
    font-size: 1.02rem;
    border: 2px solid #4a6fa5;
    border-radius: 10px;
    outline: none;
    transition: all 0.3s ease;
    min-width: 240px;
    max-width: 340px;
    background-color: #ffffff;
    color: #222;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

#topicSelector:focus,
#articleSearch:focus {
    border-color: #e54926;
    box-shadow: 0 0 0 3px rgba(229, 73, 38, 0.15);
}

#topicSelector:hover,
#articleSearch:hover {
    border-color: #3b8d99;
}

/* === Articles Grid === */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 12px;
}

/* === Article Card === */
.article-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    padding: 22px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 170px;
    transition: all 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 1px solid #f0f4f8;
}

.article-card:hover,
.article-card:focus {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    transform: translateY(-4px);
    outline: none;
    border-color: #e0e8f0;
}

.article-card h3 {
    margin: 0 0 16px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #2e5c8c;
    line-height: 1.35;
    word-break: break-word;
    hyphens: auto;
}

.article-card p {
    margin: 0;
    font-size: 0.95rem;
    color: #444;
    line-height: 1.6;
    flex-grow: 1;
    overflow: hidden;
    text-justify: inter-word;
}

.article-card a.read-more {
    margin-top: 16px;
    font-weight: 700;
    font-size: 0.92rem;
    color: #e54926;
    text-decoration: none;
    user-select: none;
    align-self: flex-start;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.article-card a.read-more::after {
    content: "→";
    margin-left: 4px;
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.article-card a.read-more:hover,
.article-card a.read-more:focus {
    color: #222;
    text-decoration: none;
    outline: none;
}

.article-card a.read-more:hover::after {
    transform: translateX(3px);
}

/* === Pagination === */
.pagination {
    max-width: 880px;
    margin: 36px auto 70px;
    text-align: center;
    user-select: none;
    padding: 0 20px;
}

.pagination button {
    background: #4a6fa5;
    border: none;
    color: white;
    font-weight: 700;
    margin: 0 6px 8px 0;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 44px;
    font-size: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.pagination button:hover,
.pagination button:focus {
    background-color: #3b8d99;
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.pagination button.active {
    background-color: #e54926;
    box-shadow: 0 3px 6px rgba(229, 73, 38, 0.25);
}

.pagination button[disabled] {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === Full Article Display === */
.article-display {
    max-width: 880px;
    margin: 50px auto 90px;
    padding: 40px 32px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.07);
    font-family: "Poppins", "Inter", sans-serif;
    color: #1a1a1a;
    line-height: 1.85;
    width: 100%;
    box-sizing: border-box;
    font-size: 1.05rem;
}

.article-display h2,
.article-display h3,
.article-display h4 {
    margin-top: 40px;
    margin-bottom: 16px;
    color: #2e5c8c;
    line-height: 1.3;
    font-weight: 700;
}

.article-display h2 {
    font-size: 1.6rem;
    margin-top: 50px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f4f8;
}

.article-display p {
    font-size: 1.05rem;
    margin-bottom: 22px;
    text-align: justify;
    letter-spacing: 0.02em;
    color: #222;
    hyphens: auto;
}

.article-display a {
    color: #1565c0;
    text-decoration: underline;
    font-weight: 600;
}

.article-display a:hover,
.article-display a:focus {
    color: #e54926;
    outline: none;
    text-decoration: none;
}

/* === Tables in Articles === */
.article-display table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 1rem;
    background: #fafafa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.article-display th,
.article-display td {
    border: 1px solid #ddd;
    padding: 12px 16px;
    text-align: left;
    vertical-align: top;
}

.article-display th {
    background-color: #f2f7ff;
    color: #2e5c8c;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

/* === Scrollbars === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: #aaa;
    border-radius: 6px;
}

::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.article-display table::-webkit-scrollbar {
    height: 8px;
}

.article-display table::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

/* Back button styling – Final */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: #F00017;
    color: white !important;
    border-radius: 8px;
    text-decoration: none !important; /* 🔴 Critical: prevent underline */
    font-weight: 600;
    font-size: 1.02rem;
    user-select: none;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(240, 0, 23, 0.25);
    border: 2px solid transparent;
    font-family: "Poppins", "Segoe UI", sans-serif;
}

.back-button:hover,
.back-button:focus {
    background-color: #c80013;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 0, 23, 0.35);
    outline: none;
    text-decoration: none !important; /* 🔴 Also enforce on hover/focus */
}

/* Prevent any child elements from causing underline */
.back-button *,
.back-button::before {
    text-decoration: none !important;
}
/* === Responsive Design === */

@media (max-width: 768px) {
    main.content-container {
        margin: 70px auto 50px;
        padding: 0 16px;
        top: -70px;
    }

    h1.page-title {
        font-size: 1.8rem;
        margin: 100px 0 20px;
        letter-spacing: 0.05em;
    }

    .filter-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    #topicSelector,
    #articleSearch {
        min-width: 100%;
        max-width: 100%;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .article-card {
        padding: 20px;
        min-height: auto;
    }

    .article-card h3 {
        font-size: 1.1rem;
    }

    .article-display {
        margin: 40px 16px 70px;
        padding: 30px 20px;
        font-size: 1rem;
    }

    .article-display h2 {
        font-size: 1.45rem;
        margin-top: 40px;
    }

    .article-display p {
        font-size: 1rem;
        margin-bottom: 20px;
    }

    .pagination {
        margin: 30px auto 60px;
        padding: 0 16px;
    }

    .pagination button {
        padding: 9px 14px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    main.content-container {
        margin: 20px 8px 30px !important;
        padding: 0 12px !important;
        top: -50px;
    }

    h1.page-title {
        font-size: 1.6rem;
        margin: 80px 0 18px;
    }

    .articles-grid {
        gap: 18px;
    }

    .article-card {
        padding: 18px;
    }

    .article-card h3 {
        font-size: 1.05rem;
        margin-bottom: 14px;
    }

    .article-card p {
        font-size: 0.92rem;
        line-height: 1.65;
    }

    .pagination {
        margin: 24px 8px !important;
    }

    .pagination button {
        padding: 8px 12px;
        min-width: 36px;
        margin: 0 4px 6px 0;
        font-size: 0.9rem;
    }

    .article-display {
        margin: 24px 10px !important;
        padding: 22px 16px !important;
        font-size: 0.98rem;
        line-height: 1.75;
    }

    .article-display h2 {
        font-size: 1.35rem;
        margin-top: 32px;
    }

    .article-display p {
        font-size: 0.96rem;
        margin-bottom: 18px;
    }

    .article-display table {
        font-size: 0.92rem;
    }

    .article-display th,
    .article-display td {
        padding: 10px 12px;
    }
}