:root {
    /* Updated for WCAG AAA (4.5:1 for large text against white) */
    --brand-color: #c7383c; 
    --text-main: #333333;
    --text-light: #555555;
    --bg-color: #ffffff;
    /* Updated for WCAG AAA (7:1 for normal text against white) */
    --link-color: #0050a1; 
    --focus-color: #2c3e50;
    --max-width: 1000px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-color);
    line-height: 1.8;
}

/* --- Accessibility Utility Classes --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: 0;
    left: -9999px;
    background: var(--focus-color);
    color: white;
    padding: 10px 20px;
    z-index: 1000;
    text-decoration: none;
    font-weight: bold;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.skip-link:focus {
    left: 50%;
    transform: translateX(-50%);
    outline: 3px solid var(--focus-color);
    outline-offset: 2px;
}

/* Global Link Styles & Focus States */
a {
    color: var(--link-color);
    /* WCAG SC 1.4.1: Links in text must be underlined */
    text-decoration: underline; 
    text-underline-offset: 3px;
}

a:hover, a:focus {
    text-decoration: none; /* Invert decoration on hover for feedback */
}

a:focus, button:focus {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
}

/* WCAG AAA SC 2.5.5: Inflate touch targets to at least 44x44px */
nav a, footer a, .social-links a, .research-links a {
    display: inline-block;
    padding: 0.5rem; 
    margin: -0.5rem; /* Prevents the padding from ruining your visual layout */
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Navigation --- */
nav {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
    font-size: 1.2rem;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
    justify-content: center;
}

nav a {
    color: var(--link-color);
}

nav a[aria-current="page"] {
    color: var(--text-main);
    border-bottom: 2px solid var(--text-main);
    padding-bottom: 2px;
    font-weight: bold;
}

/* --- Hero Section --- */
section.hero {
    text-align: center;
    margin: 2rem 0 0;
}

section.hero h1 {
    color: var(--brand-color);
    font-size: 3.5rem;
    font-weight: 900;
    margin: 0 0 1rem 0;
    letter-spacing: -1px;
}

section.hero p {
    font-size: 1.25rem;
    color: var(--text-main);
    margin: 0;
}

/* --- Section Dividers --- */
.section-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--brand-color);
    font-weight: 900;
    font-size: 1.8rem;
    margin: 4rem 0 2rem;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    border-bottom: 3px solid #111;
}

.section-divider::before { margin-right: 1.5rem; }
.section-divider::after { margin-left: 1.5rem; }

/* --- Objective & General Text --- */
.objective-text {
    text-align: left; /* Changed from justify for WCAG AAA */
    max-width: 80ch; /* WCAG AAA: Limits line length to 80 characters */
    margin: 0 auto 2rem; /* Keeps the block centered on the screen */
}

.social-links {
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 4rem;
}

/* --- Featured Research --- */
.research-item {
    margin-bottom: 2.5rem;
}

.research-item h3 {
    font-size: 1.1rem;
    margin: 0 0 0.5rem 0;
}

.research-item p {
    margin: 0 0 0.5rem 0;
    color: var(--text-light);
}

.research-links {
    font-size: 0.9rem;
}

/* --- Published Research Citations --- */
.citation-item {
    margin-bottom: 3rem;
    line-height: 1.8;
}

.citation-item p {
    margin: 0 0 1rem 0;
}

/* --- Portfolio Grid & Stacked Cards --- */
.portfolio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem; 
    margin-bottom: 4rem;
}

.portfolio-card {
    display: flex;
    flex-direction: column;
    gap: 1rem; 
}

.portfolio-card.item-large {
    grid-column: 1 / -1;
}

.portfolio-meta {
    text-align: left;
}

.portfolio-meta h3 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
}

.portfolio-meta h3 a {
    color: var(--link-color);
    text-decoration: underline;
}

.portfolio-meta h3 a:hover {
    text-decoration: none;
}

.portfolio-meta p {
    color: var(--text-light);
    margin: 0;
    font-size: 0.95rem;
}

/* Force perfect 16:9 so videos snap cleanly to grid lines */
.portfolio-card video,
.portfolio-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: block;
}

/* --- Portfolio Project Pages --- */
/* Text container above the image */
.project-header-text {
    text-align: center;
    padding: 1rem 20px 3rem; /* Reduced top padding to perfectly balance the spacing */
}

.project-header-text h1 {
    color: var(--brand-color);
    font-size: 4rem;
    font-weight: 900;
    margin: 0 0 0.5rem 0;
    line-height: 1.1;
}

.project-header-text p {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
    color: var(--text-main); /* Match main body text color for AAA contrast on white */
}

/* Image container */
.project-hero-image {
    background-color: #333; /* Fallback for very dark images */
    background-size: cover;
    background-position: center;
    width: 100%;
    /* We must give it a height now that it has no content */
    height: 400px; 
    margin-bottom: 4rem;
    /* Optional: Aspect ratio is more responsive but can get very tall on wide screens */
    /* aspect-ratio: 16 / 9; */
    /* max-height: 600px; */
}

