/* ==========================================================================
   Reusable components: section heads, cards, pills, carousel, footer
   Loaded on every page.
   ========================================================================== */

/* --- Section head ------------------------------------------------------- */

.tpl-section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--sp-1) var(--sp-4);
	margin-block-end: var(--sp-3);
}

.tpl-section-head__title {
	font-size: var(--fs-h2);
	font-weight: var(--fw-display);
	max-inline-size: 22ch;
	text-wrap: balance;
}

.tpl-section-head--invert .tpl-eyebrow {
	color: var(--c-sage);
}

.tpl-section-head--center {
	justify-content: center;
	text-align: center;
}

.tpl-link-arrow {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-1);
	min-block-size: var(--tap);
	color: var(--c-forest);
	font-size: var(--fs-small);
	font-weight: 500;
	text-decoration: none;
}

.tpl-link-arrow:hover {
	text-decoration: underline;
}

.tpl-empty {
	padding: var(--sp-3);
	border: 1px dashed var(--c-line);
	border-radius: var(--radius-md);
	color: var(--c-muted);
	font-size: var(--fs-small);
}

.tpl-pill {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	padding: 3px var(--sp-2);
	background-color: var(--c-sage-200);
	border-radius: var(--radius-pill);
	color: var(--c-forest);
	font-size: var(--fs-eyebrow);
	font-weight: 500;
	letter-spacing: var(--ls-label);
}

/* --- Shared content grids ------------------------------------------------ */
/* These grids are used by the homepage bands AND by the archive, single and
   page templates, so they live here rather than in the front-page stylesheet.
   Keeping them front-page-only left inner pages with unstyled lists, which
   rendered each card at full width. */

.tpl-services {
	background-color: var(--c-ivory);
}

.tpl-doctors {
	background-color: var(--c-ivory);
}

/* Two cards fit a 375px phone; the track grows from there. */
.tpl-services__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: var(--sp-2);
}

/* Capped track width so a published specialist never stretches into an
   oversized card. */
.tpl-doctors__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 240px));
	justify-content: start;
	gap: var(--sp-2);
}

/* Related services under a single service: one up, then two, then three. */
.tpl-services__grid--related {
	grid-template-columns: minmax(0, 1fr);
	gap: var(--sp-3);
}

/* Before/after cases shown as a set (homepage feature, related lists). */
.tpl-cases-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--sp-3);
}

@media (min-width: 600px) {
	/* On tablet a four-up row leaves cards so narrow that the label panel
	   covers the photograph, so the grid holds at two across. */
	.tpl-services__grid {
		grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
		gap: var(--sp-3);
	}

	.tpl-services__grid--related,
	.tpl-cases-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 900px) {
	.tpl-services__grid {
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
		gap: var(--sp-3);
	}

	.tpl-doctors__grid {
		grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
		gap: var(--sp-3);
	}

	.tpl-services__grid--related,
	.tpl-cases-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* --- Service card ------------------------------------------------------- */

.tpl-card {
	display: flex;
}

/* Reference: design-reference/final-media/services-approved.png - the photo
   fills the card and the label sits in an ivory panel over its lower edge. */
.tpl-card__link {
	position: relative;
	display: block;
	inline-size: 100%;
	aspect-ratio: 3 / 4;
	background-color: var(--c-sage-200);
	border-radius: var(--radius-md);
	overflow: hidden;
	text-decoration: none;
	box-shadow: var(--shadow-sm);
	transition: transform var(--speed) var(--ease),
		box-shadow var(--speed) var(--ease);
}

.tpl-card__link:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-md);
}

.tpl-card__media {
	position: absolute;
	inset: 0;
	display: block;
	background-color: var(--c-sage-200);
	overflow: hidden;
}

.tpl-card__img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

/* Where a service has only a square line illustration, it is shown whole on
   the sage ground rather than cropped - the frame keeps the same ratio as the
   photographic cards so the row stays even, with room for the label panel. */
.tpl-card__media--contain .tpl-card__img {
	object-fit: contain;
	padding: var(--sp-3) var(--sp-3) 38%;
}

.tpl-card__img--placeholder,
.tpl-doctor__img--placeholder,
.tpl-offer__img--placeholder {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	background-color: var(--c-sage-200);
	background-image: url("../img/pattern-repeat-light.svg");
	background-size: 120px auto;
}

