/**
 * Global styles — CSS reset and base styles.
 *
 * Design tokens (colours, typography, spacing) come from theme.json.
 * Use var(--wp--preset--color--accent) etc. in all rules.
 *
 * @package BuryGolfClub
 * @since   1.0.0
 */

/* ========================================================================
   CSS Reset
   ======================================================================== */

*,
*::before,
*::after {
	box-sizing: border-box;
}

* {
	margin: 0;
}

html {
	scroll-behavior: smooth;
	-moz-text-size-adjust: none;
	-webkit-text-size-adjust: none;
	text-size-adjust: none;
}

html,
body {
	overflow-x: hidden;
}

body {
	min-height: 100vh;
	min-height: 100dvh;
	line-height: 1.7;
	font-weight: 400;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	/* Centurion-style viewport inset — thin border frame effect.
	   Controlled via Customizer → Layout → Body Inset Margin. */
	margin: var(--bgc-body-margin, 8px);
	background-color: var(--wp--preset--color--cream, #F5F0E6);
	color: var(--bgc-text, var(--wp--preset--color--text-primary, #1A1A1A));
	font-family: var(--bgc-font-body, var(--wp--preset--font-family--body, 'Raleway', sans-serif));
	font-size: var(--bgc-font-size-base, 16px);
}

@media (min-width: 30rem) {
	body {
		margin: var(--bgc-body-margin, 8px);
	}
}

img,
picture,
video,
canvas,
svg {
	display: block;
	max-width: 100%;
}

/* Prevent text overlap — global safety net */
h1, h2, h3, h4, h5, h6, p, li, span, a {
	overflow-wrap: break-word;
	word-break: break-word;
}

h1, h2, h3, h4, h5, h6 {
	text-wrap: balance;
}

p {
	text-wrap: pretty;
}

input,
button,
textarea,
select {
	font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
	overflow-wrap: break-word;
}

#root,
#__next {
	isolation: isolate;
}

/* ========================================================================
   Layout — Sticky Footer Pattern
   ======================================================================== */

.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.site-content,
main {
	flex-grow: 1;
}

/* ========================================================================
   Utility Classes
   ======================================================================== */

.bgc-container {
	max-width: var(--bgc-content-max-width, var(--wp--style--global--wide-size, 90rem));
	margin-inline: auto;
	padding-inline: clamp(1rem, 4vw, 5rem);
}

.bgc-text-container {
	max-width: var(--bgc-text-max-width, var(--wp--custom--max-text-width, 44.25rem));
}

/* ========================================================================
   Accessibility
   ======================================================================== */

/* Skip link — first focusable element on every page. */
.skip-link {
	clip: rect(1px, 1px, 1px, 1px);
	position: absolute !important;
	height: 1px;
	width: 1px;
	overflow: hidden;
	word-wrap: normal !important;
}

.skip-link:focus {
	background-color: var(--wp--preset--color--primary, #071428);
	color: var(--wp--preset--color--white, #fff);
	display: block;
	font-family: var(--wp--preset--font-family--body, Inter, sans-serif);
	font-size: 1rem;
	font-weight: 600;
	height: auto;
	left: 5px;
	line-height: normal;
	padding: 15px 23px 14px;
	text-decoration: none;
	top: 5px;
	width: auto;
	z-index: 100001;
	clip: auto !important;
	border-radius: 4px;
	outline: 3px solid var(--wp--preset--color--gold, #C4A265);
	outline-offset: 2px;
}

/* Screen reader only. */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ========================================================================
   Focus Indicators — WCAG 2.1 AA
   ======================================================================== */

/*
 * Visible focus ring for all interactive elements.
 * Gold outline matches brand, high contrast on both light and dark backgrounds.
 */
:focus-visible {
	outline: 3px solid var(--wp--preset--color--gold, #C4A265);
	outline-offset: 2px;
}

/* Remove default outline for mouse users — keep for keyboard. */
:focus:not(:focus-visible) {
	outline: none;
}

/* Buttons and links — ensure focus ring works on dark backgrounds. */
.site-header a:focus-visible,
.site-header button:focus-visible,
.nav-overlay a:focus-visible,
.nav-overlay button:focus-visible,
.site-footer a:focus-visible,
.site-footer button:focus-visible {
	outline-color: var(--wp--preset--color--gold, #C4A265);
	outline-offset: 2px;
}

/* Form inputs — inset focus for cleaner appearance. */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
	outline: 3px solid var(--wp--preset--color--gold, #C4A265);
	outline-offset: 0;
}

/* ========================================================================
   Touch Targets — minimum 44x44px on mobile
   ======================================================================== */

/* Touch targets on mobile — applied as base, reset at desktop. */
a,
button,
input[type="submit"],
input[type="button"],
.bgc-btn,
.comp-filters__pill,
.staff-archive__filter-btn {
	min-height: 44px;
	min-width: 44px;
}

/* Inline links in body text are exempt from size requirement. */
p a,
li a,
dd a,
.news-single__content a {
	min-height: auto;
	min-width: auto;
}

@media (min-width: 48rem) {
	a,
	button,
	input[type="submit"],
	input[type="button"],
	.bgc-btn,
	.comp-filters__pill,
	.staff-archive__filter-btn {
		min-height: 0;
		min-width: 0;
	}
}

/* ========================================================================
   Reduced 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;
	}

	/* Scroll animations — show immediately */
	[data-bgc-animate] {
		opacity: 1 !important;
		transform: none !important;
	}

	/* Card hovers — no lift or shadow change */
	.bgc-card:hover {
		transform: none !important;
		box-shadow: var(--wp--preset--shadow--card) !important;
	}

	/* Image zooms — disable scale on hover */
	.bgc-img-zoom:hover img,
	a:hover .bgc-img-zoom img,
	.bgc-card:hover .bgc-card__image-wrap img {
		transform: none !important;
	}

	/* Menu transitions — instant open/close */
	.nav-overlay,
	.mega-menu,
	.mega-menu__panel,
	.header-nav__dropdown {
		transition: none !important;
	}

	/* Button hovers — no transform or transition */
	.bgc-btn,
	.bgc-btn:hover,
	.bgc-btn:focus {
		transition: none !important;
		transform: none !important;
	}

	/* Back to top — no slide animation */
	.bgc-back-to-top {
		transition: none !important;
	}

	.bgc-back-to-top:hover {
		transform: none !important;
	}

	/* Sticky CTA — no slide animation */
	.bgc-sticky-cta,
	.bgc-sticky-cta--visible {
		transition: none !important;
	}

	/* Cookie banner — no fade animation */
	.bgc-cookie-banner--dismissed {
		animation: none !important;
	}

	/* Animated underlines — disable scaleX transition */
	.bgc-section p a::after,
	.bgc-section li a::after,
	.entry-content p a::after,
	.entry-content li a::after {
		transition: none !important;
	}
}

/* ========================================================================
   Image Zoom on Hover — Global Utility
   ======================================================================== */

.bgc-img-zoom {
	overflow: hidden;
}

.bgc-img-zoom img {
	transition: transform var(--bgc-animation-duration, 0.6s) ease;
}

.bgc-img-zoom:hover img,
a:hover .bgc-img-zoom img {
	transform: scale(var(--bgc-hover-zoom, 1.05));
}

/* ========================================================================
   Scroll Reveal Animations — data-bgc-animate
   ======================================================================== */

[data-bgc-animate] {
	opacity: 0;
	transform: translateY(var(--bgc-animation-distance, 40px));
	transition: opacity var(--bgc-animation-duration, 0.8s) ease-out,
	            transform var(--bgc-animation-duration, 0.8s) ease-out;
}

[data-bgc-animate].is-visible {
	opacity: 1;
	transform: translateY(0);
}

/* No-JS fallback — sections visible immediately when JS unavailable. */
.no-js [data-bgc-animate],
html:not(.js) [data-bgc-animate] {
	opacity: 1;
	transform: none;
	transition: none;
}

/* CSS-only timeout fallback — if JS hasn't loaded, reveal sections via
   animation delay to prevent permanently hidden content. Only fires when
   body does NOT have .js-loaded (i.e., JS failed to execute). */
@keyframes bgc-animate-fallback {
	to { opacity: 1; transform: translateY(0); }
}

body:not(.js-loaded) [data-bgc-animate]:not(.is-visible) {
	animation: bgc-animate-fallback 0.8s ease-out 3s forwards;
}

/* Stagger delays for grid items. */
[data-bgc-animate].stagger-1 { transition-delay: 0.1s; }
[data-bgc-animate].stagger-2 { transition-delay: 0.2s; }
[data-bgc-animate].stagger-3 { transition-delay: 0.3s; }
[data-bgc-animate].stagger-4 { transition-delay: 0.4s; }
[data-bgc-animate].stagger-5 { transition-delay: 0.5s; }
[data-bgc-animate].stagger-6 { transition-delay: 0.6s; }

@media (prefers-reduced-motion: reduce) {
	[data-bgc-animate] {
		opacity: 1;
		transform: none;
		transition: none;
	}
}

/* ========================================================================
   Word-Level Split Text Reveals — data-bgc-split="words"
   ======================================================================== */

.bgc-split-word {
	display: inline-block;
	opacity: 0;
	transform: translateY(30px);
	transition: opacity 0.5s ease, transform 0.5s ease;
}

.bgc-split-word.is-visible {
	opacity: 1;
	transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
	.bgc-split-word {
		opacity: 1;
		transform: none;
		transition: none;
	}
}

/* ========================================================================
   Breadcrumb Navigation
   ======================================================================== */

.breadcrumb {
	background-color: var(--wp--preset--color--cream);
	padding-block: clamp(0.75rem, 1.5vw, 1.25rem);
	border-bottom: 1px solid rgba(11, 29, 58, 0.06);
}

.breadcrumb__list {
	display: flex;
	align-items: center;
	gap: 0;
	list-style: none;
	margin: 0;
	padding: 0;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.8125rem;
	font-weight: 400;
	letter-spacing: 0.02em;
}

.breadcrumb__item {
	display: inline-flex;
	align-items: center;
}

.breadcrumb__link {
	color: var(--wp--preset--color--text-secondary);
	text-decoration: none;
	transition: color 0.2s ease;
}

.breadcrumb__link:hover {
	color: var(--wp--preset--color--gold);
}

.breadcrumb__separator {
	display: inline-block;
	margin-inline: 0.5rem;
	color: var(--wp--preset--color--gold);
	font-size: 1rem;
	line-height: 1;
}

.breadcrumb__item--current span:not(.breadcrumb__separator) {
	color: var(--wp--preset--color--primary);
	font-weight: 500;
}

/* ========================================================================
   Back to Top Button
   ======================================================================== */

.bgc-back-to-top {
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	min-height: 44px;
	min-width: 44px;
	padding: 0;
	background-color: var(--wp--preset--color--primary, #071428);
	color: var(--wp--preset--color--white, #FEFCF8);
	border: 2px solid var(--wp--preset--color--gold, #C4A265);
	border-radius: 50%;
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(1rem);
	transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease,
	            background-color 0.3s ease, border-color 0.3s ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.bgc-back-to-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.bgc-back-to-top:hover {
	background-color: var(--wp--preset--color--gold, #C4A265);
	color: var(--wp--preset--color--primary, #071428);
	border-color: var(--wp--preset--color--gold, #C4A265);
	transform: translateY(-2px);
}

.bgc-back-to-top:focus-visible {
	outline: 3px solid var(--wp--preset--color--gold, #C4A265);
	outline-offset: 2px;
}

.bgc-back-to-top svg {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
	.bgc-back-to-top {
		transition: none;
	}
}

/* ========================================================================
   Animated Underline — Inline Content Links
   ======================================================================== */

/*
 * Inline links in section body text: animated underline on hover.
 * Navy underline on light backgrounds (default),
 * gold underline on dark backgrounds (via .bgc-section--dark).
 * Uses ::after pseudo-element with scaleX for smooth animation.
 */

.bgc-section p a,
.bgc-section li a,
.entry-content p a,
.entry-content li a {
	position: relative;
	display: inline;
	color: var(--wp--preset--color--primary, #071428);
	text-decoration: none;
	transition: color 0.2s ease-out;
}

.bgc-section p a::after,
.bgc-section li a::after,
.entry-content p a::after,
.entry-content li a::after {
	content: '';
	position: absolute;
	bottom: -1px;
	left: 0;
	width: 100%;
	height: 1px;
	background-color: var(--wp--preset--color--primary, #071428);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.3s ease;
}

.bgc-section p a:hover::after,
.bgc-section p a:focus-visible::after,
.bgc-section li a:hover::after,
.bgc-section li a:focus-visible::after,
.entry-content p a:hover::after,
.entry-content p a:focus-visible::after,
.entry-content li a:hover::after,
.entry-content li a:focus-visible::after {
	transform: scaleX(1);
}

/* Dark section variant — gold underline */
.bgc-section--dark p a,
.bgc-section--dark li a {
	color: var(--wp--preset--color--cream, #F5F0E6);
}

.bgc-section--dark p a::after,
.bgc-section--dark li a::after {
	background-color: var(--wp--preset--color--gold, #C4A265);
}

@media (prefers-reduced-motion: reduce) {
	.bgc-section p a::after,
	.bgc-section li a::after,
	.entry-content p a::after,
	.entry-content li a::after {
		transition: none;
	}
}

/* ========================================================================
   Print Stylesheet
   ======================================================================== */

@media print {
	/* Hide non-content elements */
	.site-header,
	.nav-overlay,
	.site-footer,
	.cookie-consent,
	.bgc-cookie-banner,
	.sticky-cta,
	.bgc-sticky-cta,
	.bgc-back-to-top,
	.bgc-facilities__carousel .swiper-button-prev,
	.bgc-facilities__carousel .swiper-button-next,
	.bgc-swiper__prev,
	.bgc-swiper__next,
	.bgc-swiper__pagination {
		display: none !important;
	}

	/* Reset body for print */
	body {
		margin: 0;
		padding: 0;
		color: #000 !important;
		background: #fff !important;
		font-size: 12pt;
		line-height: 1.5;
	}

	/* Remove background colours and images from sections */
	.bgc-section,
	.bgc-section--dark,
	.bgc-section--cream,
	.bgc-section--hero,
	[class*="bgc-section"] {
		background-color: transparent !important;
		background-image: none !important;
		color: #000 !important;
		padding-block: 1rem;
	}

	/* Ensure all text is dark */
	h1, h2, h3, h4, h5, h6,
	p, li, span, a, td, th {
		color: #000 !important;
	}

	/* Show URLs after links */
	a[href]::after {
		content: " (" attr(href) ")";
		font-size: 0.8em;
		color: #555 !important;
	}

	/* Don't show URL for internal/anchor links */
	a[href^="#"]::after,
	a[href^="javascript"]::after {
		content: "";
	}

	/* Ensure scroll-animated elements are visible */
	[data-bgc-animate] {
		opacity: 1 !important;
		transform: none !important;
	}

	/* Page break control */
	h2, h3 {
		page-break-after: avoid;
	}

	img {
		max-width: 100% !important;
		page-break-inside: avoid;
	}

	/* Remove box shadows and borders for clean print */
	.bgc-card {
		box-shadow: none !important;
		border: 1px solid #ccc !important;
	}
}
