@import url('tailwind.css');

:root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --border-color: #E5E7EB;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-headings: #11182C;

    --accent-blue: #1D4ED8;
    --accent-green: #22C55E;
    --accent-yellow: #EAB308;
    --accent-red: #EF4444;

    --font-body: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-sans: 'Playfair Display', 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
    --font-heading: 'Playfair Display', 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
}



h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
}

.font-body { font-family: var(--font-body); }
.font-sans { font-family: var(--font-sans); }
.font-serif { font-family: var(--font-heading); }

header.fixed {
    background-color: #11182C;
    border-bottom: 1px solid #1f2937;
}

.nav-link {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    transition: color 0.3s ease;
    color: #d1d5db;
}

.nav-link:hover,
.nav-link.nav-link-active {
    color: #ffffff;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-blue);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.75rem 2rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    display: inline-block;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

.btn-red {
    background-color: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.btn-red:hover {
    background-color: #d83a3a;
    border-color: #d83a3a;
}

.btn-blue {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-blue:hover {
    background-color: var(--accent-blue);
    color: white;
}

.btn-green {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.btn-green:hover {
    background-color: var(--accent-green);
    color: white;
}

section {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

@media (min-width: 768px) {
    section {
        padding-top: 7rem;
        padding-bottom: 7rem;
    }
}

.section-title {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-headings);
}

@media (min-width: 768px) {
    .section-title {
        font-size: 3rem;
    }
}

.section-subtitle {
    font-family: var(--font-sans);
    font-size: 1.125rem;
    max-width: 48rem;
    margin-left: auto;
    margin-right: auto;
    color: var(--text-secondary);
}

.project-card, .quick-link-card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    transition: border-color 0.3s ease;
    opacity: 1;
    transform: none;
}

.project-card:hover, .quick-link-card:hover {
    border-color: var(--accent-blue);
}

/* Cards injected by home-page.js after the page has already loaded (JSON
   fetch is async). They share .project-card's look but must NOT start at
   opacity:0 like it does — that reset is only ever cleared by script.js's
   one-time scroll-entrance setup, which runs before these cards exist and so
   never finds them, leaving them permanently invisible. */
.home-card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    transition: border-color 0.3s ease;
}

.home-card:hover {
    border-color: var(--accent-blue);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-headings);
}

.card-description {
    margin-bottom: 2rem;
    flex-grow: 1;
    color: var(--text-primary);
    line-height: 1.7;
    /* Some project summaries are written as "• point one\n• point two" —
       preserve those line breaks instead of collapsing them into one line. */
    white-space: pre-line;
}

.card-link {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--accent-blue);
}

.card-link:hover {
    text-decoration: underline;
}

.quick-link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.text-accent-blue { color: var(--accent-blue); }
.text-accent-green { color: var(--accent-green); }
.text-accent-yellow { color: var(--accent-yellow); }
.text-accent-red { color: var(--accent-red); }

