/*
Theme Name: Alex Barton
Theme URI: https://alex.barton.de/
Description: Lightweight child theme of Twenty Twenty-Five for alex.barton.de, with automatic dark mode and a compact layout for "Shorts".
Author: Alexander Barton
Template: twentytwentyfive
Version: 1.0.0
Requires at least: 6.7
Requires PHP: 8.1
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: alex-barton
*/

/*
 * Colors follow Alex' AX-Monokai scheme ("Pink + Grün"): pink (#f92672 /
 * #fb6ea1) for links as in the AX-Monokai VS Code theme, green (#a6e22e)
 * as second accent for code, #1e1f1c for header, footer and cards. The
 * scheme itself is dark only; the light palette in theme.json uses its
 * grays and darker variants of the accents for WCAG AA contrast.
 *
 * Dark mode: theme.json defines the light palette. Here the same preset
 * variables are overridden when the visitor's system prefers a dark color
 * scheme, so every block using palette colors switches automatically.
 */
:root {
	color-scheme: light dark;
	--ab-hover: #d0175f;
	--ab-heading: #1e1f1c;
	--ab-focus: #2c64e0;
	--ab-radius: 4px;
}

@media (prefers-color-scheme: dark) {
	/* AX-Monokai, see ~/…/Themes/AX-Monokai/AX-Monokai.conf */
	:root {
		--wp--preset--color--base: #272822;
		--wp--preset--color--contrast: #d3d2cf;
		--wp--preset--color--accent-1: #fb6ea1;
		--wp--preset--color--accent-2: #1e1f1c;
		--wp--preset--color--accent-3: #3e3d32;
		--wp--preset--color--accent-4: #969791;
		--wp--preset--color--accent-5: #a6e22e;
		--wp--preset--color--accent-6: #3e3d32;
		--ab-hover: #f92672;
		--ab-heading: #f5f4f1;
		--ab-focus: #7297ea;
	}

	img:not(.wp-block-site-logo img) {
		filter: brightness(0.92);
	}
}

/* Links: underline only on hover, keep focus visible. */
a {
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

:where(.wp-site-blocks) :focus-visible {
	outline: 2px solid var(--ab-focus);
	outline-offset: 2px;
}

/* Selection: AX-Monokai selection-background / selection-foreground. */
::selection {
	background: #0a5d78;
	color: #f5f4f1;
}

/*
 * Header: sticky with translucent background. On pages starting with a
 * banner it floats transparently over the image (like Hestia did) and gets
 * its background back once the page is scrolled (see assets/header.js).
 */
.ab-site-header {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 100;
}

.ab-header {
	backdrop-filter: saturate(160%) blur(10px);
	-webkit-backdrop-filter: saturate(160%) blur(10px);
	background: color-mix(in srgb, var(--wp--preset--color--accent-2) 90%, transparent);
	border-bottom: 1px solid var(--wp--preset--color--accent-6);
	transition: background-color 0.25s ease, border-color 0.25s ease;
}

body:has(.ab-banner) .ab-site-header {
	position: fixed;
	left: 0;
	right: 0;
}

body:has(.ab-banner) .ab-site-header:not(.is-scrolled) .ab-header {
	background: transparent;
	border-bottom-color: transparent;
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
}

body:has(.ab-banner) .ab-site-header:not(.is-scrolled) :where(
	.wp-block-site-title a,
	.wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation-item__content,
	.wp-block-navigation__responsive-container-open,
	.ab-search .wp-block-search__button
) {
	color: #f5f4f1;
	text-shadow: 0 1px 8px rgba(9, 9, 6, 0.5);
}

/* Banner pages: room for the floating header above the banner text. */
body:has(.ab-banner) .ab-banner {
	padding-top: calc(var(--wp--preset--spacing--60) + 3rem);
}

/* Search: icon only, field expands on click. */
.ab-search .wp-block-search__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	color: var(--wp--preset--color--contrast);
	border: 0;
	padding: 0.25rem;
	margin-left: 0;
}

