/**
 * JZHL — small additions that theme.json cannot express.
 * Loaded on the front end and in the editor.
 */

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

:root {
	color-scheme: dark;
}

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: 6rem; /* Anchor links clear the sticky header. */
}

@media (prefers-reduced-motion: no-preference) {
	html:focus-within {
		scroll-behavior: smooth;
	}
}

/* Better line breaking for headings and paragraphs. */
:where(h1, h2, h3, h4, h5, h6, .wp-block-post-title, .wp-block-site-title) {
	text-wrap: balance;
	overflow-wrap: break-word;
	hyphens: auto;
}

:where(p, li, figcaption, blockquote) {
	text-wrap: pretty;
}

/* Media never overflows its container on small screens. */
:where(img, svg, video, canvas, iframe) {
	max-width: 100%;
	height: auto;
}

::selection {
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent-contrast);
}

/* ---------- Accessibility ---------- */

/* Visible keyboard focus everywhere, invisible for mouse users. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
	border-radius: 2px;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus:not(:focus-visible) {
	outline: none;
}

/* Comfortable touch targets for menus and buttons (WCAG 2.2 target size). */
.jzhl-header .wp-block-navigation .wp-block-navigation-item__content,
.wp-block-navigation__responsive-container-open,
.wp-block-navigation__responsive-container-close,
.wp-block-button__link,
.wp-block-search__button {
	min-height: 44px;
	display: inline-flex;
	align-items: center;
}

.wp-block-navigation__responsive-container-open,
.wp-block-navigation__responsive-container-close {
	min-width: 44px;
	justify-content: center;
}

.skip-link.screen-reader-text:focus {
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	border-radius: 0.375rem;
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* Forced-colors (Windows high contrast) keeps buttons recognisable. */
@media (forced-colors: active) {
	.wp-block-button__link,
	.wp-element-button {
		border: 1px solid ButtonText;
	}
}

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

.jzhl-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background-color: color-mix(in srgb, var(--wp--preset--color--base) 86%, transparent);
	-webkit-backdrop-filter: saturate(160%) blur(12px);
	backdrop-filter: saturate(160%) blur(12px);
	border-bottom: 1px solid color-mix(in srgb, var(--wp--preset--color--line) 70%, transparent);
}

/* Keep the sticky header below the admin bar when logged in. */
.admin-bar .jzhl-header {
	top: var(--wp-admin--admin-bar--height, 0px);
}

@media (max-width: 600px) {
	.admin-bar .jzhl-header {
		top: 0;
	}
}

/* Footer menu: comfortable, but compact, targets (WCAG 2.2 minimum is 24px). */
.jzhl-footer .wp-block-navigation .wp-block-navigation-item__content {
	display: inline-block;
	padding-block: 0.15rem;
}

/* Mobile menu overlay uses theme colors. */
.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--50) var(--wp--preset--spacing--40);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	font-size: var(--wp--preset--font-size--x-large);
	font-family: var(--wp--preset--font-family--heading);
	gap: var(--wp--preset--spacing--30);
}

/* Current page indicator in the menu. */
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content,
.wp-block-navigation .wp-block-navigation-item__content[aria-current="page"] {
	text-decoration: underline;
	text-decoration-color: var(--wp--preset--color--accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.35em;
}

/* ---------- Buttons ---------- */

.wp-block-button__link:active,
.wp-element-button:active {
	transform: translateY(1px);
}

.wp-block-button.is-style-outline > .wp-block-button__link {
	border: 1.5px solid currentColor;
	background: transparent;
	color: var(--wp--preset--color--contrast);
}

.wp-block-button.is-style-outline > .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--accent);
	border-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent-contrast);
}

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

:where(input[type="text"], input[type="email"], input[type="url"], input[type="search"],
	input[type="password"], input[type="tel"], input[type="number"], textarea, select) {
	font: inherit;
	color: var(--wp--preset--color--contrast);
	background-color: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--preset--border-radius--small);
	padding: 0.7em 0.9em;
	max-width: 100%;
}

:where(input, textarea, select):focus-visible {
	border-color: var(--wp--preset--color--accent);
}

.wp-block-search__input {
	border-radius: var(--wp--preset--border-radius--pill);
	padding-inline: 1.1em;
}

/* ---------- Content blocks ---------- */

.wp-block-post-featured-image img,
.wp-block-image img {
	display: block;
}

/* Cards in query loops lift slightly on hover. */
.jzhl-post-card {
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	height: 100%;
}

@media (hover: hover) {
	.jzhl-post-card:hover {
		transform: translateY(-3px);
		box-shadow: var(--wp--preset--shadow--lifted);
	}
}

.jzhl-post-card .wp-block-post-featured-image {
	overflow: hidden;
}

/* Accordion icon */
.wp-block-accordion-heading__toggle {
	font: inherit;
	color: inherit;
}

