/*
 * Yhteystiedot-kaista (avalon/contact + avalon/contact-item).
 *
 * The band's default padding is m (block.json), so the band on every page (pattern 11776) is about 440px high on
 * desktop instead of 727px. The item title is a paragraph (not a heading). Buttons are 44px high, 48px on phones
 * (--ab-btn-h).
 * Phones: the items are rows between hairlines – title and text on the left, the button (at least 128px wide, the
 * label centred) on the right. At 380px and less, and in a band with long texts or labels (.ab-contact--stack from
 * render.php, e.g. the Swedish band), the button goes under the text.
 * "Kortti" style (.ab-contact--cards): bordered cards with the icon in a tint circle; on phones rows too, with the
 * icon on the left and the button below the text (their labels are long). Tablets: 2 across, 3 when there are
 * exactly 3 cards (no card alone on a row). On a photo or navy the cards' buttons are outlined in white, like the
 * band's (a navy button vanishes there).
 * Cards that are links (.ab-contact--links from render.php, e.g. the entry cards of /fi/tuki/: each button only jumps
 * within the page or repeats the card's title): the button's link covers the card, its label is hidden visually (it
 * stays the link's name for screen readers) and a chevron in a tint circle marks the card – top right on tablets and
 * desktops (in line with the icon), at the end of the row on phones.
 */

/* the band with a photo at the end of the pages (patterns 11776 / 11782): more air above and below than the sections
   (--ab-pad-band 64 / 112 / 160px, blocks.css; the footer below has the same), whatever the block's padding setting */
.ab-section.wp-block-avalon-contact.ab-bg-image {
	padding-top: var(--ab-pad-band);
	padding-bottom: var(--ab-pad-band);
}

.ab-contact .ab-grid {
	gap: 32px;
}

/* desktops: the band's items 100px apart (2026-09-25; the card style keeps its own gap) */
@media (min-width: 1025px) {
	.ab-contact:not(.ab-contact--cards) .ab-grid {
		column-gap: 100px;
	}
}

.ab-contact-item {
	display: flex;
	align-items: flex-start;
	min-width: 0;
}

.ab-contact-item__icon {
	flex: 0 0 34px;
	padding-top: 3px;
}

.ab-contact-item__icon .ab-icon {
	display: block;
	width: auto;
	max-width: 22px;
	height: 22px;
}

.ab-contact-item__body {
	flex: 1 1 auto;
	min-width: 0;
}

.ab-contact-item__title {
	margin: 0 0 6px;
	color: var(--ab-heading);
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
}

.ab-contact-item .ab-flow.ab-flow > * + * {
	margin-block-start: 8px;
}

.ab-contact-item .ab-flow.ab-flow > * + .wp-block-buttons {
	margin-block-start: 16px;
}

.ab-contact-item .ab-flow > :is(p, ul, ol) {
	font-size: 16px;
	line-height: 1.5;
}

.ab-contact .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link,
.ab-contact:not(.ab-contact--cards) .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: var(--ab-btn-h, 44px);
	max-width: 100%;
	padding: 10px 22px;
	font-weight: 500;
	text-align: center;
	/* a long label wraps between words, never inside one */
	white-space: normal;
	overflow-wrap: normal;
	word-break: normal;
}

/* wider screens: the buttons of the items line up at the bottom */
@media (min-width: 769px) {
	.ab-contact-item {
		align-items: stretch;
	}

	.ab-contact-item__body,
	.ab-contact-item .ab-flow {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
	}

	.ab-contact-item .ab-flow.ab-flow > .wp-block-buttons {
		margin-top: auto;
		padding-top: 16px;
	}

	.ab-contact-item__icon {
		align-self: flex-start;
	}
}

/* ---------------------------------------------------------------- card style */

.ab-contact--cards .ab-grid {
	gap: 24px;
}

