
/* ─── Design Tokens ──────────────────────────────────────────────── */
:root {
    --primary: #9b1b1b;
    --primary-hover: #7a1515;
    --bg: #fffaf5;
    --bg-alt: #fdf0e2;
    --bg-card: #ffffff;
    --text: #2a2019;
    --text-light: #6b5a4d;
    --border: #ecddd0;
    --accent: #d4920b;
    --shadow-sm: 0 1px 3px rgba(42,32,25,0.06), 0 1px 2px rgba(42,32,25,0.08);
    --shadow-md: 0 4px 12px rgba(42,32,25,0.1);
    --shadow-lg: 0 8px 24px rgba(42,32,25,0.14);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-bg: rgba(255,250,245,0.85);
    /* Viz-specific tokens */
    --viz-bg: #fffcf8;
    --viz-grid: #ecddd0;
    --viz-separator: #c4a88e;
    --viz-dot-stroke: #fff;
    --viz-stripe: rgba(42,32,25,0.025);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #e8654a;
        --primary-hover: #f07d65;
        --bg: #1a1410;
        --bg-alt: #2a2118;
        --bg-card: #221c16;
        --text: #e8ddd0;
        --text-light: #a08e7d;
        --border: #3d3228;
        --accent: #f0b840;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
        --shadow-lg: 0 8px 24px rgba(0,0,0,0.45);
        --nav-bg: rgba(26,20,16,0.85);
        --viz-bg: #1e1812;
        --viz-grid: #3d3228;
        --viz-separator: #5a4d40;
        --viz-dot-stroke: #3d3228;
        --viz-stripe: rgba(255,255,255,0.04);
    }
}

/* ─── Reset & Base ───────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 18px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px 32px;
}

p { margin-bottom: 20px; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { text-decoration: underline; color: var(--primary-hover); }

/* ─── Navigation ─────────────────────────────────────────────────── */
nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 14px 32px;
    margin: 0 -32px 36px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 4px;
}
nav .nav-brand {
    font-weight: 700;
    font-size: 1em;
    color: var(--text);
    text-decoration: none;
    margin-right: auto;
    padding: 6px 4px;
    letter-spacing: -0.01em;
}
nav .nav-brand:hover {
    color: var(--primary);
    background: transparent;
}
nav a {
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.92em;
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}
nav a:hover {
    color: var(--text);
    background: var(--bg-alt);
    text-decoration: none;
}
nav a.active {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    font-weight: 600;
}

/* ─── Typography ─────────────────────────────────────────────────── */
h1 {
    font-size: 2.4em;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
h2 {
    font-size: 1.4em;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 48px 0 20px;
    color: var(--text);
}
h3 { font-size: 1.15em; font-weight: 600; margin: 20px 0 8px; }
.subtitle { color: var(--text-light); font-size: 1.1em; margin-bottom: 24px; }

/* ─── Profile Header ─────────────────────────────────────────────── */
.profile-header {
    background: linear-gradient(to right, #1a2040 0%, #2d2040 25%, #4a2030 50%, #6a3530 75%, #8a6845 100%);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 48px 44px; margin-bottom: 36px;
    display: flex; gap: 32px; align-items: center;
    color: #fff; position: relative; overflow: hidden;
}
.profile-header::before {
    content: ''; position: absolute; top: -60%; right: -10%;
    width: 400px; height: 400px; border-radius: 50%;
    background: rgba(255,255,255,0.05);
}
.profile-header img {
    width: 140px; height: 140px; border-radius: 50%; object-fit: cover;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25); border: 4px solid rgba(255,255,255,0.3);
    flex-shrink: 0; position: relative; z-index: 1;
}
.profile-info { flex: 1; position: relative; z-index: 1; }
.profile-info h1 { color: #fff; }
.profile-info p { color: rgba(255,255,255,0.88); }
.profile-info .subtitle { color: rgba(255,255,255,0.7); }
.contact-links {
    display: flex; gap: 12px; margin-top: 16px;
}
.contact-links a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.9); transition: all 0.2s;
}
.contact-links a:hover {
    background: rgba(255,255,255,0.25); color: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    text-decoration: none;
}

/* ─── Tags ───────────────────────────────────────────────────────── */
.tag {
    display: inline-block; background: var(--bg-alt); border: 1px solid var(--border);
    padding: 3px 10px; border-radius: 14px; font-size: 0.85em; margin: 2px 4px 2px 0;
}

/* ─── Publication Sections ───────────────────────────────────────── */
.year-group { margin: 36px 0 12px; }
.year-label { font-size: 1.3em; font-weight: 700; color: var(--primary); }