/* Label panel over the photograph: the icon badge straddles its top edge,
   the title and arrow sit on the row beneath. */
.tpl-card__body {
	position: absolute;
	inset-block-end: 0;
	inset-inline: 0;
	z-index: 1;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"icon  icon"
		"title go";
	align-items: center;
	gap: var(--sp-1);
	padding: 0 var(--sp-2) var(--sp-2);
	background: linear-gradient(
		to top,
		var(--c-ivory) 0%,
		var(--c-ivory) 58%,
		rgba(245, 241, 232, 0.88) 78%,
		rgba(245, 241, 232, 0) 100%
	);
}

.tpl-card__icon {
	grid-area: icon;
	justify-self: start;
	display: grid;
	place-items: center;
	inline-size: 46px;
	block-size: 46px;
	background-color: var(--c-ivory);
	border-radius: var(--radius-pill);
	box-shadow: 0 2px 10px rgba(23, 61, 53, 0.12);
	color: var(--c-forest);
	margin-block-start: calc(var(--sp-2) * -1);
	margin-block-end: var(--sp-1);
}

/* A brand icon and a dashboard-chosen one share the same 22px box, so the
   badge keeps its size, position and spacing either way. */
.tpl-card__icon .tpl-icon,
.tpl-card__icon .tpl-card__icon-img {
	inline-size: 22px;
	block-size: 22px;
}

.tpl-card__icon-img {
	object-fit: contain;
}

.tpl-card__title {
	grid-area: title;
	color: var(--c-forest);
	font-family: var(--font-display);
	font-size: var(--fs-h3);
	font-weight: var(--fw-display);
	line-height: var(--lh-snug);
	text-wrap: balance;
}

/* Two cards per row on a phone leaves a short card, so the label panel is
   kept compact to stay clear of the photograph above it. */
@media (max-width: 599px) {
	.tpl-card__title {
		font-size: var(--fs-body);
	}

	.tpl-card__icon {
		inline-size: 38px;
		block-size: 38px;
	}

	.tpl-card__icon .tpl-icon,
	.tpl-card__icon .tpl-card__icon-img {
		inline-size: 18px;
		block-size: 18px;
	}

	.tpl-card__go {
		inline-size: 32px;
		block-size: 32px;
	}
}

.tpl-card__go {
	grid-area: go;
	display: grid;
	place-items: center;
	inline-size: 36px;
	block-size: 36px;
	border: 1px solid var(--c-forest);
	border-radius: var(--radius-pill);
	color: var(--c-forest);
	transition: background-color var(--speed) var(--ease),
		color var(--speed) var(--ease);
}

.tpl-card__link:hover .tpl-card__go {
	background-color: var(--c-forest);
	color: var(--c-ivory);
}

.tpl-card__go .tpl-icon {
	inline-size: 15px;
	block-size: 15px;
}

/* --- Offer card --------------------------------------------------------- */

.tpl-offer {
	display: flex;
}

.tpl-offer__link {
	display: grid;
	grid-template-columns: 96px minmax(0, 1fr);
	inline-size: 100%;
	background-color: var(--c-white);
	border: 1px solid var(--c-line);
	border-radius: var(--radius-md);
	overflow: hidden;
	text-decoration: none;
	transition: transform var(--speed) var(--ease),
		box-shadow var(--speed) var(--ease);
}

.tpl-offer__link:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-md);
}

.tpl-offer__media {
	display: block;
	background-color: var(--c-sage-200);
	overflow: hidden;
}

.tpl-offer__img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

.tpl-offer__media--contain .tpl-offer__img {
	object-fit: contain;
	padding: var(--sp-1);
}

.tpl-offer__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	padding: var(--sp-2) var(--sp-2) var(--sp-2);
}

.tpl-offer__title {
	color: var(--c-forest);
	font-family: var(--font-display);
	font-size: var(--fs-h3);
	font-weight: 600;
	line-height: var(--lh-snug);
	text-wrap: balance;
}

.tpl-offer__sub {
	color: var(--c-muted);
	font-size: var(--fs-small);
	line-height: var(--lh-snug);
}

/* Price is the decision point on an offer card, so it is the heaviest thing
   in the block and sits on its own line above a hairline. */
