/* Info Box (docs/widgets/info-box.md), in the design language (spec §3.7). This is Soft, the default:
   a white card with a thin border and a soft shadow, the icon on a pale tint of the accent, a tinted
   button. Fonts come from the theme. info-box-outline.css and info-box-solid.css change only the
   --hafe-ib-d-* tokens below, so a Style control's own property always wins over the design.

   The card fills its column's height and keeps its button at the bottom, so cards in a row line up.
   The Layout controls set the direction (--hafe-ib-flow) and, with it, what aligns the icon: the
   alignment above the text, the vertical alignment beside it (--hafe-ib-cross). */
.hafe-ib {
	--hafe-ib-d-bg: var(--hafe-surface);
	--hafe-ib-d-line: var(--hafe-line);
	--hafe-ib-d-hover-line: var(--hafe-accent);
	--hafe-ib-d-shadow: var(--hafe-shadow);
	--hafe-ib-d-shadow-up: var(--hafe-shadow-up);
	--hafe-ib-d-radius: var(--hafe-radius);
	--hafe-ib-d-media: var(--hafe-tint);
	--hafe-ib-d-media-ink: var(--hafe-accent-ink);
	--hafe-ib-d-media-line: transparent;
	--hafe-ib-d-media-radius: var(--hafe-radius-sm);
	--hafe-ib-d-button: var(--hafe-tint);
	--hafe-ib-d-button-hover: var(--hafe-tint-strong);
	--hafe-ib-d-button-ink: var(--hafe-accent-ink);
	--hafe-ib-d-button-hover-ink: var(--hafe-accent-ink);
	--hafe-ib-d-button-line: transparent;
	--hafe-ib-d-badge: var(--hafe-tint);
	--hafe-ib-d-badge-ink: var(--hafe-accent-ink);
	--hafe-ib-d-badge-line: var(--hafe-tint);
	position: relative;
	display: flex;
	flex-direction: var(--hafe-ib-flow, column);
	align-items: var(--hafe-ib-cross, var(--hafe-ib-items, flex-start));
	gap: var(--hafe-ib-media-gap, 1.25em);
	block-size: 100%;
	padding: var(--hafe-ib-padding, 1.75em);
	border: var(--hafe-ib-line-width, 1px) solid var(--hafe-ib-line, var(--hafe-ib-d-line));
	border-radius: var(--hafe-ib-radius, var(--hafe-ib-d-radius));
	background: var(--hafe-ib-bg, var(--hafe-ib-d-bg));
	color: var(--hafe-ink);
	box-shadow: var(--hafe-ib-d-shadow);
	text-align: var(--hafe-ib-align, start);
	transition: background-color 0.2s, border-color 0.2s;
}

/* Without Elementor's lean markup there's a wrapper between the widget and the box. */
.elementor-widget-hafe-info-box > .elementor-widget-container {
	block-size: 100%;
}

/* Hover colours from the Style tab; a clickable box also shows it when its link has the keyboard,
   with its border in the accent by default. */
.hafe-ib:hover {
	border-color: var(--hafe-ib-hover-line, var(--hafe-ib-line, var(--hafe-ib-d-line)));
	background: var(--hafe-ib-hover-bg, var(--hafe-ib-bg, var(--hafe-ib-d-bg)));
}

.hafe-ib--box:is(:hover, :focus-within) {
	border-color: var(--hafe-ib-hover-line, var(--hafe-ib-d-hover-line));
	background: var(--hafe-ib-hover-bg, var(--hafe-ib-bg, var(--hafe-ib-d-bg)));
}

/* The hover effects move the box, so they're for a mouse, and for visitors happy with motion. The
   keyboard gets the same while it's on the box's link. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.hafe-ib-hover-lift .hafe-ib,
	.hafe-ib-hover-grow .hafe-ib {
		transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s, border-color 0.2s;
	}

	.hafe-ib-hover-lift .hafe-ib:is(:hover, :has(:focus-visible)) {
		box-shadow: var(--hafe-ib-d-shadow-up);
		transform: translateY(-0.1em);
	}

	.hafe-ib-hover-grow .hafe-ib:is(:hover, :has(:focus-visible)) {
		transform: scale(1.015);
	}
}

.hafe-ib--box:has(.hafe-ib__link:focus-visible) {
	outline: 2px solid var(--hafe-accent);
	outline-offset: 2px;
}

.hafe-ib--box .hafe-ib__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.hafe-ib.hafe-ib--box .hafe-ib__link:focus-visible {
	outline: none;
}

/* Links in the description stay clickable above a whole-box link. */
.hafe-ib--box .hafe-ib__text a {
	position: relative;
	z-index: 1;
}

.hafe-ib__media {
	box-sizing: border-box;
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--hafe-ib-media-line, var(--hafe-ib-d-media-line));
	border-radius: var(--hafe-ib-media-radius, var(--hafe-ib-d-media-radius));
	background: var(--hafe-ib-media-bg, var(--hafe-ib-d-media));
	color: var(--hafe-ib-media-color, var(--hafe-ib-d-media-ink));
	line-height: 1;
	transition: background-color 0.2s, color 0.2s;
}

.hafe-ib:hover .hafe-ib__media {
	background: var(--hafe-ib-media-hover-bg, var(--hafe-ib-media-bg, var(--hafe-ib-d-media)));
	color: var(--hafe-ib-media-hover-color, var(--hafe-ib-media-color, var(--hafe-ib-d-media-ink)));
}

