/* styles.css */
/* Light is the default theme; js/theme.js sets data-theme from the saved choice. */
:root {
    color-scheme: light;
    --paper: #f7f1e6;
    --ink: #2b2420;
    --accent: #bd632f;
    --accent-soft: #e9d9c8;
    --muted: #6b6058;
    --line: #ddd0bd;
    --shadow: rgba(43, 36, 32, 0.08);
    --footer-bg: #2b2420;
    --footer-ink: #f7f1e6;
    --footer-muted: #e9d9c8;
    --code-bg: #2b2420;
    --code-ink: #f7f1e6;
    --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #161514;
    --ink: #ede4d6;
    --accent: #e08a52;
    --accent-soft: #302720;
    --muted: #a09a92;
    --line: #2c2b29;
    --shadow: rgba(0, 0, 0, 0.35);
    --footer-bg: #0f0f0e;
    --footer-muted: #b8aa9a;
    --code-bg: #0e0e0d;
}

/* Base styles */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1 0 auto;
}

/* Typography */
h1, h2, h3 {
    font-family: var(--mono);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h3 {
    font-size: 0.88rem;
    line-height: 1.4;
}

h1.wordmark {
    font-size: clamp(1.75rem, 2vw + 1.25rem, 2.75rem);
    color: var(--ink);
    margin: 0;
    line-height: 1.1;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
}

h1.wordmark::after {
    content: ".";
    color: var(--accent);
}

.tagline {
    font-family: var(--mono);
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0.15rem 0 0;
}

.eyebrow {
    display: block;
    font-family: var(--mono);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

h2 {
    color: var(--ink);
    font-size: 1.15rem;
    margin: 0 0 0.25rem;
    padding-bottom: 0.4rem;
    line-height: 1.3;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.lede {
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--ink);
    margin: 0 0 0.75rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    background-image: linear-gradient(var(--accent), var(--accent));
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 0% 1px;
    transition: background-size 0.25s ease, color 0.25s ease;
}

a:hover {
    background-size: 100% 1px;
}

/* Layout components */
header {
    background: var(--paper);
    padding: 0.85rem 1rem 0.6rem;
    text-align: center;
    position: relative;
}

header .masthead-inner {
    max-width: 1200px;
    margin: 0 auto;
}

nav {
    background: var(--paper);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.container {
    max-width: 820px;
    margin: 0.5rem auto;
    padding: 0 1rem;
}

.content-card {
    background: var(--paper);
    padding: 0.75rem 0;
}

footer {
    background: var(--footer-bg);
    color: var(--footer-ink);
    text-align: center;
    padding: 0.85rem 1rem 0.7rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

footer a {
    color: var(--footer-ink);
    background-image: linear-gradient(var(--accent), var(--accent));
}

.footer-links {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    padding: 0;
    margin: 0 0 0.35rem;
}

.contact-links {
    justify-content: flex-start;
}

.footer-note {
    font-family: var(--mono);
    color: var(--footer-muted);
    font-size: 0.72rem;
    margin: 0;
}

/* Navigation */
.nav-menu {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-menu li a {
    color: var(--ink);
    text-decoration: none;
    background-size: 0 1px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.45rem 0.85rem;
    display: block;
}

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

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

/* Theme control (injected by js/main.js) */
.site-controls {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: none;
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Card grids (publications / projects / directory) */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px var(--shadow);
}

.card h3 {
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.4;
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
}

.card .authors {
    font-style: italic;
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.card .abstract {
    font-size: 0.92rem;
    line-height: 1.5;
    margin-top: 0;
    margin-bottom: 0.6rem;
}

.card .read-more {
    display: inline-block;
    background-color: var(--ink);
    color: var(--paper);
    background-image: none;
    padding: 0.4rem 0.9rem;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background-color 0.25s ease;
}

.card .read-more:hover {
    background-color: var(--accent);
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin: 0;
}

.card-actions .text-link {
    font-size: 0.85rem;
    white-space: nowrap;
}

.timeline {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.timeline li {
    padding: 0.7rem 0;
    border-top: 1px solid var(--line);
}

.timeline li:last-child {
    padding-bottom: 0;
}

.timeline-role {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 1.5rem;
}

.timeline-role h3 {
    margin: 0;
}

.timeline-dates {
    font-family: var(--mono);
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Blog post list */
.post-list a {
    display: block;
    color: var(--ink);
    text-decoration: none;
    background-image: none;
}

.post-list li {
    padding: 0.95rem 0;
}

.post-list h3 {
    transition: color 0.25s ease;
}

.post-list h3::after {
    content: "\2192";
    display: inline-block;
    margin-left: 0.4em;
    color: var(--accent);
    opacity: 0;
    transform: translateX(-0.3em);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.post-list a:hover h3 {
    color: var(--accent);
}

.post-list a:hover h3::after {
    opacity: 1;
    transform: none;
}

.post-list .abstract {
    margin: 0.2rem 0 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--muted);
}

/* Publications use the same rows, with the abstract cut to a few lines */
.paper-list h3 {
    margin: 0;
}

.paper-list .authors {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--muted);
}

.paper-list .abstract {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    margin-top: 0.4rem;
}

/* Newer / older controls under the blog list (added by js/main.js) */
.post-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.post-pager button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--ink);
    cursor: pointer;
    transition: color 0.25s ease;
}

.post-pager button:hover {
    color: var(--accent);
}

.post-pager button:disabled {
    color: var(--line);
    cursor: default;
}

.badge {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

/* Blog post body */
.post-body {
    max-width: 68ch;
    margin-top: 1rem;
}

.post-body p {
    margin: 0 0 0.9rem;
}

.post-body h3 {
    font-size: 1.05rem;
    margin: 1.5rem 0 0.5rem;
}

.post-body h4 {
    font-size: 1.05rem;
    margin: 1.25rem 0 0.4rem;
}

.post-body ul,
.post-body ol {
    margin: 0 0 0.9rem;
    padding-left: 1.4rem;
}

.post-body li {
    margin-bottom: 0.3rem;
}

.post-body blockquote {
    margin: 1.25rem 0;
    padding-left: 1rem;
    border-left: 2px solid var(--accent);
    color: var(--muted);
    font-style: italic;
}

.post-body strong {
    color: var(--ink);
}

.post-body ul ul,
.post-body ul ol,
.post-body ol ul,
.post-body ol ol {
    margin-top: 0.5rem;
}

.post-body pre {
    background: var(--code-bg);
    color: var(--code-ink);
    padding: 1rem 1.25rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0 0 0.9rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.post-body code {
    font-family: var(--mono);
    font-size: 0.85em;
}

.post-body p code {
    background: var(--accent-soft);
    color: var(--ink);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

.post-body .table-wrap {
    overflow-x: auto;
    margin: 0 0 0.9rem;
}

.post-body table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.92rem;
}

.post-body th,
.post-body td {
    border: 1px solid var(--line);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.post-body th {
    background: var(--accent-soft);
    color: var(--ink);
}

.post-figure {
    margin: 1.25rem 0;
}

.post-figure img {
    max-width: 100%;
    border-radius: 4px;
    display: block;
}

.post-figure figcaption {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

.post-body img {
    max-width: 100%;
    border-radius: 4px;
}

/* Interactive charts (```plotly in a post); js/charts.js draws into the div.
   The fixed height keeps the text below from jumping when the chart loads. */
.plotly-chart {
    width: 100%;
    height: 380px;
}

@media (max-width: 768px) {
    .plotly-chart {
        height: 300px;
    }
}

/* The single page (index.html) */
html {
    scroll-behavior: smooth;
}

body.onepage nav {
    position: sticky;
    top: 0;
    z-index: 10;
}

body.onepage section {
    scroll-margin-top: 3rem;
}

body.onepage .container {
    margin-top: 2rem;
    margin-bottom: 3rem;
    counter-reset: section;
}

/* Number the section labels: "01 / Blog" */
body.onepage section {
    counter-increment: section;
}

body.onepage section .eyebrow::before {
    content: counter(section, decimal-leading-zero) " / ";
    color: var(--muted);
}

body.onepage section + section {
    border-top: 1px solid var(--line);
    margin-top: 2.5rem;
    padding-top: 2.5rem;
}

body.onepage .content-card + .content-card {
    padding-top: 1.5rem;
}

/* Media Queries */
@media (max-width: 1024px) {
    .nav-menu li a {
        padding: 0.45rem 0.6rem;
    }
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .timeline-dates {
        white-space: normal;
    }

    .site-controls {
        position: static;
        justify-content: center;
        margin-top: 0.5rem;
    }

    .menu-toggle {
        display: block;
        width: 100%;
        text-align: right;
        padding: 1rem;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu li {
        margin: 0;
        text-align: center;
    }

    .nav-menu li a {
        padding: 1rem;
    }
}

/* Wide screens: the masthead and nav become a sidebar pinned to the left of
   the content column. */
@media (min-width: 1025px) {
    :root {
        --side: max(1.5rem, calc(50% - 566px));
        --sidebar: 280px;
    }

    header {
        position: fixed;
        top: 3.5rem;
        left: var(--side);
        width: 230px;
        padding: 0;
        background: none;
        text-align: left;
    }

    nav,
    body.onepage nav {
        position: fixed;
        top: 8.75rem;
        left: var(--side);
        width: 230px;
        background: none;
        border: 0;
    }

    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-menu li a {
        padding: 0.4rem 0;
    }

    .site-controls {
        position: fixed;
        top: auto;
        right: auto;
        bottom: 2rem;
        left: var(--side);
    }

    .container,
    body.onepage .container {
        margin-top: 3.5rem;
        margin-left: calc(var(--side) + var(--sidebar));
        margin-right: 0.5rem;
    }

    body.onepage section {
        scroll-margin-top: 3.5rem;
    }

    footer {
        max-width: 820px;
        margin: 2rem 1.5rem 0 calc(var(--side) + var(--sidebar) + 1rem);
        padding: 1.25rem 0 2rem;
        background: none;
        border-top: 1px solid var(--line);
        color: var(--muted);
        text-align: left;
    }

    footer a {
        color: var(--ink);
    }

    .footer-links {
        justify-content: flex-start;
    }

    .footer-note {
        color: var(--muted);
    }
}
