/* ------------------------------------------------------------------
   Resume / CV — LaTeX-style paper document
   ------------------------------------------------------------------ */

:root {
    color-scheme: light dark;

    --paper: #ffffff;
    --backdrop: #ffffff;
    --ink: #101010;
    --ink-muted: #3a3a3a;
    --rule: #101010;
    --link: #2b5f83;
    --footer: #8a8a8a;

    /* On screen the document fills the browser width; the letter sheet with
       1in margins is produced by the print rules below. */
    --page-pad-x: clamp(1.15rem, 4vw, 3.25rem);
    --page-pad-y: clamp(1.4rem, 3vw, 2.5rem);
    /* Hanging indent for entries; collapses to 0 on narrow screens. */
    --entry-indent: clamp(0rem, 2.4vw, 1.5rem);

    /* Type scale in rem, so it rides the fluid root size set on <html>:
       constant up to 1440px, then growing with the viewport. */
    --fs-body: 0.875rem;
    --fs-name: clamp(26px, 6vw, 2.5rem);
    --fs-contact: 0.8125rem;
    --fs-section: 1.0625rem;
    --fs-title: 0.9375rem;
    --fs-footer: 0.75rem;

    /* Latin Modern / Computer Modern if the machine has them, else a
       well-matched book serif. */
    --serif: "Latin Modern Roman", "CMU Serif", "Computer Modern",
        Charter, "Bitstream Charter", Cambria, Georgia,
        "Times New Roman", Times, serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #121212;
        --backdrop: #121212;
        --ink: #ececec;
        --ink-muted: #bdbdbd;
        --rule: #ececec;
        --link: #7fb3d5;
        --footer: #7c7c7c;
    }
}

:root[data-theme="dark"] {
    --paper: #121212;
    --backdrop: #121212;
    --ink: #ececec;
    --ink-muted: #bdbdbd;
    --rule: #ececec;
    --link: #7fb3d5;
    --footer: #7c7c7c;
}

* {
    box-sizing: border-box;
}

html {
    /* 16px up to 1440px wide, scaling to 20.6px at 2560px. */
    font-size: clamp(16px, 10.1px + 0.41vw, 20.6px);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--backdrop);
    color: var(--ink);
    font-family: var(--serif);
    font-size: var(--fs-body);
    line-height: 1.4;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
}

