@import './colors.css';

/* ========================================
   Font Setup
   ======================================== */
@font-face {
    font-family: 'Fira Code';
    src: url('./FiraCode/Fira%20Code%20Retina%20Nerd%20Font%20Complete.ttf') format('truetype');
    font-display: swap;
}

/* ========================================
   CSS Reset & Base Styles
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Fira Code', monospace;
    background-color: var(--bg-dark);
    color: var(--fg-dark);
    line-height: 1.7;
    font-size: 16px;
    min-height: 100vh;
}

/* ========================================
   Layout Container
   ======================================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding: 1rem 0;
}

/* ========================================
   Header & Navigation
   ======================================== */
header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--bg-highlight);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.site-title {
    font-size: 2.5rem;
    margin-bottom: 0;
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.site-title::before {
    content: none;
}

.topnav {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.topnav a {
    color: var(--fg);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    position: relative;
}

.topnav a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--cyan);
    transition: all 0.2s ease;
    transform: translateX(-50%);
}

.topnav a:hover {
    color: var(--cyan);
    background-color: var(--bg-highlight);
    text-decoration: none;
}

.topnav a:hover::before {
    width: 60%;
}

.topnav a.active {
    color: var(--cyan);
    background-color: var(--bg-highlight);
}

/* ========================================
   Theme Toggle Button
   ======================================== */
.theme-toggle {
    background: var(--bg-highlight);
    border: 1px solid var(--bg-float);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--bg-float);
    border-color: var(--cyan);
}

.theme-icon {
    width: 20px;
    height: 20px;
    position: relative;
}

/* Sun icon (shown in dark mode) */
.theme-icon::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 
        0 0 0 2px var(--bg-highlight),
        0 0 0 4px var(--yellow),
        0 0 8px var(--yellow);
    transition: all 0.3s ease;
}

/* Moon icon (shown in light mode) */
:root[data-theme="light"] .theme-icon::before,
:root:not([data-theme="dark"]) .theme-icon::before {
    background: var(--blue);
    box-shadow: 
        inset -6px -2px 0 0 var(--bg-highlight),
        0 0 0 2px transparent;
}

/* Keep sun in dark mode when explicitly set */
:root[data-theme="dark"] .theme-icon::before {
    background: var(--yellow);
    box-shadow: 
        0 0 0 2px var(--bg-highlight),
        0 0 0 4px var(--yellow),
        0 0 8px var(--yellow);
}

/* Override for system preference light mode */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-icon::before {
        background: var(--blue);
        box-shadow: inset -6px -2px 0 0 var(--bg-highlight);
    }
}

/* ========================================
   Typography - Headings
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    margin: 0.0em 0 0.75em 0;
    line-height: 1.3;
    font-weight: 600;
}

h1 {
    color: var(--cyan);
    font-size: 2rem;
}

h1::before {
    content: "# ";
    color: var(--comment);
    font-weight: normal;
}

h2 {
    color: var(--blue);
    font-size: 1.5rem;
}

h2::before {
    content: "## ";
    color: var(--comment);
    font-weight: normal;
}

h3 {
    color: var(--orange);
    font-size: 1.25rem;
}

h3::before {
    content: "### ";
    color: var(--comment);
    font-weight: normal;
}

h4 {
    color: var(--green);
    font-size: 1.1rem;
}

h4::before {
    content: "#### ";
    color: var(--comment);
    font-weight: normal;
}

/* ========================================
   Typography - Body Elements
   ======================================== */
p {
    margin: 1em 0;
    color: var(--fg-dark);
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--cyan);
    text-decoration: underline;
}

b, strong {
    color: var(--fg);
    font-weight: 600;
}

b::before, strong::before {
    content: none;
}

code {
    background-color: var(--bg-highlight);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--magenta);
}

pre {
    background-color: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--bg-highlight);
    margin: 1em 0;
}

pre code {
    background: none;
    padding: 0;
}

blockquote {
    border-left: 4px solid var(--blue);
    padding-left: 1rem;
    margin: 1em 0;
    color: var(--comment);
    font-style: italic;
}

/* ========================================
   Lists
   ======================================== */
ul, ol {
    margin: 1em 0;
    padding-left: 1.5em;
}

ul {
    list-style-type: none;
}