.wp-block-accordion-heading__toggle-icon {
	color: var(--wp--preset--color--accent);
	font-weight: 400;
}

/* Tables scroll horizontally instead of breaking the layout on phones. */
.wp-block-table {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.wp-block-table table {
	border-collapse: collapse;
	width: 100%;
}

.wp-block-table th,
.wp-block-table td {
	border: 1px solid var(--wp--preset--color--line);
	padding: 0.6em 0.8em;
	text-align: start;
}

.wp-block-table thead {
	border-bottom: 2px solid var(--wp--preset--color--accent);
}

.wp-block-table th {
	font-weight: 600;
	background-color: var(--wp--preset--color--subtle);
}

/* Long words and URLs wrap instead of overflowing. */
.wp-block-post-content {
	overflow-wrap: break-word;
}

/* Comments */
.wp-block-comment-template li {
	margin-block-end: var(--wp--preset--spacing--40);
}

.wp-block-avatar img {
	border-radius: 50%;
}

/* Pagination */
.wp-block-query-pagination-numbers .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.75rem;
	min-height: 2.75rem;
	border-radius: var(--wp--preset--border-radius--pill);
	text-decoration: none;
}

.wp-block-query-pagination-numbers .page-numbers.current {
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* ---------- Page transitions ---------- */

/* Smooth cross-page transitions in browsers that support View Transitions. */
@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}

	.jzhl-header {
		view-transition-name: jzhl-header;
	}
}

/* ---------- Print ---------- */

@media print {
	.jzhl-header,
	.jzhl-footer,
	.wp-block-navigation,
	.wp-block-post-comments-form,
	.wp-block-query-pagination {
		display: none !important;
	}

	body {
		background: #fff !important;
		color: #000 !important;
	}

	.wp-block-post-content a[href^="http"]::after {
		content: " (" attr(href) ")";
		font-size: 0.85em;
	}
}

/* ---------- Section styles ---------- */

/* Muted text and lines adapt to the neon section they sit on. */
.is-style-section-bold {
	--wp--preset--color--muted: color-mix(in srgb, currentColor 78%, transparent);
	--wp--preset--color--line: color-mix(in srgb, currentColor 25%, transparent);
}

/* ---------- Soccer details ---------- */

/* Big headings get a soft floodlight glow. */
:where(h1, h2).has-display-font-size,
:where(h1, h2).has-xx-large-font-size {
	text-shadow: 0 0 32px color-mix(in srgb, var(--wp--preset--color--accent) 30%, transparent);
}

.is-style-section-bold :where(h1, h2) {
	text-shadow: none;
}

/* Scoreboard numbers line up neatly. */
.jzhl-score,
.wp-block-table td,
.jzhl-number {
	font-variant-numeric: tabular-nums;
}

/* Match card: team | VS | team, stacking on phones. */
.jzhl-match .jzhl-vs {
	font-family: var(--wp--preset--font-family--heading);
	color: var(--wp--preset--color--accent);
	text-shadow: 0 0 24px color-mix(in srgb, var(--wp--preset--color--accent) 45%, transparent);
}

/* Squad cards: big shirt numbers. */
.jzhl-player .jzhl-number {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 900;
	line-height: 0.85;
	color: transparent;
	-webkit-text-stroke: 2px var(--wp--preset--color--accent);
}

@media (forced-colors: active) {
	.jzhl-player .jzhl-number {
		color: CanvasText;
		-webkit-text-stroke: 0;
	}
}

/* League and fixtures tables: scoreboard look. */
.wp-block-table.is-style-scoreboard thead th {
	font-family: var(--wp--preset--font-family--heading);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wp--preset--color--accent);
	background-color: var(--wp--preset--color--surface);
}

.wp-block-table.is-style-scoreboard tbody tr:nth-child(odd) {
	background-color: color-mix(in srgb, var(--wp--preset--color--surface) 60%, transparent);
}

.wp-block-table.is-style-scoreboard td,
.wp-block-table.is-style-scoreboard th {
	border-width: 0 0 1px 0;
	white-space: nowrap;
}

/* Tighter tables on phones; they scroll sideways if still too wide. */
@media (max-width: 600px) {
	.wp-block-table th,
	.wp-block-table td {
		padding: 0.55em 0.6em;
	}

	.wp-block-table.is-style-scoreboard {
		font-size: var(--wp--preset--font-size--small);
	}
}

.wp-block-table.is-style-scoreboard tbody tr:has(strong) {
	background-color: var(--wp--preset--color--accent-soft);
	box-shadow: inset 3px 0 0 var(--wp--preset--color--accent);
}

/* Post cards get a neon edge on hover. */
@media (hover: hover) {
	.jzhl-post-card:hover {
		box-shadow: var(--wp--preset--shadow--neon-glow);
	}
}
