/* The site's frame (header, menu, home page list, footer) drawn from the
   theme's tokens. A note's body is styled by Deft's own document.css, through
   the .rendered-note class, so it looks as it does in the editor. */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	background: var(--editor-background);
	color: var(--editor-foreground);
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	font-family: var(--editor-font-family);
	font-size: var(--editor-font-size);
	font-weight: var(--editor-font-weight);
	line-height: var(--editor-line-height);
	/* One line of the note's text: the gap a blank line leaves in the editor. */
	--line: calc(var(--editor-font-size) * var(--editor-line-height));
}

a {
	color: var(--link);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}

/* The editor's Narrow width, 38 times the font size, plus the page's inset;
   a site set to Wide takes the editor's Wide, 53. A theme lays its own column
   out by --site-width. A column as tall as the window, so a short page's
   footer sits at its foot. */
.deft-site {
	--site-width: 38em;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
	max-width: calc(var(--site-width) + 3rem);
	margin: 0 auto;
	padding: 0 1.5rem;
}
.deft-site.deft-site-wide {
	--site-width: 53em;
}
/* Full: the window's width, with more room at its sides as it grows. */
.deft-site.deft-site-full {
	max-width: none;
	padding-inline: clamp(1.5rem, 4vw, 3.5rem);
}
.deft-site > main {
	flex: 1;
}
/* A site with no footer ends with the room its footer would keep under the page. */
.deft-site > main:last-child {
	padding-bottom: 4rem;
}

.deft-site-header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.4em 2em;
	padding: 1.5rem 0 1.75rem;
}
.deft-site-title {
	margin: 0;
	font-family: var(--heading-font-family);
	font-size: 2em;
	font-weight: 650;
	line-height: 1.25;
}
.deft-site-title a {
	color: var(--editor-foreground);
}
.deft-site-title a:hover {
	text-decoration: none;
}

/* The menu: the site's undated notes beside the title on every page,
   wrapping under it where they don't fit. */
.deft-site-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.2em 1.4em;
}
.deft-site-nav a {
	color: var(--editor-foreground-muted);
}
.deft-site-nav a:hover {
	color: var(--editor-foreground);
	text-decoration: none;
}
/* The page being read is in the site's colour, under the pointer too. */
.deft-site-nav a[aria-current] {
	color: var(--link);
	text-decoration: none;
}
/* Links that don't fit on a line fold into one button, which opens them as a
   list under it. A details element, so it opens with no script. */
.deft-site-nav details {
	position: relative;
}
/* The button stays on the title's line, at its far end, and a long title
   wraps beside it: under the title it would open its list off the page. */
.deft-site-header:has(.deft-site-nav > details) {
	flex-wrap: nowrap;
}
.deft-site-nav summary {
	display: flex;
	align-items: center;
	height: var(--line);
	list-style: none;
	color: var(--editor-foreground-muted);
	cursor: pointer;
}
.deft-site-nav summary::-webkit-details-marker {
	display: none;
}
.deft-site-nav summary:hover,
.deft-site-nav details[open] summary {
	color: var(--editor-foreground);
}
.deft-site-nav details > div {
	position: absolute;
	top: calc(100% + 0.4em);
	right: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	min-width: 12em;
	max-height: 60vh;
	overflow-y: auto;
	padding: 0.4em 0;
	background: var(--editor-background);
	border: 1px solid var(--editor-border);
	border-radius: var(--border-radius-medium);
	box-shadow: var(--box-shadow-medium);
}
.deft-site-nav details a {
	padding: 0.2em 0.9em;
	color: var(--editor-foreground);
	white-space: nowrap;
}
.deft-site-nav details a:hover,
.deft-site-nav details a[aria-current] {
	background: var(--editor-background-muted);
}

/* The index: one list of titles, a date at the far end of a dated row. */
.deft-site-index > ul {
	list-style: none;
	margin: 0;
	padding: 0;
}
.deft-site-index > ul + ul {
	margin-top: var(--line);
}
/* The home page's text above the list: two lines clear of it. */
.deft-site-index > .deft-site-content {
	margin-top: 0;
}
.deft-site-index > .deft-site-content + ul {
	margin-top: calc(var(--line) * 2);
}
.deft-site-index > ul > li {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1.5em;
	padding: 0.2em 0;
}
.deft-site-index > ul a {
	color: var(--editor-foreground);
}
.deft-site-index time {
	flex: none;
	color: var(--editor-foreground-muted);
	font-size: 0.9em;
	font-variant-numeric: tabular-nums;
}