ul li {
    position: relative;
    margin: 0.5em 0;
    padding-left: 0.5em;
}

ul li::before {
    content: '';
    position: absolute;
    left: -1em;
    top: 0.65em;
    width: 6px;
    height: 6px;
    background-color: var(--cyan);
    border-radius: 50%;
}

ol {
    list-style-type: decimal;
}

ol li {
    margin: 0.5em 0;
    padding-left: 0.5em;
}

ol li::marker {
    color: var(--cyan);
}

/* Nested lists */
ul ul, ol ul, ul ol, ol ol {
    margin: 0.25em 0;
}

/* Logo images in lists - vertically align with text */
ul li img, ol li img {
    vertical-align: middle;
    margin-right: 0.5em;
}

/* ========================================
   Collaborations Section
   ======================================== */
#collaborations + p + ul {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#collaborations + p + ul li {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background-color: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--blue0);
    transition: all 0.2s ease;
}

#collaborations + p + ul li::before {
    content: none;
}

#collaborations + p + ul li:hover {
    border-left-color: var(--cyan);
    background-color: var(--bg-highlight);
}

#collaborations + p + ul li img {
    flex-shrink: 0;
    width: 150px;
    height: 100px;
    object-fit: contain;
    margin: 0;
    /* padding: 0.5rem; */
    background-color: white;
    border-radius: 4px;
}

/* Remove background in light mode */
:root[data-theme="light"] #collaborations + p + ul li img {
    background-color: transparent;
    padding: 0;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) #collaborations + p + ul li img {
        background-color: transparent;
        padding: 0;
    }
}

#collaborations + p + ul li p {
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 768px) {
    #collaborations + p + ul li {
        flex-direction: column;
        text-align: center;
    }
    
    #collaborations + p + ul li img {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   Horizontal Rules
   ======================================== */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--bg-highlight), var(--blue0), var(--bg-highlight), transparent);
    margin: 2rem 0;
}

/* ========================================
   Tables
   ======================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    background-color: var(--bg);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-highlight);
}

th {
    background-color: var(--bg-highlight);
    color: var(--cyan);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: var(--bg-highlight);
}

/* ========================================
   Forms & Inputs
   ======================================== */
input[type=checkbox] {
    display: none;
}

input[type=checkbox] + label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

input[type=checkbox] + label::before {
    content: '[ ]';
    color: var(--cyan);
    font-family: 'Fira Code', monospace;
}

input[type=checkbox]:checked + label::before {
    content: '[x]';
    color: var(--green);
}

input[type=checkbox]:hover + label::before {
    color: var(--blue);
}

/* ========================================
   Bibliography & Citations (Pandoc/CSL)
   ======================================== */
#refs {
    margin-top: 1rem;
}

.csl-entry {
    display: flex;
    margin: 1rem 0;
    padding: 1rem;
    background-color: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--blue0);
    transition: all 0.2s ease;
}

.csl-entry:hover {
    border-left-color: var(--cyan);
    background-color: var(--bg-highlight);
}

.csl-left-margin {
    color: var(--cyan);
    font-weight: 600;
    min-width: 2.5em;
    flex-shrink: 0;
}

.csl-right-inline {
    margin-left: 0.5em;
    color: var(--fg-dark);
}

.csl-right-inline span {
    margin-left: 0;
}

/* ========================================
   Footer
   ======================================== */
footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
}

footer p {
    color: var(--comment);
    font-size: 0.85rem;
}

footer .footer-built {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.social-links a {
    color: var(--comment);
    transition: color 0.2s ease;
}

.social-links a:hover {
    color: var(--cyan);
}

.social-links svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   Contact Card
   ======================================== */
.contact-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background-color: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--blue0);
    transition: all 0.2s ease;
}

.contact-item:hover {
    border-left-color: var(--cyan);
    background-color: var(--bg-highlight);
}

.contact-item p {
    margin: 0;
    line-height: 1.6;
    padding-left: 2.5rem;
    text-indent: -2.5rem;
}

.contact-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}

.contact-item a {
    color: var(--cyan);
    font-weight: 500;
}

.contact-item a:hover {
    color: var(--blue);
}

