/* Predictable sizing prevents padding/borders from increasing element width. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: clip;
}

html,
body,
button,
input,
select,
textarea {
    font-family: 'Inter', sans-serif;
}

body {
    min-height: 100vh;
    font-weight: 400;
    color: var(--text-primary, #252743);

    /* Keep the lavender background fixed to the viewport while content scrolls. */
    background:
        radial-gradient(
            circle at 50% 0%,
            rgba(255,255,255,0.95) 0%,
            rgba(225,222,255,0.65) 34%,
            transparent 68%
        ),
        linear-gradient(
            145deg,
            #e5e4fc,
            #dcdafb 55%,
            #e9e8ff
        );
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
    background-attachment: fixed;
    background-color: #e5e4fc;
}

/* ============================================================
DERAGLE THEME VARIABLES
Only variables used by Study Page
============================================================ */

:root {
    --text-primary: hsl(235 42% 18%);
    --text-secondary: hsl(235 28% 38%);
    --text-muted: hsl(235 22% 52%);

    --brand-text: hsl(242 52% 48%);

    --primary: hsl(228 65% 55%);

    --gradient-btn:
        linear-gradient(
            135deg,
            hsl(228 70% 55%),
            hsl(260 60% 60%)
        );
}


/* ============================================================
DERAGLE — STUDY PAGE
Lavender Glass Theme
============================================================ */

.study-page {
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0 20px 50px;
    overflow-x: clip;
}


/* HEADER */

.study-header {
    max-width: 1050px;
    margin: auto;
    min-height: 76px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid rgba(255,255,255,0.55);
}

