/*
Theme Name: Libro
Theme URI: https://alessandromatera.com
Author: Alessandro Matera
Author URI: https://alessandromatera.com
Description: A quiet, book-like theme on paper. EB Garamond, small caps, one column, contents with dotted leaders, automatic dark mode. Bilingual with Polylang.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.0
Version: 1.4.3
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: am-libro
*/

/* Book typography ------------------------------------------------------- */

body {
	font-kerning: normal;
	font-variant-numeric: lining-nums proportional-nums;
	text-rendering: optimizeLegibility;
}

::selection {
	background: var(--wp--preset--color--rule);
	color: var(--wp--preset--color--ink);
}

a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
	text-decoration-color: var(--wp--preset--color--rule);
	transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover,
a:focus {
	text-decoration-color: currentColor;
}

:where(a, button, input, textarea, select):focus-visible {
	outline: 1.5px solid var(--wp--preset--color--brick);
	outline-offset: 3px;
}

/* Small caps label, used for the site name, section names and meta lines.
   Numeric variants off, so the digits take the small-cap figures and match
   the letters (proportional-nums would block them). */
.am-smallcaps,
.am-site-title,
.am-label,
.am-meta,
.am-toc-date,
.am-colophon,
.am-menu .am-menu-lang {
	font-variant-caps: all-small-caps;
	font-variant-numeric: normal;
}

/* Header ---------------------------------------------------------------- */

.am-header {
	padding-top: clamp(2.25rem, 7vw, 4rem);
	text-align: center;
}

.am-header > * + * {
	margin-block-start: 0.4rem;
}

.am-site-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--large);
	font-style: normal;
	font-weight: 500;
	letter-spacing: 0.17em;
	line-height: 1.2;
}

.am-site-title a {
	color: inherit;
	text-decoration: none;
}

.am-menu ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.15rem 1.15em;
	margin: 0;
	padding: 0;
	list-style: none;
	font-style: italic;
}

.am-menu a {
	color: var(--wp--preset--color--pencil);
	text-decoration: none;
}

.am-menu a:hover,
.am-menu a:focus {
	color: var(--wp--preset--color--brick);
}

.am-menu a[aria-current] {
	color: var(--wp--preset--color--ink);
}

.am-menu .am-menu-lang a {
	font-style: normal;
	letter-spacing: 0.08em;
}

/* Main ------------------------------------------------------------------ */

.am-main {
	padding-top: clamp(2.5rem, 7vw, 4rem);
}

/* Front page intro: the content of the page set as front page. */
.am-intro {
	text-align: center;
}

.am-intro > p:first-of-type {
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.42;
	text-wrap: balance;
}

.am-intro > p + p {
	color: var(--wp--preset--color--pencil);
	font-style: italic;
	text-wrap: balance;
}

/* Portrait: an image block with the class am-portrait, first in the intro.
   On phones it sits on top, centred; on wider screens it moves to the left
   of the text. */
.am-intro > .am-portrait {
	width: 190px;
	margin: 0 auto 1.75rem;
}

.am-portrait img {
	display: block;
	width: 190px;
	height: 190px;
	border-radius: 50%;
	object-fit: cover;
}

@media (min-width: 40rem) {
	.am-intro:has(> .am-portrait) {
		display: grid;
		grid-template-columns: 190px 1fr;
		gap: 0.9rem 2.25rem;
		align-items: center;
		text-align: left;
	}

	.am-intro:has(> .am-portrait) > .am-portrait {
		grid-row: 1 / span 2;
		margin: 0;
	}

	.am-intro:has(> .am-portrait) > p {
		grid-column: 2;
		max-width: none;
		margin: 0;
		text-wrap: pretty;
	}

	.am-intro:has(> .am-portrait) > p:first-of-type {
		align-self: end;
	}

	.am-intro:has(> .am-portrait) > p + p {
		align-self: start;
	}
}

/* Ornament: a separator block style, three asterisks in brick, as books
   mark a break inside a chapter. */
.wp-block-separator.is-style-ornament {
	width: auto;
	height: auto;
	max-width: none;
	margin-block: 2.25rem;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brick);
	opacity: 1;
	text-align: center;
	line-height: 1;
}

