/*
Theme Name: Agent Loop
Theme URI: https://floralwhite-jackal-213047.hostingersite.com/
Description: A quiet, gallery-like block theme for the Minh-Hy blog, built on the Agent Loop design system: a flat white canvas, near-black ink, pill controls, no shadows, and hand-drawn illustrations standing in for missing featured images.
Version: 1.3.0
Requires at least: 6.6
Tested up to: 6.9
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: agent-loop
*/

/* Things theme.json cannot express. Everything else lives in theme.json. */

/* Sticky header: white, no divider or shadow. */
.al-site-header {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 20;
	background: var(--wp--preset--color--bg);
}
.al-header { min-height: var(--wp--custom--header-height); box-sizing: border-box; }

/* Search: 56px pill on the input surface with the one accent circle. */
.wp-block-search .wp-block-search__inside-wrapper {
	position: relative;
	height: var(--wp--custom--control--input);
	padding: 0;
	border: var(--wp--custom--border--thin) solid transparent;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--surface-input);
}
.wp-block-search .wp-block-search__input {
	height: 100%;
	padding: 0 56px 0 var(--wp--preset--spacing--24);
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: none;
	color: var(--wp--preset--color--text-nav);
	font: 400 14px/20px var(--wp--preset--font-family--sans);
}
.wp-block-search .wp-block-search__input::placeholder { color: var(--wp--preset--color--text-muted); }
.wp-block-search .wp-block-search__button {
	position: absolute;
	top: 50%;
	right: 8px;
	transform: translateY(-50%);
	width: var(--wp--custom--control--md);
	height: var(--wp--custom--control--md);
	margin: 0;
	padding: 0;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: var(--wp--custom--radius--circle);
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--bg);
}
.wp-block-search .wp-block-search__button svg { width: 18px; height: 18px; fill: currentColor; }
.al-header .wp-block-search { width: min(100%, 360px); }
@media (min-width: 1200px) { .al-header .wp-block-search { width: 520px; } }

/* Header: below bp-md the nav collapses to WordPress' overlay menu and search moves into a 40px icon link. */
.al-search-icon { display: none; }
/* One accent per view: these pages carry their own search field. */
:is(body.search, body.error404) .al-header :is(.wp-block-search, .al-search-icon) { display: none !important; }
@media (max-width: 767px) {
	.al-header .wp-block-search { display: none; }
	.al-search-icon { display: inline-grid; }
}
.al-search-icon a,
.wp-block-navigation__responsive-container-open {
	display: inline-grid;
	place-items: center;
	width: var(--wp--custom--control--md);
	height: var(--wp--custom--control--md);
	box-sizing: border-box;
	border: var(--wp--custom--border--hairline) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--circle);
	color: var(--wp--preset--color--text);
}
.al-search-icon svg, .wp-block-navigation__responsive-container-open svg { width: 18px; height: 18px; }
.wp-block-navigation .wp-block-navigation-item__content { padding: 5px var(--wp--preset--spacing--16); }
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content { text-decoration: underline; text-underline-offset: 6px; }

/* Ghost pill: category links. */
.al-pills a,
.wp-block-post-navigation-link a,
.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	height: var(--wp--custom--control--sm);
	padding: 0 var(--wp--preset--spacing--16);
	box-sizing: border-box;
	border: var(--wp--custom--border--hairline) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--bg);
	color: var(--wp--preset--color--text);
	font: 700 12px/16px var(--wp--preset--font-family--sans);
	text-decoration: none;
}
.al-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.al-pills .wp-block-post-terms__separator { display: none; }
.wp-block-query-pagination .page-numbers.current { background: var(--wp--preset--color--primary); border-color: var(--wp--preset--color--primary); color: var(--wp--preset--color--bg); }
.wp-block-query-pagination .page-numbers.dots { border-color: transparent; }

/* Post cards: category meta in muted label type. */
.al-card-meta a { color: var(--wp--preset--color--text-muted); text-decoration: none; font-weight: 600; }

/* Images: radius only, no border, no shadow. Illustrations crop to fill their frame. */
.wp-block-post-featured-image img { border-radius: var(--wp--custom--radius--media); }
.wp-block-post-featured-image.is-fallback-art { margin-inline: 0; margin-bottom: 0; } /* drop the browser's default <figure> margins only */
.wp-block-post-featured-image.is-fallback-art img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Inline code. */
:where(p, li) code { padding: 2px 6px; border-radius: 6px; background: var(--wp--preset--color--surface-input); font: 0.875em var(--wp--preset--font-family--mono); }
.wp-block-code { overflow-x: auto; }
/* Bare <pre> pasted from elsewhere (no block class) gets the same look as the code block. */
:where(.al-content) pre:not(.wp-block-code) {
	overflow-x: auto;
	padding: 20px 24px;
	border-radius: var(--wp--custom--radius--media);
	background: var(--wp--preset--color--surface-input);
	font: 14px/22px var(--wp--preset--font-family--mono);
}

/* Long-form body text gets the lede size for the first paragraph. */
.al-content > p:first-child { font-size: var(--wp--preset--font-size--lede); line-height: 32px; }