/* The tile grows with the icon, a little over twice its size. */
.hafe-ib__media--icon {
	inline-size: 2.25em;
	block-size: 2.25em;
	font-size: var(--hafe-ib-icon, 1.5em);
}

.hafe-ib__media--icon i,
.hafe-ib__media--icon svg {
	inline-size: 1em;
	block-size: 1em;
	font-size: 1em;
	line-height: 1;
	text-align: center;
	fill: currentColor;
}

.hafe-ib__media--number {
	min-inline-size: 2.25em;
	padding: 0.4em 0.6em;
	font-size: 1.5em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* An image shows as it is: no frame or tint. */
.hafe-ib .hafe-ib__media--image {
	inline-size: var(--hafe-ib-image, 5em);
	max-inline-size: 100%;
	overflow: hidden;
	border: 0;
	background: none;
}

.hafe-ib .hafe-ib__media--image img {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
}

/* The text column. It stretches across the box, or down it beside an icon, so the button sits at
   the bottom. */
.hafe-ib__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: var(--hafe-ib-items, flex-start);
	align-self: stretch;
	gap: var(--hafe-ib-gap, 0.6em);
	min-inline-size: 0;
}

.hafe-ib__head {
	display: flex;
	flex-direction: column;
	align-items: inherit;
	gap: 0.35em;
	margin: 0;
}

.hafe-ib .hafe-ib__above {
	margin: 0;
	color: var(--hafe-ib-above-color, var(--hafe-accent-ink));
	font-size: 0.8em;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* Themes size tags very differently, so the title's size follows the box until the Style tab says
   otherwise. */
.hafe-ib .hafe-ib__title {
	margin: 0;
	color: var(--hafe-ib-title-color, var(--hafe-ink));
	font-size: 1.25em;
	font-weight: 600;
	line-height: 1.3;
	transition: color 0.2s;
}

.hafe-ib .hafe-ib__link {
	color: inherit;
	text-decoration: none;
}

.hafe-ib__link:hover {
	text-decoration: underline;
}

.hafe-ib__title:has(.hafe-ib__link:hover),
.hafe-ib--box:hover .hafe-ib__title {
	color: var(--hafe-ib-title-hover-color, var(--hafe-ib-title-color, var(--hafe-ink)));
}

.hafe-ib--box .hafe-ib__link:hover {
	text-decoration: none;
}

.hafe-ib__text {
	color: var(--hafe-ib-text-color, var(--hafe-ink-soft));
}

.hafe-ib__text > :first-child {
	margin-block-start: 0;
}

.hafe-ib__text > :last-child {
	margin-block-end: 0;
}

/* Links in a description stand out by more than colour (WCAG 1.4.1), whatever the theme does. */
.hafe-ib .hafe-ib__text a {
	text-decoration: underline;
}

.hafe-ib__action {
	margin-block-start: auto;
	padding-block-start: 0.6em;
}

.hafe-ib .hafe-ib__button {
	display: inline-flex;
	flex-direction: var(--hafe-ib-button-dir, row);
	align-items: center;
	gap: 0.5em;
	padding: 0.6em 1.2em;
	border: 1px solid var(--hafe-ib-button-line, var(--hafe-ib-d-button-line));
	border-radius: var(--hafe-pill);
	background: var(--hafe-ib-button-bg, var(--hafe-ib-d-button));
	color: var(--hafe-ib-button-color, var(--hafe-ib-d-button-ink));
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.hafe-ib .hafe-ib__button:hover,
.hafe-ib--box:hover .hafe-ib__button {
	background: var(--hafe-ib-button-hover-bg, var(--hafe-ib-d-button-hover));
	color: var(--hafe-ib-button-hover-color, var(--hafe-ib-button-color, var(--hafe-ib-d-button-hover-ink)));
}

.hafe-ib__button-icon {
	display: inline-flex;
	font-size: 0.85em;
}

.hafe-ib__button-icon svg {
	inline-size: 1em;
	block-size: 1em;
	fill: currentColor;
}

/* As a text link, from the Style tab: no frame, underlined on hover. */
.hafe-ib-button-text .hafe-ib .hafe-ib__button {
	padding: 0;
	border: 0;
	background: none;
	color: var(--hafe-ib-button-color, var(--hafe-accent-ink));
}

.hafe-ib-button-text .hafe-ib .hafe-ib__button:hover,
.hafe-ib-button-text .hafe-ib--box:hover .hafe-ib__button {
	background: none;
	text-decoration: underline;
}

/* The badge sits in the top corner, inside the box, so a box with one is the same size as the
   others in its row. */
.hafe-ib__badge {
	position: absolute;
	inset-block-start: 1em;
	inset-inline-end: 1em;
	padding: 0.2em 0.75em;
	border: 1px solid var(--hafe-ib-badge-line, var(--hafe-ib-d-badge-line));
	border-radius: var(--hafe-pill);
	background: var(--hafe-ib-badge-bg, var(--hafe-ib-d-badge));
	color: var(--hafe-ib-badge-color, var(--hafe-ib-d-badge-ink));
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.4;
}

.hafe-empty {
	margin: 0;
	padding: 1em;
	border: 1px dashed currentColor;
	opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
	.hafe-ib,
	.hafe-ib__title,
	.hafe-ib .hafe-ib__button {
		transition: none;
	}
}
