/*
Theme Name: Quirenote
Author: Fabio Huwyler
Author URI: https://profiles.wordpress.org/fabiohuwyler/
Description: A calm, earth-toned block theme for writing with asides and notes. Clear Figtree type, sand, clay and moss colors, a pill-shaped navigation and light topographic and dotted background patterns. Posts leave room on the right, so asides can sit in the margin on wide screens and fold into the text on small ones. Built the WordPress way: theme.json, core blocks, section styles and patterns, with five color styles to choose from. Pairs well with the Inkaside notes plugin and works fully without it.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: quirenote
Tags: blog, one-column, wide-blocks, block-patterns, block-styles, full-site-editing, style-variations, translation-ready, editor-style, threaded-comments, custom-colors, custom-menu, featured-images
*/

/* Almost everything lives in theme.json. This file only holds what theme.json can't
   express: the pill navigation, the background patterns and asides in the margin. */

:root {
	--qn-margin-room: 16rem;
	--qn-aside-width: 13rem;
	--qn-aside-gap: 2.5rem;
}

a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 3px;
}

::selection {
	background: color-mix(in srgb, var(--wp--preset--color--primary) 25%, transparent);
}

/* ---------- Header: sticky ---------- */

html {
	scroll-padding-top: 6rem; /* keep anchor targets (footnotes, notes) clear of the header */
}

.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 50;
	background: color-mix(in srgb, var(--wp--preset--color--base) 88%, transparent);
	-webkit-backdrop-filter: blur(12px) saturate(1.2);
	backdrop-filter: blur(12px) saturate(1.2);
}

/* A line fades in under the header once the page scrolls (where browsers support it). */
@supports (animation-timeline: scroll()) {
	.wp-site-blocks > header.wp-block-template-part {
		animation: qn-header-stuck linear both;
		animation-timeline: scroll();
		animation-range: 0 6rem;
	}

	@keyframes qn-header-stuck {
		to {
			box-shadow: 0 1px 0 var(--wp--preset--color--rule);
		}
	}
}

/* On phones the admin bar scrolls away, and a backdrop filter would trap the full-screen
   menu inside the header, so the header gets a plain background there. */
@media (max-width: 599px) {
	.wp-site-blocks > header.wp-block-template-part {
		top: 0;
		background: var(--wp--preset--color--base);
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
	}
}

.wp-site-blocks > header.wp-block-template-part:has(.is-menu-open) {
	-webkit-backdrop-filter: none;
	backdrop-filter: none;
}

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

.qn-header {
	padding-top: var(--wp--preset--spacing--30);
	padding-bottom: var(--wp--preset--spacing--30);
}

.qn-header .wp-block-site-title {
	margin: 0;
	min-width: 0;
}

/* Keep title, menu and any extra controls (like an appearance toggle) on one line. */
.qn-header .is-layout-flex {
	flex-wrap: nowrap;
}

@media (max-width: 599px) {
	.qn-header .is-layout-flex {
		gap: 0.6rem;
	}

	.dark-palette-appearance-toggle__controls {
		padding: 0.2rem;
	}

	.dark-palette-appearance-toggle__button {
		min-width: 1.9rem;
		min-height: 1.9rem;
		padding: 0.3rem 0.4rem;
	}
}

.qn-header .wp-block-site-title a::before {
	content: "";
	display: inline-block;
	width: 0.7em;
	height: 0.7em;
	margin-right: 0.5em;
	border-radius: 50%;
	background:
		radial-gradient(circle, var(--wp--preset--color--base) 0 22%, transparent 23%),
		radial-gradient(circle, var(--wp--preset--color--primary) 0 45%, var(--wp--preset--color--base) 46% 56%, var(--wp--preset--color--primary) 57%);
	vertical-align: -0.05em;
}

/* ---------- Pill navigation (wide screens) ----------
   Applies to every Navigation block in the header, also in headers customised in the
   Site Editor, and to any Navigation block with the "Pill" style. Choose the "Plain"
   style to turn it off for a header menu. */