.tpl-offer__price {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0;
	inline-size: 100%;
	margin-block-start: auto;
	padding-block-start: var(--sp-1);
	border-block-start: 1px solid var(--c-line);
}

.tpl-offer__price-label {
	color: var(--c-muted);
	font-size: var(--fs-eyebrow);
	letter-spacing: var(--ls-label);
	text-transform: uppercase;
}

html[lang^="ar"] .tpl-offer__price-label {
	text-transform: none;
	letter-spacing: 0;
}

.tpl-offer__price-value {
	color: var(--c-forest);
	font-family: var(--font-display);
	font-size: var(--fs-price);
	font-weight: 600;
	line-height: 1.25;
}

/* --- Doctor card -------------------------------------------------------- */

.tpl-doctor {
	display: flex;
}

.tpl-doctor__link {
	display: flex;
	flex-direction: column;
	gap: var(--sp-1);
	inline-size: 100%;
	text-decoration: none;
}

.tpl-doctor__media {
	display: block;
	aspect-ratio: 4 / 5;
	background-color: var(--c-sage-200);
	border-radius: var(--radius-md);
	overflow: hidden;
	margin-block-end: var(--sp-1);
}

.tpl-doctor__img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	transition: transform 400ms var(--ease);
}

.tpl-doctor__link:hover .tpl-doctor__img {
	transform: scale(1.03);
}

.tpl-doctor__name {
	color: var(--c-forest);
	font-size: var(--fs-small);
	font-weight: var(--fw-display);
}

.tpl-doctor__role {
	color: var(--c-muted);
	font-size: var(--fs-eyebrow);
}

/* --- Carousel ----------------------------------------------------------- */

.tpl-carousel {
	position: relative;
}

.tpl-carousel__track {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(260px, 1fr);
	gap: var(--sp-2);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-padding-inline-start: 0;
	overscroll-behavior-x: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--c-sage) transparent;
	/* Room for the card lift on hover and for the scrollbar. */
	padding-block: 2px var(--sp-2);
}

.tpl-carousel__track > * {
	scroll-snap-align: start;
}

.tpl-carousel-nav {
	display: flex;
	gap: var(--sp-1);
}

.tpl-carousel-nav[hidden] {
	display: none;
}

.tpl-carousel-nav__btn {
	display: grid;
	place-items: center;
	inline-size: var(--tap);
	block-size: var(--tap);
	background: none;
	border: 1px solid var(--c-line);
	border-radius: var(--radius-pill);
	color: var(--c-forest);
	cursor: pointer;
	transition: background-color var(--speed) var(--ease),
		color var(--speed) var(--ease);
}

.tpl-carousel-nav__btn:hover:not(:disabled) {
	background-color: var(--c-forest);
	color: var(--c-ivory);
}

.tpl-carousel-nav__btn:disabled {
	opacity: 0.4;
	cursor: default;
}

.tpl-carousel-nav__btn .tpl-icon {
	inline-size: 18px;
	block-size: 18px;
}

/* The previous button points against the reading direction. */
.tpl-carousel-nav__glyph--prev {
	display: inline-flex;
	transform: scaleX(-1);
}

.tpl-section-head--invert .tpl-carousel-nav__btn {
	border-color: var(--c-line-dark);
	color: var(--c-ivory);
}

.tpl-section-head--invert .tpl-carousel-nav__btn:hover:not(:disabled) {
	background-color: var(--c-ivory);
	color: var(--c-forest);
}

/* --- Footer ------------------------------------------------------------- */

.tpl-footer {
	background-color: var(--c-forest);
	background-image: url("../img/pattern-repeat-dark.svg");
	background-size: 240px auto;
	color: var(--c-ivory);
}

.tpl-footer__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--sp-4);
	padding-block: var(--sp-5) var(--sp-4);
}

.tpl-footer__brand {
	display: inline-flex;
}

.tpl-footer__brand .tpl-logo {
	inline-size: 300px;
	block-size: auto;
}

.tpl-footer__text {
	margin-block-start: var(--sp-2);
	max-inline-size: 34ch;
	color: var(--c-sage-200);
	font-size: var(--fs-small);
	line-height: 1.7;
}

