@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,200..900;1,200..900&display=swap');

/* Reset & Base */
:root {
    --bg-color: #26262c;
    --text-color: #ededef;
    --text-muted: #787888;
    --text-inverse: #ffffff;
    --link-color: #8ab4f8;
    --link-visited: #547dbf;
    --link-hover: #d2e3fc;
    --border-color: #333333;
    --table-border: #444444; 
    --table-hover: #2f2f36;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: "Crimson Pro", serif;

    --container-padding: 2rem;
    --section-gap: 4rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--link-color); text-decoration: none; border-bottom: 1px solid var(--link-color); transition: border-color 0.2s, color 0.2s; }
a:visited { color: var(--link-visited); border-bottom-color: var(--link-visited); }
a:hover { border-bottom-color: var(--link-hover); color: var(--link-hover); }

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--section-gap) var(--container-padding);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}

main {
    flex: 1;
    display: block;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    position: relative;
}

h1 { 
    font-size: 1.5rem; 
    font-weight: 550; 
    letter-spacing: -0.02em;
    font-family: var(--font-serif);
    z-index: 1001;
}
h1 a { 
    border: none; 
}

/* Desktop nav */
nav a { 
    font-size: 1.25rem; 
    margin-left: 1.5rem; 
    font-weight: 550; 
    border: none; 
    color: var(--text-muted);
    font-family: var(--font-serif);
}
nav a:hover { color: var(--text-color); }
nav a.active { color: var(--text-color); font-weight: 500; }

/* Hamburger Button */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    -webkit-tap-highlight-color: transparent;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    margin: 5px 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Nav Overlay */
.nav-overlay {
    display: none;
}

/* Main Grid (Homepage) */
.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
}

/* Content */
.text-block { max-width: 32rem; }
.text-block p { margin-bottom: 1.5rem; }

.text-muted { color: var(--text-muted); }
.text-muted a { border-bottom: none; }
.text-muted a:hover { color: var(--link-hover); }

/* Publications & Filters */
.filters { 
    margin-bottom: 3rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}
.filters button {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem 0;
    font-family: inherit;
    transition: color 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.filters button:hover { color: var(--text-color); }
.filters button.active { color: var(--text-color); font-weight: 600; border-bottom: 2px solid var(--link-color); padding-bottom: 2px; }

.publication-list { 
    list-style: disc; 
    padding-left: 1.5rem; 
    font-family: var(--font-serif);
    font-size: 1.1rem;
}
.publication-list li { margin-bottom: 2rem; padding-right: 2rem; }
.publication-list li a.link { font-weight: 500; border-bottom: 1px solid var(--link-color); }
.publication-list li a.link:hover { border-bottom-color: var(--link-hover); color: var(--link-hover); }

/* Course Table */
.course-table-wrapper {
    overflow-x: auto;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: transparent;
    color: var(--text-color);
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Scroll hint for table on mobile */
.course-table-wrapper::after {
    content: '';
    display: none;
}

/* Hide filtered elements */
.course-table-wrapper.hidden,
.publication-list li.hidden {
    display: none !important;
}

.course-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    min-width: 600px;
}

.course-table thead {
    background-color: var(--bg-color);
    color: var(--text-color);
    border-bottom: 2px solid var(--table-border);
}

.course-table th, .course-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--table-border);
}

.course-table tbody tr:hover {
    background-color: var(--table-hover);
}

/* Footer */
footer {
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Honour Text */
.honour-text {
    font-size: 0.9em;
    color: #e0aa3e;
    display: block;
    margin-top: 0.25rem;
}

/* Page Specific */
.page-home {
    font-family: var(--font-serif);
    font-optical-sizing: auto;
    font-style: normal;
}

/* ========== RESPONSIVE ========== */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --container-padding: 1.5rem;
        --section-gap: 3rem;
    }

    .grid-2-col {
        gap: 2.5rem;
    }

    .text-block {
        max-width: 100%;
    }
}

/* Mobile landscape / small tablet */
@media (max-width: 768px) {
    :root {
        --container-padding: 1.25rem;
        --section-gap: 2rem;
    }

    body {
        font-size: 16px;
    }

    .grid-2-col { 
        grid-template-columns: 1fr; 
        gap: 1.5rem; 
    }

    /* Hamburger visible */
    .hamburger {
        display: block;
    }

    /* Nav becomes overlay */
    nav {
        position: fixed;
        top: 0;
        right: 0;
        width: min(280px, 75vw);
        height: 100vh;
        background-color: var(--bg-color);
        border-left: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2rem;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    }

    nav.open {
        transform: translateX(0);
    }

    nav a {
        margin-left: 0;
        font-size: 1.5rem;
        padding: 0.75rem 1.5rem;
        display: block;
    }

    /* Overlay backdrop */
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .nav-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Prevent body scroll when menu open */
    body.menu-open {
        overflow: hidden;
    }

    h1 { font-size: 1.25rem; } 

    /* Filters: horizontal scroll on mobile */
    .filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        margin-bottom: 2rem;
        gap: 0.25rem 1rem;
        scrollbar-width: none;
    }
    .filters::-webkit-scrollbar {
        display: none;
    }
    .filters button {
        font-size: 0.95rem;
        padding: 0.5rem 0.25rem;
        min-height: 44px;
    }

    /* Publication list tighter on mobile */
    .publication-list {
        padding-left: 1.2rem;
        font-size: 1rem;
    }
    .publication-list li {
        margin-bottom: 1.5rem;
        padding-right: 0.5rem;
    }

    /* Table scroll hint */
    .course-table-wrapper::after {
        content: '→ Scroll for more';
        display: block;
        text-align: right;
        font-size: 0.8rem;
        color: var(--text-muted);
        padding: 0.5rem 0.75rem;
        font-family: var(--font-sans);
    }

    .course-table {
        font-size: 0.95rem;
    }

    .course-table th, .course-table td {
        padding: 10px 12px;
    }

    footer {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Small phones */
@media (max-width: 400px) {
    :root {
        --container-padding: 1rem;
        --section-gap: 1.5rem;
    }

    body {
        font-size: 15px;
    }

    h1 {
        font-size: 1.15rem;
    }

    .publication-list {
        font-size: 0.95rem;
    }

    .course-table {
        font-size: 0.9rem;
    }
}
