/* One Dark (reduced palette) */
:root {
    color-scheme: light dark;
    --font-sans:
        Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        sans-serif;
    --font-title: var(--font-sans);
    --font-mono:
        "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono",
        "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono",
        monospace;
    --bg: #282c33;
    --surface: #2f343e;
    --fg: #dce0e5;
    --fg-muted: #a9afbc;
    --border: #464b57;
    --string: #a1c181;
    --link: #74ade8;

    /* Vertical rhythm on a baseline grid: the base unit is the body line-height
       (1.5 x 16px = 24px), and every gap is a whole multiple of it, so spacing
       follows one scale instead of hand-picked values. Section : entry stays 2 : 1. */
    --space-unit: 1.5rem; /* 24px - the baseline */
    --space-tight: calc(var(--space-unit) / 2); /* 12px - within a group */
    --space-block: var(--space-unit); /* 24px - paragraphs, lists */
    --space-heading: var(--space-unit); /* 24px - heading to its body */
    --space-entry: calc(var(--space-unit) * 3); /* 72px - between entries */
    --space-section: calc(var(--space-unit) * 6); /* 144px - between sections */
}

/* One Light */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #fafafa;
        --surface: #ebebec;
        --fg: #242529;
        --fg-muted: #58585a;
        --border: #c9c9ca;
        --string: #649f57;
        --link: #5c78e2;
    }
}

html {
    scroll-behavior: smooth;
    /* reserve the scrollbar gutter so short and long pages centre the body identically */
    scrollbar-gutter: stable;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--fg);
    margin: 0 auto;
    padding: 0 2rem 25vh 2rem;
    max-width: calc(210mm + 4rem);
    line-height: 1.5;
}

a {
    color: var(--link);
    font-family: var(--font-mono);
}

code {
    font-family: var(--font-mono);
    color: var(--string);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.15em 0.4em;
    font-size: 0.9em;
    white-space: nowrap;
}

pre {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1em;
    overflow-x: auto;
    white-space: pre-wrap;
    margin: 0;
}

pre code {
    border: none;
    padding: 0;
    background: none;
}

p {
    margin: 0 0 var(--space-block) 0;
}

small {
    color: var(--fg-muted);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: calc(var(--space-entry) / 2) 0;
}

ul {
    list-style: "• " outside;
    padding-left: 1.2ch;
    margin: var(--space-block) 0;
}

li {
    margin-bottom: var(--space-tight);
}

/* ---- link rows: under the hero name (home), and a single up-link at the top
   of CV / blog pages ---- */
.nav-links {
    display: flex;
    flex-direction: column;

    margin: var(--space-tight) 0 0 0;
}

.nav-links a {
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.nav-links a:hover {
    color: var(--link);
}

/* the lone up-link sits at the very top of CV / blog pages */
body > nav.nav-links {
    margin: calc(var(--space-unit) * 2) 0 var(--space-heading) 0;
}

/* ---- hero ---- */
.hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-block);
    /* masthead sits close to its intro paragraph (2 units), not a section apart */
    margin: calc(var(--space-unit) * 2) 0;
}

.profile {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
    object-position: 50% 20%;
}

h1 {
    font-family: var(--font-title);
    color: var(--fg);
    margin: 0 0 var(--space-tight) 0;
}

.hero h1 {
    font-size: 3.25rem;
    line-height: 1;
}

.role {
    font-family: var(--font-title);
    color: var(--fg-muted);
    font-size: 2rem;
    margin: 0;
}

/* icon links (PDF, GitHub, LinkedIn) pushed to the far right of the hero */
.hero-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-tight);
    margin-left: auto;
}

.hero-links a {
    display: block;
    color: var(--fg-muted);
}

.hero-links a:hover {
    color: var(--link);
}