.study-brand {
    display: flex;
    align-items: center;
    gap: 10px;

    color: var(--brand-text, #5964e8);
    font-size: 21px;
    font-weight: 750;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.brand-mark {
    width: 34px;
    height: 34px;

    display: grid;
    place-items: center;

    color: white;
    font-size: 19px;
    font-weight: 800;

    border-radius: 11px;
    /* background: var(--gradient-btn, linear-gradient(135deg, #5964e8, #7657e8)); */

    border: 1px solid var(--gradient-btn);

    overflow: hidden;
    box-shadow: 0 5px 13px rgba(89,100,232,0.20);
}

.study-header-label {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 8px 14px;

    color: var(--text-secondary, #555b80);
    font-size: 13px;
    font-weight: 650;

    background: rgba(255,255,255,0.42);
    border: 1px solid rgba(255,255,255,0.65);
    border-radius: 30px;
}

.header-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6d67e8;
}


/* MAIN CONTAINER */

.study-container {
    max-width: 850px;
    margin: 0 auto;
}


/* INTRO */

.study-intro {
    padding: 65px 0 34px;
    text-align: center;
}

.study-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    padding: 7px 13px;

    color: var(--brand-text, #5964e8);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.3px;

    background: rgba(255,255,255,0.48);
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: 30px;
}

.eyebrow-icon {
    font-size: 13px;
}

.study-intro h1 {
    margin: 20px 0 12px;

    color: var(--text-primary, #252743);
    font-size: clamp(30px, 5vw, 43px);
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -1.5px;
}

.study-intro h1 span {
    color: var(--brand-text, #5964e8);
}

.study-intro p {
    max-width: 510px;
    margin: auto;

    color: var(--text-secondary, #555b80);
    font-size: 14px;
    line-height: 1.75;
}


/* FINDER CARD */

.finder-card {
    padding: 27px;

    background: rgba(255,255,255,0.57);
    border: 1px solid rgba(255,255,255,0.82);
    border-radius: 23px;

    box-shadow:
        0 15px 40px rgba(70,76,140,0.09),
        inset 0 1px 0 rgba(255,255,255,0.8);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.finder-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    margin-bottom: 25px;
}

.finder-heading h2 {
    margin: 0 0 5px;

    color: var(--text-primary, #252743);
    font-size: 20px;
    font-weight: 750;
}

.finder-heading p {
    margin: 0;

    color: var(--text-muted, #777b9b);
    font-size: 12px;
}

.board-badge {
    padding: 8px 13px;

    color: var(--brand-text, #5964e8);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;

    background: rgba(89,100,232,0.09);
    border: 1px solid rgba(89,100,232,0.16);
    border-radius: 10px;
}


/* FILTERS */

.finder-form {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr) minmax(0, 0.9fr) auto;
    min-width: 0;
    align-items: end;
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.filter-group label {
    color: var(--text-secondary, #555b80);
    font-size: 12px;
    font-weight: 700;
}

.filter-group select,
.filter-group input {
    width: 100%;
    max-width: 100%;
    height: 46px;
    min-width: 0;

    padding: 0 12px;

    color: var(--text-primary, #252743);
    font-family: inherit;
    font-size: 13px;
    font-weight: 550;

    background: rgba(255,255,255,0.68);
    border: 1px solid rgba(120,117,190,0.18);
    border-radius: 11px;
    outline: none;

    transition: 0.2s ease;
}

.filter-group select {
    cursor: pointer;
}

.filter-group input::placeholder {
    color: var(--text-muted, #8588a5);
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: rgba(89,100,232,0.55);
    box-shadow: 0 0 0 3px rgba(89,100,232,0.08);
    background: rgba(255,255,255,0.9);
}


/* SEARCH BUTTON */

.search-button {
    height: 46px;
    padding: 0 17px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    color: white;
    font-family: inherit;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;

    background: var(--gradient-btn, linear-gradient(135deg, #5964e8, #7657e8));
    border: none;
    border-radius: 11px;

    cursor: pointer;
    box-shadow: 0 6px 15px rgba(89,76,220,0.20);

    transition: 0.2s ease;
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 9px 19px rgba(89,76,220,0.27);
}

.search-button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

.search-arrow {
    font-size: 17px;
}


/* FINDER NOTE */

.finder-note {
    display: flex;
    align-items: center;
    gap: 7px;

    margin-top: 17px;

    color: var(--text-muted, #777b9b);
    font-size: 11px;
}


/* RESULTS */

.results-section {
    margin-top: 42px;
}

.results-header {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    margin-bottom: 17px;
}

.results-header h2 {
    margin: 0 0 5px;

    color: var(--text-primary, #252743);
    font-size: 19px;
    font-weight: 750;
}

.results-header p {
    margin: 0;

    color: var(--text-muted, #777b9b);
    font-size: 12px;
}

.results-count {
    padding: 7px 11px;

    color: var(--brand-text, #5964e8);
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;

    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.78);
    border-radius: 30px;
}


/* RESULT CARD */

.results-container {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.paper-card {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    padding: 17px 19px;

    background: rgba(255,255,255,0.61);
    border: 1px solid rgba(255,255,255,0.82);
    border-radius: 16px;

    box-shadow: 0 6px 18px rgba(70,76,140,0.055);

    transition: 0.2s ease;
}

.paper-card:hover {
    transform: translateY(-2px);
    border-color: rgba(126,112,230,0.35);
    box-shadow: 0 10px 23px rgba(70,76,140,0.10);
}

.paper-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

.paper-subject {
    margin: 0 0 9px;

    color: var(--text-primary, #252743);
    font-size: 15px;
    font-weight: 750;
}

.paper-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.paper-meta span {
    padding: 5px 9px;

    color: var(--text-secondary, #555b80);
    font-size: 10px;
    font-weight: 650;

    background: rgba(89,100,232,0.07);
    border: 1px solid rgba(89,100,232,0.10);
    border-radius: 7px;
}

.paper-year {
    color: var(--brand-text, #5964e8) !important;
    background: rgba(89,100,232,0.12) !important;
}

.view-paper-button {
    flex-shrink: 0;

    padding: 10px 14px;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: var(--brand-text, #5964e8);
    font-size: 11px;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;

    background: rgba(255,255,255,0.65);
    border: 1px solid rgba(89,100,232,0.20);
    border-radius: 10px;

    transition: 0.2s ease;
}

.view-paper-button:hover {
    color: white;
    background: var(--gradient-btn, linear-gradient(135deg, #5964e8, #7657e8));
    border-color: transparent;
}


/* EMPTY / LOADING / ERROR */

.empty-state {
    padding: 45px 20px;
    text-align: center;

    background: rgba(255,255,255,0.35);
    border: 1px dashed rgba(126,112,230,0.28);
    border-radius: 17px;
}

.empty-icon {
    width: 48px;
    height: 48px;

    display: grid;
    place-items: center;

    margin: 0 auto 14px;

    color: var(--brand-text, #5964e8);
    font-size: 28px;

    background: rgba(255,255,255,0.65);
    border-radius: 15px;
}

.empty-state h3 {
    margin: 0 0 8px;

    color: var(--text-primary, #252743);
    font-size: 15px;
    font-weight: 750;
}

.empty-state p {
    max-width: 350px;
    margin: auto;

    color: var(--text-muted, #777b9b);
    font-size: 12px;
    line-height: 1.7;
}

.empty-state.error h3 {
    color: #b34e62;
}

.loading-indicator {
    padding: 35px 15px;
    text-align: center;

    color: var(--text-secondary, #555b80);
    font-size: 12px;
}

.loading-spinner {
    width: 25px;
    height: 25px;

    margin: 0 auto 12px;

    border: 3px solid rgba(89,100,232,0.15);
    border-top-color: var(--primary, #5964e8);
    border-radius: 50%;

    animation: study-spin 0.7s linear infinite;
}

@keyframes study-spin {
    to {
        transform: rotate(360deg);
    }
}


/* FOOTER NOTE */

.study-footer-note {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 9px;

    max-width: 550px;
    margin: 35px auto 0;

    color: var(--text-muted, #777b9b);
    text-align: center;
}

.study-footer-note span {
    color: var(--brand-text, #5964e8);
}

.study-footer-note p {
    margin: 0;
    font-size: 11px;
    line-height: 1.7;
}


/* RESPONSIVE */

@media (max-width: 700px) {

    .study-page {
        padding: 0 15px 35px;
    }

    .study-header {
        min-height: 65px;
    }

    .study-intro {
        padding: 48px 0 27px;
    }

    .study-intro h1 {
        letter-spacing: -1px;
    }

    .finder-card {
        padding: 21px 17px;
        border-radius: 19px;
    }

    .finder-form {
        grid-template-columns: 1fr 1fr;
    }

    .subject-filter {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .search-button {
        width: 100%;
    }

    .paper-card {
        padding: 15px;
    }
}


@media (max-width: 420px) {

    .finder-form {
        grid-template-columns: 1fr;
    }

    .subject-filter {
        grid-column: auto;
    }

    .finder-heading h2 {
        font-size: 18px;
    }

    .paper-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .view-paper-button {
        width: 100%;
        justify-content: center;
    }

    .results-header h2 {
        font-size: 17px;
    }
}


/* removing header label when width is less than 400px */
@media (max-width: 400px) {
    .study-header-label {
        display: none;
    }
}  