/* --- GLOBAL STYLES --- */
:root {
    --structure-color: #2563eb; /* Blue for Roads */
    --chemical-color: #ef4444;  /* Red for Traffic */
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --card-bg: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: #475569;
}

/* --- NAVIGATION --- */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e2e8f0;
    z-index: 1000;
    padding: 1rem 0;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.logo {
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--text-color);
}

.nav-links a {
    text-decoration: none;
    color: #64748b;
    margin-left: 2rem;
    font-weight: 500;
    transition: color 0.2s;
    font-size: 0.9rem;
}

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

/* --- HERO SECTION --- */
header {
    padding: 160px 20px 100px;
    text-align: center;
    background: radial-gradient(circle at 50% 50%, #eff6ff 0%, #f8fafc 100%);
}

.hero-title {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(90deg, var(--structure-color), var(--chemical-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: #64748b;
    max-width: 700px;
    margin: 0 auto 3rem;
}

.btn {
    display: inline-block;
    background: var(--text-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* --- CONTENT SECTIONS --- */
section {
    padding: 80px 20px;
    max-width: 900px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-tag {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--structure-color);
    margin-bottom: 0.5rem;
    display: block;
}

/* --- THE ANALOGY (GRID) --- */
.analogy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.analogy-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

.analogy-card:hover {
    transform: translateY(-5px);
}

.icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

/* 3D Brain Viewer within the Analogy Cards */
.card-brain-viewer {
    width: 100%;
    height: 300px;
    margin-top: auto; /* Pushes the viewer to the bottom of the card */
    border-radius: 0.75rem;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

.card-brain-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    pointer-events: auto;
}

/* --- METHODS --- */
.methods-container {
    background: white;
    padding: 3rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.methods-text {
    flex: 2;
}

.math-block {
    text-align: center;
    font-size: 1.2rem;
    overflow-x: auto;
    padding: 1rem 0;
    margin: 0;
}

/* --- RESULTS --- */
.result-block {
    margin-bottom: 4rem;
}

.figure-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 3rem 3rem 2rem; 
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    width: fit-content;    
    margin: 0 auto;        
    box-sizing: border-box;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    position: relative;
    overflow-x: auto;      
}

.figure-caption {
    font-size: 0.9rem;
    color: #64748b;
    text-align: center;
    font-style: italic;
    margin-top: 1rem;
}

/* --- INTERACTIVE MATRIX STYLES --- */
.matrix-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.matrix-container {
    display: grid;
    grid-template-columns: 160px repeat(8, 55px); 
    grid-template-rows: 110px repeat(8, 55px);    
    gap: 3px;
    font-size: 12px;                              
}

.matrix-label.top-label {
    transform: rotate(-45deg);
    transform-origin: bottom left;
    white-space: nowrap;
    justify-content: flex-start;
    align-items: flex-end;
    margin-left: 27px; 
    padding-bottom: 5px;
}

/* Tooltip */
#tooltip {
    position: fixed; 
    background: rgba(15, 23, 42, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s; 
    z-index: 9999; 
    white-space: nowrap;
}

.matrix-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    transition: transform 0.1s, box-shadow 0.1s;
    cursor: pointer;
    border-radius: 4px;
}

.matrix-cell.data-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 10;
}

.matrix-label {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: bold;
    color: #475569;
    padding: 5px;
    transition: color 0.2s;
}

.matrix-label.left-label {
    justify-content: flex-end;
    text-align: right;
    padding-right: 15px;
}

.label-highlight {
    color: var(--text-color);
    font-weight: 900;
}


.impact-section {
    background: white; 
    border-radius: 20px; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); 
    padding: 4rem 2rem;
}

/* --- FOOTER --- */
footer {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-top: 1px solid #e2e8f0;
    margin-top: 4rem;
}

.footer-links a {
    margin: 0 10px;
    color: var(--structure-color);
    text-decoration: none;
    font-weight: 600;
}

.footer-authors {
    font-size: 0.8rem; 
    color: #94a3b8; 
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .figure-placeholder {
        padding: 1rem;
    }
    .matrix-container {
        grid-template-columns: 120px repeat(8, 40px);
        grid-template-rows: 120px repeat(8, 40px);
        font-size: 11px;
    }
    .matrix-label.top-label {
        margin-left: 20px; 
    }
    .analogy-grid {
        grid-template-columns: 1fr;
    }
}

/* --- PCA TOGGLE BAR --- */
.pca-toggle-bar {
    display: inline-flex;
    background: #f1f5f9;
    padding: 0.35rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.pca-toggle-btn {
    background: transparent;
    border: none;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
}

.pca-toggle-btn.active {
    background: #ffffff;
    color: var(--structure-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.pca-toggle-btn:hover:not(.active) {
    color: var(--text-color);
}

/* --- COUPLING CASE STUDIES --- */
.coupling-cases-container {
    display: flex;
    flex-direction: column;
    gap: 2rem; /* Reduced gap between cards */
    margin-top: 1.5rem;
}

.coupling-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.5rem 2rem; /* Reduced from 2.5rem to remove excess white space */
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.coupling-header {
    text-align: center;
    margin-bottom: 0.75rem; /* Pulled the header closer to the stats */
}

.coupling-header h4 {
    font-size: 1.35rem;
    margin: 0 0 0.5rem 0; /* Pulled the title closer to the badges */
    color: #1e293b;
    font-weight: 800;
}

.coupling-header h4 span {
    color: #94a3b8;
    font-weight: 500;
    font-size: 1.1rem;
    margin: 0 10px;
}

.coupling-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.structural {
    background: #eff6ff;
    color: var(--structure-color);
    border: 1px solid #bfdbfe;
}

.badge.functional {
    background: #fef2f2;
    color: var(--chemical-color);
    border: 1px solid #fecaca;
}

.badge.vs {
    background: transparent;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: lowercase;
}

.coupling-stats {
    display: flex;
    justify-content: center;
    gap: 3rem; /* Brought stats closer together */
    margin-bottom: 1.25rem; /* Tighter margin above images */
    padding-bottom: 1rem; /* Tighter padding below badges */
    border-bottom: 2px dashed #f1f5f9;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item span {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}

.stat-item strong {
    font-size: 1.35rem;
    color: #1e293b;
}

.coupling-images {
    display: flex;
    gap: 1.5rem;
    align-items: stretch; /* FIX: Forces both image boxes to be the exact same height */
}

.image-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f8fafc;
    border-radius: 0.75rem;
    padding: 1rem; /* Reduced padding inside the image box */
    border: 1px solid #e2e8f0;
}

.image-box img {
    width: 100%;
    max-height: 240px; /* Optional: Constrains extremely tall plots */
    object-fit: contain; /* Prevents aspect ratio distortion */
    margin: auto 0 1rem 0; /* Auto margin pushes the image vertically if needed */
    mix-blend-mode: multiply;
}

.image-box span {
    font-size: 0.9rem;
    color: #475569;
    font-weight: 600;
    text-align: center;
    margin-top: auto; /* FIX: This permanently pins the text to the bottom baseline! */
}

@media (max-width: 768px) {
    .coupling-images {
        flex-direction: column;
    }
    .coupling-stats {
        gap: 1.5rem;
        flex-wrap: wrap;
    }
}
/* --- NAV BAR DROPDOWN --- */
/* --- NAV BAR DROPDOWN --- */
.nav-dropdown {
    position: relative;
    display: inline-block;
    margin-left: 2rem;
    padding-bottom: 1rem; /* Creates an invisible bridge so the mouse never loses hover! */
    margin-bottom: -1rem; /* Offsets the padding so the layout doesn't break */
}

.nav-dropdown .dropbtn {
    margin-left: 0; 
    cursor: pointer;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: rgba(255, 255, 255, 0.95);
    min-width: 220px;
    box-shadow: 0px 10px 15px -3px rgba(0,0,0,0.1);
    border-radius: 0.5rem;
    z-index: 1001;
    top: 100%; /* FIX: Brought this up to 100% so there is no dead zone */
    left: -10px;
    backdrop-filter: blur(10px);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.dropdown-content a {
    color: #475569;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    margin-left: 0;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s;
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: #f8fafc;
    color: var(--structure-color);
    padding-left: 20px; /* Slight indent effect on hover */
}

/* Show the dropdown menu on hover */
.nav-dropdown:hover .dropdown-content {
    display: block;
}