.wp-block-separator.is-style-ornament::before {
	content: "*\2003*\2003*";
}

/* Section labels in small caps. */
.am-label {
	margin-bottom: 1rem;
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--medium);
	font-style: normal;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-align: center;
}

/* Contents: title, dotted leader, date, like the index of a book. ------- */

.am-toc {
	display: grid;
	gap: 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.am-toc > li {
	margin-block: 0;
}

.am-toc .am-toc-item {
	display: flex;
	align-items: baseline;
	gap: 0.5em;
}

.am-toc .am-toc-item::after {
	content: "";
	order: 1;
	flex: 1 1 1.5em;
	min-width: 1.5em;
	border-bottom: 2px dotted color-mix(in srgb, var(--wp--preset--color--pencil) 45%, transparent);
	transform: translateY(-0.3em);
}

.am-toc-title {
	margin: 0;
	min-width: 0;
	font-size: var(--wp--preset--font-size--medium);
	font-style: italic;
	font-weight: 400;
	line-height: 1.35;
}

.am-toc-title a {
	text-decoration: none;
}

.am-toc-date {
	order: 2;
	flex: none;
	color: var(--wp--preset--color--pencil);
	letter-spacing: 0.05em;
	white-space: nowrap;
}

/* Under each entry: the subtitle and the reading time, or for a project the
   first sentence of its description. */
.am-toc .am-subtitle {
	max-width: none;
	margin: 0.15rem 0 0;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
	text-align: left;
	text-wrap: pretty;
}

.am-subtitle-time {
	font-variant-caps: all-small-caps;
	font-variant-numeric: normal;
	letter-spacing: 0.08em;
}

/* Projects on the front page: same contents list, the site in place of the date. */
.am-projects {
	margin-top: 3rem;
}

.am-toc-site {
	order: 2;
	flex: none;
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--small);
	font-style: italic;
	white-space: nowrap;
}

.am-more {
	margin: 1.25rem 0 0;
	text-align: center;
	font-style: italic;
}

.am-more a {
	color: var(--wp--preset--color--pencil);
	text-decoration: none;
}

.am-more a::after {
	content: " →";
}

.am-more a:hover,
.am-more a:focus {
	color: var(--wp--preset--color--brick);
}

.wp-block-query-pagination {
	justify-content: center;
	margin-top: 1.75rem;
	font-style: italic;
}

/* Article --------------------------------------------------------------- */

.am-meta {
	gap: 0 0.6em;
	color: var(--wp--preset--color--pencil);
	letter-spacing: 0.12em;
}

.am-meta > * + *::before {
	content: "·";
	margin-right: 0.6em;
	color: var(--wp--preset--color--pencil);
}

/* On phones the translation link gets a line of its own. */
@media (max-width: 30rem) {
	.am-meta .am-translation {
		flex-basis: 100%;
		text-align: center;
	}

	.am-meta .am-translation::before {
		content: none;
	}
}

.am-meta a {
	color: var(--wp--preset--color--brick);
	text-decoration: none;
}

.am-meta a:hover,
.am-meta a:focus {
	text-decoration: underline;
}

.am-title {
	margin-block: 0.45rem 0;
	text-align: center;
	font-size: var(--wp--preset--font-size--x-large);
	text-wrap: balance;
}

.am-subtitle {
	max-width: 30em;
	margin-inline: auto;
	color: var(--wp--preset--color--pencil);
	text-align: center;
	text-wrap: balance;
}

.am-cover {
	margin-top: 2.25rem;
}

.am-cover img {
	display: block;
	width: 100%;
	height: auto;
}

.am-prose {
	margin-top: 2.25rem;
}

/* Paragraphs are set apart by a gap, not a first-line indent: the short
   one-line paragraphs are pauses and should read as such. */
.am-prose > p + p {
	margin-block-start: 0.85em;
}

/* Opening of an article: a raised initial and the first line in small caps.
   Raised, not dropped, because the first paragraph is often a single line. */
.am-article .am-prose > p:first-child::first-line {
	font-variant-caps: all-small-caps;
	font-variant-numeric: normal;
	letter-spacing: 0.06em;
}

