/* ─── Shared stylesheet for individual project pages ──────────────────────
   Reuses the same warm-parchment design tokens as the main portfolio, but
   lays content out as a single centred reading column instead of a sidebar. */

:root {
    --bg:            #e8ddd0;
    --bg-sidebar:    #ddd2c2;
    --surface:       #f0e8da;
    --surface-raised:#f7f1e8;

    --border:        #cfc3b3;

    --accent:        #9c6d44;
    --accent-light:  #c49a72;
    --accent-sage:   #5c8a6b;

    --text:          #221a12;
    --text-muted:    #6b5d4f;
    --text-light:    #9e8c7c;

    --tag-bg:        #dbc9b5;
    --tag-fg:        #5a3f25;
    --tag-green-bg:  #c8dac8;
    --tag-green-fg:  #2a5c3a;

    --code-bg:       #ded2c0;

    --shadow-sm:  0 1px 3px rgba(60,35,10,.10), 0 1px 2px rgba(60,35,10,.06);
    --shadow-md:  0 4px 16px rgba(60,35,10,.13);

    --radius:     10px;
    --radius-sm:  6px;
}

[data-theme="dark"] {
    --bg:            #1c1610;
    --bg-sidebar:    #161009;
    --surface:       #241c14;
    --surface-raised:#2c2218;

    --border:        #3a2e22;

    --accent:        #c49a72;
    --accent-light:  #d4b08a;
    --accent-sage:   #7aaa88;

    --text:          #f0e4d4;
    --text-muted:    #a89278;
    --text-light:    #6e5c48;

    --tag-bg:        #3a2e20;
    --tag-fg:        #d4aa7a;
    --tag-green-bg:  #1e3228;
    --tag-green-fg:  #7aaa88;

    --code-bg:       #14100b;

    --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
    --shadow-md:  0 4px 16px rgba(0,0,0,.4);
}

/* ─── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: auto; }   /* smooth is enabled after load, see project.js */
img  { display: block; max-width: 100%; }
a    { color: inherit; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    transition: background .25s, color .25s;
    -webkit-font-smoothing: antialiased;
}

/* ─── Theme toggle ────────────────────────────────────────────────────── */
.theme-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
    transition: background .2s, color .2s, border-color .2s;
}

.theme-btn:hover {
    background: var(--accent);
    color: var(--surface-raised);
    border-color: var(--accent);
}

/* ─── Page shell ──────────────────────────────────────────────────────── */
.page {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1.75rem 5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 2.5rem;
    transition: color .15s;
}

.back-link:hover { color: var(--accent); }

/* ─── Hero ────────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding-bottom: 2rem;
    border-bottom: 1.5px solid var(--border);
    margin-bottom: 2.75rem;
}

.hero .eyebrow {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent);
    margin-bottom: 0.9rem;
}

.hero h1 {
    font-size: 1.85rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.015em;
    margin-bottom: 0.6rem;
}

.hero .subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 42rem;
    margin: 0 auto 1.1rem;
}

.hero .authors {
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.hero .authors .me { font-weight: 600; }

.hero .affil {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 1.3rem;
}

.hero .venue {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.3rem;
}

.status-chip {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.65rem;
    border-radius: 4px;
    background: #e8d4bc;
    color: #8a4a18;
    margin-bottom: 1rem;
}

[data-theme="dark"] .status-chip { background: #3a2810; color: #d4a070; }

.status-chip.pub { background: #dccce8; color: #5a3480; }
[data-theme="dark"] .status-chip.pub { background: #3a2a52; color: #c4a8e8; }

/* Link buttons */
.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.35rem 0.9rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--accent);
    transition: background .15s, color .15s;
}

.btn:hover { background: var(--accent); color: var(--surface-raised); }

.btn.disabled {
    border-color: var(--border);
    color: var(--text-light);
    pointer-events: none;
}

/* ─── Sections ────────────────────────────────────────────────────────── */
.page section { margin-bottom: 3rem; }

.page section > h2 {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent);
    margin-bottom: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1.5px solid var(--border);
}

.page h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.6rem 0 0.5rem;
}

.page h3:first-child { margin-top: 0; }

.page h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 1.2rem 0 0.4rem;
}

.page p {
    font-size: 0.94rem;
    margin-bottom: 0.9rem;
}

.page p:last-child { margin-bottom: 0; }

.page ul, .page ol {
    padding-left: 1.3rem;
    margin-bottom: 1rem;
    font-size: 0.92rem;
}

