/* Matteo Lanza — one stylesheet for the whole site */

:root {
  color-scheme: light only;
  --bg: #f7f3ec;
  --ink: #26221c;
  --muted: #6f6759;
  --rule: #e3dccd;
  --code-bg: #efe9dc;
  --accent: #7d2b26;
  --tok-kw: #34557c;
  --tok-str: #44663f;
  --tok-num: #8a5a1e;
  --tok-com: #8b8172;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
@media (max-width: 640px) { html { font-size: 17.5px; } }

body {
  box-sizing: content-box;          /* keep the measure at 680px, padding outside */
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 1.2rem 2rem;
  background: var(--bg);
  color: var(--ink);
  font-family: "Source Serif 4", Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  font-optical-sizing: auto;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2.5px; text-decoration-color: color-mix(in oklab, var(--accent) 40%, transparent); }
a:hover { text-decoration-color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in oklab, var(--accent) 18%, var(--bg)); }

h1, h2, h3 { font-weight: 600; line-height: 1.28; letter-spacing: -0.01em; text-wrap: pretty; }
p { margin: 0 0 1.05em; text-wrap: pretty; }
strong { font-weight: 600; }
img { max-width: 100%; height: auto; }
hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* ---------- chrome ---------- */
nav.top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72rem; letter-spacing: 0.03em;
  margin-bottom: 2.8rem;
}
nav.top .nav-links { display: flex; gap: 1.1rem; }
nav.top a { color: var(--muted); text-decoration: none; }
nav.top a:hover { color: var(--accent); }

form.contact { display: flex; flex-direction: column; gap: 0.4rem; max-width: 26rem; margin-top: 1rem; }
form.contact label { font-size: 0.85rem; color: var(--muted); margin-top: 0.6rem; }
form.contact input, form.contact textarea { font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--code-bg); border: 1px solid var(--rule); border-radius: 3px; padding: 0.5rem 0.6rem; }
form.contact input:focus, form.contact textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
form.contact button { align-self: flex-start; margin-top: 0.9rem; font: inherit; font-size: 0.95rem; color: var(--bg); background: var(--accent); border: none; border-radius: 3px; padding: 0.5rem 1.2rem; cursor: pointer; }
form.contact button:hover { opacity: 0.88; }

footer {
  margin-top: 4.5rem; padding-top: 1rem; border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: baseline;
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem; color: var(--muted); letter-spacing: 0.03em;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }
.sep { opacity: 0.45; }

/* ---------- home ---------- */
.masthead { margin-bottom: 2.6rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--rule); }
.masthead h1 { font-size: 1.4rem; margin: 0 0 0.35rem; }
.masthead p { margin: 0; color: var(--muted); font-size: 0.95rem; }

ul.posts { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.55rem; }
.post-line { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.post-line a { font-weight: 600; text-decoration: none; }
.post-line a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.post-line time { margin-left: auto; }
time {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem; color: var(--muted); letter-spacing: 0.02em; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.type {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.68rem; color: var(--muted); letter-spacing: 0.03em; text-transform: lowercase;
  white-space: nowrap;
}
p.summary { margin: 0.25rem 0 0; font-size: 0.9rem; line-height: 1.5; color: var(--muted); }

/* projects */
section.projects { margin-top: 3.4rem; padding-top: 1.6rem; border-top: 1px solid var(--rule); }
section.projects > h2 { font-size: 1.1rem; margin: 0 0 1.5rem; }
.project { margin: 0 0 2.4rem; }
.project h3 { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.35rem; }
.project p { margin: 0 0 0.35rem; font-size: 0.92rem; line-height: 1.55; }
.project p.plist { color: var(--muted); font-size: 0.9rem; }
.project p.status {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.68rem; color: var(--muted); letter-spacing: 0.03em;
}

/* ---------- article ---------- */
.post-title { font-size: 1.55rem; margin: 0 0 0.45rem; }
p.subtitle { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.9rem; }
.post-meta {
  display: flex; gap: 0.55rem; align-items: baseline; margin: 0 0 2.2rem;
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem; color: var(--muted); letter-spacing: 0.03em;
}
article h2 { font-size: 1.22rem; margin: 2.4rem 0 0.9rem; }
article h3 { font-size: 1rem; font-weight: 700; margin: 1.9rem 0 0.7rem; }
article ul, article ol { margin: 0 0 1.05em; padding-left: 1.3rem; }
article li { margin: 0 0 0.45em; }
article li p { margin: 0; }

blockquote { margin: 1.5rem 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--rule); color: color-mix(in oklab, var(--ink) 80%, var(--bg)); }
blockquote p { margin: 0 0 0.4em; }

/* code */
code, pre, kbd { font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
code { font-size: 0.78em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 2px; }
pre {
  background: var(--code-bg); border: 1px solid var(--rule);
  padding: 0.85rem 1rem; margin: 1.3rem 0;
  font-size: 0.7rem; line-height: 1.65; overflow-x: auto;
}
pre code { background: none; padding: 0; font-size: 1em; border-radius: 0; }
.tok-k { color: var(--tok-kw); }
.tok-d { color: var(--tok-kw); font-weight: 600; }
.tok-s { color: var(--tok-str); }
.tok-n { color: var(--tok-num); }
.tok-c { color: var(--tok-com); font-style: italic; }

/* math */
.katex { font-size: 1.04em; }
.katex-display { margin: 1.4rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.1rem 0; }

/* figures */
figure { margin: 1.9rem 0; }
figure img { display: block; margin: 0 auto; }
.placeholder {
  width: 100%; aspect-ratio: 16 / 7; min-height: 200px;
  border: 1px solid var(--rule);
  background: repeating-linear-gradient(-45deg, var(--code-bg), var(--code-bg) 8px, var(--bg) 8px, var(--bg) 16px);
  display: grid; place-items: center; padding: 1rem; text-align: center;
}
.placeholder span {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.68rem; color: var(--muted); letter-spacing: 0.02em;
}
figcaption { margin-top: 0.55rem; font-size: 0.84rem; line-height: 1.5; color: var(--muted); }

/* interactive figures may break out of the text column on desktop */
@media (min-width: 1020px) {
  figure.gw {
    max-width: none;
    width: min(960px, calc(100vw - 3rem));
    position: relative; left: 50%; transform: translateX(-50%);
  }
}

/* tables */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; }
table { border-collapse: collapse; font-size: 0.88rem; line-height: 1.45; }
th { font-weight: 600; text-align: left; }
th, td { padding: 0.32rem 1.1rem 0.32rem 0; vertical-align: baseline; }

/* about */
ul.links { list-style: none; margin: 1.4rem 0; padding: 0; display: grid; gap: 0.5rem; }
