/*-------------------------
  Base styles
--------------------------*/
html, body {
    height: 100%;
}

body {
    padding-top: 55px;
    display: flex;
    text-align: center;
    flex-direction: column;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--body-bg); /* Applies the soft light mode background */
}

/* Tighten header tracking for a sleeker look */
h1, h2, h3, h4 {
    letter-spacing: -0.02em;
    font-weight: 600;
}

/*-------------------------
  Variables
--------------------------*/
/* Light mode variables */
:root {
    --body-bg: #f8fafc;        /* Soft slate-tinted off-white for main background */
    --section-bg: #f1f5f9;     /* Slightly darker for section blocks */
    --panel-bg: #ffffff;       /* Pure white for panels to create elevation */
    
    --button-bg: #0077cc;
    --button-hover-bg: #005fa3;
    --button-color: #ffffff;
    
    --text-color: #1e293b;     /* Deep slate instead of pure black for reduced glare */
    --text-muted: #64748b;     /* Muted slate */
    
    --border-color: rgba(15, 23, 42, 0.1); /* Subtle, semi-transparent border */
}

/* Dark mode variables */
html.dark-mode {
    --section-bg: #2c2c2c;
    --button-bg: #0077cc; 
    --button-hover-bg: #005fa3;
    --button-color: #ffffff;
    --text-color: #f5f5f5;
    --text-muted: #aaa;
    --border-color: #1e90ff;
    --panel-bg: #3a3a3a;
}

/*-------------------------
  Typography & links
--------------------------*/
main {
    margin: auto;
    padding: 25px;
    flex: 1 0 auto;
    max-width: 1000px;
}

img {
    max-width: 100%;
}

a:link, a:visited {
    color: var(--button-bg); /* Links match the button accent color */
}

a:hover, a:focus {
    color: var(--button-hover-bg) !important;
    text-decoration: none;
}

a.icon:hover {
    text-decoration: none;
}

/*-------------------------
  Navbar search bar + results
--------------------------*/
.navbar-nav {
    display: flex;
    align-items: center; 
}

.navbar-search-wrapper {
    position: relative; 
    display: flex;
    align-items: center; 
    width: 250px; 
}

#navbar-search {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
}

#navbar-search .form-control {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-size: 1.25rem;
    width: 100%;
    line-height: 1.5;
    background-color: var(--panel-bg);
    color: var(--text-color);
    height: 2.5rem;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#navbar-search .form-control:focus {
    outline: none;
    border-color: var(--button-bg);
    background-color: var(--panel-bg);
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.2); 
}

/* Dropdown container */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Slightly softer radius to match new aesthetic */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-size: 1.25rem;
    text-align: left;
    z-index: 1000;
    overflow-y: auto;
    max-height: 300px;
    width: 100%; 
    box-sizing: border-box;
}

/* Each result item */
.search-results-dropdown div {
    padding: 0;
    border-bottom: none;
    background: none;
}

.search-results-dropdown a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    background-color: var(--panel-bg);
}

.search-results-dropdown a:hover {
    background-color: var(--section-bg);
}

html.dark-mode .search-results-dropdown a:hover {
    background-color: #444;
}

/*-------------------------
  Navbar & icons
--------------------------*/
.navbar-icon-img {
    height: 1.25em;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    filter: invert(0%);
    transition: filter 0.3s ease;
}

html.dark-mode .navbar-icon-img {
    filter: invert(100%);
}

.navbar.navbar-default {
    border-top: 2px solid var(--border-color);
}

.nav {
  flex-wrap: wrap;      
}

.nav-item {
  white-space: normal;  
}

/*-------------------------
  Homepage content & panels
--------------------------*/
.homepage-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

@media (max-width: 800px) {
    .homepage-content {
        grid-template-columns: 1fr;
    }
}

/* If the very last panel is an odd number, make it span all columns on larger screens */
@media (min-width: 801px) { 
    .homepage-content .panel:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

.homepage-content .panel {
    border-radius: 12px; 
    overflow: hidden;
    /* Clean "glass" shadow */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color); 
    background-color: var(--panel-bg);
    padding: 1.75rem; 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.homepage-content .panel:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Force dark mode panel colors to override injected HTML inline styles */
html.dark-mode .homepage-content .panel {
    background-color: var(--panel-bg) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Ensure text inside the panel doesn't get overridden either */
html.dark-mode .homepage-content .panel h3,
html.dark-mode .homepage-content .panel p {
    color: var(--text-color) !important;
}

.homepage-content .panel img {
    width: 100%;
    height: auto;
    border-radius: 5px;
}

.homepage-content .panel h3 {
    margin: 0.5rem 0;
}

.homepage-content .panel p {
    margin-bottom: 0.5rem;
}

.homepage-content a.btn, .btn {
    background-color: var(--button-bg);
    color: var(--button-color);
    border: none;
    padding: 0.6rem 1.5rem; 
    border-radius: 8px; 
    text-decoration: none;
    font-weight: 600; 
    letter-spacing: 0.01em;
    display: inline-block;
    box-shadow: 0 4px 14px 0 rgba(0, 119, 204, 0.39); 
    transition: all 0.2s ease-in-out;
}

.homepage-content a.btn:hover, .btn:hover {
    background-color: var(--button-hover-bg);
    transform: translateY(-2px); 
    box-shadow: 0 6px 20px rgba(0, 119, 204, 0.23);
    color: #ffffff !important; /* Forces text to stay white on hover */
}


/*-------------------------
  Featured Research
--------------------------*/

.featured-research {
    text-align: left;
    margin: 2.5rem 0;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--panel-bg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05),
                0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.2s ease;
}

.featured-research:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08),
                0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