.am-article .am-prose > p:first-child::first-letter {
	color: var(--wp--preset--color--brick);
	font-size: 2.6em;
	font-style: normal;
	line-height: 1;
	letter-spacing: 0;
}

.am-prose > p {
	text-align: justify;
	hyphens: auto;
	-webkit-hyphens: auto;
	hyphenate-limit-chars: 7 3 3;
}

.am-prose :where(h2, h3, h4) {
	margin-block-start: 2.25rem;
}

.am-prose :where(h2) {
	font-size: var(--wp--preset--font-size--large);
}

.am-prose :where(ul, ol) {
	padding-left: 1.4em;
}

.wp-block-quote {
	padding-left: 1.4em;
	border-left: 0;
	color: var(--wp--preset--color--ink);
}

.wp-block-quote cite {
	display: block;
	margin-top: 0.4rem;
	font-size: var(--wp--preset--font-size--small);
	font-variant-caps: all-small-caps;
	letter-spacing: 0.1em;
}

.wp-block-pullquote {
	padding: 1.5rem 0;
	border-block: 1px solid var(--wp--preset--color--rule);
	font-style: italic;
}

.wp-block-code,
.am-prose code {
	font-family: var(--wp--preset--font-family--mono);
	font-variant-numeric: normal;
}

.wp-block-code {
	overflow-x: auto;
	border: 0;
	border-radius: 2px;
}

.am-prose :not(pre) > code {
	padding: 0.1em 0.3em;
	background: var(--wp--preset--color--paper-deep);
	border-radius: 2px;
	font-size: 0.8em;
}

.wp-block-image figcaption,
.wp-element-caption {
	text-align: center;
}

.am-post-nav {
	margin-top: 2.25rem;
	font-style: italic;
}

.am-post-nav a {
	text-decoration: none;
}

/* Share: plain links in small caps, like the meta line. ----------------- */

.am-share {
	margin-top: 2.75rem;
	text-align: center;
}

.am-share-label,
.am-share-links,
.am-share-native {
	font-variant-caps: all-small-caps;
	font-variant-numeric: normal;
}

.am-share-label {
	margin: 0 0 0.4rem;
	color: var(--wp--preset--color--pencil);
	letter-spacing: 0.16em;
}

/* No separators: when the line wraps, a dot would start the next line. */
.am-share-links {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.2em 1.15em;
	margin: 0;
	letter-spacing: 0.12em;
}

.am-share a,
.am-share button {
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brick);
	cursor: pointer;
	font: inherit;
	letter-spacing: inherit;
	text-decoration: none;
}

.am-share a:hover,
.am-share a:focus,
.am-share button:hover,
.am-share button:focus {
	text-decoration: underline;
}

/* On phones and tablets: the system share sheet takes the place of the label. */
.am-share.has-native .am-share-label {
	display: none;
}

.am-share .am-share-native {
	margin: 0 0 0.7rem;
	padding: 0.3em 1.2em 0.4em;
	border: 1px solid var(--wp--preset--color--rule);
	border-radius: 999px;
	letter-spacing: 0.12em;
}

.am-share .am-share-native[hidden] {
	display: none;
}

.am-share .am-share-native:hover,
.am-share .am-share-native:focus {
	border-color: var(--wp--preset--color--brick);
	text-decoration: none;
}

.am-share-status {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Footer: newsletter and colophon --------------------------------------- */

.am-footer {
	padding-bottom: clamp(2.5rem, 7vw, 4rem);
	text-align: center;
}

.am-newsletter {
	display: grid;
	justify-items: center;
	gap: 0.8rem;
	scroll-margin-top: 2rem;
}

.am-newsletter p {
	margin: 0;
	text-wrap: balance;
}

.am-newsletter form {
	display: flex;
	width: min(100%, 24rem);
	border-bottom: 1px solid var(--wp--preset--color--ink);
}

.am-newsletter input[type="email"] {
	flex: 1;
	min-width: 0;
	padding: 0.45em 0;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--ink);
	font: inherit;
	font-style: italic;
}

.am-newsletter input[type="email"]::placeholder {
	color: var(--wp--preset--color--pencil);
	opacity: 1;
}

