:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --text: #0c0a09;
    --muted: #57534e;
    --border: #e7e5e4;
    --accent: #038735;
    --accent-soft: #dcfee9;
    --hero-bg: #0a0a0a;
    --hero-text: #fafaf9;
    --hero-muted: #a8a29e;
    --hero-accent: #73fca7;       /* location line and contact buttons in the header */
    --accent-ink: #ffffff;        /* text on accent-coloured buttons */
    --glow-rgb: 3, 155, 61;       /* the glow behind the card */
    --ripple-rgb: 115, 252, 167;  /* ripples and lit-up characters in the background (public/js/hero-code.js) */
    --radius: 14px;
    --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c0a09;
        --surface: #1c1917;
        --text: #e7e5e4;
        --muted: #a8a29e;
        --border: #292524;
        --accent: #37fb82;
        --accent-soft: #014b1e;
        --hero-bg: #050505;
        --accent-ink: #013c18;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

/* scrollbar-gutter: the page keeps its width when switching between short and long pages */
html { scroll-behavior: smooth; scroll-padding-top: 4rem; scrollbar-gutter: stable; }
html:has(.subnav) { scroll-padding-top: 6.5rem; }

body {
    margin: 0;
    background: var(--hero-bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0; }

/* Focused after moving to another page (public/js/page-swap.js), for screen readers; no outline needed */
#main:focus { outline: none; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }

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

.skip {
    position: absolute; left: -999px; top: 0;
    background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 100;
}
.skip:focus { left: 1rem; }

/* ---------- Background ---------- */
/* Field of faint code characters fixed to the viewport, drawn by public/js/hero-code.js */
.hero-code {
    position: fixed; top: 0; left: 0; z-index: 0;
    width: 100%;
    /* Reaches past the bottom of the screen, so a strip exposed when a phone's bars hide
       or the page bounces at the end still shows the background, not a plain colour. */
    --overscan: 160px;
    height: calc(100vh + var(--overscan));
    height: calc(100lvh + var(--overscan)); /* lvh: stays put while mobile address bars show and hide */
    pointer-events: none;
    /* Accent-coloured glow: an upright 3:2 oval. --glow-size is its half-height as a share of the
       window's larger side; smaller on phones (see below). */
    --glow-size: .5;
    --glow-height: calc(var(--glow-size) * max(100vw, 100lvh));
    --glow-width: calc(var(--glow-height) * 2 / 3);
    background:
        radial-gradient(ellipse var(--glow-width) var(--glow-height) at 50% 80lvh, rgba(var(--glow-rgb), .22), transparent),
        var(--hero-bg);
}

/* ---------- Hero ---------- */
.hero {
    position: relative; z-index: 1;
    color: var(--hero-text);
    padding: 5rem 0 4rem;
}

/* ---------- Card that scrolls over the background ---------- */
.sheet {
    position: relative; z-index: 1;
    max-width: 1080px;
    margin: 0 auto 3rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: clip; /* rounds the corners without breaking the sticky menu */
    box-shadow: 0 20px 70px rgba(0, 0, 0, .45);
}

.hero-name { margin: 0; font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }


.location {
    font-family: var(--mono); font-size: .8rem; letter-spacing: .12em;
    text-transform: uppercase; color: var(--hero-accent); margin: .6rem 0 0;
}

.headline { font-size: clamp(1.05rem, 2.4vw, 1.3rem); font-weight: 500; margin: 1.25rem 0 .25rem; }
.tagline { color: var(--hero-muted); margin: 0 0 2rem; max-width: 40rem; }

.contact { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .75rem; }
.contact a {
    display: inline-flex; align-items: center; gap: .5rem;
    color: var(--hero-text); padding: .55rem 1rem;
    border: 1px solid rgba(168, 162, 158, .3); border-radius: 999px;
    font-size: .92rem; transition: border-color .15s, background .15s;
}
.contact a:hover { text-decoration: none; border-color: var(--hero-accent); background: rgba(var(--glow-rgb), .08); }
.contact svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

/* ---------- Nav ---------- */
.nav {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.nav .wrap { position: relative; display: flex; gap: 1.5rem; overflow-x: auto; scrollbar-width: none; }
.nav a {
    color: var(--muted); font-size: .9rem; font-weight: 500;
    padding: .9rem 0; white-space: nowrap;
}
.nav a:hover { color: var(--accent); text-decoration: none; }
.nav a[aria-current] { color: var(--accent); }
/* The underline under the current item slides between items (public/js/nav-indicator.js);
   without JavaScript the current page gets a fixed underline instead. */
html:not(.has-nav-indicator) .nav a[aria-current="page"] { box-shadow: inset 0 -2px var(--accent); }
.nav-indicator {
    position: absolute; left: 0; bottom: 0;
    width: 0; height: 2px; border-radius: 2px;
    background: var(--accent); opacity: 0; pointer-events: none;
    transition: transform .35s cubic-bezier(.4, 0, .2, 1), width .35s cubic-bezier(.4, 0, .2, 1), opacity .2s;
}
.nav-indicator.is-visible { opacity: 1; }
.nav-indicator.no-slide { transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) {
    .nav-indicator { transition: opacity .2s; }
}
/* Second row under the main menu, for the sections of a long page */
.subnav { border-top: 1px solid var(--border); }
.subnav .wrap { gap: 1.25rem; }
.nav .subnav a { font-size: .82rem; padding: .5rem 0; }

/* ---------- Sections ---------- */
.section { padding: 4rem 0 0; }
.section h2 {
    font-size: 1.5rem; font-weight: 700; margin-bottom: 1.75rem;
    display: flex; align-items: baseline; gap: .75rem;
}
.num { font-family: var(--mono); font-size: .85rem; color: var(--accent); font-weight: 500; }
.section h3 { font-size: 1.08rem; font-weight: 600; }

.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 2.5rem; align-items: start; }
.prose p { margin: 0 0 1rem; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 0; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem;
}
.stat dt { font-size: 1.6rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat dd { margin: .3rem 0 0; font-size: .82rem; color: var(--muted); line-height: 1.4; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.5rem; border-left: 2px solid var(--border); }
.entry { position: relative; padding-bottom: 2.25rem; }
.entry:last-child { padding-bottom: 0; }
.entry::before {
    content: ""; position: absolute; left: calc(-1.5rem - 7px); top: .45rem;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--bg); border: 2px solid var(--accent);
}
.entry:first-child::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.entry-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.org { margin: .15rem 0 0; font-weight: 500; }
.period {
    font-family: var(--mono); font-size: .8rem; color: var(--muted);
    margin: .2rem 0 0; white-space: nowrap;
}
.points { margin: .75rem 0 0; padding-left: 1.1rem; }
.points li { margin-bottom: .3rem; }
.points li::marker { color: var(--accent); }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.4rem;
}
.card .period { margin: 0 0 .5rem; }
.card p:last-child { margin-bottom: 0; }
.thesis { font-size: .93rem; margin: .9rem 0 0; }
.label {
    display: inline-block; font-family: var(--mono); font-size: .7rem;
    text-transform: uppercase; letter-spacing: .08em;
    background: var(--accent-soft); color: var(--accent);
    padding: .1rem .45rem; border-radius: 6px; margin-right: .35rem;
}

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.skill-group h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .7rem; }
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.tags li {
    background: var(--surface); border: 1px solid var(--border);
    padding: .3rem .75rem; border-radius: 999px; font-size: .88rem;
}