.ab-contact--cards .ab-contact-item {
	flex-direction: column;
	box-sizing: border-box;
	padding: 24px;
	border-radius: var(--ab-radius, 12px);
	background: #fff;
	color: var(--wp--preset--color--body, #282828);
}

.ab-contact--cards .ab-contact-item__icon {
	display: grid;
	flex: 0 0 auto;
	place-items: center;
	width: 48px;
	height: 48px;
	margin-bottom: 16px;
	padding: 0;
	border-radius: 50%;
	background: var(--ab-tint, #eaf8f9);
	color: var(--ab-navy, #002b56);
}

.ab-contact--cards .ab-contact-item__icon .ab-icon {
	max-width: 24px;
	height: 22px;
}

.ab-contact--cards .ab-contact-item__title {
	color: var(--wp--preset--color--heading, #012b55);
}

.ab-contact--cards .ab-contact-item__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	width: 100%;
}

/* buttons of the cards line up at the bottom */
.ab-contact--cards .ab-contact-item .ab-flow {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
}

.ab-contact--cards .ab-contact-item .ab-flow > .wp-block-buttons {
	margin-top: auto;
	padding-top: 16px;
}

.is-dark.ab-contact--cards .ab-contact-item {
	border-color: rgba(255, 255, 255, 0.18);
	background: rgba(255, 255, 255, 0.07);
	color: #fff;
}

.is-dark.ab-contact--cards .ab-contact-item__icon {
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
}

.is-dark.ab-contact--cards .ab-contact-item__title {
	color: #fff;
}

/* on a photo or navy a button of the theme's navy fill is outlined in white, like the band's outline buttons */
.is-dark.ab-contact .ab-contact-item .wp-block-button:not(.is-style-outline, .is-style-accent) > .wp-block-button__link {
	border-color: #fff;
	background-color: transparent;
	color: #fff;
}

.is-dark.ab-contact .ab-contact-item .wp-block-button:not(.is-style-outline, .is-style-accent) > .wp-block-button__link:hover {
	background-color: rgba(255, 255, 255, 0.12);
}

/* ---------------------------------------------------------------- cards that are links */

.ab-contact--links .ab-contact-item {
	position: relative;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

/* the buttons' wrappers leave the layout; the link itself is a 1px box (its label clipped by overflow, not by clip
   or clip-path, which would clip the stretched ::after too) */
.ab-contact--links .ab-contact-item .wp-block-buttons,
.ab-contact--links .ab-contact-item .wp-block-buttons > .wp-block-button {
	display: contents;
}

.ab-contact.ab-contact--links .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link {
	display: block;
	position: static;
	width: 1px;
	min-width: 0;
	max-width: 1px;
	height: 1px;
	min-height: 0;
	margin: 0 0 -1px;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: none;
	white-space: nowrap;
}

.ab-contact.ab-contact--links .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link::after {
	content: "";
	position: absolute;
	inset: -1px;
	z-index: 1;
	display: block;
	width: auto;
	height: auto;
	margin: 0;
	border-radius: var(--ab-radius, 12px);
	background: none;
	-webkit-mask: none;
	mask: none;
}

.ab-contact.ab-contact--links .ab-contact-item .wp-block-button__link:focus-visible {
	outline: none;
}

.ab-contact--links .ab-contact-item:has(.wp-block-button__link:focus-visible) {
	outline: 3px solid var(--ab-navy, #002b56);
	outline-offset: 3px;
}

.is-dark.ab-contact--links .ab-contact-item:has(.wp-block-button__link:focus-visible) {
	outline-color: var(--wp--preset--color--accent, #30cbd3);
}

.ab-contact--links .ab-contact-item:hover .ab-contact-item__title {
	text-decoration: underline;
	text-decoration-thickness: var(--ab-underline, 2px);
	text-underline-offset: 0.18em;
}

.ab-contact-item__chev {
	display: grid;
	flex: none;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--ab-tint, #eaf8f9);
	color: var(--ab-navy, #002b56);
	transition: background-color 0.2s ease;
}

.ab-contact-item__chev svg {
	display: block;
	width: 18px;
	height: 18px;
}

.ab-contact--links .ab-contact-item:hover .ab-contact-item__chev {
	background: var(--wp--preset--color--accent, #30cbd3);
}

.is-dark .ab-contact-item__chev {
	background: rgba(255, 255, 255, 0.12);
	color: var(--wp--preset--color--accent, #30cbd3);
}

.is-dark.ab-contact--links .ab-contact-item:hover .ab-contact-item__chev {
	background: var(--wp--preset--color--accent, #30cbd3);
	color: var(--ab-navy, #002b56);
}

@media (min-width: 769px) {
	/* the chevron top right, in line with the 48px icon circle */
	.ab-contact--links .ab-contact-item__chev {
		position: absolute;
		top: 32px;
		right: 24px;
	}


	.is-dark.ab-contact--links .ab-contact-item:hover {
		background: rgba(255, 255, 255, 0.1);
		box-shadow: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ab-contact--links .ab-contact-item,
	.ab-contact-item__chev {
		transition: none;
	}
}

/* ---------------------------------------------------------------- tablet */

@media (min-width: 769px) and (max-width: 1024px) {
	.ab-contact .ab-grid {
		gap: 24px;
	}

	.ab-contact-item__title {
		font-size: 17px;
	}

	.ab-contact-item__icon {
		flex-basis: 30px;
	}

	.ab-contact--cards .ab-grid {
		grid-template-columns: repeat(min(var(--ab-cols, 3), 2), minmax(0, 1fr));
	}

	/* exactly three cards: three across (about 240px at 820px), not two and one alone on the next row; a smaller gap
	   and padding leave the text and a one-word label ("Kontaktinformation") about 200px */
	.ab-contact--cards .ab-grid:has(> :nth-child(3):last-child) {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 16px;
	}

	.ab-contact--cards .ab-grid:has(> :nth-child(3):last-child) > .ab-contact-item {
		padding: 20px 18px;
	}

	.ab-contact--cards:not(.ab-contact--links) .ab-grid:has(> :nth-child(3):last-child) .wp-block-buttons > .wp-block-button > .wp-block-button__link {
		padding-inline: 16px;
	}

	.ab-contact--links .ab-grid:has(> :nth-child(3):last-child) .ab-contact-item__chev {
		top: 28px;
		right: 18px;
	}
}

/* ---------------------------------------------------------------- phones: rows */

@media (max-width: 768px) {
	/* (the first row's hairline follows the head closely) */
	.ab-contact .ab-head {
		margin-bottom: 12px;
	}

	.ab-contact .ab-grid,
	.ab-contact--cards .ab-grid {
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 0;
	}

	.ab-contact .ab-contact-item {
		flex-direction: row;
		align-items: center;
		padding: 12px 0;
		border: 0;
		border-top: 1px solid var(--ab-line, #e3e8ee);
		border-radius: 0;
		background: none;
	}

	.is-dark.ab-contact .ab-contact-item {
		border-top-color: rgba(255, 255, 255, 0.2);
		background: none;
	}

	/* the band's icons are left out on phones; the cards keep theirs in a smaller circle */
	.ab-contact:not(.ab-contact--cards) .ab-contact-item__icon {
		display: none;
	}

	.ab-contact--cards .ab-contact-item__icon {
		flex: 0 0 40px;
		width: 40px;
		height: 40px;
		margin: 0 12px 0 0;
	}

	.ab-contact--cards .ab-contact-item__icon .ab-icon {
		height: 18px;
	}

	.ab-contact-item__body {
		display: grid;
		flex: 1 1 auto;
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: 12px;
		align-items: center;
	}

	.ab-contact-item__body > .ab-flow {
		display: contents;
	}

	.ab-contact-item__title {
		grid-column: 1;
		margin: 0;
		font-size: 17px;
		line-height: 1.3;
	}

	.ab-contact-item .ab-flow.ab-flow > * {
		grid-column: 1;
		margin: 3px 0 0;
	}

	.ab-contact-item .ab-flow > :is(p, ul, ol) {
		font-size: 14px;
		line-height: 1.4;
	}

	.is-dark .ab-contact-item .ab-flow > :is(p, ul, ol) {
		color: rgba(255, 255, 255, 0.85);
	}

	.ab-contact-item .ab-flow.ab-flow > .wp-block-buttons {
		grid-row: 1 / span 6;
		grid-column: 2;
		margin: 0;
		padding: 0;
	}

	/* one width for the buttons of the rows (a straight right-hand column), the label centred */
	.ab-contact .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link,
	.ab-contact:not(.ab-contact--cards) .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link {
		min-width: 128px;
		padding: 10px 16px;
		font-size: 15px;
		white-space: nowrap;
	}

	/* long texts or labels: the button under the text */
	.ab-contact--stack .ab-contact-item__body {
		display: block;
	}

	.ab-contact--stack .ab-contact-item__body > .ab-flow {
		display: block;
	}

	.ab-contact--stack .ab-contact-item .ab-flow.ab-flow > .wp-block-buttons {
		margin-top: 10px;
	}

	/* the buttons under the texts are one width (not 128 / 142 / 135px after each other) */
	.ab-contact--stack:not(.ab-contact--cards) .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link {
		min-width: 176px;
	}

	/* cards: icon | title, text and the button below them; a hairline closes the list */
	.ab-contact--cards .ab-contact-item {
		align-items: flex-start;
	}

	.ab-contact--cards .ab-contact-item:last-child {
		border-bottom: 1px solid var(--ab-line, #e3e8ee);
	}

	.is-dark.ab-contact--cards .ab-contact-item:last-child {
		border-bottom-color: rgba(255, 255, 255, 0.2);
	}

	.ab-contact--cards .ab-contact-item__body {
		display: block;
	}

	.ab-contact--cards .ab-contact-item__body > .ab-flow {
		display: block;
	}

	.ab-contact--cards .ab-contact-item .ab-flow.ab-flow > .wp-block-buttons {
		margin-top: 10px;
	}

	.ab-contact--cards .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link {
		white-space: normal;
	}

	/* cards that are links: the chevron at the end of the row */
	.ab-contact--links .ab-contact-item__chev {
		align-self: center;
		margin-left: 12px;
	}
}

/* small phones: every band puts the button under the text (next to it the text column would be ~180px) */
@media (max-width: 380px) {
	.ab-contact .ab-contact-item__body {
		display: block;
	}

	.ab-contact .ab-contact-item__body > .ab-flow {
		display: block;
	}

	.ab-contact .ab-contact-item .ab-flow.ab-flow > .wp-block-buttons {
		margin-top: 10px;
	}

	.ab-contact:not(.ab-contact--cards) .ab-contact-item .wp-block-buttons > .wp-block-button > .wp-block-button__link {
		min-width: 176px;
	}
}