.am-newsletter button {
	padding: 0.45em 0 0.45em 0.8em;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brick);
	cursor: pointer;
	font: inherit;
	font-variant-caps: all-small-caps;
	font-weight: 500;
	letter-spacing: 0.12em;
}

.am-newsletter button:hover,
.am-newsletter button:focus {
	color: var(--wp--preset--color--ink);
}

.am-newsletter [hidden] {
	display: none;
}

/* Field for bots only: people never see it. */
.am-newsletter-trap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.am-newsletter-msg {
	max-width: 26rem;
	font-style: italic;
}

.am-newsletter-note {
	max-width: 26rem;
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--small);
}

.am-newsletter-note a {
	color: inherit;
}

.am-newsletter-hint {
	padding: 0.8rem 1rem;
	border: 1px dashed var(--wp--preset--color--rule);
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--small);
	font-style: italic;
}

.am-colophon {
	margin-top: 2.5rem;
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0.12em;
}

/* Comments -------------------------------------------------------------- */

.am-comments {
	margin-top: 2.75rem;
}

.am-comments .wp-block-comment-template {
	margin: 0;
	padding: 0;
	list-style: none;
}

.am-comments .wp-block-comment-template li {
	margin: 0;
}

.am-comments .wp-block-comment-template li + li,
.am-comments .wp-block-comment-template ol {
	margin-top: 1.6rem;
}

.am-comments .wp-block-comment-template ol {
	padding-left: 1.4em;
	border-left: 1px solid var(--wp--preset--color--rule);
	list-style: none;
}

.am-comment-meta {
	gap: 0 0.7em;
	align-items: baseline;
	color: var(--wp--preset--color--pencil);
	font-variant-caps: all-small-caps;
	font-variant-numeric: normal;
	letter-spacing: 0.08em;
}

.am-comment-meta .wp-block-comment-author-name {
	color: var(--wp--preset--color--ink);
	font-weight: 500;
}

.am-comment-meta a {
	color: inherit;
	text-decoration: none;
}

.am-comment .wp-block-comment-content p {
	margin-block: 0.3rem 0;
}

.am-comment-actions {
	gap: 0 1em;
	margin-top: 0.3rem;
	font-size: var(--wp--preset--font-size--small);
	font-style: italic;
}

.am-comment-actions a {
	color: var(--wp--preset--color--brick);
	text-decoration: none;
}

.comment-respond {
	margin-top: 2.75rem;
}

.comment-reply-title {
	margin-bottom: 1rem;
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--medium);
	font-style: normal;
	font-variant-caps: all-small-caps;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-align: center;
}

.comment-reply-title small {
	display: block;
	font-size: var(--wp--preset--font-size--small);
	font-style: italic;
	font-variant-caps: normal;
	letter-spacing: 0;
}

.comment-form {
	display: grid;
	gap: 1rem;
}

.comment-form p {
	margin: 0;
}

.comment-form .comment-notes,
.comment-form .logged-in-as {
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--small);
	font-style: italic;
	text-align: center;
}

.comment-form label {
	display: block;
	color: var(--wp--preset--color--pencil);
	font-size: var(--wp--preset--font-size--small);
	font-style: italic;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
	width: 100%;
	padding: 0.35em 0;
	border: 0;
	border-bottom: 1px solid var(--wp--preset--color--pencil);
	border-radius: 0;
	background: transparent;
	color: var(--wp--preset--color--ink);
	font: inherit;
}

.comment-form textarea {
	height: 9em;
	min-height: 6em;
	padding: 0.6em 0.75em;
	border: 1px solid var(--wp--preset--color--rule);
	resize: vertical;
}

.comment-form .comment-form-cookies-consent {
	display: flex;
	gap: 0.5em;
	align-items: baseline;
}

.comment-form .comment-form-cookies-consent label {
	display: inline;
}

.comment-form .form-submit {
	text-align: center;
}

.wp-element-button,
.wp-block-button__link {
	padding: 0.4em 1.3em 0.5em;
	font-variant-caps: all-small-caps;
	letter-spacing: 0.12em;
}

/* Utilities ----------------------------------------------------------- */

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
	white-space: nowrap;
	word-wrap: normal !important;
}

/* 404 ------------------------------------------------------------------- */

.am-notfound {
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	a {
		transition: none;
	}
}
