/* ------------------------------------------------------------------
   Design tokens
------------------------------------------------------------------ */
:root {
    --ink: #1f2328;
    --ink-soft: rgba(0, 0, 0, 0.72);
    --ink-muted: rgba(0, 0, 0, 0.6);
    --ink-faint: rgba(0, 0, 0, 0.45);

    --paper: #ffffff;
    --cream: #f3f6fa;       /* snow — was warm #f7f7f3 */
    --cream-2: #e8edf3;     /* snow-2 — was warm #f1f1ea */

    --accent: #1b4f9a;
    --accent-deep: #0b3b75;
    --accent-soft: #e7ecf2;

    --border: rgba(0, 0, 0, 0.08);
    --border-soft: #e6ebf1;

    --footer-bg: #1f2328;
    --footer-fg: #f8f9fb;

    --serif: Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", "URW Palladio L", "TeX Gyre Pagella", Georgia, serif;
    --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    --sidebar-w: 300px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.7;
    font-weight: 500;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}
a:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4, h5 {
    font-family: var(--serif);
    font-weight: 700;
    color: var(--ink-soft);
    line-height: 1.25;
    letter-spacing: 0.005em;
}

img { max-width: 100%; height: auto; display: block; }

/* ------------------------------------------------------------------
   Page shell — fixed sidebar + flowing main column
------------------------------------------------------------------ */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--cream);
    border-right: 1px solid var(--border-soft);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 2.5rem 1.75rem 1.5rem;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
}

.sidebar-photo-link { display: block; margin-bottom: 1.25rem; }
.sidebar-photo-wrap {
    position: relative;
    display: block;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #181b1f;
}
.sidebar-photo-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 2;     /* overlays the ASCII canvas during the final fade */
    opacity: 0;
}
.sidebar-photo-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    display: block;
}
.sidebar-photo {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    display: block;
    z-index: 0;     /* back: only visible as the no-JS / failure fallback */
}
/* When JS is present we hide the static photo by default so it can't flash
   in before the reveal script runs.  The script's early-return paths and
   the mobile fallback add .is-shown back when the photo is the intended
   state.  Without JS, the photo stays visible as a graceful fallback. */
.js .sidebar-photo:not(.is-shown) { opacity: 0; visibility: hidden; }
.sidebar-photo.is-hidden { opacity: 0; visibility: hidden; }

.sidebar-name {
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0.25rem 0 0.4rem;
    letter-spacing: 0.005em;
}
.sidebar-role {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 500;
    color: var(--ink-soft);
    margin: 0 0 0.15rem;
    line-height: 1.4;
}
.sidebar-affil {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--ink-muted);
    margin: 0 0 1.5rem;
    letter-spacing: 0.02em;
}

.sidebar-nav { width: 100%; }
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li {
    margin: 0.15rem 0;
    font-size: 1.05rem;
    font-family: var(--serif);
}
.sidebar-nav a {
    display: inline-block;
    color: var(--ink-soft);
    padding: 0.25rem 0;
    position: relative;
    font-weight: 600;
    letter-spacing: 0;
}
.sidebar-nav a::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 4px;
    height: 1px;
    background: var(--ink);
    transform: scaleX(0);
    transition: transform 0.25s cubic-bezier(.175,.885,.32,1.275);
}
.sidebar-nav a:hover { color: var(--ink); text-decoration: none; }
.sidebar-nav a:hover::after { transform: scaleX(1); }

.sidebar-meta {
    margin-top: 1.5rem;
    font-family: var(--sans);
    font-size: 0.78rem;
    color: var(--ink-muted);
    letter-spacing: 0.02em;
}
.sidebar-meta p { margin: 0.15rem 0; }

.sidebar-social {
    list-style: none;
    padding: 0;
    margin: 1.25rem 0 0.25rem;
    display: flex;
    justify-content: center;
    gap: 0.6rem;
}
.sidebar-social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--ink-soft);
    background: rgba(0, 0, 0, 0.04);
    transition: background 0.2s ease, color 0.2s ease;
}
.sidebar-social a:hover {
    background: rgba(27, 79, 154, 0.12);
    color: var(--accent);
    text-decoration: none;
}

/* ------------------------------------------------------------------
   Main column
------------------------------------------------------------------ */
.main-col {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 760px;
    padding: 3.5rem 2.5rem 4rem;
    margin: 0 auto;
    flex: 1;
}

