/*
 * NWX Case Studies
 *
 * Isolated nwx- namespace so this component can run beside
 * the legacy Case Studies implementation during migration.
 */

.nwx-case-studies {
	--nwx-case-bg: var(--nw-bg-blue-soft, #f5f8ff);
	--nwx-case-border: var(--nw-border, #d7e5ff);
	--nwx-case-brand: var(--nw-brand-blue, #2563eb);
	--nwx-case-brand-dark: #1d4ed8;
	--nwx-case-heading: #1e293b;
	--nwx-case-copy: #64748b;
	--nwx-case-focus: #f59e0b;

	--nwx-case-gap: 32px;
	--nwx-case-control-size: 40px;
	--nwx-case-footer-height: 72px;

	position: relative;

	width: 100%;
	max-width: 1240px;
	min-width: 0;

	margin-inline: auto;

	overflow: visible;
}

.nwx-case-studies *,
.nwx-case-studies *::before,
.nwx-case-studies *::after {
	box-sizing: border-box;
}


/* =========================================================
   COMPONENT LAYOUT
   ========================================================= */

.nwx-case-studies__slider {
	position: relative;

	width: 100%;
	min-width: 0;

	/*
	 * Reserve the control rail before Swiper initializes.
	 * This space is used by pagination and autoplay controls.
	 */
	padding: 10px 4px var(--nwx-case-footer-height);

	--swiper-navigation-size: var(--nwx-case-control-size);
}

.nwx-case-studies__track {
	align-items: stretch;
}

.nwx-case-studies__item {
	display: flex;

	height: auto;
	min-width: 0;
}


/* =========================================================
   INITIALIZED SWIPER HEIGHT ALIGNMENT
   ========================================================= */

.nwx-case-studies__slider.swiper-initialized .swiper-wrapper {
	align-items: stretch;
}

.nwx-case-studies__slider.swiper-initialized .swiper-slide {
	display: flex;

	height: auto;
	min-width: 0;
}

.nwx-case-studies__slider.swiper-initialized
	.nwx-case-studies__item {
	display: flex;

	height: auto;
}


/* =========================================================
   PROGRESSIVE ENHANCEMENT

   Before Swiper initializes, use approximately the same
   single-row flex geometry that Swiper will create.

   This prevents all carousel cards forming multiple grid rows
   and then collapsing into a single row after initialization.
   ========================================================= */

.nwx-case-studies__slider[data-nwx-carousel="true"]:not(.swiper-initialized) {
	overflow: hidden;
}

.nwx-case-studies__slider[data-nwx-carousel="true"]:not(.swiper-initialized)
	.nwx-case-studies__track {
	display: flex;
	align-items: stretch;

	gap: var(--nwx-case-gap);

	transform: none !important;
}

.nwx-case-studies__slider[data-nwx-carousel="true"]:not(.swiper-initialized)
	.nwx-case-studies__item {
	flex: 0 0 calc((100% - var(--nwx-case-gap)) / 2);

	width: calc((100% - var(--nwx-case-gap)) / 2) !important;
	height: auto;

	margin: 0 !important;
}


/* =========================================================
   STATIC CASE STUDIES

   1-2 results:
   - no Swiper initialization
   - no arrows
   - no pagination
   - no autoplay
   ========================================================= */

.nwx-case-studies--static .nwx-case-studies__slider {
	padding: 10px 4px;
}

.nwx-case-studies--static .nwx-case-studies__track {
	display: grid;

	grid-template-columns: repeat(2, minmax(0, 1fr));

	gap: var(--nwx-case-gap);
}

.nwx-case-studies--static .nwx-case-studies__item {
	display: flex;

	min-width: 0;
}

.nwx-case-studies--static .nwx-case-card {
	width: 100%;
}

/*
 * Do not stretch a single Case Study across the full
 * 1240px content width.
 */
.nwx-case-studies--static
	.nwx-case-studies__item:only-child {
	width: 100%;
	max-width: 600px;
}


/* =========================================================
   CASE STUDY CARD
   ========================================================= */

.nwx-case-card {
	display: flex;

	flex: 1 1 auto;
	flex-direction: column;

	width: 100%;
	height: 100%;

	overflow: hidden;

	border: 1px solid var(--nwx-case-border);
	border-radius: 12px;

	background: var(--nwx-case-bg);
	background: var(--nw-bg-white);

	box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);

	transition:
		border-color 0.25s ease,
		box-shadow 0.25s ease,
		transform 0.25s ease;
}

.nwx-case-card:hover {
	border-color: #bfd3f5;

	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);

}


/* =========================================================
   CARD IMAGE
   ========================================================= */

.nwx-case-card__image {
	display: block;

	position: relative;

	flex: 0 0 auto;

	aspect-ratio: 16 / 7;

	overflow: hidden;

	line-height: 0;

	background: #e9eff9;
}

.nwx-case-card__image img,
.nwx-case-card__img {
	display: block;

	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;

	object-fit: cover;
}


/* =========================================================
   CARD CONTENT
   ========================================================= */

.nwx-case-card__content {
	display: flex;

	flex: 1 1 auto;
	flex-direction: column;

	min-height: 0;

	padding: 20px 25px;

	border-top: 1px solid var(--nwx-case-border);
}


/* =========================================================
   META / BADGES
   ========================================================= */

.nwx-case-card__meta {
	display: flex;
	flex-wrap: wrap;

	flex: 0 0 auto;

	gap: 10px;

	margin: 0 0 12px;
}

.nwx-case-card__badge {
	display: inline-flex;
	align-items: center;

	max-width: 100%;

	padding: 6px 14px;

	border: 1px solid #dfe7f0;
	border-radius: 999px;

	background: var(--nw-post-meta-bg);

	font-size: 12px;
	font-weight: 600;
	line-height: 1;
}

/*
 * Preserve solution metadata in the HTML while maintaining
 * the current visual design.
 */
.nwx-case-card__badge--solution {
	display: none;
}


/* =========================================================
   CARD TITLE
   ========================================================= */

.nwx-case-card__title {
	display: -webkit-box;

	flex: 0 0 auto;

	margin: 0 0 16px !important;

	overflow: hidden;

	color: var(--nwx-case-heading);

	font-size: 1.125rem;
	font-weight: 500;
	line-height: 1.375;

	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.nwx-case-card__title a {
	color: inherit;

	text-decoration: none;
}


/* =========================================================
   CARD SUMMARY
   ========================================================= */

.nwx-case-card__summary {
	display: -webkit-box;

	flex: 0 0 auto;

	margin: 0;

	overflow: hidden;

	color: var(--nwx-case-copy);

	font-size: 1.05rem;
	line-height: 1.3;

	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}


/* =========================================================
   CARD CTA

   Keeps all CTAs aligned along the card bottom.
   ========================================================= */

.nwx-case-card__link {
	display: inline-flex;

	align-items: center;
	align-self: flex-start;

	flex: 0 0 auto;

	gap: 6px;

	margin-top: auto;
	padding-top: 16px;

	color: var(--nwx-case-brand);

	font-size: 15px;
	font-weight: 600;

	text-decoration: none;

	transition:
		color 0.2s ease,
		gap 0.2s ease;
}

.nwx-case-card__link:hover {
	gap: 10px;

	color: var(--nwx-case-brand-dark);
}


/* =========================================================
   FOCUS
   ========================================================= */

.nwx-case-card__title a:focus-visible,
.nwx-case-card__link:focus-visible,
.nwx-case-studies__prev:focus-visible,
.nwx-case-studies__next:focus-visible,
.nwx-case-studies__autoplay-toggle:focus-visible,
.nwx-case-studies .swiper-pagination-bullet:focus-visible {
	outline: 3px solid var(--nwx-case-focus);
	outline-offset: 3px;
}


/*
 * PREVIOUS / NEXT
 *
 * Centered against the card area while excluding the
 * dedicated footer control rail.
 */

.nwx-case-studies__prev,
.nwx-case-studies__next {
	display: none;

	position: absolute;

	top: calc((100% - var(--nwx-case-footer-height)) / 2);

	z-index: 20;

	width: var(--nwx-case-control-size);
	height: var(--nwx-case-control-size);

	margin-top: calc(var(--nwx-case-control-size) / -2);

	padding: 0;

	border: 1px solid #1f4ea3;
	border-radius: 50%;

	background: #1f4ea3;

	box-shadow: 0 5px 16px rgba(31, 78, 163, 0.22);

	color: #fff;

	cursor: pointer;

	-webkit-appearance: none;
	appearance: none;
}

.nwx-case-studies__slider.swiper-initialized
	.nwx-case-studies__prev,
.nwx-case-studies__slider.swiper-initialized
	.nwx-case-studies__next {
	display: flex;

	align-items: center;
	justify-content: center;
}

.nwx-case-studies__prev {
	left: 8px;
}

.nwx-case-studies__next {
	right: 8px;
}

.nwx-case-studies__prev::after,
.nwx-case-studies__next::after {
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
}

.nwx-case-studies__prev::after {
	content: "\276E";
}

.nwx-case-studies__next::after {
	content: "\276F";
}

.nwx-case-studies__prev:hover,
.nwx-case-studies__next:hover {
	border-color: #163d82;

	background: #163d82;

	color: #fff;
}

.nwx-case-studies__prev.swiper-button-disabled,
.nwx-case-studies__next.swiper-button-disabled {
	cursor: default;

	opacity: 0.4;
}


/* =========================================================
   DESKTOP ARROW REVEAL
   ========================================================= */

@media (hover: hover) and (pointer: fine) {

	.nwx-case-studies__slider.swiper-initialized
		.nwx-case-studies__prev,
	.nwx-case-studies__slider.swiper-initialized
		.nwx-case-studies__next {
		opacity: 0;
		visibility: hidden;

		transition:
			opacity 0.2s ease,
			visibility 0.2s ease,
			background-color 0.2s ease,
			border-color 0.2s ease;
	}

	.nwx-case-studies:hover
		.nwx-case-studies__prev,
	.nwx-case-studies:hover
		.nwx-case-studies__next,
	.nwx-case-studies:focus-within
		.nwx-case-studies__prev,
	.nwx-case-studies:focus-within
		.nwx-case-studies__next {
		opacity: 1;
		visibility: visible;
	}

}


/* =========================================================
   PAGINATION

   Uses a symmetric safe area so pagination remains centered
   while leaving room for the autoplay control.
   ========================================================= */

.nwx-case-studies__pagination {
	position: absolute;

	top: auto;
	right: 60px;
	bottom: 10px;
	left: 60px;

	z-index: 10;

	display: flex;
	align-items: center;
	justify-content: center;

	width: auto;
	max-width: none;
	min-width: 0;
	min-height: 36px;

	margin: 0 !important;
	padding: 0;

	text-align: center;

	opacity: 0;
	visibility: hidden;

	transform: none;
}

.nwx-case-studies__slider.swiper-initialized
	.nwx-case-studies__pagination.swiper-pagination-horizontal {
	top: auto;
	right: 60px;
	bottom: 10px;
	left: 60px;

	width: auto;
	max-width: none;
	min-width: 0;

	opacity: 1;
	visibility: visible;

	transform: none;
}


/* =========================================================
   PAGINATION BULLETS

   24px target, 9px visual dot, active page pill.
   ========================================================= */

.nwx-case-studies .swiper-pagination-bullet {
	position: relative;

	width: 24px;
	height: 24px;

	margin: 0 !important;
	padding: 0;

	border: 0;
	border-radius: 0;

	background: transparent;

	opacity: 1;

	cursor: pointer;

	-webkit-appearance: none;
	appearance: none;
}

.nwx-case-studies .swiper-pagination-bullet::before {
	content: "";

	position: absolute;

	top: 50%;
	left: 50%;

	width: 9px;
	height: 9px;

	border-radius: 50%;

	background: #94a3b8;

	transform: translate(-50%, -50%);

	transition:
		width 0.25s ease,
		border-radius 0.25s ease,
		background-color 0.25s ease;
}

.nwx-case-studies
	.swiper-pagination-bullet-active::before {
	width: 25px;

	border-radius: 10px;

	background: linear-gradient(135deg, #1f6fdb 0%, #1558b5 100%);
}


/* =========================================================
   AUTOPLAY CONTROL
   ========================================================= */

.nwx-case-studies__autoplay-toggle {
	position: absolute;

	right: 8px;
	bottom: 10px;

	z-index: 20;

	display: inline-flex;

	align-items: center;
	justify-content: center;

	width: 36px;
	height: 36px;

	padding: 0;

	border: 1px solid #dbeafe;
	border-radius: 50%;

	background: #fff;

	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);

	color: var(--nwx-case-brand);

	cursor: pointer;

	-webkit-appearance: none;
	appearance: none;
}

.nwx-case-studies__autoplay-toggle:hover {
	border-color: var(--nwx-case-brand);

	background: var(--nwx-case-brand);

	color: #fff;
}

.nwx-case-studies__autoplay-icon {
	display: block;

	position: relative;

	width: 12px;
	height: 14px;
}


/* Pause icon while autoplay is running. */

.nwx-case-studies__autoplay-toggle.is-playing
	.nwx-case-studies__autoplay-icon::before,
.nwx-case-studies__autoplay-toggle.is-playing
	.nwx-case-studies__autoplay-icon::after {
	content: "";

	position: absolute;

	top: 1px;
	bottom: 1px;

	width: 3px;

	border-radius: 1px;

	background: currentColor;
}

.nwx-case-studies__autoplay-toggle.is-playing
	.nwx-case-studies__autoplay-icon::before {
	left: 1px;
}

.nwx-case-studies__autoplay-toggle.is-playing
	.nwx-case-studies__autoplay-icon::after {
	right: 1px;
}


/* Play icon while autoplay is stopped. */

.nwx-case-studies__autoplay-toggle:not(.is-playing)
	.nwx-case-studies__autoplay-icon::before {
	content: "";

	position: absolute;

	top: 1px;
	left: 2px;

	width: 0;
	height: 0;

	border-top: 6px solid transparent;
	border-bottom: 6px solid transparent;
	border-left: 9px solid currentColor;
}


/* =========================================================
   VISUALLY HIDDEN
   ========================================================= */

.nwx-visually-hidden {
	position: absolute !important;

	width: 1px !important;
	height: 1px !important;

	margin: -1px !important;
	padding: 0 !important;

	overflow: hidden !important;

	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;

	border: 0 !important;

	white-space: nowrap !important;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {

	/*
	 * Match Swiper's mobile one-card geometry before JS initializes.
	 * Additional cards remain in the horizontal track instead of
	 * creating additional rows.
	 */
	.nwx-case-studies__slider[data-nwx-carousel="true"]:not(.swiper-initialized)
		.nwx-case-studies__item {
		flex-basis: 100%;
		width: 100% !important;
	}

	/*
	 * Static 1–2 Case Studies stack vertically on mobile.
	 * Outer horizontal spacing is controlled by the parent
	 * Gutenberg Section / Group / Row block.
	 */
	.nwx-case-studies--static
		.nwx-case-studies__track {
		grid-template-columns: minmax(0, 1fr);
		gap: 24px;
	}

	/*
	 * Allow a single static card to use the full available
	 * width supplied by its parent block.
	 */
	.nwx-case-studies--static
		.nwx-case-studies__item:only-child {
		max-width: none;
	}

	.nwx-case-card__content {
		padding: 18px;
	}

	.nwx-case-card__title {
		font-size: 1rem;
	}

	.nwx-case-card__summary {
		font-size: 0.8rem;
		line-height: 1.7;
	}

	/*
	 * Touch users swipe or use pagination.
	 * Previous / next controls remain desktop-only.
	 */
	.nwx-case-studies__prev,
	.nwx-case-studies__next {
		display: none !important;
	}

	.nwx-case-studies__autoplay-toggle {
	    right: 12px;
	}
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

	.nwx-case-card,
	.nwx-case-card__link,
	.nwx-case-studies__prev,
	.nwx-case-studies__next,
	.nwx-case-studies__autoplay-toggle,
	.nwx-case-studies .swiper-pagination-bullet::before {
		transition: none !important;
	}

	.nwx-case-card:hover {
		transform: none;
	}

}

/* =========================================================
   CONTROL RAIL
   Final component control geometry.
   ========================================================= */

.nwx-case-studies__slider {
	padding-bottom: var(--nwx-case-footer-height)!important;
}



/* =========================================================
   NWX CASE STUDY CARD
   Modern inset-image treatment
   ========================================================= */

.nwx-case-card {
	padding: 15px;

	border: 1px solid var(--nwx-case-border);
	border-radius: 18px;

	background: #fff;

	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
}


/* =========================================================
   CARD IMAGE
   ========================================================= */

.nwx-case-card__image {
	aspect-ratio: 16 / 7;

	border-radius: 12px;

	background: #e9eff9;
}


/* =========================================================
   CARD CONTENT
   ========================================================= */

.nwx-case-card__content {
	padding: 24px 18px 18px;

	border-top: 0;
}


/* =========================================================
   META / BADGES
   ========================================================= */

.nwx-case-card__meta {
	margin-bottom: 14px;
}

/*
 * Keep the existing NWX industry badge as a defining
 * component element.
 */
.nwx-case-card__badge {
	padding: 6px 14px;

	border: 1px solid #dfe7f0;
	border-radius: 999px;

	background: #edf4fc;
}


/* =========================================================
   TITLE
   ========================================================= */

.nwx-case-card__title {
	margin-bottom: 14px;

	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.375;
}


/* =========================================================
   SUMMARY
   ========================================================= */

.nwx-case-card__summary {
	color: var(--nwx-case-copy);

	font-size: 1rem;
	line-height: 1.5;
}


/* =========================================================
   CTA
   ========================================================= */

.nwx-case-card__link {
	gap: 8px;

	margin-top: auto;
	padding-top: 24px;

	color: var(--nwx-case-brand);
}

/*
 * Compact circular CTA icon.
 */
.nwx-case-card__link::before {
	content: "\276F";

	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: 28px;
	height: 28px;

	flex: 0 0 28px;

	border-radius: 50%;

	background: var(--nwx-case-brand);
	color: #fff;

	font-size: 10px;
	font-weight: 700;
	line-height: 1;

	transition:
		background-color 0.2s ease,
		transform 0.2s ease;
}

.nwx-case-card__link:hover {
	gap: 8px;

	color: var(--nwx-case-brand-dark);
}

.nwx-case-card__link:hover::before {
	background: var(--nwx-case-brand-dark);

	transform: translateX(2px);
}

.nwx-case-card__link:focus-visible::before {
	outline: 3px solid var(--nwx-case-focus);
	outline-offset: 3px;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {

	.nwx-case-card {
		padding: 8px;

		border-radius: 16px;
	}

	.nwx-case-card__image {
		border-radius: 10px;
	}

	.nwx-case-card__content {
		padding: 20px 12px 14px;
	}

	.nwx-case-card__title {
		margin-bottom: 12px;

		font-size: 1rem;
		line-height: 1.4;
	}

	.nwx-case-card__summary {
		font-size: 0.9rem;
		line-height: 1.5;
	}

	.nwx-case-card__link {
		padding-top: 20px;
	}

}