/* Column headings read as labels, not as headlines: sage, small, tracked -
   the links beneath them are the brighter, larger element. */
.tpl-footer__heading {
	margin-block-end: var(--sp-2);
	padding-block-end: var(--sp-1);
	border-block-end: 1px solid var(--c-line-dark);
	color: var(--c-sage);
	font-family: var(--font-body);
	font-size: var(--fs-eyebrow);
	font-weight: 500;
	letter-spacing: var(--ls-eyebrow);
	text-transform: uppercase;
}

html[lang^="ar"] .tpl-footer__heading {
	text-transform: none;
	letter-spacing: 0;
	font-size: var(--fs-small);
}

.tpl-footer__list,
.tpl-footer__social {
	display: flex;
	flex-direction: column;
	gap: 10px;
	font-size: var(--fs-small);
	line-height: 1.5;
}

.tpl-footer__list a,
.tpl-footer__social-link,
.tpl-footer__list .tpl-nav__link {
	color: var(--c-sage-200);
	text-decoration: none;
	transition: color var(--speed) var(--ease);
}

.tpl-footer__list a:hover,
.tpl-footer__social-link:hover,
.tpl-footer__list .tpl-nav__link:hover {
	color: var(--c-white);
}

/* The shared nav walker is reused here, so neutralise its header styling. */
.tpl-footer__list .tpl-nav__item {
	display: block;
}

.tpl-footer__list .tpl-nav__link {
	min-block-size: 0;
	padding-block: 2px;
	font-size: var(--fs-small);
}

.tpl-footer__list .tpl-nav__toggle,
.tpl-footer__list .tpl-nav__submenu {
	display: none;
}

.tpl-footer__social {
	flex-direction: row;
	flex-wrap: wrap;
	gap: var(--sp-1);
	margin-block-start: var(--sp-3);
}

.tpl-footer__social-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 44px;
	min-block-size: 44px;
	padding: 0;
	border: 1px solid var(--c-line-dark);
	border-radius: var(--radius-pill);
	font-size: var(--fs-eyebrow);
	letter-spacing: var(--ls-label);
	transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}

.tpl-footer__social-link:hover {
	border-color: var(--c-sage);
}

.tpl-footer__address {
	color: var(--c-sage-200);
	font-size: var(--fs-small);
	font-style: normal;
	line-height: 1.7;
	max-inline-size: 30ch;
}

.tpl-footer__muted {
	color: var(--c-sage);
}

.tpl-footer__bar {
	border-block-start: 1px solid var(--c-line-dark);
}

.tpl-footer__bar-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-2);
	padding-block: var(--sp-2);
}

.tpl-footer__copy {
	color: var(--c-sage);
	font-size: var(--fs-small);
}

/* --- Floating WhatsApp -------------------------------------------------- */

.tpl-float-cta {
	position: fixed;
	inset-block-end: var(--sp-2);
	inset-inline-end: var(--sp-2);
	z-index: 40;
	display: grid;
	place-items: center;
	inline-size: 52px;
	block-size: 52px;
	background-color: var(--c-forest);
	border-radius: var(--radius-pill);
	box-shadow: var(--shadow-md);
	color: var(--c-ivory);
}

.tpl-float-cta .tpl-icon {
	inline-size: 24px;
	block-size: 24px;
}

@media (min-width: 1100px) {
	.tpl-float-cta {
		display: none;
	}
}

/* Two columns on tablet; four only once each can hold a readable measure. */
@media (min-width: 600px) {
	.tpl-footer__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--sp-4);
	}

	.tpl-footer__col--brand {
		grid-column: 1 / -1;
	}

	.tpl-offer__link {
		grid-template-columns: 120px minmax(0, 1fr);
	}
}

@media (min-width: 900px) {
	.tpl-footer__grid {
		grid-template-columns: 1.5fr 1fr 1.15fr 1.15fr;
		padding-block: var(--sp-6) var(--sp-5);
	}

	.tpl-footer__col--brand {
		grid-column: auto;
	}

	.tpl-carousel__track {
		gap: var(--sp-3);
	}
}

/* --- Before/after comparison widget ------------------------------------- */
/* Shared by the homepage band, the gallery page and single cases, so it
   lives here rather than in the front-page-only stylesheet. */

