/* The murdoch.is visual language. design/LANGUAGE.md documents every token and component here;
   pages use only these rules and carry no <style> blocks of their own.
   The only stylesheet: the site and the mockups in design/ both use it. */

/* ---- 1. Tokens ---- */
:root {
  color-scheme: light;
  /* Colour */
  --paper: #fcfcfa;
  --ink: #1a1a19;
  --muted: #6b6b66;
  --accent: #26428b;
  --numeral: #8e8e88;  /* large grey numerals only: 3.2:1, enough for large text */
  --rule: #dcdcd6;
  --target: #eef1f8;
  --link-rule: rgba(38, 66, 139, 0.4);
  /* The palette: colour for data and code only, never for interface. Four hues in a fixed order, validated
     for colour-blind readers (adjacent pairs, protanopia and deuteranopia) and at least 5:1 on paper, so each
     works as text as well as a line. Used sparingly: charts and syntax highlighting. LANGUAGE.md §2 has the figures. */
  --hue-1: #c2410c;  /* vermilion */
  --hue-2: #047857;  /* green */
  --hue-3: #a21caf;  /* fuchsia */
  --hue-4: #7d6b00;  /* olive */
  /* Faces */
  --text: "Equity B", Georgia, serif;
  --ui: "Concourse", system-ui, sans-serif;
  --code: "Triplicate A", ui-monospace, monospace;
  /* Type scale */
  --t-numeral: 2rem;
  --t-title: 1.8rem;
  --t-site: 1.1rem;
  --t-body: 1rem;
  --t-ui: 0.85rem;
  --t-meta: 0.78rem;
  --t-label: 0.72rem;
  --t-code: 0.68rem;
  /* Space */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.9rem;
  --s-4: 1.6rem;
  --s-5: 2.5rem;
  /* Grid */
  --margin: 9.5rem;
  --measure: 31rem;
  --gap: 2rem;
}

/* ---- 2. Base ---- */
* { box-sizing: border-box; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--t-body)/1.5 var(--text); font-kerning: normal; text-rendering: optimizeLegibility; hanging-punctuation: first; overflow-wrap: break-word; }
p { margin: 0 0 var(--s-3); hyphens: auto; }
address { font-style: normal; }
/* Images in content never overflow the text column. */
main img { max-width: 100%; height: auto; }
h1 { margin: 0; font: 700 var(--t-title)/1.15 var(--text); }

/* Links: accent; underlined only in running text, where colour alone is not enough (WCAG 1.4.1). */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.16em; text-decoration-thickness: 1px; }
/* The same applies wherever a link sits among plain words: an entry's authors and venue, a title block's values. */
p a, .entry-line a, .facts > dd > a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; text-decoration-color: var(--link-rule); }
p a:hover, .entry-line a:hover, .facts > dd > a:hover { text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---- 3. Page grid: a margin column for labels and a text column ---- */
.page { max-width: calc(var(--margin) + var(--gap) + var(--measure) + 4rem); margin: 0 auto; padding: 3.5rem 2rem 4rem; display: grid; grid-template-columns: var(--margin) minmax(0, var(--measure)); column-gap: var(--gap); align-items: baseline; }
.page > * { grid-column: 2; }

/* ---- 4. Header ---- */
.portrait { grid-column: 1; grid-row: 1 / span 3; align-self: start; margin: 0.4rem 0 0; }
.portrait img { display: block; width: 100%; height: auto; }
header .role { margin: var(--s-1) 0 0; color: var(--muted); }
.site-name { margin: 0; font: 700 var(--t-site)/1.2 var(--text); }
.site-name a { color: var(--ink); text-decoration: none; }
header nav { margin: var(--s-3) 0 0; display: flex; flex-wrap: wrap; gap: 0.2rem 1.5rem; font: var(--t-ui)/1.5 var(--ui); }
header nav a { color: var(--accent); }
header nav a[aria-current] { color: var(--ink); border-bottom: 1.5px solid var(--accent); }
header nav a:hover { text-decoration: underline; text-underline-offset: 0.16em; }
header nav a[aria-current]:hover { text-decoration: none; }
.page-title { margin: var(--s-5) 0 var(--s-3); hyphens: auto; }  /* long words in a title still fit a phone */

/* ---- 5. Sections and pinpoint links ---- */
h2 { margin: var(--s-4) 0 var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--rule); font: 400 var(--t-body)/1.5 var(--text); font-variant-caps: small-caps; letter-spacing: 0.086em; scroll-margin-top: 1rem; }
.rule-margin { grid-column: 1; align-self: start; margin-top: var(--s-4); border-top: 1px solid var(--rule); }
.pin { font-family: var(--text); font-variant-caps: normal; letter-spacing: 0; color: var(--muted); margin-left: 0.35rem; opacity: 0; transition: opacity 0.15s; }
h2:hover .pin, .entry-body:hover .pin, .pin:focus { opacity: 1; }
.pin:hover { color: var(--accent); text-decoration: none; }

