/* DEFAULT (Light Mode) */
:root {
    --bg: #ffffff;
    --text: #1a1a1a;
    --accent: #666666;
    --light-gray: #f9f9f9;
    --border-color: #e5e5e5;
}

/* AUTOMATIC DARK MODE (Triggers if visitor's OS is set to Dark Theme) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;          /* Charcoal instead of pure black */
        --text: #e0e0e0;        /* Soft off-white to prevent eye strain */
        --accent: #a0a0a0;      /* Muted gray for captions and metadata */
        --light-gray: #1e1e1e;  /* Dark card background */
        --border-color: #2c2c2c;/* Subtle dark border */
    }
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    background-color: var(--bg);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- NAVIGATION --- */
nav {
    padding: 1.5rem 0 0.5rem 0;
}

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

/* Logo: Matches the Playfair Display editorial serif */
.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap; /* Prevents name from wrapping on mobile */
}

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

/* Nav Links: Clean Title Case Inter */
nav a {
    text-decoration: none;
    color: var(--text);
    font-weight: 400;
    font-size: 0.95rem;
    text-transform: none; /* Removes ALL CAPS */
    letter-spacing: normal;
}

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

header {
    padding: 2.5rem 0 1rem 0; /* Compact top/bottom padding for "Thinking with biology" */
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 700;
    max-width: 700px;
    line-height: 1.2;
    margin: 0;
}

.italic { 
    font-style: italic; 
    color: var(--accent); 
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.card {
    background: var(--light-gray);
    padding: 10px;
    border: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}

.card p {
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 0.5rem;
    margin-bottom: 0;
}

section {
    padding: 2rem 0; /* Compact spacing between content sections */
}

article {
    border-bottom: 1px solid #eee;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

footer {
    text-align: center;
    padding: 4rem 0;
    font-size: 0.8rem;
    color: var(--accent);
}

/* --- MOBILE-SPECIFIC ADJUSTMENTS --- */
@media (max-width: 600px) {
    /* Stack logo on top, menu links directly below */
    nav .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    nav ul {
        gap: 1.25rem;
        width: 100%;
    }

    nav a {
        font-size: 0.9rem;
    }

    header {
        padding: 1.5rem 0 0.5rem 0;
    }

    h1 { 
        font-size: 2.2rem; 
    }

    section {
        padding: 1.5rem 0;
    }

    .grid { 
        grid-template-columns: 1fr; 
    }
}

/* Enables smooth scrolling when clicking footnote links */
html {
    scroll-behavior: smooth;
}

/* Style for inline superscript links like [1] */
sup a {
    text-decoration: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85em;
    padding: 0 2px;
}

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

/* Footnotes block at the bottom of the page */
.footnotes {
    margin-top: 4rem;
    font-size: 0.9rem;
    color: var(--accent);
}

.footnotes hr {
    border: 0;
    border-top: 1px solid #eee;
    margin-bottom: 2rem;
}

.footnotes p {
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.footnotes a {
    text-decoration: none;
    color: var(--accent);
    margin-left: 4px;
}

.footnotes a:hover {
    color: var(--text);
}

/* Article Image Container */
.article-image {
    margin: 2.5rem 0;
    padding: 0;
    text-align: center;
}

/* Image behavior inside articles */
.article-image img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border: 1px solid #e5e5e5;
}

/* Captions */
figcaption {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--accent);
    font-style: italic;
    line-height: 1.4;
}