/* Near-instant transitions, removed for reduced motion. */
.wp-element-button, .wp-block-button__link, .al-pills a, .wp-block-query-pagination a, .wp-block-post-navigation-link a {
	transition: background-color var(--wp--custom--transition), border-color var(--wp--custom--transition);
}
.al-pills a:hover, .wp-block-query-pagination a:hover, .wp-block-post-navigation-link a:hover { border-color: var(--wp--preset--color--text-muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Focus: 2px ink ring, 2px offset, on every control. */
:where(a, button, input, textarea, select, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--text);
	outline-offset: 2px;
}
.wp-block-search .wp-block-search__input:focus-visible { outline-offset: -2px; }

/* Comment form fields: pills for inputs, soft rectangle for the textarea. */
.wp-block-post-comments-form :where(input[type="text"], input[type="email"], input[type="url"]),
.wp-block-post-comments-form textarea {
	box-sizing: border-box;
	width: 100%;
	padding: 14px var(--wp--preset--spacing--24);
	border: var(--wp--custom--border--thin) solid transparent;
	background: var(--wp--preset--color--surface-input);
	color: var(--wp--preset--color--text-nav);
	font: 400 14px/20px var(--wp--preset--font-family--sans);
}
.wp-block-post-comments-form :where(input[type="text"], input[type="email"], input[type="url"]) { border-radius: var(--wp--custom--radius--pill); }
.wp-block-post-comments-form textarea { border-radius: 24px; }

/* Doormat footer: hairline on top, link columns, newsletter form, legal row. */
.al-footer { border-top: var(--wp--custom--border--hairline) solid var(--wp--preset--color--border); }
.al-footer-heading { margin: 0 0 var(--wp--preset--spacing--16); font-size: var(--wp--preset--font-size--label); line-height: 20px; font-weight: 600; color: var(--wp--preset--color--text-muted); }
.al-footer-links { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: var(--wp--preset--font-size--label); line-height: 20px; font-weight: 600; }
.al-footer-links a { color: var(--wp--preset--color--text-nav); text-decoration: none; }
.al-footer-links a:hover { text-decoration: underline; }
.al-legal p { margin: 0; }
.al-legal a { color: var(--wp--preset--color--text-muted); }

.al-subscribe { display: flex; flex-wrap: nowrap; gap: 8px; }
.al-subscribe input[type="email"] {
	flex: 1 1 auto;
	min-width: 0;
	height: var(--wp--custom--control--lg);
	box-sizing: border-box;
	padding: 0 var(--wp--preset--spacing--24);
	border: var(--wp--custom--border--thin) solid transparent;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--surface-input);
	color: var(--wp--preset--color--text-nav);
	font: 400 14px/20px var(--wp--preset--font-family--sans);
}
.al-subscribe input[type="email"]::placeholder { color: var(--wp--preset--color--text-muted); }
.al-subscribe input[type="email"]:focus-visible { outline-offset: -2px; }
.al-subscribe .wp-element-button { flex: none; height: var(--wp--custom--control--lg); padding-top: 0; padding-bottom: 0; cursor: pointer; }
.al-subscribe-status { margin: 12px 0 0; font-size: var(--wp--preset--font-size--label); line-height: 20px; font-weight: 600; }
.al-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/*
 * Spacing rhythm: the closer two things are related, the smaller the gap.
 *   12px  parts of one item (card image, category, title, date)
 *   16–24 a heading and its own content
 *   40px  sibling items in a group (cards across, post header to its image, article to prev/next)
 *   64px  sections; when two sections share a column they also get a hairline (.al-section)
 *   64–128 content to footer, scaled down on phones
 */
.al-section {
	padding-top: var(--wp--preset--spacing--64);
	border-top: var(--wp--custom--border--hairline) solid var(--wp--preset--color--border);
}
.wp-block-comments.al-section:not(:has(> *)) { display: none; } /* comments closed and none posted: no empty divider */
.wp-block-comments .comment-respond { margin-top: var(--wp--preset--spacing--40); }
/* Rows of cards need more air than the gap between columns, so each card reads as one unit. */
.wp-block-post-template.is-layout-grid { row-gap: clamp(40px, 6vw, 64px); }

/* Contact form: same field look as the comment form, labels above fields. */
.al-contact form p { margin: 0 0 var(--wp--preset--spacing--20); }
.al-contact label { display: block; margin-bottom: 8px; font: 600 14px/20px var(--wp--preset--font-family--sans); color: var(--wp--preset--color--text-nav); }
.al-contact :is(input[type="text"], input[type="email"], textarea) {
	box-sizing: border-box;
	width: 100%;
	padding: 14px var(--wp--preset--spacing--24);
	border: var(--wp--custom--border--thin) solid transparent;
	background: var(--wp--preset--color--surface-input);
	color: var(--wp--preset--color--text-nav);
	font: 400 14px/20px var(--wp--preset--font-family--sans);
}
.al-contact :is(input[type="text"], input[type="email"]) { height: var(--wp--custom--control--lg); border-radius: var(--wp--custom--radius--pill); }
.al-contact textarea { border-radius: 24px; resize: vertical; }
.al-contact :is(input, textarea):focus-visible { outline-offset: -2px; }
.al-contact .wp-element-button { height: var(--wp--custom--control--lg); padding-top: 0; padding-bottom: 0; margin-top: 4px; cursor: pointer; }
.al-contact-status { margin: 0 0 var(--wp--preset--spacing--24); font: 600 16px/24px var(--wp--preset--font-family--sans); }
