:root {
    --bg: #fdfcf8;
    --ink: #1a1a1a;
    --ink-muted: #4a4a4a;
    --accent: #2c5282;
    --accent-soft: #ebf8ff;
    --border: #e2e8f0;
    --clay: #f4f1ea;
    --glass: rgba(255, 255, 255, 0.7);
    --cursor: var(--accent);
}

/* Custom Cursor */
#custom-cursor {
    width: 20px;
    height: 20px;
    background: var(--cursor);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    mix-blend-mode: difference;
    transition: width 0.3s, height 0.3s, background 0.3s;
    transform: translate(-50%, -50%);
    display: none;
}

#cursor-blur {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.3;
    transform: translate(-50%, -50%);
    display: none;
}

@media (pointer: fine) {
    #custom-cursor, #cursor-blur {
        display: block;
    }
    body {
        cursor: none;
    }
    a, button, .cta-btn, .work-item {
        cursor: none;
    }
}

/* Base Grain Texture */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://grainy-gradients.vercel.app/noise.svg');
    opacity: 0.04;
    pointer-events: none;
    z-index: 9999;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    line-height: 1.1;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 40px;
}

/* --- Header --- */
header {
    padding: 25px 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    transition: all 0.4s ease;
}

header.scrolled {
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 15px 0;
}

/* Scroll Progress Bar */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent);
    z-index: 10001;
    transition: width 0.1s;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    position: relative;
    display: flex;
    align-items: center;
    height: auto;
}

.logo img {
    height: 40px;
    width: auto;
    display: block;
    transition: opacity 0.3s ease;
}

.logo:hover img {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: 40px;
}

.nav-links a {
    text-decoration: none;
    color: var(--ink);
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--accent);
}

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ink);
    z-index: 101;
}

.menu-close {
    display: none;
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--ink);
    z-index: 102;
    padding: 10px;
    transition: color 0.3s, transform 0.3s;
}

.menu-close:hover {
    color: var(--accent);
    transform: rotate(90deg);
}

/* --- Hero Section --- */
.hero {
    padding: 160px 0 80px;
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: center;
    overflow: hidden;
    background: #f4f1ea; /* Footer color - var(--clay) */
}

.hero-top-bar {
    width: 100%;
    height: 10px; /* Reduced height to make it a thin belt */
    background: #000;
    position: absolute;
    top: 80px; /* Shifted down to be clearly visible below the header */
    left: 0;
    z-index: 1;
    opacity: 0.9;
}

#curveCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.6; /* Increased global opacity */
    pointer-events: none;
}

.hero-bg {
    position: absolute;
    top: 0;
    right: 0;
    width: 60%;
    height: 100%;
    background: var(--clay);
    z-index: -1;
    clip-path: polygon(15% 0%, 100% 0%, 100% 100%, 0% 100%);
    transition: transform 0.1s ease-out;
}

.hero-content {
    max-width: 850px;
    position: relative;
    z-index: 10;
}

.hero-tag {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: var(--accent);
    margin-bottom: 24px;
    display: block;
    font-weight: 700;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.8s forwards 0.2s;
}

.hero h1 {
    font-size: clamp(3.5rem, 6.5vw, 6rem);
    margin-bottom: 30px;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.hero p {
    font-size: 1.25rem;
    color: var(--ink-muted);
    max-width: 650px;
    margin-bottom: 45px;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s forwards 0.6s;
}

.cta-group {
    display: flex;
    gap: 20px;
    align-items: center;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s forwards 0.8s;
}

@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}

.cta-btn {
    display: inline-block;
    background: var(--ink);
    color: white;
    padding: 20px 45px;
    text-decoration: none;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.text-reveal {
    color: var(--accent);
    position: relative;
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
}

.text-reveal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent);
    transform: translateX(-101%);
}

.text-reveal.animating::after {
    animation: revealBlock 1.5s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes revealBlock {
    0% { transform: translateX(-101%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(101%); }
}

.secondary-link {
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    font-size: 1rem;
    margin-left: 30px;
    position: relative;
    padding-bottom: 5px;
}

.secondary-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

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

.hero-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: linear-gradient(to bottom, black, transparent);
    opacity: 0.3;
    z-index: -2;
}

/* --- Identity Section --- */
.identity {
    padding: 160px 0;
    background: var(--ink);
    color: white;
    position: relative;
}

.identity-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 80px;
    align-items: center;
}

.identity-image {
    position: relative;
    height: 600px;
    overflow: hidden;
    border-radius: 4px;
}

.identity-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    filter: grayscale(100%);
    transition: filter 0.8s, transform 1.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.identity:hover .identity-image img {
    transform: scale(1.05);
}

.identity-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 60%, var(--ink));
}

.identity h2 {
    font-size: 3rem;
    margin-bottom: 30px;
}

.identity p {
    font-size: 1.1rem;
    color: #ccc;
    margin-bottom: 20px;
}

.identity-list {
    list-style: none;
}

.identity-list li {
    padding: 15px 0;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.identity-list li span {
    color: var(--accent-soft);
    font-weight: 600;
}

/* --- Expertise Section --- */
.expertise {
    padding: 120px 0;
    position: relative;
    overflow: hidden;
}

#causalCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
}

.expertise .container {
    position: relative;
    z-index: 1;
}

