/* Jost: a geometric sans in the same family of shapes as the logo. Latin subset, variable weight. */
@font-face {
  font-family: "Jost"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/jost.woff2) format("woff2");
}

/* Dark only: the logo is drawn for a black background. */
:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --panel: #111213;
  --line: #232527;
  --fg: #cfd2d4;
  --bright: #f2f3f4;
  --muted: #7c8287;
  --accent: #00aeef;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
/* Everything is sized in rem, and the rem grows a little with the window: 16px on a phone, about 18px on a laptop, up to 24px on a very wide screen. */
html { -webkit-text-size-adjust: 100%; background: var(--bg); font-size: clamp(100%, .85rem + .3vw, 150%); }
body {
  margin: 0 auto; padding: 0 clamp(1.25rem, 5vw, 4rem) 5rem; max-width: 80rem;
  color: var(--fg); font: 1.0625rem/1.65 var(--sans);
}
::selection { background: var(--accent); color: #000; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ---- header ---- */
header.site {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.5rem 0 1.1rem; margin-bottom: 3rem;
}
.logo { display: block; line-height: 0; }
.logo img { height: 1.375rem; width: auto; }
header.site nav { display: flex; gap: 1.5rem; font: .8125rem var(--mono); }
header.site nav a { color: var(--muted); }
header.site nav a:hover { color: var(--bright); text-decoration: none; }

/* ---- post list ---- */
ul.posts { list-style: none; margin: 0; padding: 0; max-width: 60rem; }
ul.posts li {
  display: grid; grid-template-columns: 7rem 1fr auto; gap: 0 1rem; align-items: baseline;
  padding: .7rem 0; border-bottom: 1px solid var(--line);
}
ul.posts a { color: var(--bright); }
ul.posts a:hover { color: var(--accent); text-decoration: none; }
time, .tag, .meta { font: .8125rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.tag + .tag { margin-left: .5rem; }
@media (max-width: 34rem) {
  ul.posts li { grid-template-columns: 1fr; }
  ul.posts .tags { display: none; }
}

/* ---- landing page ---- */
/* One fixed screen: header, then the hero (or the writing / contact view) filling the rest, then the footer. */
body.home { display: flex; flex-direction: column; height: 100vh; height: 100svh; padding-bottom: 1.5rem; overflow: hidden; overscroll-behavior: none; }
body.home header.site { margin-bottom: 0; }
body.home main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.home footer.site { margin-top: 0; }
.hero, .view { flex: 1; min-height: 0; flex-direction: column; justify-content: center; padding: 2rem 0 4rem; }
.hero { display: flex; }
/* A view is hidden until the URL points at it (#writing, #contact); then it takes the hero's place. */
.view { display: none; overflow-y: auto; justify-content: flex-start; }
.view:target { display: flex; }
.view:target ~ .hero { display: none; }
.view > :first-child { margin-top: auto; } /* centres the content, but lets a long list scroll from its top */
.view > :last-child { margin-bottom: auto; }
.view .label, .hero .label { margin-bottom: 1.5rem; }
.view .big { font-size: clamp(1.75rem, 1rem + 3.4vw, 4.25rem); font-weight: 500; line-height: 1.15; letter-spacing: -.025em; overflow-wrap: anywhere; }
.view p { margin-top: 0; }
.view ul.posts { width: 100%; font-size: clamp(1.125rem, 1rem + .6vw, 1.5rem); }
.view ul.posts li { border-bottom: 0; grid-template-columns: 7rem 1fr; }
.view ul.posts .tags { display: none; }
body:has(#writing:target) header.site nav a[href$="#writing"],
body:has(#contact:target) header.site nav a[href$="#contact"] { color: var(--bright); }
@media (max-height: 26rem) { body.home { height: auto; min-height: 100svh; overflow: visible; } } /* too short to fit: scroll normally */

.statement {
  margin: 0; max-width: 22em;
  font-size: clamp(1.75rem, 1rem + 3.4vw, 4.25rem); font-weight: 500; line-height: 1.15; letter-spacing: -.025em;
  color: var(--muted); text-wrap: balance;
}
.statement em { font-style: normal; color: var(--bright); cursor: default; outline: 0; transition: color .2s; }
.statement em:nth-of-type(even) { color: var(--accent); } /* white, blue, white, blue: the logo's two colours */
.notes { position: relative; min-height: 5em; margin-top: 2rem; font-size: clamp(1rem, .85rem + .6vw, 1.375rem); }
.notes p { position: absolute; top: 0; left: 0; margin: 0; max-width: 34em; opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
/* home.js marks the selected term and its note with .on; the other terms dim. */
.statement.stepped em:not(.on) { color: var(--muted); }
.notes p.on { opacity: 1; visibility: visible; }
/* Without the script, hovering or tabbing to a term does the same in CSS (up to six terms). */
html:not(.js) .statement:has(em:is(:hover, :focus)) em:not(:hover, :focus) { color: var(--muted); }
html:not(.js) .hero:has(.statement em:nth-of-type(1):is(:hover, :focus)) .notes p:nth-of-type(1),
html:not(.js) .hero:has(.statement em:nth-of-type(2):is(:hover, :focus)) .notes p:nth-of-type(2),
html:not(.js) .hero:has(.statement em:nth-of-type(3):is(:hover, :focus)) .notes p:nth-of-type(3),
html:not(.js) .hero:has(.statement em:nth-of-type(4):is(:hover, :focus)) .notes p:nth-of-type(4),
html:not(.js) .hero:has(.statement em:nth-of-type(5):is(:hover, :focus)) .notes p:nth-of-type(5),
html:not(.js) .hero:has(.statement em:nth-of-type(6):is(:hover, :focus)) .notes p:nth-of-type(6) { opacity: 1; visibility: visible; }
/* The newest post, on one line at the bottom of the hero. The auto margins keep the sentence centred in the space above it. */
.hero:has(.latest) { padding-bottom: 1rem; }
.hero:has(.latest) > .label { margin-top: auto; }
.latest { margin: auto 0 0; padding-top: 2rem; font: .8125rem/1.7rem var(--mono); }
.latest a { color: var(--bright); }
.latest a span { color: var(--muted); margin-right: .75em; }
.latest a i { font-style: normal; color: var(--accent); margin-left: .25em; }
.latest a:hover { color: var(--accent); text-decoration: none; }
.label { margin: 0; padding: 0; border: 0; font: 400 .8125rem/1.7rem var(--mono); letter-spacing: 0; color: var(--muted); }
.more { font: .8125rem var(--mono); margin: 1rem 0 0; }
.more a { color: var(--muted); }
.more a:hover { color: var(--bright); text-decoration: none; }
h1.label { margin-bottom: 1.5rem; }
footer.site { margin-top: 3rem; padding-top: 1.1rem; font: .75rem var(--mono); color: var(--muted); }

/* ---- article ---- */
article { max-width: 45rem; } /* a readable line length, however wide the window */
.meta { margin: 0 0 .75rem; }
.meta time { margin-right: .75rem; }
h1, h2, h3, h4 { color: var(--bright); line-height: 1.25; font-weight: 650; }
h1 { font-size: 2rem; letter-spacing: -.02em; margin: 0 0 2.5rem; }
h2 { font-size: 1.25rem; margin: 3rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
h3 { font-size: 1.05rem; margin: 2rem 0 .75rem; }
h4 { font: 600 .8125rem var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.75rem 0 .5rem; }
article a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 3px; }
article a:hover { text-decoration-color: var(--accent); }
strong { color: var(--bright); }
img, video { max-width: 100%; height: auto; }
article p > img:only-child { display: block; border: 1px solid var(--line); }
hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--bright); padding: 0 .2em; }
li::marker { color: var(--muted); }

/* ---- code ---- */
code, pre, kbd { font-family: var(--mono); font-size: .875em; }
:not(pre) > code { color: var(--bright); background: var(--panel); border: 1px solid var(--line); padding: .05em .35em; overflow-wrap: anywhere; }
pre { position: relative; margin: 1.5rem 0; background: var(--panel); border: 1px solid var(--line); line-height: 1.55; tab-size: 4; }
pre code { display: block; padding: 1rem 1.1rem; overflow-x: auto; font-size: .8125rem; }
pre code[data-lang]::before {
  content: attr(data-lang); position: absolute; top: 0; right: 0;
  padding: .1rem .5rem; font-size: .6875rem; color: var(--muted);
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg);
}
kbd { border: 1px solid var(--line); border-bottom-width: 2px; padding: .05em .35em; }

/* ---- tables ---- */
table { display: block; overflow-x: auto; max-width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: .9375rem; }
th, td { padding: .45rem 1.25rem .45rem 0; text-align: left; border-bottom: 1px solid var(--line); }
th { font: 500 .75rem var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---- quotes and callouts ---- */
blockquote { margin: 1.5rem 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); color: var(--muted); }
blockquote.callout { color: var(--fg); padding: .75rem 1rem; border-left-color: var(--accent); background: var(--panel); }
blockquote.callout p { margin: .35rem 0; }
.callout-title { font: 600 .75rem var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
blockquote.callout-warning, blockquote.callout-caution, blockquote.callout-attention { border-left-color: #e0a100; }
blockquote.callout-warning .callout-title, blockquote.callout-caution .callout-title, blockquote.callout-attention .callout-title { color: #e0a100; }
blockquote.callout-danger, blockquote.callout-error, blockquote.callout-bug, blockquote.callout-failure { border-left-color: #f0524f; }
blockquote.callout-danger .callout-title, blockquote.callout-error .callout-title, blockquote.callout-bug .callout-title, blockquote.callout-failure .callout-title { color: #f0524f; }
blockquote.callout-tip, blockquote.callout-success, blockquote.callout-hint { border-left-color: #3fb96b; }
blockquote.callout-tip .callout-title, blockquote.callout-success .callout-title, blockquote.callout-hint .callout-title { color: #3fb96b; }

/* ---- highlight.js tokens ---- */
.hljs-comment, .hljs-quote, .hljs-meta { color: #6b7278; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type, .hljs-built_in, .hljs-doctag { color: #5cc8f5; }
.hljs-string, .hljs-regexp, .hljs-symbol, .hljs-char.escape_, .hljs-attr, .hljs-attribute { color: #b5d08a; }
.hljs-number, .hljs-variable, .hljs-template-variable, .hljs-selector-attr, .hljs-selector-pseudo { color: #e6b673; }
.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id, .hljs-selector-class { color: var(--bright); }
.hljs-addition { color: #3fb96b; }
.hljs-deletion { color: #f0524f; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
