/**
 * No Way No: global styles that theme.json can't express.
 * Loaded on the front end and in the editor (add_editor_style).
 * Block-specific styles live in assets/css/blocks/ and load on demand.
 */

/* ---------- Base ---------- */

html {
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

::selection {
	background: var(--wp--preset--color--red);
	color: var(--wp--preset--color--black);
}

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

/* Anchored sections clear the header. */
[id] {
	scroll-margin-top: var(--wp--custom--header--height);
}

.screen-reader-text {
	border: 0;
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

img {
	height: auto;
}

/* Film grain over the whole page: a tiny SVG noise tile, no image request. */
body:not(.editor-styles-wrapper)::after {
	content: "";
	position: fixed;
	inset: 0;
	z-index: 9999;
	pointer-events: none;
	opacity: 0.07;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

.nwn-header {
	position: relative;
	z-index: 20;
	min-height: var(--wp--custom--header--height);
}

/* Front page: the header floats over the hero. */
.nwn-header-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 30;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
}

.admin-bar .nwn-header-overlay {
	top: var(--wp-admin--admin-bar--height, 32px);
}

.nwn-site-name {
	margin: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	letter-spacing: var(--wp--custom--letter-spacing--label);
	text-transform: uppercase;
}

/* ---------- Sections ---------- */

/* Section heading row: index + label on one side, oversized title on the other. */
.nwn-section-head {
	align-items: end !important;
}

.nwn-index {
	color: var(--wp--preset--color--red);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	letter-spacing: var(--wp--custom--letter-spacing--label);
	text-transform: uppercase;
}

/* Huge type that bleeds out of the viewport edge. */
.nwn-bleed {
	margin-inline-start: -0.04em;
	white-space: nowrap;
	overflow: hidden;
}

.nwn-on-black {
	background-color: var(--wp--preset--color--black);
}

/* Live section: the title column stays put while the dates scroll. */
@media (min-width: 782px) {
	.nwn-sticky {
		position: sticky;
		top: calc(var(--wp--custom--header--height) + var(--wp--preset--spacing--40));
	}
}

/* Photos: the outlined title sits behind the top of the mosaic. */
.nwn-photos-title {
	position: relative;
	z-index: 0;
	line-height: 0.8 !important;
}

.nwn-photos-title + .wp-block-gallery {
	position: relative;
	z-index: 1;
	margin-top: calc(var(--wp--preset--font-size--mega) * -0.14) !important;
}

/* Footer joins the last section without a gap. */
.wp-site-blocks > footer {
	margin-block-start: 0;
}

/* ---------- News list ---------- */

.nwn-news {
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.nwn-news__item {
	display: grid;
	gap: 0.5rem var(--wp--preset--spacing--50);
	padding-block: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--border);
}

.nwn-news__item > * {
	margin: 0 !important;
}

.nwn-news__item .wp-block-post-title a:hover {
	color: var(--wp--preset--color--white);
	text-decoration: underline;
	text-decoration-color: var(--wp--preset--color--red);
}

@media (min-width: 782px) {
	.nwn-news__item {
		grid-template-columns: 10rem minmax(0, 1fr);
	}

	.nwn-news__item > :not(.wp-block-post-date) {
		grid-column: 2;
	}

	.nwn-news__item > .wp-block-post-date {
		grid-row: 1 / span 2;
		padding-top: 0.6em;
	}
}

/* ---------- Forms ---------- */

.wp-block-search__input,
.wp-block-post-comments-form input:not([type="submit"]):not([type="checkbox"]),
.wp-block-post-comments-form textarea {
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 0;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--white);
	padding: 0.85rem 1rem;
}

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

/* ---------- Motion ---------- */
/* Hidden states apply only once motion.js is running (html.nwn-ready), and
   never with prefers-reduced-motion, so content is never lost without JS. */

@media (prefers-reduced-motion: no-preference) {
	.nwn-ready .nwn-reveal:not(.is-revealed) {
		opacity: 0;
		transform: translateY(2.5rem);
	}

	.nwn-ready .nwn-reveal {
		transition:
			opacity var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--ease-out),
			transform var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--ease-out);
	}

	/* Text reveal: the line slides up from behind a mask. */
	.nwn-ready .nwn-reveal-text {
		clip-path: inset(-0.2em -0.2em -0.2em -0.2em);
		transition:
			clip-path 0.6s var(--wp--custom--motion--ease-out),
			transform 0.6s var(--wp--custom--motion--ease-out);
	}

	.nwn-ready .nwn-reveal-text:not(.is-revealed) {
		clip-path: inset(0 0 100% 0);
		transform: translateY(0.35em);
	}

	/* Stagger children of a revealed group. */
	.nwn-ready .nwn-stagger > * {
		transition:
			opacity var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--ease-out),
			transform var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--ease-out);
	}

	.nwn-ready .nwn-stagger:not(.is-revealed) > * {
		opacity: 0;
		transform: translateY(2rem);
	}

	.nwn-ready .nwn-stagger > :nth-child(2) { transition-delay: 80ms; }
	.nwn-ready .nwn-stagger > :nth-child(3) { transition-delay: 160ms; }
	.nwn-ready .nwn-stagger > :nth-child(4) { transition-delay: 240ms; }
	.nwn-ready .nwn-stagger > :nth-child(5) { transition-delay: 320ms; }
	.nwn-ready .nwn-stagger > :nth-child(n + 6) { transition-delay: 400ms; }
}

/* The editor shows everything as-is. */
.editor-styles-wrapper .nwn-reveal,
.editor-styles-wrapper .nwn-reveal-text,
.editor-styles-wrapper .nwn-stagger > * {
	opacity: 1 !important;
	transform: none !important;
	clip-path: none !important;
}

/* Long titles never push the page sideways. */
.wp-block-query-title,
.wp-block-post-title,
.wp-block-heading {
	overflow-wrap: break-word;
	hyphens: auto;
}