.ab-search .wp-block-search__button svg {
	display: block;
	vertical-align: middle;
	fill: currentColor;
	width: 1.4rem;
	height: 1.4rem;
}

.ab-search .wp-block-search__input {
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: var(--ab-radius);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	padding: 0.35rem 0.6rem;
}

/* Post list: regular posts as cards. */
.ab-post-list > .wp-block-post {
	padding-block: var(--wp--preset--spacing--40);
	border-bottom: 1px solid var(--wp--preset--color--accent-6);
}

.ab-post-list > .wp-block-post:last-child {
	border-bottom: 0;
}

/*
 * Shorts: untitled posts with format "status" (category "Shorts").
 * They are shown compact, like a toot: small title if any, no image.
 */
.ab-post-list > .wp-block-post.format-status,
.ab-post-list > .wp-block-post.category-shorts {
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	margin-block: var(--wp--preset--spacing--30);
	background: var(--wp--preset--color--accent-2);
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: var(--ab-radius);
}

.ab-post-list > .wp-block-post.format-status .wp-block-post-featured-image,
.ab-post-list > .wp-block-post.category-shorts .wp-block-post-featured-image {
	display: none;
}

/* Shorts may have a title: keep it small, like a first line. */
.ab-post-list > .wp-block-post.format-status .wp-block-post-title,
.ab-post-list > .wp-block-post.category-shorts .wp-block-post-title {
	font-size: var(--wp--preset--font-size--medium) !important;
	margin-bottom: 0.15rem;
}

/* Shorts: the full text replaces the excerpt, so drop its spacing. */
.ab-post-list > .wp-block-post.format-status .ab-short > :first-child {
	margin-top: 0;
}

/* Footer social icons in the muted text color (both themes). */
.wp-block-social-links .wp-social-link {
	color: var(--wp--preset--color--accent-4);
}

.wp-block-social-links .wp-social-link:hover {
	color: var(--ab-hover);
}

/* UI text in the sans family; running text stays serif (Source Serif 4). */
.ab-meta,
.wp-site-blocks > footer,
.wp-block-query-title,
.lwptoc,
figcaption,
.wp-element-caption {
	font-family: var(--wp--preset--font-family--sans);
}

/* Code blocks. */
:where(pre, code, kbd, samp) {
	font-family: var(--wp--preset--font-family--mono);
	/* Same OpenType features as Alex' terminal (kitty), no contextual alternates. */
	font-feature-settings: "calt" 0, "liga" 1, "ss01", "ss02", "ss03", "ss04", "ss05", "ss07", "ss08", "ss09";
	font-variant-ligatures: no-contextual;
}

:where(p, li) code {
	padding: 0.1em 0.35em;
	border-radius: 4px;
	background: var(--wp--preset--color--accent-2);
	font-size: 0.9em;
}

/* Tables (some older pages use them). */
.wp-block-table table {
	border-collapse: collapse;
}

.wp-block-table td,
.wp-block-table th {
	border-color: var(--wp--preset--color--accent-6);
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto !important;
		transition: none !important;
	}
}

/* Banner (cover block) on the front page and on pages. */
.ab-banner {
	margin-block-start: 0;
}

/*
 * Align banner text with the content column below. The selector must beat
 * core's ".has-custom-content-position" rule, which resets width and margin.
 */
.wp-block-cover.has-custom-content-position.ab-banner.ab-banner .wp-block-cover__inner-container {
	width: 100%;
	max-width: var(--wp--style--global--content-size);
	margin-inline: auto;
}

.ab-banner :where(h1, p) {
	color: #f5f4f1;
	text-shadow: 0 1px 12px rgba(9, 9, 6, 0.45);
}

:root :where(a:hover) {
	color: var(--ab-hover);
}

