/* wp-content/plugins/ceca-widgets/widgets/region-grid/region-grid.css */

/* Defaults mirror Figma node 2005:1607: 4-up square cards, 24px gaps,
   rgba(0,0,0,.2) overlay, name 25/30 bold white inset 20px top-left.
   Custom props are driven by the widget's Elementor controls. */

.ceca-region-grid {
	--ceca-rg-cols: 4;
	--ceca-rg-gap: 24px;
	--ceca-rg-ratio: 1 / 1;
	--ceca-rg-overlay: rgba(0, 0, 0, 0.2);
	--ceca-rg-overlay-hover: rgba(0, 0, 0, 0.35);
}

/* Elementor's flex column measures this widget's flex-basis from the images'
   NATURAL width; when cards render wider (e.g. mobile single column upscales
   a 306px source to 350px), the wrapper under-measures and everything after
   the grid is laid out inside it (verified in headless Edge: wrapper 2690px
   vs content 3042px). Block formatting can't mis-measure, so the widget's
   direct container drops flex; the sibling margin restores Elementor's
   widget gap that flex `gap` was providing. */
.e-con-inner:has(> .elementor-widget-ceca-region-grid),
.e-con:has(> .elementor-widget-ceca-region-grid) {
	display: block;
}

/* Desktop only: on mobile the page sets explicit per-widget margins and
   this restored gap stacked on top of them (user, 2026-09-16). */
@media (min-width: 768px) {
	.e-con-inner:has(> .elementor-widget-ceca-region-grid) > * + *,
	.e-con:has(> .elementor-widget-ceca-region-grid) > * + * {
		margin-top: var(--widgets-spacing-row, 20px);
	}
}

/* Figma 152:777: 40/50 Bold black. */
.ceca-region-grid__title {
	margin: 0 0 24px;
	color: #000000;
	font-size: 40px;
	font-weight: 700;
	line-height: 1.25;
}

.ceca-region-grid__grid {
	display: grid;
	grid-template-columns: repeat(var(--ceca-rg-cols), 1fr);
	gap: var(--ceca-rg-gap);
}

/* Double-class + element selectors so card/name styling beats theme/kit rules
   that target bare `a` elements.
   The IMAGE is the in-flow sizing element (aspect-ratio on the img, not the
   card): a card whose only content is absolutely-positioned collapses to zero
   height if the ratio ever fails to apply, which let the whole grid shrink
   and painted cards over the footer. */
.ceca-region-grid .ceca-region-grid__card {
	position: relative;
	display: block;
	overflow: hidden;
	text-decoration: none;
}

.ceca-region-grid .ceca-region-grid__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--ceca-rg-ratio, 1 / 1);
	object-fit: cover;
}

.ceca-region-grid__overlay {
	position: absolute;
	inset: 0;
	background: var(--ceca-rg-overlay);
	transition: background-color 0.2s ease;
}

.ceca-region-grid .ceca-region-grid__name {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1;
	padding: 20px;
	color: #fff;
	font-size: 25px;
	font-weight: 700;
	line-height: 30px;
}

a.ceca-region-grid__card:hover .ceca-region-grid__overlay,
a.ceca-region-grid__card:focus-visible .ceca-region-grid__overlay {
	background: var(--ceca-rg-overlay-hover);
}

/* --- mobile design pass (Figma 2372:7357): heading + chevron accordion ---- */
.ceca-region-grid__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
}

.ceca-region-grid .ceca-region-grid__toggle,
.ceca-region-grid .ceca-region-grid__toggle:hover,
.ceca-region-grid .ceca-region-grid__toggle:focus {
	display: none;
	padding: 10px 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: #000;
	cursor: pointer;
}

.ceca-region-grid__toggle svg {
	width: 33px;
	height: 16px;
	display: block;
	transition: transform 0.25s ease;
}

.ceca-region-grid.is-open .ceca-region-grid__toggle svg {
	transform: rotate(180deg);
}

@media (max-width: 767px) {
	.ceca-region-grid .ceca-region-grid__toggle,
	.ceca-region-grid .ceca-region-grid__toggle:hover,
	.ceca-region-grid .ceca-region-grid__toggle:focus {
		display: block;
	}

	.ceca-region-grid .ceca-region-grid__title {
		font-size: 36px;
		line-height: 45px;
		margin-bottom: 0;
	}

	.ceca-region-grid__grid {
		display: none;
	}

	.ceca-region-grid.is-open .ceca-region-grid__grid {
		display: grid;
		margin-top: 25px;
	}
}

/* Mobile refinements (critic pass): force the design's "Regions & /
   Devolved Nations" break and centre the chevron on the two-line block. */
@media (max-width: 767px) {
	.ceca-region-grid__head {
		align-items: center;
	}

	.ceca-region-grid .ceca-region-grid__title {
		max-width: 300px;
	}
}

/* Critic round 2: 38px per design, and the max-width window that forces
   "Regions & / Devolved Nations" ("Devolved Nations" ~296px at 38px must
   fit; "Regions & Devolved" ~322px must not). */
@media (max-width: 767px) {
	.ceca-region-grid .ceca-region-grid__title {
		max-width: 302px;
		font-size: 38px;
		line-height: 48px;
	}
}