/* A rule across both columns where a block ends without a heading after it (a post's title block). */
.page > hr { grid-column: 1 / -1; width: 100%; margin: var(--s-4) 0 var(--s-3); border: 0; border-top: 1px solid var(--rule); }

/* ---- 6. Labels: everything in the margin column ---- */
.label, .facts > dt { grid-column: 1; margin: 0; padding-top: 0.2rem; text-align: right; font: var(--t-label)/1.35 var(--ui); color: var(--muted); }
.label b, .facts > dt b { font-weight: 400; color: var(--ink); }
.label > span:not(.sign) { display: block; }
.label a { color: var(--accent); text-decoration: none; }

/* ---- 7. Entries: a paper, talk, chapter or patent, wherever it appears ---- */
.entry { display: contents; }
.entry[hidden] { display: none; }
.entry-body { grid-column: 2; margin: 0 0 var(--s-3); scroll-margin-top: 1rem; }
.entry-body:target { background: var(--target); box-shadow: 0 0 0 var(--s-2) var(--target); }
.entry-title { margin: 0; font: 400 var(--t-body)/1.4 var(--text); }
.entry-line { display: block; font: var(--t-meta)/1.5 var(--ui); color: var(--muted); }
.entry-line.award { color: var(--ink); }
.files { list-style: none; margin: 0; padding: 0; }
.entry .files { font: var(--t-meta)/1.5 var(--ui); }
.entry .files li { display: inline; }
.entry .files li + li::before { content: "·"; display: inline-block; margin: 0 0.35em; position: relative; top: -0.09em; color: var(--muted); }
/* An entry that needs prose (a course, a photograph): the description follows the metadata, in the text face. */
.entry-text { margin-top: var(--s-1); }
.entry-text p { margin: 0 0 var(--s-2); }
.entry-text p:last-child { margin-bottom: 0; }
.entry-text ul { margin: 0 0 var(--s-2); padding-left: 1.1em; }
/* A list inside an entry that only some readers need (a course's lecture slides) opens like "Cite as". */
.entry-more ol { margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3) var(--s-2) 2.1rem; border-left: 2px solid var(--rule); }
.entry-more li + li { margin-top: 0.15rem; }

/* ---- 7a. Photographs: a row of thumbnails, each linking to the full-size file ---- */
.photos { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-2) 0; padding: 0; }
.photos img { display: block; height: 7rem; width: auto; }

/* ---- 8. Year groups: large grey numerals in the margin, sticky while their entries pass ---- */
.year { grid-column: 1 / -1; display: grid; grid-template-columns: var(--margin) minmax(0, var(--measure)); column-gap: var(--gap); align-items: baseline; margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--rule); }
.year[hidden] { display: none; }
.numeral { grid-column: 1; justify-self: start; align-self: start; position: sticky; top: 1rem; margin: 0; padding: 0; border: 0; font: 800 var(--t-numeral)/1 var(--ui); font-variant-numeric: tabular-nums; letter-spacing: 0; color: var(--numeral); }
.year .label { justify-self: end; max-width: 4.4rem; }