.featured-research .research-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
}

.featured-research h2 {
    font-size: 1.65rem;
    line-height: 1.35;
    margin: 0 0 1rem;
    color: var(--text-color);
}

.featured-research p {
    color: var(--text-color);
    margin-bottom: 0.85rem;
}

.featured-research .research-description {
    font-size: 1.05rem;
}

.featured-research .research-topics {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}

.featured-research .research-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.featured-research .research-secondary-link {
    font-weight: 600;
    text-decoration: none;
}

.featured-research .research-citation {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1.5rem;
    margin-bottom: 0;
}

/* Dark mode */
html.dark-mode .featured-research {
    background-color: var(--panel-bg);
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .featured-research h2,
html.dark-mode .featured-research p {
    color: var(--text-color);
}

html.dark-mode .featured-research .research-label,
html.dark-mode .featured-research .research-citation,
html.dark-mode .featured-research .research-topics {
    color: var(--text-muted);
}

/* Mobile */
@media (max-width: 600px) {
    .featured-research {
        padding: 1.25rem;
    }

    .featured-research h2 {
        font-size: 1.35rem;
    }

    .featured-research .research-links {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }
}

/*-------------------------
  Post list & items
--------------------------*/
.item {
    padding: 10px 0;
}

.item-tag {
    background-color: var(--section-bg);
    color: var(--text-color) !important; /* Forces slate in light mode, off-white in dark */
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    display: inline-block;
    margin: 0.15rem;
    transition: all 0.2s ease;
}

.pages {
    padding: 15px 0;
}

.pages-icon {
    padding: 0 15px;
}

/*-------------------------
  Section blocks
--------------------------*/
.section-block {
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    background-color: var(--section-bg);
}

/*-------------------------
  Privacy notice
--------------------------*/
.privacy-notice {
    text-align: center;
    font-size: 0.875rem;
    padding: 0.5rem;
    background-color: var(--section-bg);
    color: var(--text-color);
}

.privacy-notice button {
    margin-left: 0.5rem;
}

/*-------------------------
  Footer
--------------------------*/
footer {
    border-bottom: 2px solid var(--border-color);
    padding: 2rem 0; /* Adding a bit of breathing room */
}

/*-------------------------
  Post meta (author + date)
--------------------------*/
.post-author {
    font-style: italic;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
    transition: color 0.3s ease;
}

.post-date {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.95em;
    transition: color 0.3s ease;
}

/*-------------------------
  GT Tables
--------------------------*/
.gt_table {
    color: var(--text-color);
    background-color: var(--panel-bg);
    width: 100%;
    margin: 1.5rem 0;
}

.gt_table thead th {
    position: sticky;
    top: 0;
    background-color: var(--section-bg); 
    z-index: 2;
    font-weight: 600;
}

.gt_table th, .gt_table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* 1. Force the main table structural elements and headers to use dark mode */
html.dark-mode .gt_table, 
html.dark-mode .gt_table thead, 
html.dark-mode .gt_table tbody, 
html.dark-mode .gt_table th {
    background-color: var(--panel-bg) !important;
    color: var(--text-color) !important;
    border-bottom-color: var(--border-color) !important;
}

/* 2. Apply dark mode styling ONLY to standard data cells that don't have custom colors */
html.dark-mode .gt_table td:not([style*="background-color"]) {
    background-color: var(--panel-bg) !important;
    color: var(--text-color) !important;
}

/* 3. Ensure ALL cells (including the colored ones) get the correct dark mode border */
html.dark-mode .gt_table td {
    border-bottom-color: var(--border-color) !important;
}

/* (Keep your interactive footer fixes from before) */
html.dark-mode .gt_table .gt_sourcenotes,
html.dark-mode .gt_table .gt_options {
    background-color: var(--panel-bg) !important;
    color: var(--text-color) !important;
}

/*-------------------------
  Misc
--------------------------*/
.index-cover-image img {
    width: 100%;
    height: auto;
    border-radius: 8px; /* Modernized edge */
    margin-bottom: 10px;
    border: 1px solid var(--border-color); /* Replaced harsh black border */
}

.profile {
    width: 10vh;
    height: 10vh;
    border-radius: 50%;
}

/* Privacy notice banner */
.privacy-notice-banner {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90%;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.95); /* Adjusted for modern light mode */
    color: var(--text-color); 
    font-size: 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    text-align: center;
    opacity: 0; 
    transition: opacity 0.6s ease, transform 0.4s ease;
}

/* Dark mode override */
html.dark-mode .privacy-notice-banner {
    background-color: rgba(44, 44, 44, 0.95); 
    color: #f5f5f5; 
    border: 1px solid rgba(255,255,255,0.1);
}

/* Button styles inside the banner */
.privacy-notice-banner button {
    margin-left: 0.5rem;
    background-color: rgba(0,0,0,0.05); 
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-weight: 600;
    color: inherit; 
    transition: all 0.2s ease;
}

.privacy-notice-banner button:hover {
    background-color: rgba(0,0,0,0.1); 
}

/* Print Stylesheet for Policymakers */
@media print {
    nav, .navbar, footer, .privacy-notice-banner, .btn {
        display: none !important;
    }
    
    body {
        background-color: #fff !important;
        color: #000 !important;
        font-size: 11pt;
    }
    
    .homepage-content .panel, .gt_table {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    h2, h3 {
        page-break-after: avoid;
    }
    
    p, table, figure {
        page-break-inside: avoid;
    }
}