/* vilvoiu.ro — an engineer's notebook */

:root {
    --paper: #f6f2ea;
    --ink: #1d1a16;
    --muted: #6f685c;
    --rule: #d9d2c4;
    --accent: #b5461f;
    --accent-ink: #8a3414;
    --well: #ece6da;
    --tok-kw: #8a3414;
    --tok-str: #4a6b2a;
    --tok-num: #2f5f8a;
    --tok-com: #8b8374;

    --serif: Lora, Georgia, serif;
    --display: Newsreader, "Times New Roman", serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #15130f;
        --ink: #e8e2d6;
        --muted: #9a917f;
        --rule: #2e2a23;
        --accent: #e0774e;
        --accent-ink: #f0a07f;
        --well: #1f1c17;
        --tok-kw: #e0774e;
        --tok-str: #9fc06a;
        --tok-num: #7fb0dd;
        --tok-com: #7d7568;
    }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.65;
    -webkit-text-size-adjust: 100%;
}

body {
    max-width: 42rem;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
}

::selection {
    background: var(--accent);
    color: var(--paper);
}

a {
    color: var(--accent-ink);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    transition: text-decoration-color 150ms ease, color 150ms ease;
}

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

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ---------- Typography ---------- */

h1, h2, h3 {
    font-family: var(--display);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.01em;
    margin: 0;
}

h1 { font-size: 2.6rem; }
h2 { font-size: 1.65rem; margin-top: 2.75rem; margin-bottom: 0.9rem; }
h3 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: 0.6rem; }

p, ul, ol { margin: 0 0 1.2rem; }

ul, ol { padding-left: 1.4rem; }

li { margin-bottom: 0.3rem; }

li::marker { color: var(--muted); }

em { font-style: italic; }

strong { font-weight: 600; }

hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 3rem 0;
}

small, time { color: var(--muted); }

blockquote {
    margin: 1.5rem 0;
    padding: 0.2rem 0 0.2rem 1.25rem;
    border-left: 2px solid var(--accent);
    color: var(--muted);
    font-style: italic;
}

sup { font-size: 0.75em; line-height: 0; }

img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95em;
}

th, td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--rule);
}

th {
    font-family: var(--mono);
    font-weight: 500;
    font-size: 0.8em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---------- Code ---------- */

code, pre, kbd {
    font-family: var(--mono);
    font-size: 0.85em;
}

code {
    background: var(--well);
    padding: 0.1em 0.4em;
    border-radius: 3px;
}

pre {
    background: var(--well);
    border-left: 3px solid var(--accent);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    line-height: 1.5;
}

pre code {
    background: none;
    padding: 0;
    font-size: 1em;
}

pre code a { display: none; }   /* pandoc's hidden line anchors */

.sourceCode .kw, .sourceCode .cf { color: var(--tok-kw); font-weight: 500; }
.sourceCode .st { color: var(--tok-str); }
.sourceCode .dv, .sourceCode .fl, .sourceCode .bn { color: var(--tok-num); }
.sourceCode .co { color: var(--tok-com); font-style: italic; }
.sourceCode .op, .sourceCode .va, .sourceCode .fu, .sourceCode .er { color: inherit; }

/* ---------- Page chrome ---------- */

body > nav {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 3rem;
}

body > nav a { text-decoration: none; color: var(--muted); }
body > nav a:hover { color: var(--accent); }

main > header {
    margin-bottom: 2.5rem;
}

main > header time {
    display: block;
    margin-top: 0.9rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

footer {
    margin-top: 5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
}

footer a { color: inherit; text-decoration-color: var(--rule); }
footer a:hover { color: var(--accent); }

/* ---------- Footnotes ---------- */

.footnotes {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    font-size: 0.9em;
    color: var(--muted);
}

.footnotes hr { display: none; }

.footnote-ref { text-decoration: none; }

/* ---------- Home page ---------- */

.home main > header h1 {
    font-size: 3.4rem;
    letter-spacing: -0.02em;
}

.home main > header + p {
    font-family: var(--display);
    font-style: italic;
    font-size: 1.5rem;
    color: var(--muted);
    margin-top: -1.5rem;
}

.home main { counter-reset: section; }

.home main h2 {
    counter-increment: section;
    position: relative;
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
}

.home main h2::before {
    content: counter(section, decimal-leading-zero);
    display: block;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

@media (min-width: 56rem) {
    .home main h2::before {
        position: absolute;
        left: -4.5rem;
        top: 1.5rem;
        line-height: 1.8rem;    /* align with the heading's first line */
        margin: 0;
    }
}

.email {
    display: inline;
    margin: 0;
    vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
    .email { filter: invert(0.9); }
}

/* Table of contents: title ....... date */

.toc {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
}

.toc li {
    display: flex;
    align-items: baseline;
    gap: 0.6em;
    margin: 0;
    padding: 0.3rem 0;
}

.toc a {
    text-decoration: none;
    color: var(--ink);
}

.toc a:hover { color: var(--accent); }

.toc .leader {
    flex: 1 1 auto;
    min-width: 1.5em;
    border-bottom: 1px dotted var(--muted);
    opacity: 0.5;
    transform: translateY(-0.3em);
}

.toc time {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ---------- Motion ---------- */

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

main > * {
    animation: rise 500ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

main > :nth-child(2) { animation-delay: 60ms; }
main > :nth-child(3) { animation-delay: 120ms; }
main > :nth-child(4) { animation-delay: 180ms; }
main > :nth-child(5) { animation-delay: 240ms; }
main > :nth-child(n+6) { animation-delay: 300ms; }

@media (prefers-reduced-motion: reduce) {
    main > * { animation: none; }
    a { transition: none; }
}

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
    html { font-size: 16px; }
    h1 { font-size: 2.1rem; }
    .home main > header h1 { font-size: 2.6rem; }
    .home main > header + p { font-size: 1.25rem; }
    pre { padding: 0.85rem 1rem; }
    .toc li { flex-wrap: wrap; gap: 0.15rem 0; }
    .toc .leader { display: none; }
    .toc time { flex-basis: 100%; }
}