/* ---- 9. Facts: label-and-value rows on the page grid ---- */
.facts { grid-column: 1 / -1; display: grid; grid-template-columns: var(--margin) minmax(0, var(--measure)); column-gap: var(--gap); align-items: baseline; margin: 0; }
.facts > dd { grid-column: 2; margin: 0 0 0.45rem; }
.facts > dd p { margin: 0; }
/* Several values under one label: a small gap between them, so a value that wraps still reads as one item. */
.facts.list > dd { margin: 0; }
.facts.list > dd + dd { margin-top: var(--s-1); }
.facts.list > dt:not(:first-of-type), .facts.list > dt:not(:first-of-type) + dd { margin-top: 0.6rem; }
.facts.titleblock { margin-top: var(--s-1); padding-top: var(--s-3); border-top: 1px solid var(--ink); }

/* ---- 7b. Code in running text (blog posts, archived project pages): Triplicate, highlighted in the palette ----
   Blocks are the markup sitebuild's Pygments formatter writes (div.highlight > pre > code, one class per token).
   Code keeps its line breaks, so a long line scrolls inside its block rather than widening the page. */
code, tt, kbd, samp { font: 0.86em/1 var(--code); font-feature-settings: "ss02"; }
/* Code from archival pages' HTML: the code face, at one weight, scrolling inside itself if too wide. */
main pre { margin: 0 0 var(--s-3); font: var(--t-code)/1.5 var(--code); font-feature-settings: "ss02"; overflow-x: auto; }
code b, code strong { font-weight: 400; }
.highlight pre { margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border-left: 2px solid var(--rule); font: var(--t-code)/1.5 var(--code); font-feature-settings: "ss02"; white-space: pre; overflow-x: auto; tab-size: 4; }
.highlight code { font: inherit; }
/* Four token kinds, each a palette colour; everything else stays ink. Comments are grey italic. */
.highlight :is(.k, .kc, .kd, .kn, .kp, .kr, .kt, .ow) { color: var(--hue-3); }
.highlight :is(.s, .s1, .s2, .sa, .sb, .sc, .sd, .se, .sh, .si, .sr, .ss, .sx) { color: var(--hue-2); }
.highlight :is(.m, .mb, .mf, .mh, .mi, .mo, .il) { color: var(--hue-4); }
.highlight :is(.nb, .nf, .nv, .vi, .vg, .vc, .bp, .fm) { color: var(--hue-1); }
.highlight :is(.c, .c1, .ch, .cm, .cp, .cpf, .cs) { color: var(--muted); font-style: italic; }
.highlight .err { color: inherit; }

/* ---- 7c. Long text: subsections and lists in running text (posts, the COVID page, archival pages) ---- */
.page > h3, .page > div[lang] > h3 { margin: var(--s-4) 0 var(--s-2); font: italic 400 var(--t-body)/1.4 var(--text); scroll-margin-top: 1rem; }
.prose-list { margin: 0 0 var(--s-3); padding-left: 1.1em; }
.prose-list li + li { margin-top: var(--s-1); }
/* A heading inside a subsection, such as a function's name on an archival page: body size, upright. */
.page > h4 { margin: var(--s-3) 0 var(--s-1); font: 400 var(--t-body)/1.4 var(--text); }
/* A passage in another language (<div lang="de">): transparent to the grid, so its headings and
   paragraphs lay out like any others while the language still applies to them. */
.page > div[lang] { display: contents; }
.page > div[lang] > * { grid-column: 2; }
/* A figure in running text: the image fills the text column at most, and links to the full-size file. */
.figure { margin: var(--s-2) 0 var(--s-3); }
/* A table in running text (the archival pages lay out figures and captions this way): cells apart,
   captions under their images. */
