/* Brentwood Interlinking — image tile + label pill, migrated from brentwood.ca.
 * Self-contained (no Tailwind dependency). Shape comes from --bw-il-ratio so the
 * same block renders at any size inside a Columns / Row layout. */

.bw-il {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: var(--bw-il-ratio, 3 / 2);
	overflow: hidden;
	border-radius: var(--bw-il-radius, 8px);
	text-decoration: none;
	background: #e9e9e9;
}

.bw-il__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .5s ease;
}

/* ── Fill section height (responsive only) ───────────────────────────────────
 * A per-breakpoint option: on tablet and/or mobile the tile drops its fixed
 * aspect-ratio and stretches to its parent's full height, so it can match a
 * taller neighbouring column. Desktop always keeps the aspect ratio. Works when
 * the containing column/section stretches to the row height (Kadence Row/Columns
 * do so by default — align-items: stretch). Tablet and Mobile are independent
 * bands so either toggle can be used on its own.
 *
 * The wrapper is stretched too so the tile has a full-height parent to fill: for
 * the link/div tile the wrapper IS .bw-il; the accordion/modal wrappers hold
 * .bw-il as a nested button, hence the :has() selectors. */

/* Tablet: 768–1024px. */
@media (min-width: 768px) and (max-width: 1024px) {
	.bw-il--fill-tablet {
		aspect-ratio: auto;
		height: 100%;
	}
	.wp-block-bw-interlinking:has( > .bw-il--fill-tablet ),
	.bw-il-acc:has( .bw-il--fill-tablet ),
	.bw-il-modal-block:has( .bw-il--fill-tablet ) {
		height: 100%;
	}
}

/* Mobile: ≤767px. */
@media (max-width: 767px) {
	.bw-il--fill-mobile {
		aspect-ratio: auto;
		height: 100%;
	}
	.wp-block-bw-interlinking:has( > .bw-il--fill-mobile ),
	.bw-il-acc:has( .bw-il--fill-mobile ),
	.bw-il-modal-block:has( .bw-il--fill-mobile ) {
		height: 100%;
	}
}

.bw-il__img--empty {
	background: repeating-linear-gradient(45deg, #e0e0e0 0 12px, #ededed 12px 24px);
}

.bw-il:hover .bw-il__img {
	transform: scale(1.05);
}

/* Overlay: stacks the pill + subtext, anchored bottom-right. */
.bw-il__overlay {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-end;
	pointer-events: none;
}

.bw-il__pill {
	display: inline-flex;
	align-items: center;
	padding: .25rem 0;
	margin-bottom: .5rem;
	border-top-left-radius: .25rem;
	border-bottom-left-radius: .25rem;
	background: rgba(255, 255, 255, .9);
	/* Card lift — stronger/darker than Tailwind's default shadow-md so it reads
	 * clearly over busy photos. */
	box-shadow: 0 6px 10px -2px rgba(0, 0, 0, .28), 0 3px 5px -2px rgba(0, 0, 0, .2);
	font-weight: 500;
	transition: box-shadow .3s ease, background-color .3s ease;
}

/* Whole-tile hover lifts the pill (Tailwind shadow-lg + full opacity), like live. */
.bw-il:hover .bw-il__pill {
	background: rgba(255, 255, 255, 1);
	box-shadow: 0 12px 20px -4px rgba(0, 0, 0, .35), 0 6px 8px -4px rgba(0, 0, 0, .25);
}

.bw-il__label {
	padding-left: .5rem;
	text-align: right;
}

.bw-il__chevron-wrap {
	display: inline-flex;
	align-items: center;
	padding: 0 .5rem 0 .25rem;
}

.bw-il__chevron {
	width: .85em;
	height: .85em;
	display: block;
}

/* Subtext bar: no vertical padding (like live) so it sits shorter than the
 * taller pill above it. */
.bw-il__subtext {
	padding: 0 .5rem;
	margin-bottom: .5rem;
	border-bottom-left-radius: .25rem;
	background: rgba(255, 255, 255, .8);
	color: #374151;
	font-weight: 500;
	text-align: right;
}

/* When a subtext follows the pill, the pill drops its bottom margin so the two
 * abut flush; the subtext carries the gap to the tile's bottom edge. */
.bw-il__pill:has(+ .bw-il__subtext) {
	margin-bottom: 0;
}

@media (min-width: 768px) {
	.bw-il__pill        { margin-bottom: 1rem; font-size: 1.125rem; }
	.bw-il__pill:has(+ .bw-il__subtext) { margin-bottom: 0; }
	.bw-il__label       { padding-left: 1rem; }
	.bw-il__chevron-wrap{ padding-right: 1rem; }
	.bw-il__subtext     { padding-left: 1rem; padding-right: 1rem; margin-bottom: 1rem; font-size: 1.125rem; }
}

/* ── Accordion mode ─────────────────────────────────────────────────────────
 * The tile is a <button> that carries the .bw-il tile styles; the panel renders
 * directly below it and reveals on toggle. */
.bw-il-acc {
	display: block;
}

/* Full-width host the view script inserts after the row; the open panel is
 * moved here so it spans the whole row instead of being trapped in a column. */
.bw-il-acc-host {
	width: 100%;
	/* Keep the panel clear of a sticky site header when it scrolls into view. */
	scroll-margin-top: 100px;
}

.bw-il-acc-host[hidden] {
	display: none;
}

.bw-il--button {
	-webkit-appearance: none;
	appearance: none;
	margin: 0;
	border: 0;
	padding: 0;
	font: inherit;
	color: inherit;
	text-align: inherit;
	cursor: pointer;
}

.bw-il__panel[hidden] {
	display: none;
}

.bw-il__panel-inner {
	position: relative;
	width: var(--bw-il-panel-w, 50%);
	padding-top: 2.5rem;
	padding-right: 3rem;
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity .25s ease, transform .25s ease;
}

/* Remove the default top margin on the panel's first block (e.g. the heading)
 * so it sits close under the × instead of leaving a large gap. */
.bw-il__panel-inner > .bw-il__close + * {
	margin-top: 0;
}

.bw-il__panel--left   .bw-il__panel-inner { margin-left: 0;    margin-right: auto; }
.bw-il__panel--center .bw-il__panel-inner { margin-left: auto; margin-right: auto; }
.bw-il__panel--right  .bw-il__panel-inner { margin-left: auto; margin-right: 0; }

.bw-il__panel.is-open .bw-il__panel-inner {
	opacity: 1;
	transform: none;
}

/* Round × close button, top-right of the panel content. */
.bw-il__close {
	position: absolute;
	top: .5rem;
	right: 1rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, .25);
	border-radius: 50%;
	background: transparent;
	color: #333;
	cursor: pointer;
	transition: background .15s ease;
}