.qrs-wordmark, .qrs-footer-wordmark { width: 2.25rem; height: 2.25rem; object-fit: contain; }
.qrs-brand-title { color: #fff; font-family: var(--font-heading); font-size: 1.05rem; }
.nav-cta { color: #fff; background: var(--accent-blue); border-radius: .375rem; padding: .45rem .8rem; }
.nav-cta:hover { color: #fff; background: #163ea8; }
.empty-state { max-width: 42rem; margin: 0 auto; padding: 3rem 2rem; text-align: center; background: #fff; border: 1px solid var(--border-color); border-radius: .5rem; }
.site-footer { background: #11182c; color: #d1d5db; }
.footer-columns { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.footer-brand { display: flex; align-items: center; gap: .75rem; color: #fff; }
.footer-brand-name, .footer-col-title { font-family: var(--font-heading); color: #fff; font-weight: 600; }
.footer-blurb { max-width: 24rem; margin-top: 1rem; }
.footer-links { display: grid; gap: .4rem; }
.footer-link { color: #d1d5db; }
.footer-link:hover { color: #fff; text-decoration: underline; }
.footer-bottom { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid #374151; margin-top: 2rem; padding-top: 1rem; font-size: .9rem; }
.hero-section::before { background: linear-gradient(135deg, rgba(17,24,44,.98), rgba(29,78,216,.78)); }

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fade-in-up 0.8s cubic-bezier(0.215, 0.610, 0.355, 1.000) forwards;
}

.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 767px) {
    .nav-link::after {
        display: none;
    }
    #mobile-menu .nav-link {
        padding: 0.5rem;
        border-radius: 0.375rem;
        transition: background-color 0.2s ease, color 0.2s ease;
    }
    #mobile-menu .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.08);
        color: #ffffff;
    }
    .nav-cta {
        align-self: flex-start;
    }
}

/* Join QRS: the visually distinct primary CTA in the nav */
.nav-cta {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--accent-blue);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    transition: background-color 0.2s ease;
    display: inline-block;
    text-align: center;
}

.nav-cta:hover {
    background-color: #1E40AF;
    color: #ffffff;
}

/* Hero Section Redesign */
.hero-section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60vh;
    color: #ffffff;
    overflow: hidden;
    background-image:
            linear-gradient(rgba(10, 25, 47, 0.85), rgba(10, 25, 47, 0.85)),
            url('https://images.unsplash.com/photo-1644088379091-d574269d422f');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.hero-title {
    font-family: 'Montserrat', 'Segoe UI', 'Helvetica Neue', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    line-height: 1.2;
    text-align: center;
    color: #e6f1ff;
    max-width: 1200px;
    margin: 0;
    padding: 0 1rem;
    text-shadow: 0px 2px 8px rgba(0, 0, 0, 0.5);
}

.hero-content {
    z-index: 1;
}

.hero-subtitle {
    font-family: var(--font-sans);
    font-size: 1.125rem;
    color: #cbd5e1;
    max-width: 42rem;
    margin: 1.5rem auto 0;
    text-align: center;
    padding: 0 1rem;
}

.hero-ctas {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
}

/* Footer and Text Color Overrides for Dark Theme */
body > #root > footer {
    background-color: #11182C;
    border-top-color: #1f2937;
}

/* Footer text color overrides */
body > #root > footer,
body > #root > footer p {
    color: #9ca3af;
}

body > #root > footer a {
    color: #d1d5db;
    transition: color 0.3s;
}

body > #root > footer a:hover,
body > #root > footer a:hover i {
    color: var(--accent-blue);
}

/* ===================================== */
/* Multi-column site footer              */
/* ===================================== */

.footer-columns {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2.5rem;
    text-align: left;
    padding-bottom: 2rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.footer-col {
    flex: 1 1 160px;
    min-width: 150px;
}

.footer-col-brand {
    flex: 2 1 220px;
}
#header .qrs-header-nav { max-width: 1440px; }
.qrs-wordmark { width: 64px; height: 64px; object-fit: contain; flex-shrink: 0; }
.qrs-brand-title { font-family: var(--font-heading); color: #fff; font-size: 1.25rem; line-height: 1.25; white-space: nowrap; }
#header .nav-link, #header .nav-cta { font-size: 1rem; }
/* Slimmer navigation bar; assets/header.js adds .nav-hidden while the reader scrolls down. */
#header { transition: transform .3s ease, background-color .3s; }
#header .qrs-header-nav { padding-block: .65rem; }
#header .qrs-wordmark { width: 48px; height: 48px; }
#header.nav-hidden { transform: translateY(-100%); }
main.pt-24 { padding-top: 4.5rem; }
main.pt-28 { padding-top: 5.5rem; }
main.pt-32 { padding-top: 6.5rem; }
@media (prefers-reduced-motion: reduce) { #header { transition: none; } }
.qrs-footer-wordmark { width: 64px; height: 64px; object-fit: contain; flex-shrink: 0; }
.footer-col-community { flex: 2 1 380px; }
.footer-community-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
@media (max-width: 640px) {
    #header .qrs-header-nav { padding-inline: 12px; }
    #header #mobile-menu-button { padding: 4px; }
    .qrs-brand { gap: 8px; }
    #header .qrs-wordmark { width: 40px; height: 40px; }
    .qrs-brand-title { font-size: clamp(.75rem, 3.7vw, 1.1rem); }
    .footer-community-grid { grid-template-columns: 1fr; }
    .footer-brand { flex-wrap: wrap; }
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.footer-brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: #ffffff;
}

.footer-blurb {
    font-size: 0.9rem;
    max-width: 24rem;
    margin-bottom: 1.25rem;
}

.footer-social {
    display: flex;
    gap: 1.25rem;
}

.footer-col-title {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 1rem;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Chapters and Collaborators share one footer column as two labeled
   sub-groups, so the footer stays 3 columns regardless of how many "other
   society" categories exist. */
.footer-subgroup + .footer-subgroup {
    margin-top: 1.25rem;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    width: fit-content;
}

.footer-bottom {
    text-align: center;
    font-size: 0.9rem;
}

.footer-copyright {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

@media (max-width: 640px) {
    .footer-columns {
        text-align: center;
        justify-content: center;
    }

    .footer-brand,
    .footer-social,
    .footer-link {
        justify-content: center;
    }

    .footer-blurb {
        max-width: none;
    }
}

h1, h2, h3, h4, h5, h6,
.font-serif {
    font-family: var(--font-heading) !important;
}

/* ===================================== */
/* Math Notes Specific Styles - START */
/* ===================================== */

/* Course card styling for math notes page */
.course-card {
    opacity: 1;
    transform: none;
    transition: all 0.3s ease;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Material type badges */
.material-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #EFF6FF;
    color: #1E40AF;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Button for viewing materials */
.btn-view-materials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    background-color: var(--accent-blue);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-view-materials:hover {
    background-color: #1E40AF;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Search input styling for math notes */
#search-input {
    font-family: var(--font-body);
}

#search-input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Results count text */
#results-count {
    font-family: var(--font-sans);
}

/* Loading state spinner */
#loading-state {
    font-family: var(--font-sans);
}

/* No results message */
#no-results {
    font-family: var(--font-sans);
}

/* Year breakdown inside course cards */
.course-card h4 {
    font-family: var(--font-sans);
}

/* Download links for revision notes and ZIP files */
.course-card a[download] {
    text-decoration: none;
}

.course-card a[download]:hover {
    text-decoration: underline;
}

/* Checkmark indicators for materials */
.course-card .text-green-600,
.course-card .text-blue-600,
.course-card .text-purple-600 {
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===================================== */
/* Math Notes Specific Styles - END */
/* ===================================== */

/* Respect reduced-motion preferences: disable transitions/animations and
   remove scroll-driven parallax/entrance effects entirely. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===================================== */
/* Shared data-driven page components    */
/* (Projects, Publications, Events,      */
/* People, Person profile)               */
/* ===================================== */

.badge {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    background-color: #eff6ff;
    color: #1e40af;
    margin-right: 0.4rem;
    margin-bottom: 0.5rem;
}

.badge-status {
    background-color: #f0fdf4;
    color: #166534;
}

.project-full-card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    scroll-margin-top: 6rem;
}

.project-alt-title {
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-style: italic;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.project-participants .label,
.event-meta .label {
    font-weight: 600;
    color: var(--text-headings);
}

.project-recognition {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.project-recognition h4 {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.project-recognition ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-links {
    margin-top: 1.25rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.external-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent-blue);
    font-weight: 600;
    font-family: var(--font-sans);
    font-size: 0.9rem;
}

.external-link:hover {
    text-decoration: underline;
}

.person-link {
    color: var(--accent-blue);
}

.person-link:hover {
    text-decoration: underline;
}

.person-plain {
    color: var(--text-secondary);
}

.event-card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
    scroll-margin-top: 6rem;
}

.event-meta {
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

/* People directory */
.person-directory-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    transition: border-color 0.2s ease;
}

.person-directory-card:hover {
    border-color: var(--accent-blue);
}

.person-directory-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-headings);
}

/* Only the preferred-name substring (wrapped in <strong> by qrs-data.js)
   should read as bold, so the surrounding name stays a lighter weight. */
.person-directory-name strong,
.person-name strong {
    font-weight: 800;
}

.person-directory-role {
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
}

/* Person profile page */
.person-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.person-photo {
    width: 5rem;
    height: 5rem;
    border-radius: 9999px;
    object-fit: cover;
    flex-shrink: 0;
}

.person-name {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 500;
    color: var(--text-headings);
    margin-bottom: 0.25rem;
}

.person-role {
    color: var(--text-secondary);
    font-family: var(--font-sans);
    margin-bottom: 0.75rem;
}

.external-links {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.person-section {
    margin-bottom: 2rem;
}

.person-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.person-list a {
    color: var(--accent-blue);
    font-weight: 500;
}

.person-list a:hover {
    text-decoration: underline;
}

.person-list-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* Publications */
.publication-year-group {
    margin-bottom: 2.5rem;
}

.publication-year {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-headings);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
}

.publication-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.publication-entry {
    scroll-margin-top: 6rem;
}

.publication-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-headings);
    margin-bottom: 0.25rem;
}

.publication-authors {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.publication-venue {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Programmes */
.programme-card {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2.5rem;
}

.programme-card ul {
    list-style: disc;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--text-primary);
}

/* Search controls retained independently of the visual redesign. */
.catalog-toolbar { max-width: 56rem; margin: 0 auto 1.75rem; }
.catalog-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 1rem; }
.catalog-controls label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.75rem; font-weight: 600; color: #465466; min-width: 8rem; }
.catalog-search { flex: 1 1 16rem; }
.catalog-controls input, .catalog-controls select { font: 400 0.875rem var(--font-body); color: #202d40; background: #fff; border: 1px solid #aeb8bf; border-radius: 3px; min-height: 44px; padding: 0.65rem 0.75rem; width: 100%; }
.catalog-controls select { max-width: 16rem; }
.catalog-reset { font-size: 0.8rem; min-height: 44px; color: #284e78; text-decoration: underline; }
.catalog-reset:disabled { color: #747b83; cursor: default; text-decoration: none; }
.catalog-count { font-size: 0.8rem; color: #586474; margin-top: 0.85rem; }
.catalog-empty { padding: 3rem 1.5rem; border: 1px solid #d2d6d8; background: #fff; }
.catalog-empty h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #37699a; outline-offset: 4px; }

main > .container > .catalog-toolbar { max-width: 48rem; }
.publication-year-group { padding-top: 0; padding-bottom: 0; }
@media (max-width: 1279px) {
    #header #mobile-menu { display: none; width: 100%; }
    #header #mobile-menu:not(.hidden) { display: block; }
    #header #mobile-menu > div { flex-direction: column; align-items: flex-start; gap: 0.75rem; margin-top: 1rem; }
    #header #mobile-menu > div > a { margin-left: 0; }
    #header #mobile-menu-button { display: block; }
}

@media (max-width: 640px) {
    .catalog-controls label { flex: 1 1 40%; min-width: 0; }
    .catalog-controls .catalog-search { flex-basis: 100%; }
    .catalog-controls select { max-width: 100%; }
}