.page {
    width: 100%;
    padding: var(--page-pad-y) var(--page-pad-x);
    background: var(--paper);
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

/* Entry titles and location metadata read as document text; the trailing
   glyph is what marks them as links (as in the reference document). */
.entry-title a,
.entry-sub a,
.entry-meta a {
    color: inherit;
}

/* Boxed external-link glyph, as in the reference document. */
a.ext::after {
    content: "";
    display: inline-block;
    width: 0.62em;
    height: 0.62em;
    margin-left: 0.22em;
    background-color: currentColor;
    -webkit-mask: var(--ext-icon) no-repeat center / contain;
    mask: var(--ext-icon) no-repeat center / contain;
    --ext-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 3.2A1.2 1.2 0 0 1 3.2 2H8v1.6H3.6v8.8h8.8V8H14v4.8a1.2 1.2 0 0 1-1.2 1.2H3.2A1.2 1.2 0 0 1 2 12.8z'/%3E%3Cpath d='M9.4 2H14v4.6h-1.6V4.72l-4.3 4.3-1.13-1.13 4.3-4.29H9.4z'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------- masthead */

header.masthead {
    text-align: center;
    margin-bottom: 1.6rem;
}

h1.name {
    margin: 0 0 0.45rem;
    font-size: var(--fs-name);
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.12;
}

.contact {
    margin: 0 0 0.5rem;
    font-size: var(--fs-contact);
    line-height: 1.8;
}

.contact .sep {
    margin: 0 0.3em;
    color: var(--ink-muted);
}


/* ---------------------------------------------------------- sections */

section {
    margin-bottom: 1.3rem;
}

h2.section-title {
    margin: 0 0 0.6rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid var(--rule);
    font-size: var(--fs-section);
    font-weight: 700;
    line-height: 1.25;
}

/* ----------------------------------------------------------- entries */

.entry {
    margin: 0 0 0.85rem var(--entry-indent);
}

.entry:last-child {
    margin-bottom: 0;
}

.entry-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0 1.25rem;
}

.entry-title {
    margin: 0;
    min-width: 0;
    font-size: var(--fs-title);
    font-weight: 700;
    line-height: 1.35;
}

.entry-sub {
    min-width: 0;
    font-style: italic;
}

.entry-meta {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    font-style: italic;
    text-align: right;
    color: var(--ink-muted);
}

.entry ul {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
    list-style: circle outside;
}

.entry li {
    margin-bottom: 0.2rem;
    text-align: justify;
    hyphens: auto;
}

.entry li:last-child {
    margin-bottom: 0;
}

.entry li::marker {
    font-size: 0.85em;
}

/* Section-level prose (e.g. an experience summary) */

.summary {
    margin: 0 0 0 var(--entry-indent);
    text-align: justify;
    hyphens: auto;
}

/* Label + value rows (Technologies) */

.facts {
    margin: 0 0 0 var(--entry-indent);
    padding: 0;
    list-style: none;
}

.facts li {
    margin-bottom: 0.4rem;
    text-align: justify;
    hyphens: auto;
}

.facts li:last-child {
    margin-bottom: 0;
}

.label {
    font-weight: 700;
}

/* ------------------------------------------------------------ footer */

footer.colophon {
    margin-top: 1.6rem;
    font-size: var(--fs-footer);
    font-style: italic;
    text-align: center;
    color: var(--footer);
}

/* ------------------------------------------------------------ narrow */

@media (max-width: 760px) {
    :root {
        --fs-body: 0.9375rem;
        --fs-contact: 0.875rem;
        --fs-section: 1.0625rem;
        --fs-title: 1rem;
    }

    .entry li,
    .facts li {
        text-align: left;
        hyphens: manual;
    }
}

/* Below this the two-column entry rows have no room left — stack them. */
@media (max-width: 560px) {
    .entry-row {
        display: block;
    }

    .entry-meta {
        display: block;
        margin-left: 0;
        text-align: left;
    }

    .contact .sep {
        display: none;
    }

    .contact a {
        display: inline-block;
        margin: 0 0.4em;
    }
}

/* ------------------------------------------------------------- print */

@page {
    size: letter;
    margin: 0.55in 0.6in;
}

@media print {
    :root {
        --paper: #fff;
        --backdrop: #fff;
        --ink: #000;
        --ink-muted: #1a1a1a;
        --rule: #000;
        --link: #1d4a6b;

        --page-pad-x: 0;
        --page-pad-y: 0;
        --entry-indent: 0.28in;

        /* pt scale: print rasterises at high DPI, so fractional sizes are safe */
        --fs-body: 9.5pt;
        --fs-name: 24pt;
        --fs-contact: 9pt;
        --fs-section: 12pt;
        --fs-title: 10pt;
    }

    html {
        font-size: 16px;
    }

    body {
        padding: 0;
        background: #fff;
        line-height: 1.26;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .page {
        width: auto;
    }

    header.masthead {
        margin-bottom: 0.6rem;
    }

    section {
        margin-bottom: 0.6rem;
    }

    .entry {
        margin-bottom: 0.38rem;
    }

    .entry ul {
        margin-top: 0.12rem;
    }

    .entry li,
    .facts li {
        margin-bottom: 0.08rem;
    }

    .facts li {
        margin-bottom: 0.15rem;
    }

    /* Keep an entry whole and a heading with its first entry, but never
       lock a whole section together - that would push it to a fresh page. */
    .entry,
    .facts li,
    .summary {
        break-inside: avoid;
    }

    h2.section-title {
        break-after: avoid;
    }

    p,
    li {
        orphans: 2;
        widows: 2;
    }

    /* Never strand a section heading, or an entry heading, at a page foot. */
    .entry-row {
        break-after: avoid;
    }

    section {
        break-before: auto;
    }

    /* Links stay live in the PDF but print as ink, not colour. */
    a {
        color: #000;
        text-decoration: none;
    }

    /* The link glyph is a CSS mask and means nothing on paper. */
    a.ext::after {
        display: none;
    }

    footer.colophon {
        display: none;
    }
}
