/*
Theme Name: AFP548
Description: The AFP548 site theme (CHANGELOG #101): the logo's slate, grey and blue; a slim masthead with search; a topic bar; the newest article leading; one row per article; no sidebar; dark mode from the device setting; no JavaScript of its own. Decisions in server/theme-design-notes.md.
Version: 0.1.0
Requires at least: 7.0
Requires PHP: 8.3
License: GPL-2.0-or-later
Text Domain: afp548
*/

/* Palette: the logo's colours. Light by default, dark when the device asks for it. */
:root {
	--slate: #3a3d4a;
	--grey: #61646e;
	--steel: #5c7aa1;
	--lavender: #b3bad0;
	--bg: #ffffff;
	--surface: #f4f5f8;
	--border: #dfe2ea;
	--text: #1f2128;
	--muted: #5b5f6b;
	--link: #3f5f8a;
	--link-hover: #2c476d;
	--masthead: var(--slate);
	--masthead-text: #ffffff;
	--masthead-muted: #c9cdd9;
	--topicbar: var(--steel);
	--topicbar-text: #ffffff;
	--code-bg: #f6f8fa;
	--code-border: #e1e4e8;
	--inline-code-bg: #eef0f4;
	--tile-0: #3a3d4a;
	--tile-1: #5c7aa1;
	--tile-2: #61646e;
	--tile-3: #4a5d80;
	--radius: 6px;
	--wrap: 72rem;
	--measure: 52rem;
	--wide: 72rem;
	color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #17181d;
		--surface: #1f2128;
		--border: #31343e;
		--text: #e6e7ec;
		--muted: #a4a8b6;
		--link: #a3b8db;
		--link-hover: #c7d3ea;
		--masthead: #24262e;
		--masthead-muted: #a4a8b6;
		--topicbar: #3d5272;
		--code-bg: #0d1117;
		--code-border: #30363d;
		--inline-code-bg: #262a33;
		--tile-0: #2c2f3a;
		--tile-1: #3d5272;
		--tile-2: #44474f;
		--tile-3: #33415c;
	}
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 400 1.0625rem/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	text-rendering: optimizeLegibility;
}
a { color: var(--link); text-underline-offset: .15em; }
a:hover { color: var(--link-hover); }
img, video, iframe, embed, object { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--bg); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

