
/* ─── 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);
    /* Semantic aliases */
    --pf-muted: var(--text-light);
    --pf-accent-2: #4a7fb5;
    /* Viz-specific tokens */
    --viz-bg: #fffcf8;
    --viz-grid: #ecddd0;
    --viz-separator: #c4a88e;
    --viz-dot-stroke: #fff;
    --viz-stripe: rgba(42,32,25,0.025);
    --mono: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

@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);
        --pf-accent-2: #6a9fd8;
        --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: 'Inter', 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;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-synthesis: none;
}

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

/* ─── Footer ─────────────────────────────────────────────────────── */
.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0;
    padding: 14px 32px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 0.92rem;
}
.site-footer .footer-text { color: var(--text-light); font-weight: 500; }
.site-footer .footer-icon {
    display: flex; align-items: center;
    color: var(--text-light);
    text-decoration: none; border-bottom: none;
    transition: color 0.15s;
}
.site-footer .footer-icon:hover { color: var(--primary); }

/* ─── Typography ─────────────────────────────────────────────────── */
h1 {
    font-size: 2.4em;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.4em;
    font-weight: 700;
    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; }

/* ─── Publications Toggle Row ────────────────────────────────── */
.pub-toggle-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.pub-toggle-row .subtitle {
    margin-bottom: 0;
}

.pub-toggle {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-light);
    font-size: 1.1em;
    font-weight: normal;
    cursor: pointer;
    transition: color 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pub-toggle:hover {
    color: var(--primary);
}

.pub-toggle .toggle-chevron {
    display: inline-block;
    font-size: 0.85em;
    transition: transform 0.2s ease;
    transform: rotate(90deg);
    color: var(--primary);
}

.pub-toggle.open .toggle-chevron {
    transform: rotate(270deg);
}

/* Concertinas below publications heading — invisible when closed */
.projects-concertina:not([open]),
.archived-concertina:not([open]) {
    border: none;
    background: transparent;
    margin: 0;
}

.projects-concertina,
.archived-concertina {
    margin: 0 0 32px 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
}

.projects-concertina .concertina-content,
.archived-concertina .concertina-content {
    padding: 24px;
}

.projects-concertina h2,
.archived-concertina h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.projects-concertina .project-grid,
.archived-concertina .project-grid {
    margin-bottom: 28px;
}

.projects-concertina .project-grid:last-of-type,
.archived-concertina .project-grid:last-of-type {
    margin-bottom: 0;
}

.archived-concertina .archive-card {
    margin-bottom: 24px;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.archived-concertina ul {
    padding-left: 2em;
}

.archived-concertina .archive-card:last-child {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .pub-toggle-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}


/* ─── About Concertina ───────────────────────────────────────────── */
.about-concertina {
    margin: 0 0 32px;
}
.about-concertina > summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    color: var(--text);
}
.about-concertina > summary::-webkit-details-marker { display: none; }
.about-concertina > summary:hover { background: var(--bg-alt); }
.concertina-chevron {
    font-size: 1.1em;
    color: var(--primary);
    transition: transform 0.25s ease;
    display: inline-block;
    flex-shrink: 0;
    transform: rotate(0deg);
}
.about-concertina[open] .concertina-chevron { transform: rotate(90deg); }
.concertina-content { padding-top: 20px; }

/* ─── 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: "▸ "; }

.year-titles-preview {
  display: block;
  font-size: 0.78em;
  color: var(--text-light);
  font-weight: 400;
  margin: 4px 0 0 1.2em;
  padding: 0;
  list-style: disc;
}
.year-titles-preview li { margin: 2px 0; }
.year-section[open] .year-titles-preview { display: none; }

/* ─── 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: var(--mono); 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; }

/* ─── 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; }


/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 800px) {
    .pub-hero { width: 120px; height: 85px; }
}

@media (max-width: 640px) {
    body { padding: 0 16px 16px; }
    .site-nav { margin-bottom: 24px; padding: 12px 16px; gap: 2px; }
    .site-nav a { padding: 5px 10px; font-size: 0.85em; }
    .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; }
}

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

/* ─── About Page: Highlight Cards ────────────────────────────────── */
.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); }

.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) {
    .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; }
    .screenplay { margin: 28px 0; padding: 20px 16px; }
    .ua-aside { float: none; width: auto; margin: 20px 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: var(--mono);
    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: var(--mono);
    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;
}

/* ─── Research Timeline Visualization ────────────────────────────── */
#graph-container {
    width: 100%; border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; position: relative; background: var(--viz-bg);
    box-shadow: var(--shadow-md);
}
#graph-container svg { width: 100%; display: block; }
.tooltip {
    position: fixed; pointer-events: none; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-width: 360px; font-size: 0.85em; line-height: 1.5; z-index: 1000;
    opacity: 0; transition: opacity 0.15s ease;
}
.tooltip.visible { opacity: 1; }
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; color: var(--text); }
.tooltip .tt-meta { color: var(--text-light); margin-bottom: 4px; }
.tooltip .tt-keywords { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tooltip .tt-kw {
    background: var(--bg-alt); border: 1px solid var(--border);
    padding: 1px 8px; border-radius: 10px; font-size: 0.8em;
}
.tooltip .tt-abstract { color: var(--text-light); font-size: 0.82em; margin-top: 6px; }
.graph-info { font-size: 0.82em; color: var(--text-light); margin-top: 6px; margin-bottom: 30px; }
.lane-label { font-size: 13px; font-weight: 600; fill: var(--text); }
.lane-count { font-size: 11px; fill: var(--text-light); }
.year-tick { font-size: 12px; fill: var(--text); font-weight: 500; }
.year-grid { stroke: var(--viz-grid); stroke-width: 1; }
.paper-dot { cursor: pointer; transition: r 0.15s, opacity 0.18s ease; }
.paper-dot:hover { r: 9; }
.legend {
    display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 12px;
    font-size: 0.82em; color: var(--text-light);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ─── Publications Page Layout ────────────────────────────────────── */
.explore-controls {
    display: flex; flex-direction: column; gap: 12px; margin-bottom: 0;
}
.pub-below-viz {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
    margin: 24px 0 32px;
}
.pub-concertinas { display: flex; flex-direction: column; gap: 16px; }
.concertina-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    font-size: 1em;
    font-weight: 500;
    color: var(--text-light);
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    user-select: none;
}
.concertina-summary::-webkit-details-marker { display: none; }
.concertina-summary::marker { display: none; }
.concertina-summary:hover { color: var(--primary); border-color: var(--primary); }
details[open] .concertina-summary {
    border-bottom-left-radius: 0; border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}
.concertina-summary .toggle-chevron {
    display: inline-block;
    font-size: 0.85em;
    transition: transform 0.2s ease;
    transform: rotate(90deg);
    color: var(--primary);
}
details[open] .concertina-summary .toggle-chevron { transform: rotate(270deg); }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: 0.85em; color: var(--text-light); white-space: nowrap; }
.filter-group select {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.85em; background: var(--bg); color: var(--text);
}
.reset-btn {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg); color: var(--text-light); cursor: pointer; font-size: 0.85em;
}
.reset-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ─── Design Principles Sub-implications ──────────────────────────── */
.pf-implications ol > li > ul {
    list-style: disc;
    list-style-type: disc;
    padding-left: 1.5em;
    counter-reset: list-item;
}
.pf-implications ol > li > ul > li {
    margin-bottom: 12px;
    list-style-type: disc;
}

@media (max-width: 800px) {
    .pub-below-viz { grid-template-columns: 1fr; }
}