/* Collapsible year sections */
.year-section { margin: 12px 0; }
.year-section > summary { cursor: pointer; list-style: none; padding: 10px 0; }
.year-section > summary::-webkit-details-marker { display: none; }
.year-section > summary::before { content: "▾ "; color: var(--primary); font-weight: bold; }
.year-section[open] > summary::before { content: "▾ "; }
.year-section:not([open]) > summary::before { content: "▸ "; }

/* ─── Publication Cards ──────────────────────────────────────────── */
.pub-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex; gap: 16px; align-items: flex-start;
    flex-direction: row-reverse;
}
.pub-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.pub-hero {
    width: 160px; height: 110px; object-fit: cover; border-radius: var(--radius-sm);
    flex-shrink: 0; background: var(--bg-alt);
}
.pub-card-body { flex: 1; min-width: 0; }
.pub-card-body h3 { margin: 0 0 6px; }
.pub-card .authors { color: var(--text-light); font-size: 0.9em; }
.pub-card .venue { font-style: italic; font-size: 0.9em; margin: 4px 0; }
.pub-card .links { margin-top: 10px; }
.pub-card .links a {
    display: inline-block; margin-right: 8px; margin-bottom: 4px; padding: 4px 10px;
    background: var(--bg-alt); border-radius: 6px; font-size: 0.85em;
    color: var(--primary); transition: background 0.2s, color 0.2s;
}
.pub-card .links a:hover { background: var(--primary); color: #fff; text-decoration: none; }
.award {
    background: #fff3cd; color: #856404; padding: 2px 8px; border-radius: 6px;
    font-size: 0.8em; font-weight: 600; display: inline-block; margin: 4px 4px 4px 0;
}
@media (prefers-color-scheme: dark) {
    .award { background: #3d3520; color: #ffd666; }
}

/* ─── Abstract & BibTeX ──────────────────────────────────────────── */
.abstract { margin: 16px 0; line-height: 1.7; }
.bibtex {
    background: var(--bg-alt); padding: 14px; border-radius: var(--radius-sm);
    font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.82em;
    white-space: pre-wrap; word-break: break-all; overflow-x: auto; margin: 12px 0;
}
.meta-row { margin: 4px 0; font-size: 0.9em; }
.meta-label { font-weight: 600; }

/* Collapsible pub details */
.pub-details { margin-top: 10px; }
.pub-details > summary {
    cursor: pointer; font-size: 0.85em; color: var(--primary); font-weight: 500; padding: 4px 0;
}
.pub-details img.pub-thumb { max-width: 250px; margin: 10px 0; border-radius: 6px; display: block; }

/* ─── Footer ─────────────────────────────────────────────────────── */
footer {
    margin-top: 60px; padding: 24px 0; border-top: 1px solid var(--border);
    color: var(--text-light); font-size: 0.85em; text-align: center;
}

/* ─── Project Grid ───────────────────────────────────────────────── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 24px 0 36px;
}
.project-tile {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.15s;
}
.project-tile:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    text-decoration: none;
}
.project-tile img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--bg-alt);
}
.project-tile-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, var(--primary), #50a0e0);
}
.project-tile-body { padding: 16px 18px; }
.project-tile-body h3 { font-size: 1.05em; margin: 0 0 4px; color: var(--text); }
.project-tile-body p { font-size: 0.85em; color: var(--text-light); margin: 0; }

/* ─── About Layout (two-column with sidebar collage) ─────────────── */
.about-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 32px;
    align-items: start;
    margin-bottom: 36px;
}
.about-content { min-width: 0; }

/* ─── Research Collage ───────────────────────────────────────────── */
.collage {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
    box-shadow: var(--shadow-md);
}
.collage--sidebar {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow: hidden;
}
.collage img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.collage:hover { opacity: 0.92; }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 800px) {
    .pub-hero { width: 120px; height: 85px; }
    .about-layout { grid-template-columns: 1fr; }
    .collage--sidebar { position: static; max-height: none; }
    .collage { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 640px) {
    body { padding: 0 16px 16px; }
    nav { margin: 0 -16px 24px; padding: 12px 16px; gap: 2px; }
    nav a { padding: 5px 10px; font-size: 0.85em; }
    .profile-header { flex-direction: column; align-items: center; text-align: center; padding: 36px 24px; }
    .profile-header img { width: 110px; height: 110px; }
    .contact-links { justify-content: center; }
    .pub-card { flex-direction: column; gap: 10px; }
    .pub-hero { width: 100%; height: 160px; }
    h1 { font-size: 1.6em; }
    h2 { font-size: 1.2em; margin: 32px 0 14px; }
    .project-grid { grid-template-columns: 1fr; }
    .collage { border-radius: var(--radius-sm); grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 400px) {
    .pub-hero { display: none; }
    nav a { padding: 4px 8px; font-size: 0.82em; }
}

/* ─── About Page: Highlight Cards ────────────────────────────────── */
.about-lead {
    font-size: 1.12em;
    line-height: 1.8;
    margin-bottom: 28px;
}
.about-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--border);
}
.about-card h3 {
    font-size: 1.05em;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text);
}
.about-card p { margin-bottom: 10px; }
.about-card p:last-child { margin-bottom: 0; }
.about-card--primary { border-left-color: var(--primary); }
.about-card--accent  { border-left-color: var(--accent); }
.about-card--muted   { border-left-color: var(--text-light); }