@media (min-width: 600px) {
	:is(.qn-nav, .is-style-qn-pill, header.wp-block-template-part .wp-block-navigation:not(.is-style-qn-plain)) .wp-block-navigation__container {
		flex-wrap: nowrap;
		white-space: nowrap;
		gap: 0.2rem;
		padding: 0.3rem;
		border: 1px solid var(--wp--preset--color--rule);
		border-radius: 999px;
		background: color-mix(in srgb, var(--wp--preset--color--surface) 55%, var(--wp--preset--color--base));
	}

	:is(.qn-nav, .is-style-qn-pill, header.wp-block-template-part .wp-block-navigation:not(.is-style-qn-plain)) .wp-block-navigation-item__content {
		padding: 0.4rem 0.95rem !important;
		border-radius: 999px;
		text-decoration: none;
	}

	:is(.qn-nav, .is-style-qn-pill, header.wp-block-template-part .wp-block-navigation:not(.is-style-qn-plain)) .wp-block-navigation-item__content:hover {
		background: var(--wp--preset--color--surface);
		color: var(--wp--preset--color--contrast);
	}

	:is(.qn-nav, .is-style-qn-pill, header.wp-block-template-part .wp-block-navigation:not(.is-style-qn-plain)) .current-menu-item > .wp-block-navigation-item__content,
	:is(.qn-nav, .is-style-qn-pill, header.wp-block-template-part .wp-block-navigation:not(.is-style-qn-plain)) .wp-block-navigation-item__content[aria-current="page"] {
		background: var(--wp--preset--color--contrast);
		color: var(--wp--preset--color--base);
	}

	:is(.qn-nav, .is-style-qn-pill, header.wp-block-template-part .wp-block-navigation:not(.is-style-qn-plain)) .wp-block-navigation__submenu-container {
		border: 1px solid var(--wp--preset--color--rule) !important;
		border-radius: 14px;
		padding: 0.3rem;
		background: var(--wp--preset--color--base) !important;
	}
}

/* Mobile menu: full screen, with the topographic pattern. */
.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) {
	--navigation-layout-justification-setting: flex-start;
	--navigation-layout-justify: flex-start;
	--navigation-layout-align: flex-start;
	padding: 1.25rem var(--wp--preset--spacing--40) var(--wp--preset--spacing--50);
	background-image: linear-gradient(color-mix(in srgb, var(--wp--preset--color--base) 82%, transparent), color-mix(in srgb, var(--wp--preset--color--base) 82%, transparent)), url(assets/patterns/topography.svg);
	background-size: cover;
	background-position: center;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	align-items: flex-start;
	padding-top: 3.5rem;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	align-items: flex-start;
	gap: 1rem;
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 600;
	letter-spacing: -0.02em;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	text-decoration: none;
}

.wp-block-navigation__responsive-container.is-menu-open :is(.wp-block-page-list, .wp-block-navigation__container) {
	align-items: flex-start !important;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	align-self: flex-start;
}

/* ---------- Soft backgrounds ----------
   The patterns themselves are section styles in styles/sections (theme.json), so they
   can be changed for the whole site in Styles > Blocks > Group, or swapped for an
   uploaded image. */

/* ---------- Post list patterns ---------- */

.qn-chip a,
.qn-chip {
	text-decoration: none;
}

.wp-block-post-terms.qn-chip a {
	display: inline-block;
	padding: 0.15em 0.75em;
	border: 1px solid var(--wp--preset--color--rule);
	border-radius: 999px;
	background: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--contrast);
}

.wp-block-post-terms.qn-chip .wp-block-post-terms__separator {
	display: none;
}

/* Margin notes: title on the left, excerpt beside it like an aside. */
.qn-posts-margin .wp-block-post-template {
	padding: 0;
	margin: 0;
	border-top: 1px solid var(--wp--preset--color--rule);
}

.qn-posts-margin .wp-block-post {
	padding-block: var(--wp--preset--spacing--40);
	border-bottom: 1px solid var(--wp--preset--color--rule);
}

.qn-margin-row .wp-block-post-title {
	margin: 0;
}

@media (min-width: 48em) {
	.qn-margin-row.is-layout-grid {
		grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
		column-gap: var(--wp--preset--spacing--50);
	}
}

.qn-margin-row .wp-block-post-excerpt.is-style-qn-aside {
	margin: 0.35rem 0 0;
}

.qn-margin-row .wp-block-post-excerpt__excerpt {
	margin: 0;
}

/* Table of contents: title, dotted leader, year. */
.qn-posts-contents .wp-block-post-template {
	padding: 0;
	margin: 0;
}

.qn-posts-contents .wp-block-post {
	margin: 0;
	padding-block: 0.4rem;
}

.qn-contents-row {
	gap: 0;
}

.qn-contents-row .wp-block-post-title {
	order: 0;
	flex: 0 1 auto;
	margin: 0;
	font-weight: 500;
	letter-spacing: -0.01em;
}

.qn-contents-row::after {
	content: "";
	order: 1;
	flex: 1 1 2rem;
	min-width: 2rem;
	height: 0.3em;
	margin: 0 0.6rem 0.3em;
	background: radial-gradient(circle, var(--wp--preset--color--muted) 0.9px, transparent 1.3px) left bottom / 7px 4px repeat-x;
}