.section-header {
    margin-bottom: 80px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.section-header h2 {
    font-size: 4rem;
    max-width: 600px;
}

.section-header p {
    font-size: 1.1rem;
    color: var(--ink-muted);
    max-width: 400px;
}

.expertise-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
}

.expertise-card {
    padding: 60px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
}

.expertise-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 0;
    background: var(--accent);
    transition: height 0.4s ease;
}

.expertise-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 30px 60px rgba(0,0,0,0.05);
}

.expertise-card:hover::before {
    height: 100%;
}

.expertise-card h3 {
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.expertise-card p {
    font-size: 1rem;
    color: var(--ink-muted);
}

/* --- Works Section --- */
.works {
    padding: 160px 0;
    background: #fff;
}

.work-item {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    padding: 100px 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: calc(50vw - 50% + 40px);
    padding-right: calc(50vw - 50% + 40px);
}

/* Footer color - White - Footer color pattern */
.work-item-first {
    background: #f4f1ea !important; /* Footer color - FIRST */
    position: relative;
    z-index: 1;
}

.work-item-middle {
    background: #ffffff !important; /* White - MIDDLE */
    position: relative;
    z-index: 1;
}

.work-item-last {
    background: #f4f1ea !important; /* Footer color - LAST */
    position: relative;
    z-index: 1;
}

.work-item:nth-child(even) {
    direction: rtl;
}

.work-item:nth-child(even) .work-info {
    direction: ltr;
}

.work-item:last-child {
    border-bottom: none;
}

.work-visual {
    position: relative;
    height: 450px;
    background: var(--clay);
    border-radius: 4px;
    overflow: hidden;
}

.work-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.work-item:hover .work-visual img {
    transform: scale(1.1);
}

.work-info {
    flex: 1;
}

/* --- Impact Metrics --- */
.impact-metrics {
    padding: 120px 0;
    background: var(--ink);
    color: white;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    text-align: center;
}

.metric-number {
    font-family: 'Fraunces', serif;
    font-size: 5rem;
    font-weight: 700;
    color: var(--accent-soft);
    margin-bottom: 10px;
}

.work-info ul {
    list-style: none;
    margin-bottom: 25px;
    color: var(--ink-muted);
    font-size: 0.95rem;
}

.work-info .secondary-link-standalone {
    margin-left: 0;
    margin-top: 20px;
    display: inline-block;
}

.work-info .preprint-info {
    font-size: 0.85rem;
    color: var(--accent);
    margin-top: -10px;
}

.work-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.work-tags span {
    background: var(--clay);
    padding: 6px 15px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 100px;
    color: var(--ink);
}

.work-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 1;
}

.work-overlay-dark {
    opacity: 0.4 !important; /* Permanent gradient for this specific image */
    background: linear-gradient(135deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.work-item:hover .work-overlay {
    opacity: 1;
}

@media (max-width: 968px) {
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 60px;
    }
    .metric-number {
        font-size: 4rem;
    }
}

.work-info h3 {
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.work-info p {
    font-size: 1.1rem;
    color: var(--ink-muted);
    margin-bottom: 30px;
}

/* --- Footer --- */
footer {
    padding: 100px 0 50px;
    background: var(--clay);
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 60px;
    margin-bottom: 60px;
}

.footer-logo {
    margin-bottom: 20px;
}

.footer-logo img {
    height: 50px;
    width: auto;
    display: block;
}

.footer-links h4 {
    margin-bottom: 25px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.footer-links a {
    display: block;
    text-decoration: none;
    color: var(--ink-muted);
    margin-bottom: 15px;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--accent);
}

.copyright {
    padding-top: 40px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 0.8rem;
    color: var(--ink-muted);
    text-align: center;
}

.contact-section {
    padding: 150px 0;
    text-align: center;
}

.contact-section h2 {
    font-size: 3.5rem;
    margin-bottom: 40px;
}

.cta-btn-large {
    padding: 25px 60px;
    font-size: 1.2rem;
}

.footer-desc {
    color: var(--ink-muted);
    max-width: 300px;
}

/* Animation */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 968px) {
    .container {
        padding: 0 25px;
    }

    .menu-toggle {
        display: block;
        margin-right: 20px;
        margin-left: 8px; /* Tiny bit to the right */
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        background: var(--bg);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 30px;
        transition: right 0.4s ease-in-out;
        box-shadow: -10px 0 30px rgba(0,0,0,0.05);
        z-index: 100;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links.active .menu-close {
        display: block;
    }

    .identity-grid {
        grid-template-columns: 1fr;
        gap: 50px;
    }

    .identity-image {
        height: 500px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        margin-bottom: 50px;
    }

    .section-header h2 {
        font-size: 2.8rem;
    }

    .work-item {
        grid-template-columns: 1fr;
        gap: 30px;
        padding: 50px 0;
        direction: ltr !important;
        margin-left: calc(-50vw + 50%);
        margin-right: calc(-50vw + 50%);
        padding-left: calc(50vw - 50% + 25px);
        padding-right: calc(50vw - 50% + 25px);
    }

    .work-visual {
        height: 300px;
    }

    .work-info h3 {
        font-size: 2rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero-bg {
        width: 100%;
        opacity: 0.1;
    }

    .hero-visual {
        display: none;
    }

    .hero {
        padding: 140px 0 60px;
    }

    .hero h1 {
        font-size: 3rem;
    }

    .contact-section h2 {
        font-size: 2.5rem;
    }
}
