/* ==========================================================================
   Brand Nest Digitals — Services section
   Loaded ONLY on the Services landing page and the individual service pages
   (see brandnest_services_assets() in inc/services.php).
   Every selector is prefixed .bnd-service- so nothing leaks into other templates
   or into Elementor content. Uses the theme variables from style.css.
   ========================================================================== */

/* Visually hidden, still read by screen readers */
.bnd-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------------------
   Hero (same look as the other inner-page heroes)
   -------------------------------------------------------------------------- */
.bnd-service-hero {
	padding: 140px 0 70px;
	background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
	text-align: center;
}
.bnd-service-hero h1 {
	color: var(--white);
	font-size: clamp(2rem, 5vw, 3.5rem);
	margin-bottom: 1rem;
}
.bnd-service-hero p {
	color: rgba(255, 255, 255, 0.75);
	font-size: 1.1rem;
	max-width: 720px;
	margin: 0 auto;
}
.bnd-service-hero > .container > :last-child {
	margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Services landing — card grid
   Desktop: 3 columns (last two cards centred). Tablet: 2. Mobile: 1.
   -------------------------------------------------------------------------- */
.bnd-service-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 2rem;
}
.bnd-service-grid__item {
	grid-column: span 2;
	display: flex;
	min-width: 0;
}
.bnd-service-grid__item:nth-child(4) { grid-column: 2 / span 2; }
.bnd-service-grid__item:nth-child(5) { grid-column: 4 / span 2; }

.bnd-service-flip {
	flex: 1 1 auto;
	width: 100%;
	perspective: 1400px;
}
.bnd-service-flip__inner {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	height: 100%;
}

/* Faces */
.bnd-service-flip__face {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	min-height: 340px;
	padding: 2rem;
	border-radius: 14px;
}
.bnd-service-flip__face--front {
	background: var(--white);
	border: 1px solid rgba(15, 23, 42, 0.08);
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
}
.bnd-service-flip__face--back {
	justify-content: center;
	background: var(--primary-dark);
	border: 1px solid var(--primary-dark);
	color: var(--white);
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
}

/* Front content */
.bnd-service-flip__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin-bottom: 1.5rem;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--accent-gold), var(--accent-hover));
	color: var(--white);
}
.bnd-service-flip__icon .bnd-service-icon {
	width: 28px;
	height: 28px;
}
.bnd-service-flip__title {
	margin: 0 0 0.75rem;
	font-size: 1.35rem;
	line-height: 1.25;
}
.bnd-service-flip__intro {
	margin: 0 0 1.5rem;
	color: var(--text-muted);
	font-size: 0.95rem;
	line-height: 1.6;
}

/* Back content */
.bnd-service-flip__kicker {
	margin: 0 0 0.75rem;
	color: var(--accent-gold);
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
}
.bnd-service-flip__summary {
	margin: 0 0 1.5rem;
	color: rgba(255, 255, 255, 0.88);
	font-size: 1rem;
	line-height: 1.7;
}
.bnd-service-flip__link {
	align-self: flex-start;
}

/* Toggle buttons (revealed by JS — they are `hidden` in the markup) */
.bnd-service-flip__toggle[hidden] {
	display: none;
}
.bnd-service-flip__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	align-self: flex-start;
	padding: 0.4rem 0;
	border: 0;
	background: none;
	font-family: 'Inter', sans-serif;
	font-weight: 600;
	cursor: pointer;
}
.bnd-service-flip__toggle--open {
	margin-top: auto;
	border-bottom: 2px solid var(--accent-gold);
	color: var(--primary-dark);
	font-size: 0.9rem;
}
.bnd-service-flip__toggle--open .bnd-service-icon {
	width: 18px;
	height: 18px;
	color: var(--accent-gold);
	transition: transform 0.2s ease;
}
.bnd-service-flip__toggle--open:hover .bnd-service-icon {
	transform: translateX(3px);
}
.bnd-service-flip__toggle--close {
	margin-top: 1rem;
	color: rgba(255, 255, 255, 0.8);
	font-size: 0.85rem;
	text-decoration: underline;
	text-underline-offset: 3px;
}
.bnd-service-flip__toggle--close:hover {
	color: var(--white);
}