.deft-site-page-title {
	margin: 0.6em 0 0;
	font-family: var(--heading-font-family);
	font-size: 2.25em;
	font-weight: var(--heading-1-font-weight);
	color: var(--heading-1-foreground);
	line-height: 1.15;
	text-wrap: balance;
}
.deft-site-page-date {
	display: block;
	margin-top: 0.9em;
	color: var(--editor-foreground-muted);
	font-size: 0.9em;
	font-variant-numeric: tabular-nums;
}

.deft-site-content {
	margin-top: var(--line);
}
.deft-site-page-title ~ .deft-site-content {
	margin-top: calc(var(--line) * 1.5);
}
/* No word left alone on a paragraph's last line, and headings broken into even lines. */
.rendered-note :is(p, li) {
	text-wrap: pretty;
}
.rendered-note :is(h1, h2, h3, h4, h5, h6) {
	text-wrap: balance;
}
/* A tall picture fits in the window, narrowing to keep its shape. One in a
   sentence is a line tall already, and an HTML <img> keeps its author's size.
   :where keeps the rule as light as a theme's own on .rendered-note img. */
.rendered-note img:where(:not(.inline, .html, .html-block img)) {
	max-height: 80vh;
}

/* Lines of one paragraph set to the centre or the right are blocks already,
   so the break after one would add an empty line. */
.rendered-note span[style*='text-align'] + br {
	display: none;
}

/* The site's own footer text, with the credit and the feed's link at the far
   end of its line, or of the next where a narrow screen has no room for both. */
.deft-site-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.6em 1.25em;
	margin-top: 2.5rem;
	padding: 1.25rem 0 1.5rem;
	color: var(--editor-foreground-muted);
	font-size: 0.85em;
}
.deft-site-footer a {
	color: inherit;
}
/* The footer page's text: a note's blocks at the footer's own size and
   colour, its links underlined since they share the text's colour. */
.deft-site-footer-text {
	flex: 1 1 20em;
	font: inherit;
	color: inherit;
	background: none;
}
.deft-site-footer-text a {
	color: inherit;
	text-decoration: underline;
}
.deft-site-footer-end {
	display: flex;
	gap: 1.25em;
	white-space: nowrap;
}
.deft-site-footer-text + .deft-site-footer-end {
	margin-left: auto;
}

/* A publication list from a .bib: one paper per item, its title, authors,
   venue and links each on a line, a line's gap between papers. */
.rendered-note .deft-pubs > li {
	padding-left: 0;
}
.rendered-note .deft-pubs > li::before {
	content: none;
}
/* A numbered one keeps the document's own numbers and their room. */
.rendered-note ol.deft-pubs > li {
	padding-left: var(--hang);
}
.rendered-note ol.deft-pubs > li::before {
	content: attr(data-marker);
}
.rendered-note .deft-pubs > li + li {
	margin-top: calc(var(--line) * 0.75);
}
.deft-pubs > li > span:not(.deft-pub-links) {
	display: block;
}
.deft-pub-title {
	color: var(--editor-foreground);
	font-weight: 600;
}
.deft-pub-authors,
.deft-pub-venue {
	color: var(--editor-foreground-muted);
}
.deft-pub-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1em;
	font-size: 0.9em;
}
/* The same list with each paper as one reference: a bibliography's hanging
   indent, so each paper's first word stands clear of its other lines, and
   the links run on after the reference. */
.rendered-note .deft-pubs-cited > li {
	padding-left: 1.75em;
	text-indent: -1.75em;
}
/* Numbered, the number is what stands clear, so the reference has no hang
   of its own. */
.rendered-note ol.deft-pubs-cited > li {
	text-indent: 0;
}
.deft-pubs-cited > li > span.deft-pub-cite {
	display: inline;
}
.deft-pubs-cited .deft-pub-links {
	display: inline;
}