/* Everything after the title (date, categories, tags…) goes to the right of the dots,
   in the order the blocks have in the row. */
.qn-contents-row > :not(.wp-block-post-title) {
	order: 2;
	flex: none;
	margin: 0;
}

.qn-contents-row > :not(.wp-block-post-title) + :not(.wp-block-post-title) {
	margin-left: 0.75rem;
}

.qn-contents-row .wp-block-post-terms {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

/* Cards on soft backgrounds. */
.qn-posts-cards .wp-block-post-template {
	padding: 0;
	margin: 0;
}

.qn-card {
	height: 100%;
	box-sizing: border-box;
	padding: var(--wp--preset--spacing--40);
	border-radius: 18px;
	gap: 0.75rem;
}

.qn-card .wp-block-post-title,
.qn-card .wp-block-post-excerpt,
.qn-card .wp-block-post-excerpt__excerpt {
	margin: 0;
}

.qn-card .qn-card__date {
	margin-top: auto;
	padding-top: 0.75rem;
}

/* Featured post and list. */
.qn-featured__card {
	border-radius: 20px;
	padding: var(--wp--preset--spacing--50) !important;
}

.qn-featured__card .wp-block-post-title {
	margin-top: 1rem;
}

.qn-featured__card .wp-block-post-excerpt {
	color: var(--wp--preset--color--muted);
}

.qn-featured__more {
	margin-top: var(--wp--preset--spacing--40);
}

.qn-featured__more .wp-block-post-template {
	padding: 0;
	margin: 0;
}

.qn-featured__more .wp-block-post {
	padding-top: 1rem;
	border-top: 1px solid var(--wp--preset--color--rule);
}

.qn-featured__more .wp-block-post-title {
	margin: 0.3rem 0 0;
}

/* Numbered essays. */
.qn-posts-numbered .wp-block-post-template {
	padding: 0;
	margin: 0;
	counter-reset: qn-essay;
}

.qn-posts-numbered .wp-block-post {
	counter-increment: qn-essay;
	display: grid;
	grid-template-columns: 4.5rem minmax(0, 1fr);
	column-gap: 1rem;
	align-items: baseline;
	margin: 0;
	padding-block: var(--wp--preset--spacing--40);
	border-bottom: 1px solid var(--wp--preset--color--rule);
}

.qn-posts-numbered .wp-block-post::before {
	content: counter(qn-essay, decimal-leading-zero);
	grid-row: 1 / span 2;
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-large);
	color: var(--wp--preset--color--primary);
	line-height: 1;
}

.qn-posts-numbered .wp-block-post > * {
	grid-column: 2;
	margin: 0;
}

.qn-posts-numbered .wp-block-post-excerpt {
	margin-top: 0.4rem;
}

.qn-posts-numbered .wp-block-post-excerpt__excerpt {
	margin: 0;
}

/* ---------- Small details ---------- */