/* Visible focus states */
.bnd-service-flip__face--front button:focus-visible,
.bnd-service-flip__face--front a:focus-visible {
	outline: 3px solid var(--primary-dark);
	outline-offset: 3px;
}
.bnd-service-flip__face--back button:focus-visible,
.bnd-service-flip__face--back a:focus-visible {
	outline: 3px solid var(--white);
	outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Flip behaviour — only when JS has enhanced the grid.
   Without JS the cards stay as two stacked blocks, so the link is always usable.
   -------------------------------------------------------------------------- */
.bnd-service-grid--enhanced .bnd-service-flip__inner {
	display: grid;
	gap: 0;
	transform-style: preserve-3d;
	transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.bnd-service-grid--enhanced .bnd-service-flip__face {
	grid-area: 1 / 1;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}
/* Only one face is exposed to keyboard and screen readers at a time:
   the face that is hiding switches to visibility:hidden once the turn ends,
   the face that is appearing becomes available immediately. */
.bnd-service-grid--enhanced .bnd-service-flip__face--front {
	visibility: visible;
	transition: visibility 0s linear 0s;
}
.bnd-service-grid--enhanced .bnd-service-flip__face--back {
	transform: rotateY(180deg);
	visibility: hidden;
	transition: visibility 0s linear 0.6s;
}
.bnd-service-grid--enhanced .bnd-service-flip.is-flipped .bnd-service-flip__inner {
	transform: rotateY(180deg);
}
.bnd-service-grid--enhanced .bnd-service-flip.is-flipped .bnd-service-flip__face--front {
	visibility: hidden;
	transition-delay: 0.6s;
}
.bnd-service-grid--enhanced .bnd-service-flip.is-flipped .bnd-service-flip__face--back {
	visibility: visible;
	transition-delay: 0s;
}

/* Reduced motion: no turning, the faces simply swap */
@media (prefers-reduced-motion: reduce) {
	.bnd-service-grid--enhanced .bnd-service-flip__inner,
	.bnd-service-grid--enhanced .bnd-service-flip__face {
		transition: none !important;
	}
	.bnd-service-grid--enhanced .bnd-service-flip.is-flipped .bnd-service-flip__inner {
		transform: none;
	}
	.bnd-service-grid--enhanced .bnd-service-flip__face--back {
		transform: none;
	}
	.bnd-service-flip__toggle--open .bnd-service-icon {
		transition: none;
	}
	.bnd-service-flip__toggle--open:hover .bnd-service-icon {
		transform: none;
	}
}

/* Grid breakpoints */
@media (max-width: 1023px) {
	.bnd-service-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 1.5rem;
	}
	.bnd-service-grid__item,
	.bnd-service-grid__item:nth-child(4),
	.bnd-service-grid__item:nth-child(5) {
		grid-column: auto;
	}
	.bnd-service-grid__item:nth-child(5) {
		grid-column: 1 / -1;
		justify-self: center;
		width: calc(50% - 0.75rem);
	}
}
@media (max-width: 639px) {
	.bnd-service-grid {
		grid-template-columns: minmax(0, 1fr);
	}
	.bnd-service-grid__item:nth-child(5) {
		grid-column: auto;
		justify-self: stretch;
		width: auto;
	}
	.bnd-service-flip__face {
		min-height: 300px;
		padding: 1.5rem;
	}
}

/* --------------------------------------------------------------------------
   Individual service pages — shared layout
   Content column (Elementor / editor output) + persistent audit sidebar.
   -------------------------------------------------------------------------- */
.bnd-service-page {
	padding: 60px 0 80px;
	/* Distance from the top of the viewport that the sticky sidebar keeps,
	   so it never slides under the fixed site header (~70px when sticky). */
	--bnd-service-sticky-top: 100px;
}
.bnd-service-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: 3rem;
	/* Do NOT set align-items here: the sidebar cell must span the full row
	   so the sticky box inside it has room to travel. */
}
.bnd-service-layout__content,
.bnd-service-layout__sidebar {
	min-width: 0; /* lets wide Elementor / HTML-widget content shrink instead of overflowing */
}
.bnd-service-content {
	min-width: 0;
	max-width: 100%;
	/* Intentionally no typography, list, link or heading rules: Elementor
	   and your own HTML widgets style themselves. */
}

/* Sticky audit box */
.bnd-service-audit {
	position: sticky;
	top: var(--bnd-service-sticky-top, 100px);
	max-height: calc(100vh - var(--bnd-service-sticky-top, 100px) - 1.5rem);
	overflow-y: auto;
	overscroll-behavior: contain;
	box-sizing: border-box;
	padding: 2rem;
	border-radius: 14px;
	background: var(--primary-dark);
	color: var(--white);
	box-shadow: var(--shadow);
}
@supports (height: 100dvh) {
	.bnd-service-audit {
		max-height: calc(100dvh - var(--bnd-service-sticky-top, 100px) - 1.5rem);
	}
}
.bnd-service-audit__title {
	margin: 0 0 1rem;
	color: var(--white);
	font-size: 1.35rem;
	line-height: 1.25;
}
.bnd-service-audit__text {
	margin: 0 0 1.5rem;
	color: rgba(255, 255, 255, 0.8);
	font-size: 0.95rem;
	line-height: 1.7;
}
.bnd-service-audit .bnd-service-audit__button {
	display: block;
	width: 100%;
	box-sizing: border-box;
	text-align: center;
}
.bnd-service-audit a:focus-visible {
	outline: 3px solid var(--white);
	outline-offset: 3px;
}

/* Tablet & mobile: single column, sidebar follows the content in normal flow */
@media (max-width: 1023px) {
	.bnd-service-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 2rem;
	}
	.bnd-service-audit {
		position: static;
		max-height: none;
		overflow: visible;
	}
	.bnd-service-page {
		padding: 40px 0 60px;
	}
}
