/*
 * Site chrome: header, footer, pills, focus and the skip link.
 * Colors are tokens only (tokens.css variables); never a hex value here.
 * Built from site-vision/artboards Main, MainLight and Mobile.
 */

/* ---- In-page links ("Explore the novel", "Enter Mythic Matters", the Tech
   fork, "read all 4 reviews") glide to their section; under reduced motion
   they jump. Guardrail: keep this, and keep site.js's focus hand-off. ---- */
@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}
[id] {
	scroll-margin-top: 16px;
}
/* A section that receives focus from an in-page link needs no ring. */
[tabindex="-1"]:focus {
	outline: none;
}

/* ---- Every link, button and field: 2px focus ring, 2px offset ---- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* ---- Skip link (core adds it to block themes; brand label and look) ---- */
.skip-link.screen-reader-text:focus {
	top: 12px;
	left: 16px;
	z-index: 100000;
	padding: 10px 14px;
	border-radius: var(--wp--preset--border-radius--sm);
	background: var(--text);
	color: var(--bg);
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--body-s);
	font-weight: 600;
	text-decoration: none;
	clip-path: none;
	height: auto;
	width: auto;
}

/* ---- Pills: buttons, the cart, the dark mode toggle ---- */
.as-pill {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 18px;
	border: 1px solid var(--field-border);
	border-radius: var(--wp--preset--border-radius--pill);
	background: transparent;
	color: var(--text);
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--button);
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: border-color 150ms ease, color 150ms ease;
}
.as-pill[hidden] {
	display: none;
}
.as-pill:hover {
	border-color: var(--text);
	color: var(--text);
}
.as-pill--strong {
	border-color: var(--text);
}

.as-cart {
	padding: 0 14px;
}
.as-cart__count {
	box-sizing: border-box;
	min-width: 20px;
	padding: 1px 6px;
	border-radius: var(--wp--preset--border-radius--pill);
	background: var(--button);
	color: var(--on-button);
	font-size: var(--wp--preset--font-size--record-label);
	font-weight: 600;
	text-align: center;
}

.as-copy-email__address {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--text);
	user-select: all;
}

/* ---- Header ---- */
.as-header {
	border-bottom: 1px solid var(--border);
}
.as-header__inner {
	box-sizing: border-box;
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
	padding: 18px 32px;
	gap: 16px;
}
.as-header__actions {
	gap: var(--wp--preset--spacing--6);
}

.as-wordmark {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font-family: var(--wp--preset--font-family--inscription);
	font-size: 20px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--text);
	text-decoration: none;
	white-space: nowrap;
}
.as-wordmark:hover {
	color: var(--text);
}

/* Navigation: Writing / Podcast / Tech */
.as-nav .wp-block-navigation__container {
	gap: var(--wp--preset--spacing--6);
}
.as-nav .wp-block-navigation-item__content {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--text-muted);
	font-size: var(--wp--preset--font-size--button);
	text-decoration: none;
	transition: color 150ms ease;
}
.as-nav .wp-block-navigation-item__content:hover,
.as-nav .wp-block-navigation-item__content[aria-current="page"] {
	color: var(--text);
}
.as-nav .wp-block-navigation-item__content[aria-current="page"] {
	text-decoration: underline;
	text-decoration-color: var(--accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 8px;
}

/* The menu button and the open menu on phones. WordPress folds the menu
   below 600px and hides the button above it; only style the folded state. */
@media (max-width: 599px) {
	.as-nav .wp-block-navigation__responsive-container-open,
	.as-nav .wp-block-navigation__responsive-container-close {
		box-sizing: border-box;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		border: 1px solid var(--field-border);
		border-radius: var(--wp--preset--border-radius--pill);
		color: var(--text);
	}
	.as-nav .wp-block-navigation__responsive-container-close {
		position: static;
		margin-left: auto;
	}
	.as-nav .wp-block-navigation__responsive-container.is-menu-open {
		background: var(--bg);
		color: var(--text);
		padding: 14px 20px;
	}
	.as-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
		font-family: var(--wp--preset--font-family--display);
		font-size: var(--wp--preset--font-size--display-s);
		color: var(--text);
	}
}

/* ---- Footer ---- */
.as-footer {
	border-top: 1px solid var(--border);
	background: var(--bg-deep);
	color: var(--text);
}
.as-footer__inner {
	box-sizing: border-box;
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
	padding: 48px 32px 32px;
}
.as-footer__top {
	gap: 32px;
}
.as-footer__lead {
	flex: 1 1 420px;
	gap: 10px;
}
.as-footer__subscribe {
	flex: 1 1 320px;
	gap: 10px;
	text-align: right;
}
.as-footer h2 {
	margin: 0;
	font-size: var(--wp--preset--font-size--display-s);
	line-height: var(--wp--custom--type--display-s--line-height);
	font-weight: 600;
	color: var(--text);
}
.as-footer p {
	margin: 0;
	font-size: var(--wp--preset--font-size--button);
	line-height: 1.6;
}
.as-footer__actions {
	gap: 10px;
}
.as-footer__bottom {
	gap: 16px;
	margin-top: 32px;
	padding-top: 24px;
	border-top: 1px solid var(--border);
}
.as-footer__bottom p,
.as-footer__links {
	font-size: var(--wp--preset--font-size--body-s);
}
.as-footer__meta {
	gap: 20px;
}
.as-footer__links {
	gap: 0 20px;
}
.as-footer__links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--text);
	text-decoration: none;
}
.as-footer__links a:hover {
	text-decoration: underline;
	text-underline-offset: 4px;
}