@media (max-width: 480px) {
    .contact-item {
        padding: 1rem;
    }
    
    .contact-item p {
        gap: 0.75rem;
    }
    
    .contact-icon {
        font-size: 1.25rem;
        width: 1.25rem;
    }
}

/* ========================================
   Utility Classes
   ======================================== */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--comment);
}

.highlight {
    background: linear-gradient(135deg, var(--bg-highlight), var(--bg));
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border: 1px solid var(--bg-highlight);
}

/* ========================================
   Section specific styling
   ======================================== */
section {
    margin: 2rem 0;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    body {
        font-size: 15px;
    }
    
    .container {
        padding: 1rem;
    }
    
    .site-title {
        font-size: 2rem;
    }
    
    .topnav {
        gap: 0.5rem;
    }
    
    .topnav a {
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .theme-toggle {
        width: 38px;
        height: 38px;
    }
    
    .theme-icon {
        width: 16px;
        height: 16px;
    }
    
    .theme-icon::before {
        width: 16px;
        height: 16px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.15rem; }
    
    .csl-entry {
        flex-direction: column;
        padding: 0.75rem;
    }
    
    .csl-left-margin {
        margin-bottom: 0.5em;
    }
    
    .csl-right-inline {
        margin-left: 0;
    }
    
    table {
        font-size: 0.9em;
    }
    
    th, td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 1.5rem;
    }
    
    .header-top {
        gap: 0.5rem;
    }
    
    .topnav {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .topnav a {
        text-align: center;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    body {
        background-color: white;
        color: black;
    }
    
    .topnav, .theme-toggle {
        display: none;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    h1, h2, h3, h4 {
        color: black;
    }
    
    h1::before, h2::before, h3::before, h4::before {
        content: none;
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

main {
    animation: fadeIn 0.4s ease-out;
}

/* ========================================
   Talks Page
   ======================================== */
.talks-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.talk-entry {
    display: flex;
    gap: 1.5rem;
    padding: 1.25rem;
    background-color: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--blue0);
    transition: all 0.2s ease;
}

.talk-entry:hover {
    background-color: var(--bg-highlight);
}

/* Talk type colors */
.talk-entry--invited {
    border-left-color: var(--cyan);
}

.talk-entry--invited:hover {
    border-left-color: var(--blue);
}

.talk-entry--presentation {
    border-left-color: var(--green);
}

.talk-entry--presentation:hover {
    border-left-color: var(--green1);
}

.talk-entry--poster {
    border-left-color: var(--magenta);
}

.talk-entry--poster:hover {
    border-left-color: var(--purple);
}

.talk-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.talk-logo img {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    border-radius: 4px;
    background-color: white;
}

/* Remove background in light mode */
:root[data-theme="light"] .talk-logo img {
    background-color: transparent;
    padding: 0;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .talk-logo img {
        background-color: transparent;
        padding: 0;
    }
}

.talk-content {
    flex: 1;
    min-width: 0;
}

.talk-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.talk-title::before {
    content: none;
}

.talk-conference {
    margin: 0 0 0.25rem 0;
    color: var(--fg-dark);
    font-size: 0.95rem;
}

.talk-location {
    margin: 0 0 0.5rem 0;
    color: var(--fg-dark);
    font-size: 0.9rem;
}

.talk-links {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3em;
}

.talk-links a {
    color: var(--cyan);
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    line-height: 1;
}

.talk-links a:hover {
    color: var(--blue);
}

.link-icon {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    flex-shrink: 0;
}

.link-icon--youtube {
    color: #ff0000;
}

.talk-links a:hover .link-icon--youtube {
    color: #cc0000;
}

.talk-proceedings {
    margin: 0;
    font-size: 0.85rem;
    color: var(--comment);
}

.talk-proceedings a {
    color: var(--green);
}

.talk-proceedings a:hover {
    color: var(--cyan);
}

.talk-count {
    color: var(--comment);
    font-weight: normal;
    font-size: 0.85em;
}

@media (max-width: 768px) {
    .talk-entry {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
        text-align: center;
    }
    
    .talk-links {
        justify-content: center;
    }
}

/* ========================================
   Figures & Subfigures
   ======================================== */
figure {
    margin: 1.5rem 0;
}

/* Parent figure containing subfigures */
figure > figure {
    margin: 0;
}

/* Container for side-by-side subfigures */
figure:has(> figure) {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    align-items: flex-start;
}

/* Subfigure styling */
figure > figure {
    flex: 1 1 45%;
    max-width: 48%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

figure > figure .center {
    width: 100%;
    height: 250px;  /* Set fixed height for image container */
    display: flex;
    align-items: center;
    justify-content: center;
}

figure > figure img {
    max-width: 100%;
    max-height: 250px;
    width: auto !important;  /* Override pandoc inline style */
    height: auto !important;  /* Override pandoc inline style */
    object-fit: contain;
    border-radius: 8px;
}

figure > figure figcaption {
    margin-top: 0.75rem;
    color: var(--fg-dark);
    font-size: 0.9rem;
    text-align: center;
}

/* Hide the parent figure's duplicate caption */
figure:has(> figure) > figcaption:last-child {
    display: none;
}

/* Remove center div styling that pandoc adds */
figure:not(:has(> figure)) .center {
    display: contents;
}

@media (max-width: 600px) {
    figure:has(> figure) {
        flex-direction: column;
    }
    
    figure > figure {
        max-width: 100%;
        flex: 1 1 100%;
    }
}

/* ========================================
   Selection Styling
   ======================================== */
::selection {
    background-color: var(--blue0);
    color: var(--fg);
}

/* ========================================
   Scrollbar Styling
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-highlight);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--comment);
}

/* ========================================
   CV Page Styling
   ======================================== */

/* CV header paragraphs - centered */
.cv-page .cv-name,
.cv-page .cv-title,
.cv-page .cv-contact,
.cv-page .cv-quote {
    text-align: center;
    margin: 0.3rem 0;
}

.cv-page .cv-name p,
.cv-page .cv-title p,
.cv-page .cv-contact p,
.cv-page .cv-quote p {
    margin: 0;
}

/* Name styling */
.cv-page .cv-name {
    margin-bottom: 0.5rem;
}

.cv-page .cv-name strong {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* "Curriculum Vitae [PDF]" line */
.cv-page .cv-title {
    font-size: 1.1rem;
    color: var(--fg);
    margin-bottom: 0.75rem;
}

.cv-page .cv-title a {
    color: var(--cyan);
    font-size: 0.9rem;
}

/* Contact info line */
.cv-page .cv-contact {
    color: var(--fg-dark);
    font-size: 0.95rem;
}

.cv-page .cv-contact a {
    color: var(--cyan);
}

/* Quote line */
.cv-page .cv-quote {
    color: var(--fg-dark);
    font-style: italic;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    padding: 0 2rem;
}

/* CV section headers with horizontal rule */
.cv-page .cv-section {
    margin: 0;
}

.cv-page .cv-section p {
    margin: 0;
}

.cv-page .cv-section strong {
    display: block;
    color: var(--cyan);
    font-size: 1.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.cv-page .cv-section + hr {
    border: none;
    height: 2px;
    background: var(--cyan);
    margin-top: 0;
    margin-bottom: 1rem;
}

/* CV entry tables styling */
.cv-page main > table {
    width: 100%;
    margin: 0.5rem 0;
    border-collapse: collapse;
    background: transparent;
    table-layout: fixed;
}

.cv-page main > table colgroup,
.cv-page main > table col {
    display: none;
}

.cv-page main > table td {
    padding: 0.5rem 0;
    border: none;
    vertical-align: top;
    background: transparent;
}

.cv-page main > table tr:hover {
    background: transparent;
}

.cv-page main > table td:first-child {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    color: var(--comment);
    font-size: 0.9rem;
    padding-right: 1rem;
    text-align: right;
}

.cv-page main > table td:first-child p {
    margin: 0;
}

.cv-page main > table td:last-child {
    padding-left: 1rem;
    border-left: 2px solid var(--bg-highlight);
}

.cv-page main > table td:last-child:hover {
    border-left-color: var(--cyan);
}

/* CV publications list */
.cv-page main > ol {
    counter-reset: cv-pub;
}

.cv-page main > ol > li {
    margin: 0.75rem 0;
    padding-left: 0.5rem;
}

.cv-page main > ol > li::marker {
    color: var(--cyan);
    font-weight: 600;
}

/* CV subheadings (h3 in publications) */
.cv-page main h3 {
    margin-top: 1.5rem;
}