.bw-il__close:hover {
	background: rgba(0, 0, 0, .06);
}

.bw-il__close svg {
	width: .85rem;
	height: .85rem;
	display: block;
}

/* On small screens the panel content goes full width regardless of the % set.
 * Override the inner width directly — the % is written as an inline CSS var on
 * .bw-il__panel by the view script, which would beat a var override here. */
@media (max-width: 768px) {
	.bw-il__panel-inner { width: 100%; box-sizing: border-box; }
}

/* Editor: give the empty/placeholder tile a sensible min-height so it is clickable. */
.editor-styles-wrapper .bw-il { min-height: 120px; }

/* Editor: label above the panel's InnerBlocks region. */
.bw-il__panel-edit-label {
	margin-top: .75rem;
	margin-bottom: .25rem;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: #757575;
}

/* ── Modal mode ─────────────────────────────────────────────────────────────
 * The tile is a <button> that opens a native <dialog>; the dialog fills the
 * viewport and centres a white card, and ::backdrop dims the page behind it.
 * The content inside the card is the tile's own InnerBlocks, so each tile can
 * have a completely different layout. */
.bw-il-modal-block {
	display: block;
}

/* Headless (anchor-triggered) modal: no visible tile — the block is only the
   hidden <dialog>, opened via a text link to #anchor. display:contents removes
   the wrapper's own box (and any block spacing) while the dialog still opens as
   a top-layer element. */
.bw-il-modal-block--headless {
	display: contents;
}

/* Lock background scroll while a modal is open (set by the view script). */
html.bw-il-modal-open {
	overflow: hidden;
}

dialog.bw-il-modal {
	width: 100%;
	height: 100%;
	max-width: 100vw;
	max-height: 100vh;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
}

dialog.bw-il-modal:not([open]) {
	display: none;
}

dialog.bw-il-modal[open] {
	display: flex;
	align-items: center;
	justify-content: center;
	inset: 0;
	box-sizing: border-box;
	padding: clamp(1rem, 4vw, 2.5rem);
	overflow: auto;
	overscroll-behavior: contain;
}

dialog.bw-il-modal::backdrop {
	background: rgba(0, 0, 0, .6);
	backdrop-filter: blur(2px);
}

.bw-il-modal__inner {
	position: relative;
	width: 100%;
	max-width: 720px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .45);
}

.bw-il-modal--small  .bw-il-modal__inner { max-width: 480px; }
.bw-il-modal--medium .bw-il-modal__inner { max-width: 720px; }
.bw-il-modal--large  .bw-il-modal__inner { max-width: 1000px; }
.bw-il-modal--xlarge .bw-il-modal__inner { max-width: 1200px; }
.bw-il-modal--full   .bw-il-modal__inner { max-width: 95vw; }