/* ------------------------------------------------------------------
   Intro block
------------------------------------------------------------------ */
.intro {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.5rem;
}
.intro-greeting {
    font-family: var(--serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 1rem;
    letter-spacing: 0;
    line-height: 1.2;
}
.intro-lede, .intro-body {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.7;
    color: var(--ink);
    margin: 0 0 0.9rem;
}
.intro-contact {
    font-family: var(--sans);
    font-size: 0.92rem;
    color: var(--ink-muted);
    margin: 1rem 0 0;
}
.intro-label {
    display: inline-block;
    background: var(--cream-2);
    color: var(--ink);
    padding: 0.05em 0.55em;
    border-radius: 3px;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 0.78rem;
    text-transform: uppercase;
    margin-right: 0.5rem;
}

/* ------------------------------------------------------------------
   Section headings
------------------------------------------------------------------ */
.section { margin: 2.5rem 0; }
h2 {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    margin: 2.4rem 0 1rem;
    letter-spacing: 0;
}
.section-title {
    margin: 0 0 1.25rem;
}

/* Replace markdown horizontal rules with vertical breathing room. */
.container hr {
    border: 0;
    height: 0;
    margin: 1.5rem 0;
}
h3 {
    font-family: var(--serif);
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--ink-soft);
    margin: 1.5rem 0 0.6rem;
}
h1 {
    font-family: var(--serif);
    font-size: 1.95rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 1.25rem;
    letter-spacing: 0;
}

/* ------------------------------------------------------------------
   Publications (Selected Publications section)
------------------------------------------------------------------ */
.section-note {
    font-family: var(--sans);
    font-size: 0.82rem;
    color: var(--ink-faint);
    margin: -0.75rem 0 1rem;
    letter-spacing: 0.02em;
}

.pub-list {
    list-style: decimal;
    padding-left: 1.7em;
    margin: 0;
}
.pub-list li {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.7;
    color: var(--ink);
    margin-bottom: 1.25em;
    padding-left: 0.2em;
}
.pub-list li::marker {
    color: var(--ink-muted);
    font-weight: 600;
}
.pub-me {
    text-decoration: underline;
    text-underline-offset: 2px;
    color: var(--ink);
}
.pub-title {
    font-weight: 700;
    color: var(--ink);
}
.pub-list sup {
    color: var(--accent);
    font-weight: 600;
    margin-left: 1px;
}
.pub-shield {
    display: inline-block;
    height: 20px;
    width: auto;
    max-width: none;
    vertical-align: -5px;
    margin: 0 2px;
    border-radius: 3px;
}
.pub-shield-link {
    display: inline-block;
}
.pub-shield-link:hover .pub-shield { opacity: 0.85; }

/* ------------------------------------------------------------------
   Project cards
------------------------------------------------------------------ */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.project-card {
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    border-color: var(--accent-soft);
    text-decoration: none;
}
.project-card-img {
    width: 100%;
    height: 170px;
    overflow: hidden;
    background: var(--cream-2);
}
.project-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
}
.project-card-body { padding: 1rem 1.1rem 1.2rem; flex: 1; display: flex; flex-direction: column; }
.project-card-title {
    font-family: var(--serif);
    font-size: 1.13rem;
    font-weight: 700;
    color: var(--accent-deep);
    margin: 0 0 0.2rem;
    line-height: 1.3;
}
.project-card-date {
    font-family: var(--sans);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    margin: 0 0 0.6rem;
}
.project-card-desc {
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.55;
    color: var(--ink-soft);
    margin: 0;
}

/* ------------------------------------------------------------------
   News-style writing list (date · title)
------------------------------------------------------------------ */
.news-list, .til-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.news-item, .til-item {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-soft);
    position: relative;
}
.news-item:last-child, .til-item:last-child { border-bottom: none; }

/* Hover preview — small thumbnail floats up-right on hover */
.news-preview {
    position: absolute;
    right: 0;
    bottom: calc(100% - 6px);
    width: 220px;
    height: 140px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    background: var(--cream);
    opacity: 0;
    transform: translateY(8px) scale(0.97);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 5;
}
/* !important needed to override the global .container img post-content
   rule, which has (0,4,2) specificity from its three :not() pseudos. */