.overview-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    margin-bottom: 5rem;
    align-items: start;
}

.overview-grid h2 {
    font-size: 2rem;
    font-weight: 900;
    margin: 0;
}

/* Meta Data (Year, Institution, Type) */
.meta-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    text-align: center;
    gap: 2rem;
    margin-bottom: 4rem;
}

.meta-stats h3 {
    font-size: 3rem;
    font-weight: 900;
    margin: 0;
    line-height: 1;
}

.meta-stats p {
    font-size: 1.5rem;
    color: var(--text-light);
    margin: 0.5rem 0 0 0;
}

/* Problem & Key Finding */
.meta-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    margin-bottom: 6rem;
}

.meta-summary h3 {
    font-size: 2rem;
    font-weight: 900;
    margin: 0 0 1rem 0;
}

/* Process Stepper */
.process-section {
    margin-top: 6rem;
}

.process-section h2 {
    text-align: center;
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 3rem;
}

.process-stepper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    margin-bottom: 4rem;
}

.process-stepper::before {
    content: '';
    position: absolute;
    top: 25px; 
    left: 0;
    right: 0;
    height: 2px;
    background-color: #eee;
    z-index: 1;
}

.step {
    position: relative;
    z-index: 2;
    text-align: center;
    background-color: var(--bg-color);
    padding: 0 10px;
    flex: 1;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background-color: #333;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 0 auto 1rem auto;
}

.step-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.project-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem 3rem;
    align-items: center;
    margin: 4rem 0;
}

.project-text h3 {
    font-size: 2.5rem;
    font-weight: 900;
    margin: 0 0 1.5rem 0;
}

.project-text p {
    margin-bottom: 1.5rem;
}

.project-figure {
    margin: 0;
    text-align: center;
}

.project-figure img,
.project-figure video {
    width: 100%;
    height: auto;
    display: block;
}

.project-figure figcaption {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.full-width-image {
    width: 100%;
    margin: 4rem 0;
}

.full-width-image img,
.full-width-image video {
    width: 100%;
    height: auto;
    display: block;
}

/* Styling for halved, centered images */
.halved-centered-image {
    width: 50%; 
    margin: 4rem auto; 
    text-align: center; 
}

.halved-centered-image img,
.halved-centered-image video {
    width: 100%; 
    height: auto;
    display: block;
    border-radius: 4px; 
}

@media (max-width: 768px) {
    .halved-centered-image {
        width: 100%;
        margin: 2rem 0;
    }
}

/* --- About Page Grid --- */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem 3rem;
    align-items: center; 
    margin: 4rem 0;
}

.about-text h2 {
    color: var(--brand-color);
    font-size: 2.5rem;
    font-weight: 900;
    margin: 0 0 1.5rem 0;
    letter-spacing: -1px;
}

.about-text p {
    margin-bottom: 1.5rem;
    text-align: left; /* Changed from justify for WCAG AAA */
    max-width: 80ch; /* Enforces line length */
}

.about-figure {
    margin: 0;
    text-align: center;
}

.about-figure img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}

.about-figure figcaption {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* --- Footer --- */
footer {
    border-top: 1px solid #eaeaea;
    padding: 2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem; 
    color: var(--text-light);
}

footer ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    padding: 0;
    margin: 0;
}

/* --- Takeaways & Centered Sections --- */
.centered-section {
    /* Changed from 800px to 80ch for precise WCAG AAA character compliance */
    max-width: 80ch; 
    margin: 6rem auto 4rem;
    text-align: center;
}

.centered-section h2, 
.centered-section h3 {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.centered-section ul.bullet-list {
    text-align: left;
    display: inline-block;
    font-size: 1.1rem;
    color: var(--text-light);
    line-height: 1.8;
}

.centered-section ul.bullet-list li {
    margin-bottom: 0.5rem;
}

.takeaways-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    margin: 3rem 0 6rem;
    text-align: left;
}

.takeaway-column h3 {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.takeaway-column ul {
    list-style-type: disc;
    padding-left: 1.2rem;
    font-size: 0.95rem;
    color: var(--text-light);
}

.takeaway-column li {
    margin-bottom: 0.75rem;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    margin: 4rem 0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.reflections-text {
    /* Changed from 900px to 80ch for precise WCAG AAA character compliance */
    max-width: 80ch; 
    margin: 0 auto 4rem;
}

.reflections-text p {
    margin-bottom: 1.5rem;
    text-align: left; /* Changed from justify for WCAG AAA */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    section.hero h1 {
        font-size: 2.5rem;
    }
    .section-divider {
        font-size: 1.4rem;
    }
    .about-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .overview-grid,
    .meta-stats,
    .meta-summary,
    .project-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .halved-centered-image {
        width: 100%;
        margin: 2rem 0;
    }
    .takeaways-grid {
        grid-template-columns: 1fr;
    }
    .process-stepper {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }
    .process-stepper::before {
        display: none; 
    }
    footer {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
}