.stat-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin: 20px 0 28px;
}
.stat-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 24px;
    flex: 1;
    min-width: 160px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: box-shadow 0.2s, transform 0.15s;
}
.stat-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-number {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.82em;
    color: var(--text-light);
    margin-top: 4px;
}
.method-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.method-pill {
    display: inline-block;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.82em;
    color: var(--text);
    font-weight: 500;
}
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.about-grid .about-card { margin-bottom: 0; }

@media (max-width: 640px) {
    .stat-row { flex-direction: column; }
    .about-grid { grid-template-columns: 1fr; }
    .about-card { padding: 18px 20px; }
}

/* ─── Until Anon: Magazine Layout ────────────────────────────────── */
.ua-mag-header { position: relative; margin-bottom: 24px; }
.ua-mag-header h1 { font-size: 2.4em; margin-bottom: 4px; }
.ua-mag-header .ua-subtitle {
    font-size: 1.1em; color: var(--text-light); font-style: italic; line-height: 1.6;
}
.ua-mag-opening { position: relative; margin-bottom: 20px; }
.ua-mag-opening .ua-big-quote {
    position: absolute; top: -20px; left: -8px;
    font-size: 5em; font-family: Georgia, 'Times New Roman', serif;
    color: var(--primary); opacity: 0.15; line-height: 1; pointer-events: none;
}
.ua-drop-cap {
    font-size: 1.25em; line-height: 1.6;
}
.ua-drop-cap::first-letter {
    float: left; font-size: 3.4em; line-height: 0.85; font-weight: 700;
    color: var(--primary); margin-right: 8px; margin-top: 4px;
    font-family: Georgia, 'Times New Roman', serif;
}
.ua-aside {
    float: right; width: 280px; margin: 0 0 20px 28px; padding: 20px;
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); border-top: 3px solid var(--primary);
    font-size: 0.92em; line-height: 1.7;
}
.ua-aside-label {
    font-size: 0.75em; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--primary); margin-bottom: 6px;
}
.ua-mag-sign-off {
    clear: both; text-align: left;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2em; font-style: italic; color: var(--primary);
    margin: 0; line-height: 1.2;
}
.ua-mag-sign-off:first-of-type { margin-top: 32px; }
.ua-content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 32px 40px;
    margin-bottom: 28px;
}
.ua-content-card .screenplay { margin-left: 40px; margin-right: 40px; }
@media (max-width: 640px) {
    .ua-content-card { padding: 24px 20px; }
    .ua-content-card .screenplay { margin-left: 0; margin-right: 0; }
}

/* Archived Work cards */
.archive-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 32px 36px;
    margin-bottom: 28px;
}
.archive-card h2 {
    margin-top: 0; font-size: 1.4em;
    color: var(--primary); border-bottom: 2px solid var(--border);
    padding-bottom: 12px; margin-bottom: 20px;
}
.archive-card h3 {
    font-size: 1.05em; color: var(--text);
    margin-top: 24px; margin-bottom: 8px;
}
.archive-card ul { margin-top: 8px; }
.archive-card li { margin-bottom: 6px; }
.archive-card img { border-radius: var(--radius); }
.archive-card blockquote {
    border-left: 3px solid var(--primary); padding-left: 16px;
    margin: 16px 0; color: var(--text-light); font-style: italic;
}
pre {
    background: var(--bg-card); padding: 24px 28px;
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--text-light);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88em; line-height: 1.6;
    white-space: pre-wrap; word-wrap: break-word;
    margin: 28px 40px; overflow-x: auto;
}
.screenplay {
    background: var(--bg-card); padding: 28px 40px;
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--text-light);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88em; line-height: 1.5;
    margin: 28px 80px;
}
.screenplay .char {
    text-align: center; text-transform: uppercase;
    font-weight: 700; margin: 16px 0 2px; letter-spacing: 0.04em;
}
.screenplay .char:first-child { margin-top: 0; }
.screenplay .dial {
    text-align: left; margin: 0 0 0;
    max-width: 480px; margin-left: auto; margin-right: auto;
}
.screenplay-highlight {
    background: var(--primary); color: #fff;
    padding: 2px 8px; border-radius: 3px;
    font-weight: 700;
}
@media (max-width: 640px) {
    .screenplay { margin: 28px 0; padding: 20px 16px; }
}
@media (max-width: 640px) {
    .ua-aside { float: none; width: auto; margin: 20px 0; }
}