/* Masthead */
.masthead { background: var(--masthead); color: var(--masthead-text); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .6rem; padding-bottom: .6rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; min-width: 0; }
.brand-logo { width: 44px; height: 44px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.35rem; letter-spacing: .04em; line-height: 1.1; }
.brand-tagline { color: var(--masthead-muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.masthead .site-search { flex: 0 1 18rem; }
/* Not .search: WordPress puts that class on <body> for search results */
.site-search { display: flex; min-width: 0; }
.site-search input[type="search"] {
	flex: 1; min-width: 0; font: inherit; font-size: .95rem; padding: .4rem .6rem;
	border: 1px solid transparent; border-radius: var(--radius) 0 0 var(--radius);
	background: rgba(255, 255, 255, .12); color: inherit;
}
.site-search input[type="search"]::placeholder { color: var(--masthead-muted); }
.site-search button {
	display: flex; align-items: center; padding: 0 .7rem; border: 0; cursor: pointer;
	border-radius: 0 var(--radius) var(--radius) 0; background: rgba(255, 255, 255, .2); color: inherit;
}
main .site-search input[type="search"] { background: var(--surface); border-color: var(--border); color: var(--text); }
main .site-search input[type="search"]::placeholder { color: var(--muted); }
main .site-search button { background: var(--steel); color: #fff; }
@media (max-width: 40rem) {
	.brand-tagline { display: none; }
	.masthead .site-search { flex-basis: 10rem; }
}

/* Topic bar: scrolls sideways on a phone, no JavaScript */
.topics { background: var(--topicbar); }
.topics ul { display: flex; gap: .25rem; margin: 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.topics ul::-webkit-scrollbar { display: none; }
.topics a { display: block; padding: .55rem .7rem; color: var(--topicbar-text); text-decoration: none; font-size: .92rem; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.topics a:hover, .topics a[aria-current] { border-bottom-color: var(--lavender); }
.topics .topics-other { margin-left: auto; }
/* "Other" subjects (CHANGELOG #112): a strip under the bar. Positioned against .topics, not its list, so the list's sideways scrolling does not clip it. */
.topics { position: relative; }
.topics summary { display: block; padding: .55rem .7rem; color: var(--topicbar-text); font-size: .92rem; font-weight: 600; white-space: nowrap; cursor: pointer; list-style: none; border-bottom: 3px solid transparent; }
.topics summary::-webkit-details-marker { display: none; }
.topics summary::after { content: " \25BE"; font-size: .8em; }
.topics details[open] summary::after { content: " \25B4"; }
.topics summary:hover, .topics summary.current, .topics details[open] summary { border-bottom-color: var(--lavender); }
.topics summary:focus-visible { outline: 2px solid var(--topicbar-text); outline-offset: -2px; }
.topics .topics-more ul { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; overflow: visible; padding: .2rem 1rem; background: var(--topicbar); border-top: 1px solid rgba(255, 255, 255, .25); box-shadow: 0 6px 12px rgba(0, 0, 0, .18); }

main.wrap { padding-top: 1.75rem; padding-bottom: 3rem; }

/* Labels, meta */
.kicker { margin: 0 0 .3rem; font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.kicker a { color: var(--steel); text-decoration: none; }
.meta { margin: .4rem 0 0; color: var(--muted); font-size: .88rem; }
.meta a { color: inherit; }
.meta .sep { margin: 0 .3rem; }

/* Tiles for posts without a photo */
.tile { display: flex; align-items: flex-end; width: 100%; height: 100%; padding: .6rem .7rem; color: #fff; font-weight: 700; line-height: 1.15; border-radius: var(--radius); background: var(--tile-0); position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; right: -18%; top: -30%; width: 70%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.tile-1 { background: var(--tile-1); }
.tile-2 { background: var(--tile-2); }
.tile-3 { background: var(--tile-3); }
.tile-name { position: relative; }

/* The lead article: the whole image, never cropped */
.lead { margin: 0 0 2.25rem; padding-bottom: 2.25rem; border-bottom: 1px solid var(--border); }
.lead-media { display: block; margin-bottom: 1.1rem; }
.lead-media img { display: block; width: auto; max-width: 100%; height: auto; max-height: 70vh; margin: 0 auto; border-radius: var(--radius); }
.lead-media .tile { aspect-ratio: 21 / 7; min-height: 9rem; font-size: clamp(1.4rem, 1rem + 2vw, 2.2rem); padding: 1.2rem 1.4rem; }
.lead-title { font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.5rem); margin: .1rem 0 .5rem; }
/* Long words (paths, keys, URLs) wrap instead of widening the page on a phone */
.lead-title, .row-title, .hook, .entry-title, .meta { overflow-wrap: anywhere; }
.lead-title a, .row-title a { color: var(--text); text-decoration: none; }
.lead-title a:hover, .row-title a:hover { color: var(--link); text-decoration: underline; }
.lead .hook { font-size: 1.12rem; max-width: var(--measure); margin: 0; }

/* One row per article */
.rows { display: block; }
.row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 1.25rem; padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row-media { display: block; width: 9.5rem; aspect-ratio: 4 / 3; }
.row-media img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); border-radius: var(--radius); }
.row-media .tile { font-size: .95rem; }
.row-title { font-size: 1.25rem; margin: 0 0 .35rem; }
.row .hook { margin: 0; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 40rem) {
	.row { grid-template-columns: 5.5rem minmax(0, 1fr); gap: .9rem; }
	.row-media { width: 5.5rem; }
	.row-media .tile { font-size: .72rem; padding: .4rem; }
	.row-title { font-size: 1.08rem; }
	.row .hook { -webkit-line-clamp: 2; font-size: .95rem; }
}

/* Archive and search headings */
.page-header { margin-bottom: 1rem; }
.page-title { margin-top: 0; }
.archive-description { color: var(--muted); max-width: var(--measure); }

/* Pagination */
.pagination .nav-links, .page-numbers-wrap { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 2rem; }
.page-numbers { display: inline-block; padding: .35rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.page-numbers.current { background: var(--steel); border-color: var(--steel); color: #fff; }

/* Articles and pages */
.entry { max-width: var(--measure); margin: 0 auto; }
.entry-header { margin-bottom: 1.5rem; }
.entry-title { margin: .1rem 0 .4rem; }
.entry-media { margin: 0 0 1.75rem; }
.entry-media img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: var(--radius); }
.entry-content { overflow-wrap: break-word; }
.entry-content > :first-child { margin-top: 0; }
.entry-content p, .entry-content ul, .entry-content ol { margin: 0 0 1.15em; }
.entry-content li { margin: .25em 0; }
.entry-content blockquote { margin: 1.5em 0; padding: .2em 1.1em; border-left: 3px solid var(--lavender); color: var(--muted); }
.entry-content img { border-radius: 3px; }
.entry-content .alignleft { float: left; margin: .3em 1.2em .8em 0; }
.entry-content .alignright { float: right; margin: .3em 0 .8em 1.2em; }
.entry-content .aligncenter { display: block; margin-left: auto; margin-right: auto; }
.entry-content .wp-caption { max-width: 100%; }
.entry-content .wp-caption-text, .entry-content figcaption { color: var(--muted); font-size: .88rem; }
@media (max-width: 40rem) {
	.entry-content .alignleft, .entry-content .alignright { float: none; display: block; margin: 1em auto; }
}
/* Tables: each sits in a box that scrolls when a table is wider than the screen (functions.php adds .table-wrap). Every table is at least as wide as the text, so narrow ones line up with it on both sides; wider ones grow evenly on both sides (up to --wide on large screens, below). */
.table-wrap { overflow-x: auto; margin: 1.5em 0; }
.table-wrap > table { border-collapse: collapse; margin: 0 auto; min-width: 100%; width: auto; }
.entry-content table { border-collapse: collapse; }
.entry-content th, .entry-content td { border: 1px solid var(--border); padding: .4em .6em; vertical-align: top; }
.entry-content th { background: var(--surface); }
/* Headers line up with their columns, unless the article sets an alignment (Markdown's :---: and ---:) */
.entry-content th:not([align]):not([style*="text-align"]) { text-align: left; }

/* Code: highlight.js colours the blocks (afp548-code-highlight); this lays them out */
code, kbd, pre, samp { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .9em; }
:not(pre) > code { background: var(--inline-code-bg); padding: .12em .35em; border-radius: 4px; overflow-wrap: anywhere; }
pre {
	background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--radius);
	padding: .9rem 1rem; overflow-x: auto; line-height: 1.5; margin: 1.4em 0; tab-size: 4;
}
pre code { background: none; padding: 0; font-size: .88rem; }
/* On wide screens, code, tables and script boxes in an article may be wider than the text: up to 72rem (about 1150 px), centred on it, so long lines rarely need sideways scrolling */
@media (min-width: 60rem) {
	.entry-content > .table-wrap, .entry-content > .wp-block-table {
		width: min(var(--wide), 100vw - 3rem);
		max-width: none;
		margin-left: calc(50% - min(var(--wide), 100vw - 3rem) / 2);
	}
	/* Code boxes, like tables: at least as wide as the text, as wide as their longest line up to --wide, always centred on the text */
	.entry-content > pre, .entry-content > .script, .entry-content > .wp-block-code {
		width: max-content;
		min-width: 100%;
		max-width: min(var(--wide), 100vw - 3rem);
		position: relative;
		left: 50%;
		transform: translateX(-50%);
	}
	.entry-content > .script > pre { width: auto; }
	/* Wide screens: long lines wrap inside the box instead of scrolling sideways (Sam, CHANGELOG #104). Phones keep sideways scrolling, so code does not become very tall. */
	pre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
	/* In the wide box a table is still at least as wide as the text, centred on it */
	.entry-content > .table-wrap > table { min-width: var(--measure); }
}
pre code.hljs { padding: 0; background: transparent; }
.script { margin: 1.4em 0; border: 1px solid var(--code-border); border-radius: var(--radius); overflow: hidden; }
.script figcaption { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .4rem .8rem; background: var(--surface); border-bottom: 1px solid var(--code-border); font-size: .85rem; color: var(--muted); }
.script figcaption a { font-weight: 600; }
.script pre { margin: 0; border: 0; border-radius: 0; }

/* Tags, post navigation */
.entry-footer { margin-top: 2rem; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.tags a { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .85rem; text-decoration: none; }
.post-nav { max-width: var(--measure); margin: 2.5rem auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }
.post-nav span { display: block; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.post-nav .next { text-align: right; grid-column: 2; }

/* The author box (afp548-author-box), in this theme's colours */
.wp-about-author-container { display: flex; gap: 1.25rem; margin-top: 2.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); align-items: flex-start; }
.wp-about-author-container .wp-about-author-pic img { border-radius: 50%; display: block; }
.wp-about-author-container h3 { margin: 0 0 .3rem; font-size: 1.1rem; }
.wp-about-author-container p { margin: .3rem 0; }
.wp-about-author-container .contact-svgs { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; }
.wp-about-author-container .contact-svgs svg { fill: currentColor; width: 20px; height: 20px; }
@media (max-width: 40rem) { .wp-about-author-container { flex-direction: column; align-items: center; text-align: center; } }

/* Comments */
.comments { max-width: var(--measure); margin: 2.5rem auto 0; }
.comment-list { list-style: none; padding: 0; }
.comment-list .children { list-style: none; padding-left: 1.5rem; border-left: 2px solid var(--border); }
.comment-body { padding: 1rem 0; border-bottom: 1px solid var(--border); }
/* Comments and forum posts often hold long unbroken strings (paths, LDIF, URLs): wrap them instead of widening the page */
.comment-content, #bbpress-forums .bbp-reply-content, #bbpress-forums .bbp-topic-content { overflow-wrap: anywhere; }
.comment-author { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.comment-author img { border-radius: 50%; }
.comment-meta, .comment-metadata { font-size: .82rem; color: var(--muted); }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea { width: 100%; font: inherit; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.comment-form input[type="submit"], button.button, .button { font: inherit; padding: .5rem 1rem; border: 0; border-radius: var(--radius); background: var(--steel); color: #fff; cursor: pointer; }

/* All topics */
.topics-page { max-width: var(--wrap); }
.topic-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 2rem; }
.topic-columns h2 { margin-top: 0; }
.topic-list, .topic-list ul { list-style: none; padding: 0; margin: 0; }
.topic-list ul { padding-left: 1.1rem; margin: .2rem 0 .4rem; }
.topic-list li { padding: .2rem 0; }
.topic-list .count { color: var(--muted); font-size: .85rem; }

/* Forums: bbPress's own layout, in this theme's colours and widths */
.entry.forums { max-width: var(--wrap); }
#bbpress-forums { font-size: .95rem; }
#bbpress-forums ul.bbp-forums, #bbpress-forums ul.bbp-topics, #bbpress-forums ul.bbp-replies, #bbpress-forums ul.bbp-search-results, #bbpress-forums ul.bbp-lead-topic { border-color: var(--border); }
#bbpress-forums li.bbp-header, #bbpress-forums li.bbp-footer { background: var(--surface); border-color: var(--border); }
#bbpress-forums li.bbp-body ul.forum, #bbpress-forums li.bbp-body ul.topic { border-top-color: var(--border); }
#bbpress-forums div.odd, #bbpress-forums ul.odd { background-color: var(--bg); }
#bbpress-forums div.even, #bbpress-forums ul.even { background-color: var(--surface); }
#bbpress-forums div.bbp-forum-header, #bbpress-forums div.bbp-topic-header, #bbpress-forums div.bbp-reply-header { background-color: var(--surface); border-top-color: var(--border); }
#bbpress-forums .bbp-forum-info .bbp-forum-content, #bbpress-forums p.bbp-topic-meta, #bbpress-forums .bbp-reply-post-date, #bbpress-forums .bbp-topic-post-date { color: var(--muted); }
#bbpress-forums div.bbp-reply-author img.avatar, #bbpress-forums div.bbp-topic-author img.avatar { border-radius: 50%; }
#bbpress-forums .bbp-breadcrumb { margin-bottom: 1rem; }
#bbpress-forums fieldset.bbp-form { border-color: var(--border); }
#bbpress-forums div.bbp-template-notice, #bbpress-forums div.bbp-template-notice.info, #bbpress-forums div.bbp-template-notice li, div.indicator-hint { background: var(--surface); border-color: var(--border); color: var(--text); }
#bbpress-forums .bbp-pagination-links span.current, #bbpress-forums .bbp-pagination-links .page-numbers.current { background: var(--steel); border-color: var(--steel); color: #fff; }
#bbpress-forums .bbp-pagination-links a, #bbpress-forums .bbp-pagination-links span { border-color: var(--border); }
@media (max-width: 40rem) {
	#bbpress-forums div.bbp-reply-author, #bbpress-forums div.bbp-topic-author { float: none; width: auto; text-align: left; margin: 0 0 .5rem; }
	#bbpress-forums div.bbp-reply-content, #bbpress-forums div.bbp-topic-content { margin-left: 0; padding: 0; }
}

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 2rem 0 2.5rem; font-size: .92rem; }
.site-footer .wrap { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
.site-footer h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .6rem; }
.years ul, .footer-links ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.footer-links ul { flex-direction: column; }
.colophon { color: var(--muted); margin: 1rem 0 0; }
@media (max-width: 40rem) { .site-footer .wrap { grid-template-columns: 1fr; } }

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