/* ---------- Publications ---------- */
.pubs { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.pubs li {
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius); padding: 1.2rem 1.4rem;
}
.pubs p { margin: .3rem 0 0; font-size: .9rem; }
.pub-meta { font-family: var(--mono); font-size: .8rem !important; color: var(--muted); margin: 0 0 .4rem !important; }
.year { color: var(--accent); font-weight: 500; margin-right: .4rem; }
.original { font-style: italic; color: var(--muted); }

/* ---------- Projects ---------- */
.project { display: flex; flex-direction: column; }
.project:last-child:nth-child(odd) { grid-column: 1 / -1; }
.project > p.muted { margin: .5rem 0 0; font-size: .93rem; }
.project h3 a { color: inherit; }
.project h3 a:hover { color: var(--accent); }
.project .points { font-size: .93rem; }
.tags-small { margin-top: 1rem; gap: .35rem; }
.tags-small li { font-size: .78rem; padding: .2rem .6rem; background: var(--bg); }
.project-links { margin: auto 0 0; padding-top: .5rem; display: flex; flex-wrap: wrap; column-gap: 1.25rem; }
.section-more { margin: 1.25rem 0 0; }

/* ---------- Page heading (pages other than the landing page and the CV) ---------- */
.page-head { padding: 3rem 0 0; }
.page-head h1 { font-size: clamp(1.9rem, 4.5vw, 2.5rem); font-weight: 700; letter-spacing: -.01em; }
.page-kicker { margin: 0 0 .5rem; font-size: .9rem; font-weight: 500; }
.page-lead { margin: .75rem 0 0; max-width: 46rem; font-size: 1.08rem; color: var(--muted); }
.page-links { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0 0; }
.page-head + .section { padding-top: 3rem; }