.page li { margin-bottom: 0.4rem; }

.page a:not(.btn):not(.back-link):not(.pl-link) {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-light);
}

.page a:not(.btn):not(.back-link):not(.pl-link):hover { opacity: 0.75; }

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

/* Lead paragraph under the hero */
.lead {
    font-size: 1.02rem !important;
    line-height: 1.7;
    color: var(--text);
}

/* ─── Callouts ────────────────────────────────────────────────────────── */
.callout {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 1rem 1.2rem;
    margin: 1.2rem 0;
    font-size: 0.9rem;
}

.callout strong { font-weight: 600; }

/* ─── Contribution / highlight grid ───────────────────────────────────── */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1.2rem 0;
}

.mini-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow-sm);
}

.mini-card h4 {
    margin: 0 0 0.35rem;
    color: var(--text);
    font-size: 0.9rem;
}

.mini-card p {
    font-size: 0.86rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

/* Number stats */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    margin: 1.3rem 0;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat .val {
    display: block;
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.2;
}

.stat .lbl {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* ─── Figures ─────────────────────────────────────────────────────────── */
figure {
    margin: 1.6rem 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

figure img {
    width: 100%;
    border-radius: var(--radius-sm);
}

figcaption {
    font-size: 0.79rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.7rem;
    line-height: 1.55;
    font-style: italic;
}

.fig-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.8rem;
}

/* ─── Tables ──────────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    margin: 1.3rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 460px;
}

thead th {
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.7rem 0.9rem;
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr.best {
    background: var(--tag-green-bg);
}

tbody tr.best td { color: var(--tag-green-fg); font-weight: 600; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── References ──────────────────────────────────────────────────────── */
.refs {
    list-style: none;
    padding-left: 0;
    counter-reset: ref;
    font-size: 0.85rem;
}

.refs li {
    counter-increment: ref;
    position: relative;
    padding-left: 2.4rem;
    margin-bottom: 0.55rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.refs li::before {
    content: '[' counter(ref) ']';
    position: absolute;
    left: 0;
    top: 0;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    font-weight: 500;
}

/* Highlight a reference when jumped to from an inline marker */
.refs li:target {
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 0.5rem var(--surface);
    color: var(--text);
}

.refs-note {
    font-size: 0.8rem !important;
    color: var(--text-light);
    font-style: italic;
    margin-top: 0.9rem;
}

/* Inline [n] citation marker */
a.cite {
    font-size: 0.72em;
    font-weight: 600;
    vertical-align: super;
    line-height: 0;
    margin-left: 0.1em;
    color: var(--accent) !important;
    text-decoration: none;
    border-bottom: none !important;
    white-space: nowrap;
}

a.cite:hover { opacity: 1 !important; text-decoration: underline; }

/* ─── Tags ────────────────────────────────────────────────────────────── */
.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 1.2rem;
}

.tag {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.18rem 0.55rem;
    border-radius: 4px;
    background: var(--tag-bg);
    color: var(--tag-fg);
}

.tag.tg { background: var(--tag-green-bg); color: var(--tag-green-fg); }

/* ─── Code ────────────────────────────────────────────────────────────── */
pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1.1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

code {
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 0.82rem;
}

p code, li code, td code {
    background: var(--code-bg);
    padding: 0.08rem 0.32rem;
    border-radius: 3px;
}

/* ─── Timeline (used for "how we got here" narratives) ────────────────── */
.timeline {
    list-style: none;
    padding-left: 0;
    margin: 1.3rem 0;
    border-left: 2px solid var(--border);
}

.timeline li {
    position: relative;
    padding: 0 0 1.1rem 1.5rem;
    margin-bottom: 0;
    font-size: 0.91rem;
}

.timeline li::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0.55rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
}

.timeline li.fail::before  { border-color: #b5563f; }
.timeline li.win::before   { border-color: var(--accent-sage); background: var(--accent-sage); }

.timeline .step-label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.1rem;
}

/* ─── Footer ──────────────────────────────────────────────────────────── */
.page-footer {
    margin-top: 3.5rem;
    padding-top: 1.8rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-light);
}

.page-footer a {
    color: var(--accent);
    text-decoration: none;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .page { padding: 1.5rem 1.1rem 3rem; }
    .hero h1 { font-size: 1.4rem; }
    .theme-btn { top: auto; bottom: 1rem; }
}