.page > table { margin: 0 0 var(--s-3); border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; }  /* a wide table scrolls inside itself, as code does */
.page > table td, .page > table th { padding: 0.25rem 0.5rem 0.25rem 0; vertical-align: top; text-align: left; }
.figure img { display: block; max-width: 100%; height: auto; }

/* ---- 7d. Charts: interactive line charts (Chart.js) in the palette, with the site's filters below ----
   Series colours come from --hue-1 to --hue-4, read by the page's script; a second cue (dashed lines) separates
   series that colour alone might not. Axes, grid and labels are in Concourse and grey. */
.chart-canvas { margin: var(--s-2) 0 var(--s-1); }
.chart-canvas canvas { display: block; max-width: 100%; }
/* The buttons belong to the chart above: close to it, with their rows together, and more space below the
   group than inside it, so a wrapped row doesn't read as part of the next paragraph. */
.chart-filters { margin: 0 0 var(--s-4); }
.chart-filters .filter-row { margin: 0; }

/* ---- 10. Citations: the same two forms everywhere ---- */
.cite, .entry-more { margin-top: var(--s-1); font: var(--t-meta)/1.5 var(--ui); }
.cite summary, .entry-more summary { display: inline; list-style: none; cursor: pointer; color: var(--accent); }
.cite summary::-webkit-details-marker, .entry-more summary::-webkit-details-marker { display: none; }
.cite summary:hover, .entry-more summary:hover { text-decoration: underline; text-underline-offset: 0.16em; }
/* Every disclosure says it opens, and says when it is open: + closed, − (a true minus) open. */
summary::after { content: "+"; display: inline-block; width: 0.7em; margin-left: 0.3em; text-align: center; position: relative; top: -0.04em; }
details[open] > summary::after { content: "\2212"; }
.cite-forms { margin: 0; }
.cite .cite-forms { margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3); border-left: 2px solid var(--rule); }
/* The reference needs no label: "Cite as" already says what it is. BibTeX is labelled, being a second form. */
.ref { margin: 0; font: var(--t-body)/1.45 var(--text); user-select: all; overflow-wrap: anywhere; hyphens: manual; }
/* A gap between the two forms. Qualified by .cite-forms so that it holds inside a title block, whose
   values' paragraphs otherwise have no margins. */
.cite-forms .cite-label { margin: var(--s-3) 0 0.1rem; font: var(--t-label)/1.35 var(--ui); color: var(--muted); }
.bibtex { margin: 0; font: var(--t-code)/1.45 var(--code); font-feature-settings: "ss02"; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

/* ---- 11. Filters and count ---- */
.filters { margin: 0; font: var(--t-ui)/1.5 var(--ui); }
.filter-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 1.1rem; margin: var(--s-1) 0; }
.filter-label { min-width: 3.2rem; color: var(--muted); }
.filters button { padding: 0; border: 0; border-bottom: 1.5px solid transparent; background: none; font: inherit; color: var(--accent); cursor: pointer; }
.filters button:hover { text-decoration: underline; text-underline-offset: 0.16em; }
.filters button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); text-decoration: none; cursor: default; }
.count { margin: var(--s-2) 0 0; font: var(--t-meta)/1.5 var(--ui); color: var(--muted); }

/* ---- 12. Signs: centred on the middle of a capital letter ----
   Equity and Concourse draw these on the lowercase x-height, so beside capitals and figures they sit low.
   Each is raised by the measured distance from its centre to half the cap height (see LANGUAGE.md §6).
   Relative positioning moves the sign without changing the line's height. */
.sign { position: relative; }
.sign.star { top: -0.1em; }
.sign.arrow { top: -0.08em; }
.sign.dot { top: -0.09em; }