.qn-meta {
	gap: 0.5em;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.qn-meta > * {
	margin: 0;
}

.qn-meta > * + *::before {
	content: "\00b7";
	margin-right: 0.5em;
}

.qn-kicker {
	display: inline-block;
	padding: 0.25em 0.8em;
	border: 1px solid var(--wp--preset--color--rule);
	border-radius: 999px;
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
	background: var(--wp--preset--color--base);
}

.qn-main {
	padding-top: var(--wp--preset--spacing--50);
	padding-bottom: var(--wp--preset--spacing--60);
}

.qn-entry-header {
	margin-bottom: var(--wp--preset--spacing--40);
}

.qn-post-footer,
.qn-comments {
	margin-top: var(--wp--preset--spacing--50);
}

/* ---------- Post list ---------- */

.qn-post-list .wp-block-post-template {
	margin: 0;
	padding: 0;
}

.qn-post-list .wp-block-post {
	margin: 0;
	padding-block: 1.15rem;
	border-bottom: 1px solid var(--wp--preset--color--rule);
}

.qn-post-row {
	gap: 0.25rem 1.5rem;
	align-items: baseline;
}

.qn-post-row .wp-block-post-date {
	flex: 0 0 6.5rem;
	margin: 0;
}

.qn-post-row .wp-block-post-title {
	flex: 1 1 18rem;
	margin: 0;
	font-size: var(--wp--preset--font-size--large);
	letter-spacing: -0.015em;
}

.qn-post-row .wp-block-post-title a:hover {
	color: var(--wp--preset--color--primary);
}

.qn-post-row + .wp-block-post-excerpt {
	margin: 0.3rem 0 0 calc(6.5rem + 1.5rem);
}

.qn-post-row + .wp-block-post-excerpt .wp-block-post-excerpt__excerpt {
	margin: 0;
}

@media (max-width: 40em) {
	.qn-post-row + .wp-block-post-excerpt {
		margin-left: 0;
	}
}

/* ---------- Single posts: room for asides on the right ---------- */

@media (min-width: 72em) {
	.qn-sheet {
		padding-right: calc(var(--wp--style--root--padding-right, 0px) + var(--qn-margin-room)) !important;
	}

	/* Full-width blocks inside a post still reach the right edge of the screen. */
	.qn-sheet .wp-block-post-content > .alignfull {
		margin-right: calc(-1 * (var(--wp--style--root--padding-right, 0px) + var(--qn-margin-room))) !important;
	}
}

/* ---------- Block style: Aside (paragraph, group) ---------- */

.is-style-qn-aside {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.55;
	color: var(--wp--preset--color--muted);
	border-left: 2px solid var(--wp--preset--color--secondary);
	padding-left: 1rem;
}

.is-style-qn-aside > :first-child {
	margin-top: 0;
}

.is-style-qn-aside > :last-child {
	margin-bottom: 0;
}

@media (min-width: 72em) {
	.qn-sheet .is-layout-constrained > .is-style-qn-aside,
	.qn-sheet .is-layout-flow > .is-style-qn-aside {
		float: right;
		clear: right;
		box-sizing: border-box;
		width: var(--qn-aside-width);
		max-width: none;
		margin-top: 0.3rem !important;
		margin-bottom: 1rem;
		margin-left: 0 !important;
		/* Float out past the text column, whatever the width of the post area. */
		margin-right: calc((100% - var(--wp--style--global--content-size)) / 2 - var(--qn-aside-width) - var(--qn-aside-gap)) !important;
	}
}

/* ---------- Forms and comments ---------- */

.wp-block-comment-template li {
	padding-block: 1rem;
	border-bottom: 1px solid var(--wp--preset--color--rule);
}

.wp-block-comment-template .children {
	border-left: 2px solid var(--wp--preset--color--rule);
	padding-left: 1.25rem;
}

.wp-block-post-comments-form input:not([type="submit"]):not([type="checkbox"]),
.wp-block-post-comments-form textarea,
.wp-block-search__input {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	border: 1px solid var(--wp--preset--color--rule);
	border-radius: 10px;
	padding: 0.6em 0.9em;
}

.wp-block-search__input {
	border-radius: 999px;
	padding-inline: 1.1em;
}

.wp-block-search__input::placeholder {
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

.wp-block-search__inside-wrapper {
	gap: 0.5rem;
}

/* ---------- Dark Palette (optional plugin) ---------- */

/* Its Appearance Toggle matches the pill navigation. Dark colours that suit each
   style are suggested to the plugin in theme.json (settings.custom.darkPalette). */
.dark-palette-appearance-toggle__controls {
	padding: 0.3rem;
	border-color: var(--wp--preset--color--rule);
	background: color-mix(in srgb, var(--wp--preset--color--surface) 55%, var(--wp--preset--color--base));
}

.dark-palette-appearance-toggle__button {
	min-width: 2.15rem;
	min-height: 2.15rem;
}

.dark-palette-appearance-toggle__button:hover {
	background: var(--wp--preset--color--surface);
}

.dark-palette-appearance-toggle__button:focus-visible {
	outline-color: var(--wp--preset--color--primary);
}

/* ---------- Inkaside (optional plugin) ---------- */

/* Inkaside reads the theme's accent color automatically. These rules only match the
   plugin's own classes, so nothing changes without it. */
.marginalia-inline-note,
.marginalia-note {
	font-size: 0.94em;
}

/* ---------- Panels used by the patterns ---------- */

.qn-hero,
.qn-panel {
	border-radius: 20px;
	padding: var(--wp--preset--spacing--50) var(--wp--preset--spacing--50) !important;
	margin-bottom: var(--wp--preset--spacing--50);
}

.qn-hero h1 {
	margin-top: 1rem;
}

.qn-lede {
	font-size: var(--wp--preset--font-size--large);
	color: var(--wp--preset--color--muted);
}

.qn-footer {
	margin-top: var(--wp--preset--spacing--50);
	padding-top: var(--wp--preset--spacing--50);
	padding-bottom: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--rule);
	font-size: var(--wp--preset--font-size--small);
}

.qn-footer .wp-block-site-tagline {
	margin: 0;
}

.qn-footer .wp-block-navigation a {
	text-decoration: none;
}

.qn-credit {
	margin-top: var(--wp--preset--spacing--40);
	color: var(--wp--preset--color--muted);
}

.qn-footer .is-vertical,
.qn-footer .wp-block-navigation .wp-block-navigation__container {
	gap: 0.4rem;
}