/* Inline code in the second accent color (green), like code blocks. */
:where(p, li, td) code {
	color: var(--wp--preset--color--accent-5);
}

/* Footer on the darker "chrome" surface, like the header. */
.wp-site-blocks > footer {
	background: var(--wp--preset--color--accent-2);
}

.ab-parallax {
	overflow: hidden;
}

/* LuckyWP Table of Contents: follow the theme colors (also in dark mode). */
.lwptoc .lwptoc_i {
	background: var(--wp--preset--color--accent-2) !important;
	color: var(--wp--preset--color--contrast) !important;
	border: 1px solid var(--wp--preset--color--accent-6);
	border-radius: var(--ab-radius);
}

.lwptoc .lwptoc_i a {
	color: var(--wp--preset--color--accent-1) !important;
}

.ab-banner p {
	font-family: var(--wp--preset--font-family--sans);
}

/* Front page: compact list of recent posts. */
.ab-post-list--compact > .wp-block-post {
	padding-block: 1.5rem;
}

.ab-post-list--compact > .wp-block-post + .wp-block-post {
	margin-block-start: 0;
}

.ab-post-list--compact > .wp-block-post > :first-child {
	margin-block-start: 0;
}

.ab-post-list--compact .wp-block-post-excerpt {
	margin-block: 0.5rem 0;
}

.ab-post-list--compact .wp-block-post-excerpt__more-text {
	margin-block: 0.35rem 0;
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--small);
}

.ab-post-list--compact .wp-block-post-excerpt__more-text a {
	text-decoration: none;
	font-weight: 500;
}

.ab-post-list--compact .wp-block-post-excerpt__more-text a:hover {
	text-decoration: underline;
}

.ab-post-list--compact .wp-block-post-excerpt__excerpt {
	margin-block: 0;
}

/* Post titles in lists: heading color, pink only on hover (calmer). */
.wp-block-post-title a:where(:not(.wp-element-button)) {
	color: inherit;
	text-decoration: none;
}

.wp-block-post-title a:where(:not(.wp-element-button)):hover {
	color: var(--ab-hover);
}

/*
 * Footer at the bottom of the window on short pages, scrolling with the
 * content on long ones: the page fills at least the viewport and the footer
 * takes up the remaining space above it.
 */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
	min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px));
}

.wp-site-blocks > footer {
	margin-block-start: auto;
}

.wp-site-blocks > footer > .wp-block-group {
	margin-block-start: 0;
}

.wp-site-blocks > main,
.wp-site-blocks > .wp-block-group {
	margin-block-end: var(--wp--preset--spacing--60);
}

/* Compact footer: one slim line. */
.wp-site-blocks > footer p {
	margin: 0;
}

.wp-site-blocks > footer .wp-block-social-links {
	margin: 0;
}

/*
 * File block (downloads, e.g. on "Vorträge"): core sets 0.8em, use the body
 * size. Older markup lacks "wp-element-button", so style the button here.
 */
.wp-block-file:not(.wp-element-button) {
	font-size: inherit;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
}

.wp-block-file .wp-block-file__button {
	display: inline-block;
	margin: 0;
	padding: 0.3em 0.8em;
	border-radius: var(--ab-radius);
	background: var(--wp--preset--color--accent-1);
	color: var(--wp--preset--color--base);
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	text-decoration: none;
}

.wp-block-file .wp-block-file__button:hover {
	background: var(--ab-hover);
	color: var(--wp--preset--color--base);
}

/*
 * Header on phones (menu collapsed into a button below 600px): site title,
 * menu button and search in one row. Wider screens may wrap the navigation
 * below the title instead of cutting the title.
 */
@media (max-width: 599px) {
	.ab-header > .wp-block-group {
		flex-wrap: nowrap;
		gap: 1rem;
	}

	.ab-header .wp-block-site-title {
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		font-size: var(--wp--preset--font-size--medium);
	}

	.ab-header-tools {
		flex-shrink: 0;
	}
}