.hero-links svg {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 480px) {
    .hero {
        justify-content: center;
        text-align: center;
    }

    .nav-links {
        justify-content: center;
    }

    .hero-links {
        flex-direction: row;
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
    .profile {
        width: 200px;
        height: 200px;
    }
}

/* ---- section nav: sticks to the top of the viewport once scrolled past ---- */
.page-nav {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-wrap: nowrap;
    /* gap and font scale together with the viewport so all four links stay on one line */
    gap: 1.5em;
    font-size: clamp(0.85rem, 3.4vw, 1rem);
    padding: var(--space-tight) 0;
    /* a full section gap before About, so the nav reads as a masthead, not a heading */
    margin-bottom: calc(var(--space-unit) * 2);
    background: var(--bg);
}

/* the desktop gap and font overflow a phone; spread the four links edge to edge with a smaller font, and let
   them wrap rather than widen the page on the narrowest screens (after the base rule, so it wins) */
@media (max-width: 480px) {
    .page-nav {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.4em;
        font-size: clamp(0.68rem, 3.4vw, 0.9rem);
    }
}

/* ---- sections: content-sized, generous chapter-style gaps between them ---- */
body > section {
    /* anchor jumps land below the sticky nav, not underneath it */
    scroll-margin-top: calc(var(--space-unit) * 2);
}

/* Sections are separated by a rule between them, not under their headings. The rule is its own block, so the
   section gap splits into two equal margins, one either side of it. */
body > section + section {
    margin-top: calc(var(--space-section) / 2);
}

body > section + section::before {
    content: "";
    display: block;
    border-top: 2px solid var(--border);
    margin-bottom: calc(var(--space-section) / 2);
}

h2 {
    font-family: var(--font-title);
    color: var(--fg);
    /* large and light: section headers read as quiet chapter titles (the CV sets its own h2 in cv.css) */
    font-size: 2.5rem;
    font-weight: 300;
    margin: 0 0 var(--space-heading) 0;
}

/* entry titles: the place leads (larger and semibold) and the role follows in a lighter italic, so the title line
   outranks the bullet labels beneath it */
h3 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

h3 em {
    font-weight: 400;
}

/* ---- Experience and Education: a small chevron in the gap between entries, left-aligned with the bullet text and
   pointing up towards the more recent entry, so the list reads as a quiet timeline. Drawn as a rotated corner, so
   no glyphs or markup. ---- */
#experience article + article,
#education article + article {
    position: relative;
}

#experience article + article::before,
#education article + article::before {
    content: "";
    position: absolute;
    /* the chevron's left edge lines up with the first letter of the bullet text (the list's 1.2ch padding); the
       0.125rem makes up for the rotated corner reaching past its box */
    left: calc(1.2ch + 0.125rem);
    top: calc(var(--space-entry) / -2);
    width: 0.6rem;
    height: 0.6rem;
    border-top: 3px solid var(--fg-muted);
    border-left: 3px solid var(--fg-muted);
    opacity: 0.5;
    transform: translateY(-25%) rotate(45deg);
}

h4 {
    display: inline;
    font-family: var(--font-title);
    font-size: 1em;
    font-weight: 600;
    margin: 0;
}

.meta {
    color: var(--fg-muted);
    font-size: 0.9em;
    margin: 0 0 var(--space-tight) 0;
}

.skills {
    color: var(--fg-muted);
    font-size: 0.9em;
    margin: var(--space-block) 0 0 0;
}

.label {
    font-weight: bold;
}

details {
    margin-top: var(--space-block);
}

details summary {
    cursor: pointer;
    color: var(--fg-muted);
}

details summary:hover {
    color: var(--link);
}

/* Entries are grouped by spacing, not dividers: the gap between entries is
   larger than the gaps inside one, so proximity alone reads the relationship. */
body > section article {
    margin-bottom: var(--space-entry);
}

body > section article:last-child {
    margin-bottom: 0;
}

/* The first entry sits half an entry-gap below its heading (or intro) - the
   heading already does some of the separating - while entries are a full
   --space-entry apart. Only titled entries (article); heading-to-prose stays
   tight (blog body, interests intro). */
body > section article:first-of-type {
    margin-top: calc(var(--space-entry) / 2);
}/* ---- page header (CV) ---- */
.page-header {
    margin-bottom: var(--space-heading);
}

.page-header h1 {
    margin: 0;
}

@media print {
    .nav-links,
    .hero-links,
    .page-nav {
        display: none;
    }

    /* Viewport units are meaningless on paper; let each section begin a fresh
       page - the print equivalent of a chapter. */
    body > section {
        margin-bottom: 0;
        break-before: page;
    }

    body > section:first-of-type {
        break-before: auto;
    }
}
