﻿/**
 * WordPress / Elementor bridge only.
 * Does not redesign the approved frontend — only prevents WP/Elementor defaults
 * from breaking approved spacing when pages are built with Elementor.
 */

/* Elementor: avoid double container padding fighting .container */
.elementor-section.elementor-section-boxed > .elementor-container {
	max-width: none;
}

.elementor-widget:not(:last-child) {
	margin-bottom: 0;
}

/*
 * WP core + Elementor both set img { height: auto; max-width: 100% }.
 * Elementor's `.elementor img` (0,1,1) ties `.media img` and wins by cascade order,
 * which letterboxes cover frames. Beat it with `.elementor .media img` (0,2,1).
 * Parents that only set min-height also need a definite height (% basis).
 */
.elementor .media > img,
.elementor .media img,
.media > img,
.media img {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
}

.elementor .img-band .media,
.img-band .media {
	height: clamp(260px, 36vw, 560px);
	max-width: 100%;
}

/* Preserve approved mobile img-band aspect (do not keep desktop clamp height). */
@media (max-width: 767px) {
	.elementor .img-band .media,
	.img-band .media {
		height: auto;
		min-height: 0;
		aspect-ratio: 4 / 3;
	}
}

/*
 * Non-.media cover planes from approved HTML (inventory: page-hero, cta-image).
 * Same Elementor `.elementor img` conflict; keep approved % height + object-fit.
 */
.elementor .page-hero__media > img,
.elementor .page-hero__media img,
.page-hero__media > img,
.page-hero__media img {
	width: 100%;
	height: 115%;
	max-width: none;
	object-fit: cover;
}

.elementor .cta-image__media > img,
.elementor .cta-image__media img,
.cta-image__media > img,
.cta-image__media img {
	width: 100%;
	height: 120%;
	max-width: none;
	object-fit: cover;
}

/* Intentional natural-height exception from approved CSS */
.elementor .gallery-masonry .media > img,
.elementor .gallery-masonry .media img,
.gallery-masonry .media > img,
.gallery-masonry .media img {
	position: static;
	inset: auto;
	width: 100%;
	height: auto;
	max-width: 100%;
	object-fit: cover;
}

/*
 * Care Homes case masonry: approved `.gallery-masonry figure { margin-bottom: var(--s-4) }`.
 * Elementor frontend.css uses
 * `.elementor .elementor-widget:not(.elementor-widget-text-editor):not(.elementor-widget-theme-post-content) figure`
 * (specificity 0,4,1) which zeros margins. Match that specificity, scoped to .gallery-masonry only.
 */
.elementor .elementor-widget:not(.elementor-widget-text-editor):not(.elementor-widget-theme-post-content) .gallery-masonry figure,
.gallery-masonry figure {
	margin: 0 0 var(--s-4);
}

/*
 * Service panels (Home expanding accordion): approved CSS uses
 * `.svc-panel img { position:absolute; inset:0; width/height:100%; object-fit:cover }`.
 * Elementor's `.elementor img { height:auto; max-width:100% }` collapses those images
 * into short top strips over the ink panel background. Restore full-bleed cover.
 * Specificity (0,2,1) beats `.elementor img` (0,1,1). Do not alter transforms/filters —
 * those remain in main.css (.svc-panel img / .is-active img).
 */
.elementor .svc-panel img,
.elementor .svc-panel__link > img,
.svc-panel img,
.svc-panel__link > img {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
	object-position: center;
}

/*
 * Home hero slides — approved `.slide__media img/video` uses absolute + height:100% + cover.
 * Elementor's `.elementor img { height:auto; max-width:100% }` collapses posters to natural
 * aspect (letterboxed grey bars). Beat it without touching Ken Burns transforms in main.css.
 */
.elementor .slide__media > img,
.elementor .slide__media img,
.elementor .slide__media > video,
.elementor .slide__media video,
.slide__media > img,
.slide__media img,
.slide__media > video,
.slide__media video {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
}

/*
 * Portfolio tiles — approved `.tile img { width/height:100%; object-fit:cover }` inside
 * overflow:hidden grid cells. Elementor height:auto makes natural-height images poke past
 * the tile (clipped oddly / grey gutters). Absolute fill matches .media cover behaviour.
 */
.elementor .tile img,
.tile img {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
}

/* Hero pagination thumbs (desktop) */
.elementor .hero__dot-thumb img,
.hero__dot-thumb img {
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
}

/* Region ambient poster/img fallback (video path is unaffected by .elementor img) */
.elementor .region__media > img,
.elementor .region__media img,
.region__media > img,
.region__media img {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
}

/*
 * Team portraits (About Us): approved `.team-portrait img { width/height:100%; object-fit:cover;
 * object-position:50% 25% }` inside aspect-ratio frames. Elementor's `.elementor img { height:auto }`
 * collapses portraits to intrinsic square crops with grey/empty bands in the frame. Restore fill
 * without absolute positioning (approved CSS is in-flow height:100%).
 */
.elementor .team-portrait img,
.team-portrait img {
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	object-fit: cover;
	object-position: 50% 25%;
}

/*
 * Elementor editor / preview iframe: scroll-reveal must not hide sections.
 * Frontend keeps IntersectionObserver behaviour; editor shows everything immediately.
 */
body.elementor-editor-active .js [data-reveal],
body.elementor-editor-preview .js [data-reveal],
body.elementor-editor-active .js [data-reveal="clip"],
body.elementor-editor-preview .js [data-reveal="clip"] {
	opacity: 1 !important;
	transform: none !important;
	clip-path: none !important;
	transition: none !important;
}

body.elementor-editor-active .js [data-reveal="clip"] img,
body.elementor-editor-preview .js [data-reveal="clip"] img {
	transform: none !important;
}

/* If preview JS has not yet activated the first slide, keep it visible for editing */
body.elementor-editor-preview .hero .slide:first-child {
	opacity: 1;
	visibility: visible;
	transition: none;
}

body.elementor-editor-preview .hero .slide:first-child [data-anim],
body.elementor-editor-preview .hero .slide.is-active.is-revealed [data-anim] {
	opacity: 1;
	transform: none;
}

/* Keep skip link usable if WP admin bar is present */
.admin-bar .site-header {
	/* sticky offset handled by existing header JS classes; no redesign */
}

/* Ensure main landmark exists clearly under Elementor canvas pages */
main#main:focus {
	outline: none;
}