/*
 * Long paths and commands in running text and headings must not widen the
 * page on phones: allow breaks anywhere inside inline code.
 */
.wp-site-blocks {
	overflow-wrap: break-word;
}

:where(p, li, td, h1, h2, h3, h4, h5, h6) code {
	overflow-wrap: anywhere;
}

/* Mobile menu overlay: opaque, theme colors, larger tap targets. */
.wp-block-navigation__responsive-container.is-menu-open {
	background-color: var(--wp--preset--color--base) !important;
	color: var(--wp--preset--color--contrast) !important;
	padding: var(--wp--preset--spacing--40);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--large);
	padding-block: 0.35rem;
	text-shadow: none;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
	color: var(--wp--preset--color--contrast);
}

/* Lightbox (assets/lightbox.js). */
.ab-lightbox {
	width: 100vw;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 3rem 3.5rem;
	border: 0;
	background: rgba(9, 9, 6, 0.94);
	color: #f5f4f1;
	box-sizing: border-box;
}

.ab-lightbox[open] {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.ab-lightbox::backdrop {
	background: transparent;
}

.ab-lightbox img {
	max-width: 100%;
	max-height: calc(100dvh - 8rem);
	object-fit: contain;
	cursor: zoom-out;
	filter: none !important;
}

.ab-lightbox__caption {
	margin: 0.75rem 0 0;
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--small);
	text-align: center;
}

.ab-lightbox__caption:empty {
	display: none;
}

.ab-lightbox button {
	position: absolute;
	border: 0;
	background: transparent;
	color: #f5f4f1;
	font: 300 2.5rem/1 var(--wp--preset--font-family--sans);
	padding: 0.5rem 0.75rem;
	cursor: pointer;
}

.ab-lightbox button:hover {
	color: #f92672;
}

.ab-lightbox__close {
	top: 0.5rem;
	right: 0.5rem;
}

.ab-lightbox__prev,
.ab-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.ab-lightbox__prev {
	left: 0.25rem;
}

.ab-lightbox__next {
	right: 0.25rem;
}

.ab-lightbox.is-single .ab-lightbox__prev,
.ab-lightbox.is-single .ab-lightbox__next {
	display: none;
}

.ab-zoomable {
	cursor: zoom-in;
}

/*
 * Galleries, old (WordPress 5.x, ul.blocks-gallery-grid) and current
 * (nested image blocks) alike: one photo per row in full content width,
 * uncropped, caption below. The lightbox handles the large view.
 */
.wp-block-gallery .blocks-gallery-grid,
.wp-block-gallery.has-nested-images {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--40);
	margin: 0;
	padding: 0;
	list-style: none;
}

.wp-block-gallery .blocks-gallery-item,
.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
	width: 100% !important;
	margin: 0 !important;
	flex: none !important;
}

.wp-block-gallery .blocks-gallery-item figure,
.wp-block-gallery.has-nested-images figure.wp-block-image {
	display: flex;
	flex-direction: column;
	height: auto !important;
	margin: 0;
}

.wp-block-gallery .blocks-gallery-item img,
.wp-block-gallery.has-nested-images figure.wp-block-image img {
	width: 100% !important;
	height: auto !important;
	object-fit: contain !important;
	flex: none !important;
	border-radius: var(--ab-radius);
}

/* Gallery captions below the photo, not overlaid on it. */
.wp-block-gallery .blocks-gallery-item figcaption,
.wp-block-gallery.has-nested-images figure.wp-block-image figcaption {
	position: static !important;
	max-height: none !important;
	overflow: visible !important;
	padding: 0.4rem 0 0 !important;
	background: none !important;
	color: var(--wp--preset--color--accent-4) !important;
	text-align: left !important;
	text-shadow: none !important;
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--small) !important;
}

.wp-block-image img {
	border-radius: var(--ab-radius);
}