/* ---- Phones and small tablets (brand breakpoint: 720px) ---- */
@media (max-width: 720px) {
	.as-header__inner {
		padding: 14px 20px;
	}
	.as-header__actions {
		gap: var(--wp--preset--spacing--3);
	}
	.as-wordmark {
		font-size: 16px;
	}
	.as-footer__inner {
		padding: 40px 20px 28px;
	}
	/* Footer columns stack and left-align. */
	.as-footer__subscribe {
		align-items: flex-start !important;
		text-align: left;
	}
	.as-footer__bottom {
		flex-direction: column;
		align-items: flex-start !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.as-pill,
	.as-nav .wp-block-navigation-item__content {
		transition: none;
	}
}

/* Bands and template parts butt together: no default block gap between them. */
.wp-site-blocks > *,
.wp-site-blocks > main > * {
	margin-block: 0;
}

/* Every button is at least 44px tall (brand book, Accessibility). */
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	box-sizing: border-box;
}

/* The theme paints its own ground. A page that still carries a background from
   Elementor must not show it behind the header or footer. */
.wp-site-blocks {
	background-color: var(--bg);
	color: var(--text);
}

/* Narrow phones: keep the wordmark, menu button and cart on one row. */
@media (max-width: 400px) {
	.as-wordmark {
		font-size: 14px;
		letter-spacing: 0.1em;
	}
	.as-header__actions {
		gap: 8px;
	}
}
/* Folded foldables (about 280px): trim the header so nothing leaves the screen. */
@media (max-width: 320px) {
	.as-header__inner {
		padding-inline: 12px;
		gap: 8px;
	}
	.as-wordmark {
		font-size: 12px;
		letter-spacing: 0.06em;
	}
	.as-header__actions {
		gap: 6px;
	}
}
@media (max-width: 360px) {
	/* The word "Cart" drops out visually; the icon, the count and the
	   "Cart, N items" label stay. */
	.as-cart__word {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
	.as-cart {
		padding: 0 10px;
	}
}

/* ---- The "Send a message" dialog (the only shadow besides covers) ---- */
.as-dialog {
	box-sizing: border-box;
	width: min(640px, calc(100% - 32px));
	max-height: calc(100vh - 32px);
	padding: 0;
	border: 1px solid var(--border);
	border-radius: var(--wp--preset--border-radius--md);
	background: var(--bg);
	color: var(--text);
	box-shadow: 0 24px 60px var(--shadow);
	overflow: auto;
}
.as-dialog::backdrop {
	background: color-mix(in srgb, var(--mm-night-deep) 72%, transparent);
}
.as-dialog__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 24px 24px 8px;
}
.as-dialog__title {
	margin: 0 0 6px;
	font-size: var(--wp--preset--font-size--display-m);
	font-weight: 600;
	line-height: 1.1;
}
.as-dialog__title:focus {
	outline: none;
}
.as-dialog__intro {
	margin: 0;
	font-size: var(--wp--preset--font-size--body-s);
	line-height: 1.55;
	color: var(--text-muted);
}
.as-dialog__close {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 1px solid var(--field-border);
	border-radius: var(--wp--preset--border-radius--pill);
	background: transparent;
	color: var(--text);
	cursor: pointer;
}
.as-dialog__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	min-height: 260px;
	color: var(--text-muted, var(--text));
	font-size: 15px;
}
.as-dialog.is-ready .as-dialog__loading {
	display: none;
}
.as-dialog:not(.is-ready) .as-dialog__frame {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}
.as-spinner {
	width: 20px;
	height: 20px;
	border: 2px solid color-mix(in srgb, var(--text) 25%, transparent);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: as-spin 0.8s linear infinite;
}
@keyframes as-spin {
	to {
		transform: rotate(360deg);
	}
}
@media (prefers-reduced-motion: reduce) {
	/* A still ring: the words beside it ("Loading…") carry the meaning. */
	.as-spinner {
		animation: none;
	}
}

/* ---- Loading feedback (site.js) -------------------------------------------
 * Shown only when the next page is slow: site.js waits 300ms before adding
 * .is-loading, so fast pages show nothing (NN/g: under a second feels like
 * the same moment). A clicked link is marked [data-navigating] at once, and
 * further clicks on it are ignored, so double and triple clicks do nothing.
 * Everything clears when the browser brings the page back with Back.
 */