.news-preview img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    object-fit: cover;
    display: block;
}
.news-item:hover .news-preview {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.news-item:hover .news-link { color: var(--accent); }
@media (hover: none) {
    .news-preview { display: none; }
}

.news-date, .til-date {
    flex: 0 0 auto;
    width: 110px;
    font-family: var(--sans);
    font-size: 0.82rem;
    color: var(--ink-faint);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.news-link, .til-link, .news-text {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 500;
    color: var(--ink);
    flex: 1;
}
.news-link:hover, .til-link:hover { color: var(--accent); }

.til-link { font-size: 0.95rem; }

.news-tag {
    display: inline-block;
    font-family: var(--sans);
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: var(--cream-2);
    color: var(--ink-muted);
    padding: 0.1em 0.5em;
    border-radius: 3px;
    margin-left: 0.55em;
    vertical-align: 1px;
}

/* ------------------------------------------------------------------
   Long-form post body styling (used on individual posts)
------------------------------------------------------------------ */
.container p { font-size: 1.02rem; font-weight: 500; line-height: 1.7; color: var(--ink); }
.container ul, .container ol { line-height: 1.7; font-weight: 500; color: var(--ink); }

strong {
    color: var(--ink);
    font-weight: 600;
    background: transparent;
    padding: 0;
    border-radius: 0;
}
em {
    display: block;
    text-align: center;
    color: var(--ink-faint);
    font-size: 0.9rem;
    margin: 1rem auto;
    font-style: italic;
}
em em, p > em:not(:only-child) { display: inline; text-align: inherit; margin: 0; font-size: inherit; }

blockquote {
    border-left: 3px solid var(--accent-soft);
    margin: 1.5rem 0;
    padding: 0.4rem 1rem;
    color: var(--ink-muted);
    font-style: italic;
}

/* Code blocks */
pre {
    position: relative;
    background: var(--cream);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 1rem 1.1rem;
    margin: 1.5rem 0;
    overflow: auto;
}
pre code {
    display: block;
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink);
    background: transparent;
}
code {
    font-family: var(--mono);
    font-size: 0.92em;
    background: var(--cream-2);
    color: var(--accent-deep);
    padding: 0.08em 0.35em;
    border-radius: 3px;
}
pre code { padding: 0; background: transparent; color: inherit; border-radius: 0; }

.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--ink-muted);
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: 3px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-family: var(--sans);
}
pre:hover .copy-button { opacity: 1; }
.copy-button:hover { color: var(--accent); border-color: var(--accent); }

/* Inline images inside posts */
.container img:not(.sidebar-photo):not(.project-card-img img):not(.pub-shield) {
    margin: 1.75rem auto;
    border-radius: 4px;
}

/* Twitter embeds */
.twitter-tweet {
    max-width: 350px !important;
    margin: 2rem auto !important;
    overflow: hidden !important;
}
.twitter-tweet iframe {
    border: none !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.05) !important;
    width: 100% !important;
    transform: scale(0.9) !important;
    transform-origin: 0 0 !important;
}

/* ------------------------------------------------------------------
   Footer
------------------------------------------------------------------ */
.site-footer {
    background: var(--footer-bg);
    color: var(--footer-fg);
    padding: 2.5rem 2.5rem;
    font-family: var(--sans);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    margin-top: auto;
}
.footer-inner { max-width: 760px; margin: 0 auto; }
.footer-copy { margin: 0 0 0.4rem; font-weight: 500; }
.footer-built { margin: 0; opacity: 0.65; }

/* ------------------------------------------------------------------
   Responsive — sidebar collapses to a top banner under 900px
------------------------------------------------------------------ */
@media (max-width: 900px) {
    :root { --sidebar-w: 100%; }
    .page { flex-direction: column; }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-soft);
        padding: 2rem 1.25rem 1.5rem;
    }
    .sidebar-inner { max-width: 520px; margin: 0 auto; }
    .sidebar-photo-wrap { width: 150px; height: 150px; }
    .sidebar-nav ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem 1.1rem;
    }
    .main-col { margin-left: 0; }
    .container { padding: 2.5rem 1.25rem 3rem; }
    .news-item, .til-item { flex-direction: column; gap: 0.1rem; align-items: flex-start; }
    .news-date, .til-date { width: auto; }
    .news-preview { display: none; }
}
