:root {
    --bg: #0d1117;
    --text: #e6e6e6;
    --muted: #9aa4af;
    --accent: #ffa657;
    --max-width: 640px;

    /* name block: its line height + the space beneath it.
       the nav's top margin reuses these so "About" lines up
       with the body content under the name. */
    --name-line: 29px;
    --name-space: 48px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

.wrapper {
    max-width: 820px;
    margin: 0 auto;
    padding: 48px 20px 96px;
}

.body-layout {
    display: flex;
    align-items: flex-start;
    gap: 48px;
}

.body-layout main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: var(--max-width);
}

/* HEADER — the name, sitting above the main body content */
.site-header {
    margin-bottom: var(--name-space);
}

.site-name {
    display: inline-block;
    font-weight: 700;
    font-size: 22px;
    line-height: var(--name-line);
    color: var(--text);
}

/* NAV */
.site-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 0 0 auto;
    /* aligns "About" with the body content under the name */
    margin-top: calc(var(--name-line) + var(--name-space));
}

.site-nav a {
    color: var(--text);
}

.site-nav a::before {
    content: "•";
    margin-right: 6px;
    color: transparent;
}

.site-nav a:hover,
.site-nav a:hover::before,
.site-nav a[aria-current="page"],
.site-nav a[aria-current="page"]::before {
    color: var(--accent);
    text-decoration: none;
}

/* CONTENT */
h1 {
    font-size: 28px;
    line-height: 1.3;
    margin: 0 0 24px;
}

h2 {
    font-size: 20px;
    margin: 40px 0 12px;
}

p {
    margin: 0 0 20px;
}

.post p {
    text-indent: 2em;
}

ul {
    padding-left: 40px;
}

li {
    margin-bottom: 2px;
}

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

/* WRITING LIST */
.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.post-list li:first-child {
    padding-top: 0;
}

.post-list a {
    color: var(--muted);
}

.post-list a:hover {
    text-decoration: none;
}

.post-list li:hover a,
.post-list li:hover .date {
    color: var(--text);
}

.post-list .date {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 15px;
}

/* WRITING POST HEADER — matches a list row so the post reads as a
   continuation of the list */
.post-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding-bottom: 12px;
    margin: 0 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.post-header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.6;
}

.post-header .date {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 15px;
}

/* DIAGRAMS / FIGURES */
.diagram {
    margin: 32px 0;
}

.diagram img {
    display: block;
    width: 100%;
    height: auto;
}

.diagram figcaption {
    margin-top: 10px;
    font-size: 15px;
    color: var(--muted);
}

.diagram .diagram-zoom-in {
    display: block;
    cursor: zoom-in;
}

.zoom-hint {
    font-size: 13px;
    opacity: 0.7;
}

/* JS-free lightbox: hidden until its id is the URL :target */
.lightbox {
    display: none;
}

.lightbox:target {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.92);
    cursor: zoom-out;
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* CITATIONS / REFERENCES */
.cite {
    font-size: 0.7em;
    vertical-align: super;
    line-height: 0;
    margin-left: 1px;
}

.references-heading {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.references {
    margin: 0;
    padding-left: 20px;
    font-size: 15px;
    color: var(--muted);
}

.references li {
    margin-bottom: 8px;
}

.references a {
    word-break: break-word;
}

/* FOOTER */
.site-footer {
    margin-top: 64px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--muted);
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.footer-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.site-footer .footer-name img {
    width: 11px;
    height: 11px;
    opacity: 0.7;
}

.footer-social {
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-footer a {
    color: var(--muted);
    display: inline-flex;
    align-items: center;
}

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

.site-footer img {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.site-footer a:hover img {
    opacity: 1;
}

/* NARROW SCREENS — nav collapses to a row above the body */
@media (max-width: 640px) {
    .body-layout {
        flex-direction: column;
        gap: 0;
    }

    .site-nav {
        flex-direction: row;
        gap: 24px;
        margin-top: 0;
        margin-bottom: 32px;
    }
}