/* No padding — content sits flush to the card edges. The scroll lives here (not
 * on __inner) so the close button stays pinned to the corner; border-radius +
 * overflow clip the content to the card's rounded corners. */
.bw-il-modal__content {
	max-height: calc(100vh - 2rem);
	overflow: auto;
	border-radius: 12px;
	padding: 0 !important;
	-webkit-overflow-scrolling: touch;
}

/* Close button — matches the other modals (team-modal): grey circle just off the
 * top-right corner, sitting on the dim backdrop. __inner has no overflow so it is
 * not clipped. */
.bw-il-modal__close {
	position: absolute;
	top: -0.5rem;
	right: -0.5rem;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 9999px !important;
	background: #f3f4f6 !important;
	color: #374151;
	box-shadow: 0 1px 3px 0 rgba( 0, 0, 0, .12 ), 0 1px 2px -1px rgba( 0, 0, 0, .12 );
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.bw-il-modal__close:hover,
.bw-il-modal__close:focus {
	background: #e5e7eb !important;
	color: #1f2937;
	outline: none;
}

.bw-il-modal__close svg {
	width: 1.05rem;
	height: 1.05rem;
	display: block;
	fill: currentColor;
}

@media (max-width: 600px) {
	.bw-il-modal--small  .bw-il-modal__inner,
	.bw-il-modal--medium .bw-il-modal__inner,
	.bw-il-modal--large  .bw-il-modal__inner,
	.bw-il-modal--xlarge .bw-il-modal__inner,
	.bw-il-modal--full   .bw-il-modal__inner { max-width: 100%; }
}

/* ── Editor: modal content overlay ───────────────────────────────────────────
 * The popup content is edited in a floating overlay (like the Kadence Modal
 * block): it opens over the canvas when the tile/its inner blocks are selected
 * and is dismissed with × / the dimmed area / the "Hide Modal Content" toggle.
 * position:fixed inside the editor iframe pins it to the canvas, leaving the
 * sidebar usable. */
.bw-il-modal-ov {
	position: fixed;
	inset: 0;
	/* Above every block overlay/lightbox on the page (theme blocks go up to
	 * 100000) so nothing bleeds through the dim. The block toolbar/inserter
	 * popovers are lifted even higher by an injected <style> in editor.js. */
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: 56px 24px 24px;
	background: rgba(0, 0, 0, .6);
}

/* "Popup Content" label at the top-left of the dim area, like Kadence. */
.bw-il-modal-ov__label {
	position: absolute;
	top: 18px;
	left: 24px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, .85);
}

.bw-il-modal-ov__card {
	position: relative;
	width: 100%;
	max-width: 720px;
	max-height: calc(100% - 48px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border-radius: 6px;
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .5);
}

.bw-il-modal-ov--small  .bw-il-modal-ov__card { max-width: 480px; }
.bw-il-modal-ov--medium .bw-il-modal-ov__card { max-width: 720px; }
.bw-il-modal-ov--large  .bw-il-modal-ov__card { max-width: 1000px; }
.bw-il-modal-ov--xlarge .bw-il-modal-ov__card { max-width: 1200px; }
.bw-il-modal-ov--full   .bw-il-modal-ov__card { max-width: calc(100% - 48px); }

/* Clean × in the card's top-right corner, like the Kadence Modal editor box. */
.bw-il-modal-ov__close {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: #444;
	cursor: pointer;
	transition: background .15s ease;
}

.bw-il-modal-ov__close:hover {
	background: rgba(0, 0, 0, .08);
	color: #1e1e1e;
}

.bw-il-modal-ov__close svg {
	display: block;
}

.bw-il-modal-ov__body {
	flex: 1 1 auto;
	overflow: auto;
	padding: 2rem 1.75rem 1.75rem;
}

/* Dashed placeholder on the canvas while the popup content is hidden — mirrors
 * the Kadence Modal block's "hidden" state with a Show-Modal-Content button. */
.bw-il-modal-edit-hidden {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .6rem;
	margin-top: .6rem;
	padding: 1rem;
	border: 1px dashed #c3c4c7;
	border-radius: 6px;
	background: #f6f7f7;
	text-align: center;
}

.bw-il-modal-edit-hidden__hint {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .02em;
	color: #757575;
}

/* "Show Modal Content" button (canvas placeholder). */
.bw-il-modal-edit-trigger {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	padding: .45rem 1rem;
	border: 1px solid #2271b1;
	border-radius: 4px;
	background: #2271b1;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
}

.bw-il-modal-edit-trigger:hover {
	background: #135e96;
	border-color: #135e96;
}

/* Sidebar header toggle ("Show Modal Content" / "Hide Modal Content"). */
.bw-il-modal-toggle {
	padding: 16px 16px 0;
}

.bw-il-modal-toggle__btn {
	width: 100%;
	justify-content: center;
}