[data-navigating] {
	cursor: progress;
}

/* Arches and catalog cards: a veil in the card's own ground, a spinner and
   "Opening…" centred in the arch. */
.as-loading-mark {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	border-radius: inherit;
	background: color-mix(in srgb, var(--c-bg, var(--bg)) 78%, transparent);
	color: var(--c-text, var(--text));
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--body-s);
	pointer-events: none;
	animation: as-fade-in 150ms ease both;
}
/* The arch lays its own spans out as blocks; the veil keeps its centred flex. */
.as-collection > .as-loading-mark,
.as-shelf__card > .as-loading-mark {
	display: flex !important;
}
.as-loading-mark .as-spinner {
	display: block;
	border-color: color-mix(in srgb, var(--c-text, var(--text)) 25%, transparent);
	border-top-color: var(--c-mark, var(--accent));
}

/* Pills and buttons: the label goes transparent (so the width never jumps)
   and a spinner sits in the middle, in the pill's own text color. */
.is-loading.as-pill,
.is-loading.wp-block-button__link,
.is-loading.wc-block-components-button,
.is-loading.single_add_to_cart_button,
.wpcf7-form.submitting [type="submit"] {
	position: relative;
	color: transparent !important;
	--as-spin: var(--text);
}
.is-loading.as-pill--fill,
.is-loading.as-pill--buy,
.wp-block-button:not(.is-style-outline) > .is-loading.wp-block-button__link,
.is-loading.single_add_to_cart_button,
.wpcf7-form.submitting [type="submit"] {
	--as-spin: var(--on-button);
}
.is-loading.as-pill > *,
.is-loading.wp-block-button__link > * {
	visibility: hidden;
}
.is-loading.as-pill::after,
.is-loading.wp-block-button__link::after,
.is-loading.wc-block-components-button::after,
.is-loading.single_add_to_cart_button::after,
.wpcf7-form.submitting [type="submit"]::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -11px 0 0 -11px;
	border: 2px solid color-mix(in srgb, var(--as-spin) 30%, transparent);
	border-top-color: var(--as-spin);
	border-radius: 50%;
	animation: as-spin 0.8s linear infinite;
}
.wpcf7-form.submitting [type="submit"] {
	pointer-events: none;
}

/* Text links, menus and rows: a 2px line in the accent across the top. */
.as-progress {
	position: fixed;
	inset: 0 0 auto 0;
	z-index: 100001;
	height: 2px;
	overflow: hidden;
	pointer-events: none;
	animation: as-fade-in 150ms ease both;
}
.as-progress::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 40%;
	background: var(--accent);
	animation: as-progress 1.2s ease-in-out infinite;
}
@keyframes as-progress {
	from { transform: translateX(-100%); }
	to { transform: translateX(250%); }
}
@keyframes as-fade-in {
	from { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.is-loading.as-pill::after,
	.is-loading.wp-block-button__link::after,
	.is-loading.wc-block-components-button::after,
	.is-loading.single_add_to_cart_button::after,
	.wpcf7-form.submitting [type="submit"]::after {
		animation: none;
	}
	.as-progress::before {
		width: 100%;
		animation: none;
	}
}

/* Moving between pages: a 150ms cross-fade where the browser supports it (the
   brand's one motion, a 150ms fade). Browsers without it just change page. */
@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}
	::view-transition-old(root),
	::view-transition-new(root) {
		animation-duration: 150ms;
	}
}
.as-dialog__frame {
	display: block;
	width: 100%;
	height: 460px;
	border: 0;
	background: transparent;
	color-scheme: normal;
}
.as-dialog__foot {
	padding: 0 24px 24px;
}
.as-dialog__foot:empty {
	display: none;
}
body:has(dialog[open]) {
	overflow: hidden;
}

/* Pages that still carry an Elementor body color must not show it on overscroll. */
body {
	background-color: var(--bg) !important;
}

.as-footer__copy {
	margin: 0;
}

/* The call-to-action row exists only on the home and Writing pages (blocks/footer-cta). */
.as-footer__top {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 32px;
}
.as-footer__lead,
.as-footer__subscribe {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.as-footer__lead {
	align-items: flex-start;
}
.as-footer__subscribe {
	align-items: flex-end;
}
.as-footer__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}
/* Slim footer: no call-to-action row, so the bottom row stands alone. */
.as-footer__inner:not(:has(.as-footer__top)) {
	padding-block: 16px;
}
.as-footer__inner:not(:has(.as-footer__top)) .as-footer__bottom {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}
@media (max-width: 720px) {
	.as-footer__subscribe {
		align-items: flex-start;
	}
}

.as-footer__links {
	display: flex;
	flex-wrap: wrap;
	gap: 0 20px;
}

/* One rule for the whole site: single-line text that gets cut off ends in an
   ellipsis, never a hard edge. Wrapping text wraps instead. */
select,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
.as-collection__foot > span:first-child {
	text-overflow: ellipsis;
}