/* ---- 12a. Small parts ---- */
.more { margin-top: var(--s-1); font: var(--t-ui)/1.5 var(--ui); }
/* After a list of facts, which has no bottom margin: the same space as after the works list's last entry. */
.facts + .more { margin-top: var(--s-4); }
/* The arrow, and the hair space before it, aren't underlined with the link's text: a link's underline
   doesn't reach into an inline block. */
.more .sign.arrow { display: inline-block; }

/* ---- 13. End of the page: the asterism closes the text; the footer gives the revision date ---- */
.end { margin: var(--s-5) 0 0; text-align: center; font-size: var(--t-site); line-height: 1; color: var(--muted); }
footer { margin-top: 1.4rem; text-align: center; font: var(--t-label)/1.5 var(--ui); color: var(--muted); }

/* ---- 14. Phones: one column, labels above, 44 px targets ---- */
@media screen and (max-width: 760px) {
  html { font-size: 18px; }
  .page, .facts, .year { display: block; }
  .page { padding: 2rem 16px 3rem; }
  .label, .facts > dt { padding: 0; margin: 0 0 0.1rem; text-align: left; font-size: var(--t-meta); }
  .label b, .facts > dt b { color: var(--muted); }
  .label > span:not(.sign) { display: inline; }
  .label b + span::before { content: "·"; display: inline-block; margin-right: 0.35em; position: relative; top: -0.09em; }
  .year .label { max-width: none; justify-self: auto; }
  .crumb { margin-top: var(--s-4); }
  .page-title { margin-top: var(--s-4); }
  .crumb + .page-title { margin-top: 0.3rem; }
  .rule-margin { display: none; }
  .portrait { float: right; width: 6.5rem; margin: 0.2rem 0 0.8rem 1rem; }
  header + h2 { clear: both; }
  header nav { gap: 0 1.3rem; margin: 0.6rem 0 0; }
  header nav a, .filters button { display: inline-block; padding: 0.7rem 0; }
  /* On phones the label sits above the body, so the entry itself is the block: it takes the spacing and,
     when linked to, the highlight, so label and body are marked together. */
  .entry { display: block; margin-bottom: var(--s-4); }
  /* A long entry (with a description or photographs) ends far from its small label, so space alone doesn't
     show where the next one starts: a hairline does, between any two entries when either is long. */
  .entry:has(.entry-text, .photos) + .entry, .entry + .entry:has(.entry-text, .photos) { padding-top: var(--s-3); border-top: 1px solid var(--rule); }
  .entry-body { margin-bottom: 0; scroll-margin-top: 2.2rem; }
  .entry-body:target { background: none; box-shadow: none; }
  .entry:has(> .entry-body:target) { background: var(--target); box-shadow: 0 0 0 var(--s-2) var(--target); }
  /* Parts of an entry stay close together, so they read as one entry: targets of at least 24 px
     (WCAG 2.5.8) rather than 44, with the space between entries (--s-4) larger than any space inside one. */
  .entry .files a, .cite summary, .entry-more summary { display: inline-block; padding: 0.15rem 0; }
  .cite, .entry-more { margin-top: 0; }
  .facts > dd { margin-bottom: 0.6rem; }
  .facts.list > dd { margin-bottom: 0; }
  .numeral { position: static; font-size: var(--t-title); margin-bottom: 0.7rem; }
  /* With 44 px targets a wrapped row sits about 1.4 rem below the last, so the gap after the group must be wider. */
  .chart-canvas { margin-bottom: 0; }
  .chart-filters { margin-bottom: var(--s-5); }
}

/* ---- 15. Print ---- */
@media print {
  header nav, .pin, .more, .filters, .cite, .entry-more { display: none; }
  .chart-canvas { break-inside: avoid; }
  a, p a, .entry-line a, .facts > dd > a { color: inherit; text-decoration: none; }
  h2 { break-after: avoid; }
  p, .entry-body, .facts > dd { break-inside: avoid; }
  .highlight pre { white-space: pre-wrap; overflow-wrap: anywhere; }
}