/* ---------- Landing page ---------- */
.intro { font-size: 1.15rem; max-width: 46rem; margin: 0 0 2rem; }
.destinations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.destination { display: flex; flex-direction: column; color: var(--text); transition: border-color .15s, transform .15s; }
.destination:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.destination h2 { font-size: 1.5rem; font-weight: 700; margin: .25rem 0 .5rem; }
.destination > p { margin: 0; font-size: .93rem; }
.destination-stats { display: flex; gap: 1.25rem; margin: 1rem 0 0; }
.destination-stats dt { font-size: 1.3rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.destination-stats dd { margin: .2rem 0 0; font-size: .78rem; color: var(--muted); line-height: 1.35; }
.destination .card-link { margin-top: auto; padding-top: 1rem; color: var(--accent); }

/* ---------- Contact page ---------- */
.contact-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.contact-method { display: flex; flex-direction: column; gap: .3rem; color: var(--text); transition: border-color .15s; }
.contact-method:hover { text-decoration: none; border-color: var(--accent); }
.contact-method .period { margin: 0; }
.contact-value { font-weight: 600; font-size: 1.05rem; color: var(--accent); overflow-wrap: anywhere; }
.contact-method .muted { font-size: .9rem; }
.contact-location { margin: 1.5rem 0 0; }

/* ---------- Project page ---------- */
.project-description { max-width: 46rem; }
.project-description p:last-child { margin-bottom: 0; }
.screenshots { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 1rem; align-items: start; }
.screenshot { margin: 0; }
.screenshot:first-child { grid-column: 1 / -1; }
.screenshot a { display: block; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s; }
.screenshot a:hover { border-color: var(--accent); }
.screenshot img { display: block; width: 100%; height: auto; }
.screenshot figcaption { margin-top: .5rem; font-size: .85rem; color: var(--muted); }
.project-points { max-width: 46rem; margin: 0; }
.project-points li { margin-bottom: .6rem; }
.project-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pager-link { display: flex; flex-direction: column; color: var(--text); transition: border-color .15s; }
.pager-link:hover { text-decoration: none; border-color: var(--accent); }
.pager-next { grid-column: 2; text-align: right; }
.pager-name { font-weight: 600; font-size: 1.08rem; }

/* ---------- Interests ---------- */
.interests { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.interests .card p { margin: .5rem 0 0; font-size: .93rem; }
.card-link { display: inline-block; margin-top: .75rem; font-size: .9rem; font-weight: 500; }

/* ---------- Split / CTA ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.split .card + .card { margin-top: 1rem; }

.contact-cta, .section-last { padding-bottom: 4rem; }
.contact-cta p { max-width: 36rem; margin: -.75rem 0 1.5rem; color: var(--muted); }
.cta-buttons { display: flex; flex-wrap: wrap; gap: .75rem; }
.btn {
    display: inline-block; font: inherit; font-weight: 600; font-size: .95rem;
    padding: .7rem 1.3rem; border-radius: 10px; cursor: pointer;
    background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }

.footer { border-top: 1px solid var(--border); padding: 1.5rem 0; font-size: .85rem; color: var(--muted); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .hero { padding: 3.5rem 0 3rem; }
    .hero-code { --glow-size: .4; }
    /* On phones the card is the whole page, so square corners: rounded ones would suggest it ends there. */
    .sheet { max-width: none; margin: 0; border: none; border-radius: 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .35); }
    .about, .cards, .split, .project-pager, .screenshots, .destinations { grid-template-columns: 1fr; }
    .pager-next { grid-column: auto; }
    .entry-head { flex-direction: column; gap: 0; }
    .section { padding-top: 3rem; }
}

/* ---------- Print ---------- */
@media print {
    :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --border: #ccc; --accent: #038735; }
    .nav, .skip, .cta-buttons, .section-more, .project-pager, .footer, .hero-code { display: none; }
    .hero { background: none; color: #000; padding: 0 0 1rem; }
    .tagline, .location { color: #444; }
    .contact a { color: #000; border: none; padding: 0; }
    .section { padding-top: 1.5rem; break-inside: avoid-page; }
    .entry, .card, .pubs li { break-inside: avoid; }
    .stat, .card, .pubs li, .tags li { box-shadow: none; }
    body { background: #fff; }
    .sheet { max-width: none; margin: 0; border: none; border-radius: 0; box-shadow: none; }
}