.tpl-ba__compare {
	position: relative;
	aspect-ratio: 16 / 10;
	inline-size: 100%;
	/* A full-width portrait panel on a tablet otherwise renders ~860px tall. */
	max-block-size: 72vh;
	border-radius: var(--radius-md);
	overflow: hidden;
	background-color: var(--c-sage-200);
	touch-action: pan-y;
}

.tpl-ba__layer {
	position: absolute;
	inset: 0;
}

.tpl-ba__img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

/* The "before" half is clipped from the reading-start edge, so it sits on the
   left in English and on the right in Arabic - matching both references. */
.tpl-ba__layer--before {
	clip-path: inset(0 calc(100% - var(--tpl-pos)) 0 0);
}

[dir="rtl"] .tpl-ba__layer--before {
	clip-path: inset(0 0 0 calc(100% - var(--tpl-pos)));
}

.tpl-ba__divider {
	position: absolute;
	inset-block: 0;
	inset-inline-start: var(--tpl-pos);
	inline-size: 2px;
	margin-inline-start: -1px;
	background-color: var(--c-white);
	box-shadow: 0 0 0 1px rgba(23, 61, 53, 0.18);
	pointer-events: none;
}

.tpl-ba__divider::after {
	content: "";
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	inline-size: 40px;
	block-size: 40px;
	transform: translate(-50%, -50%);
	background-color: var(--c-white);
	border-radius: var(--radius-pill);
	box-shadow: var(--shadow-md);
}

[dir="rtl"] .tpl-ba__divider::after {
	transform: translate(50%, -50%);
}

.tpl-ba__tag {
	position: absolute;
	inset-block-end: var(--sp-2);
	z-index: 2;
	padding: 4px var(--sp-2);
	background-color: rgba(245, 241, 232, 0.92);
	border-radius: var(--radius-pill);
	color: var(--c-forest);
	font-size: var(--fs-eyebrow);
	font-weight: 500;
	letter-spacing: var(--ls-label);
	pointer-events: none;
}

.tpl-ba__tag--before {
	inset-inline-start: var(--sp-2);
}

.tpl-ba__tag--after {
	inset-inline-end: var(--sp-2);
}

/* The range input is the real control: full-bleed, invisible track. */
.tpl-ba__range {
	position: absolute;
	inset: 0;
	z-index: 3;
	inline-size: 100%;
	block-size: 100%;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	appearance: none;
	-webkit-appearance: none;
	cursor: ew-resize;
}

.tpl-ba__range::-webkit-slider-thumb {
	-webkit-appearance: none;
	inline-size: 44px;
	block-size: 44px;
	border: 0;
	border-radius: var(--radius-pill);
	background: transparent;
	cursor: ew-resize;
}

.tpl-ba__range::-moz-range-thumb {
	inline-size: 44px;
	block-size: 44px;
	border: 0;
	border-radius: var(--radius-pill);
	background: transparent;
	cursor: ew-resize;
}

.tpl-ba__range:focus-visible {
	outline: none;
}

.tpl-ba__range:focus-visible ~ .tpl-ba__divider::after {
	outline: 2px solid var(--c-forest);
	outline-offset: 3px;
}

/* --- Case tile ---------------------------------------------------------- */

.tpl-case__figure {
	display: flex;
	flex-direction: column;
	block-size: 100%;
	margin: 0;
}

.tpl-case__compare {
	aspect-ratio: 4 / 5;
}

.tpl-case__caption {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-1) var(--sp-2);
	margin-block-start: var(--sp-2);
	color: var(--c-forest);
	font-size: var(--fs-small);
}

.tpl-case__meta {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	min-inline-size: 0;
}

.tpl-case__title {
	font-family: var(--font-display);
	font-size: var(--fs-h3);
	font-weight: var(--fw-display);
	line-height: var(--lh-snug);
}

.tpl-case__category {
	background-color: var(--c-sage-200);
}

.tpl-case__link {
	min-block-size: 0;
	white-space: nowrap;
}

.tpl-reviews__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: var(--sp-3);
}

.tpl-reviews__widget--page {
	margin-block-end: var(--sp-4);
	background: none;
	padding: 0;
}

.tpl-footer__social-link:focus-visible {
	outline: 2px solid var(--c-ivory);
	outline-offset: 3px;
}
