/*
 * Contactos: the contact sheet (block atv/contact-sheet) and the contact form's topic chips.
 * Under the standard photo hero: heading + tap-to-contact tiles (lima tint) → postcard band (lima tint)
 * → the form (template). Tokens only; motion on hover/focus only, off under prefers-reduced-motion.
 */

.wp-block-post-content > .atv-contact-sheet {
	margin-block: 0;
}

.atv-main.is-layout-constrained > .wp-block-post-content > .atv-contact-sheet {
	max-width: none;
	margin-inline: calc(50% - 50vw);
}

/* ---- 1. Heading ------------------------------------------------------ */
.atv-contact-head {
	margin-block-end: var(--spacing-layout-s);
}

.atv-contact-head__title {
	max-width: 22ch;
	margin: 0;
}

/* ---- 2. Tiles -------------------------------------------------------- */
/* Same lima tint as the postcard band below it: one calm band under the photo hero. */
.atv-contact-tiles-band {
	padding-block-start: var(--spacing-layout-m);
	background: var(--atv-green-light);
}

.atv-contact-tiles {
	display: grid;
	gap: var(--spacing-s);
	margin: 0;
	padding: 0;
	list-style: none;
}

.atv-contact-tile {
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	border-block-start: var(--spacing-2-xs) solid var(--atv-green);
	border-radius: var(--atv-radius-m);
	background: var(--color-white);
	color: var(--atv-navy);
	box-shadow: var(--box-shadow-l);
}

.atv-contact-tile__label {
	display: flex;
	align-items: center;
	gap: var(--spacing-2-xs);
	margin: 0;
	font-family: var(--font-heading);
	font-size: var(--fontsize-body-s);
	font-weight: 800;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--atv-green-text);
}

.atv-contact-tile__icon {
	flex: none;
	width: 1.75rem;
	height: 1.75rem;
}

.atv-contact-tile__link {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--spacing-3-xs) var(--spacing-xs);
	min-height: 44px;
	color: inherit;
	text-decoration: none;
	transition: background-color var(--atv-motion-fast) var(--atv-motion-ease);
}

/* Single-value tiles: the whole tile is the link. */
.atv-contact-tile__link--whole {
	flex: 1;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--spacing-s);
	padding: var(--spacing-m) var(--spacing-m) var(--spacing-l);
}

/* Values sit on the tile's bottom edge in every tile (equal-height tiles, no hole under a short value). */
.atv-contact-tile__link--whole .atv-contact-tile__value {
	margin-block-start: auto;
}

.atv-contact-tile__ext {
	--icon-size: 1rem;
	margin-inline-start: var(--spacing-3-xs);
}

/* Ligar: the label heads two full-width number rows (fixo, móvel), each its own tel: link. */
.atv-contact-tile--call .atv-contact-tile__label {
	padding: var(--spacing-m) var(--spacing-m) var(--spacing-2-xs);
}

.atv-contact-tile__links {
	display: flex;
	flex: 1;
	flex-direction: column;
	justify-content: flex-end;
}

.atv-contact-tile__links .atv-contact-tile__link {
	padding: var(--spacing-2-xs) var(--spacing-m);
}

.atv-contact-tile__links .atv-contact-tile__link:last-child {
	padding-block-end: var(--spacing-l);
}

.atv-contact-tile__value {
	font-family: var(--font-heading);
	font-size: clamp(1.5rem, 2.5vw, 2.25rem);
	font-weight: 800;
	line-height: var(--lineheight-m);
	letter-spacing: -0.03em;
	overflow-wrap: anywhere;
}

.atv-contact-tile__note {
	display: inline-flex;
	align-items: center;
	gap: var(--spacing-3-xs);
	font-size: var(--fontsize-body-s);
	color: var(--color-black-60);
}

.atv-contact-tile__note .hds-icon {
	--icon-size: 1em;
}

/* Hover and focus: the tile (or the number row) floods lima; text stays navy (4.89:1). Focus adds a navy ring inset,
   so it reads on the white tile and where the tile sits over the navy hero. */
.atv-contact-tile__link:hover,
.atv-contact-tile__link:focus-visible {
	background: var(--atv-green);
}

.atv-contact-tile__link:focus-visible {
	outline: var(--atv-focus-width) solid var(--atv-focus-light);
	outline-offset: calc(-2 * var(--atv-focus-width));
}

.atv-contact-tile__link:is(:hover, :focus-visible) :is(.atv-contact-tile__label, .atv-contact-tile__note) {
	color: var(--atv-navy);
}

.atv-contact-tile__link:is(:hover, :focus-visible) .atv-contact-tile__value {
	text-decoration: underline;
	text-decoration-thickness: 0.08em;
	text-underline-offset: 0.12em;
}

@media (min-width: 768px) {
	.atv-contact-tiles {
		grid-auto-columns: minmax(0, 1fr);
		grid-auto-flow: column;
		gap: var(--spacing-m);
	}

	.atv-contact-tile {
		transition: transform var(--atv-motion-base) var(--atv-motion-ease);
	}

	.atv-contact-tile--write:hover,
	.atv-contact-tile--whatsapp:hover,
	.atv-contact-tile:focus-within {
		transform: translateY(calc(-1 * var(--spacing-3-xs)));
	}

	.atv-contact-tile__link--whole,
	.atv-contact-tile--call .atv-contact-tile__label {
		padding-inline: var(--spacing-l);
	}

	.atv-contact-tile__link--whole {
		padding-block: var(--spacing-l) var(--spacing-xl);
	}

	.atv-contact-tile--call .atv-contact-tile__label {
		padding-block-start: var(--spacing-l);
	}

	.atv-contact-tile__links .atv-contact-tile__link {
		padding-inline: var(--spacing-l);
	}

	.atv-contact-tile__links .atv-contact-tile__link:last-child {
		padding-block-end: var(--spacing-xl);
	}
}

/* ---- 3. Postcard ----------------------------------------------------- */
.atv-contact-postcard-band {
	padding-block: var(--spacing-layout-m) var(--spacing-layout-l);
	background: var(--atv-green-light);
}

.atv-postcard {
	display: grid;
	gap: var(--spacing-m);
	padding: var(--spacing-s);
	border-radius: var(--atv-radius-m);
	background: var(--color-white);
	box-shadow: var(--box-shadow-m);
}

.atv-postcard__photo {
	margin: 0;
}

.atv-postcard__img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: var(--atv-radius-s);
}

.atv-postcard__side {
	padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-s);
}

/* Title and stamp share the card's top line. */
.atv-postcard__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--spacing-s);
	margin-block-end: var(--spacing-m);
}

/* Stamp: a real postage stamp. Perforated edge = a row of half-circle bites (radial-gradient mask on the padding
   ring) united with the solid content box; inside, a framed field with the zigzag and «Torres Vedras» (decorative). */
.atv-postcard__stamp {
	--atv-perf: 0.3125rem;
	flex: none;
	box-sizing: border-box;
	width: 6.25rem;
	height: 7.5rem;
	padding: calc(2 * var(--atv-perf));
	background: var(--atv-green);
	-webkit-mask:
		radial-gradient(circle at center, transparent var(--atv-perf), black calc(var(--atv-perf) + 0.5px)) calc(-1.5 * var(--atv-perf)) calc(-1.5 * var(--atv-perf)) / calc(3 * var(--atv-perf)) calc(3 * var(--atv-perf)) round,
		linear-gradient(black 0 0) content-box;
	mask:
		radial-gradient(circle at center, transparent var(--atv-perf), black calc(var(--atv-perf) + 0.5px)) calc(-1.5 * var(--atv-perf)) calc(-1.5 * var(--atv-perf)) / calc(3 * var(--atv-perf)) calc(3 * var(--atv-perf)) round,
		linear-gradient(black 0 0) content-box;
	transform: rotate(4deg);
}

.atv-postcard__stamp-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--spacing-xs);
	box-sizing: border-box;
	height: 100%;
	padding: var(--spacing-2-xs);
	background: var(--atv-green-light);
	text-align: center;
}

.atv-postcard__stamp-mark {
	width: 3.75rem;
	height: 0.9rem;
	background-color: var(--atv-navy);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 673 117'%3E%3Cpolyline fill='none' stroke='%23000' stroke-width='30' stroke-linecap='round' stroke-linejoin='round' points='53,95 124,22 195,95 266,22 337,95 408,22 479,95 550,22 621,95'/%3E%3C/svg%3E") no-repeat center / contain;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 673 117'%3E%3Cpolyline fill='none' stroke='%23000' stroke-width='30' stroke-linecap='round' stroke-linejoin='round' points='53,95 124,22 195,95 266,22 337,95 408,22 479,95 550,22 621,95'/%3E%3C/svg%3E") no-repeat center / contain;
}

.atv-postcard__stamp-text {
	font-family: var(--font-heading);
	font-size: 0.8125rem;
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--atv-navy);
}

.atv-nowrap {
	white-space: nowrap;
}

.atv-postcard__title {
	margin: var(--spacing-xs) 0 0;
	font-family: var(--font-heading);
	font-size: var(--fontsize-heading-l);
	font-weight: 800;
	line-height: var(--lineheight-m);
	letter-spacing: -0.02em;
	text-transform: uppercase;
	color: var(--atv-navy);
}

/* The address on ruled lines, as written on a card. */
.atv-postcard__address {
	margin: 0 0 var(--spacing-m);
	font-family: var(--font-heading);
	font-size: var(--fontsize-heading-m);
	font-style: normal;
	font-weight: 700;
	line-height: 1.75em;
	color: var(--atv-navy);
	background-image: linear-gradient(to bottom, transparent calc(1.75em - 1px), var(--color-black-20) calc(1.75em - 1px));
	background-size: 100% 1.75em;
}

.atv-postcard__hours,
.atv-postcard__mailing {
	margin: 0 0 var(--spacing-xs);
	color: var(--color-black-80);
}

.atv-postcard__mailing {
	font-size: var(--fontsize-body-s);
	color: var(--color-black-60);
}

.atv-postcard__mailing-label {
	font-weight: 700;
	color: var(--color-black-80);
}

.atv-postcard__action {
	margin: var(--spacing-m) 0 0;
}

.atv-postcard__map:focus-visible {
	outline: var(--atv-focus-width) solid var(--atv-focus-light);
	outline-offset: var(--atv-focus-offset);
}

@media (min-width: 992px) {
	.atv-postcard {
		grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
		align-items: stretch;
		gap: 0;
		padding: var(--spacing-m);
	}

	.atv-postcard--no-photo {
		grid-template-columns: minmax(0, 1fr);
	}

	/* The photo takes the address side's height: no white bands at any width. */
	.atv-postcard__photo {
		position: relative;
		align-self: stretch;
		min-height: 22rem;
	}

	.atv-postcard__img {
		position: absolute;
		inset: 0;
		height: 100%;
		aspect-ratio: auto;
	}

	/* The postcard's back: a rule divides the picture side from the address side. */

	.atv-postcard__side {
		align-self: stretch;
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-inline-start: var(--spacing-layout-s);
		padding: var(--spacing-s) var(--spacing-s) var(--spacing-s) var(--spacing-layout-s);
		border-inline-start: 1px solid var(--color-black-20);
	}

	.atv-postcard--no-photo .atv-postcard__side {
		margin-inline-start: 0;
		border-inline-start: 0;
	}
}

/* ---- 4. Form: no details aside next to the sheet; topic chips -------- */
/* Under the sheet the H2 is set large, a counterpart to the hero; from 992px it sits left of the form (DOM: H2, lead,
   form = reading order). */
.atv-contact__grid--sheet .atv-form-section__title {
	margin: 0;
	font-size: clamp(2.5rem, 5.5vw, 4.5rem);
	line-height: 0.92;
	letter-spacing: -0.045em;
	text-transform: none;
}

.atv-contact__lead {
	margin: var(--spacing-m) 0 var(--spacing-l);
	font-size: var(--fontsize-body-xl);
	color: var(--color-black-60);
}

@media (min-width: 992px) {
	.atv-contact__grid--sheet .atv-contact__main {
		display: grid;
		grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
		gap: var(--spacing-layout-m);
		align-items: start;
	}

	.atv-contact__grid--sheet .atv-contact__intro {
		position: sticky;
		top: calc(var(--atv-header-h) + var(--spacing-layout-s));
		padding-block-start: var(--spacing-s);
	}

	.atv-contact__grid--sheet .atv-contact__intro::before {
		content: "";
		display: block;
		width: 9rem;
		height: 1.5rem;
		margin-block-end: var(--spacing-m);
		background-color: var(--atv-green);
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 673 117'%3E%3Cpolyline fill='none' stroke='%23000' stroke-width='30' stroke-linecap='round' stroke-linejoin='round' points='53,95 124,22 195,95 266,22 337,95 408,22 479,95 550,22 621,95'/%3E%3C/svg%3E") no-repeat left center / contain;
		mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 673 117'%3E%3Cpolyline fill='none' stroke='%23000' stroke-width='30' stroke-linecap='round' stroke-linejoin='round' points='53,95 124,22 195,95 266,22 337,95 408,22 479,95 550,22 621,95'/%3E%3C/svg%3E") no-repeat left center / contain;
	}

	.atv-contact__lead {
		margin-block-end: 0;
	}

	.atv-contact__grid--sheet .atv-form {
		max-width: 40rem;
	}
}

.atv-contact__grid:not(:has(.atv-contact__aside)) {
	grid-template-columns: minmax(0, 1fr);
}

.atv-form__topics {
	margin: 0 0 var(--spacing-s);
	padding: 0;
	border: 0;
}

.atv-form__topics .hds-fieldset__legend {
	margin-bottom: var(--spacing-2-xs);
	padding: 0;
	font-weight: 600;
}

.atv-form__optional {
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
	color: var(--color-black-60);
}

.atv-topic-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--spacing-2-xs);
}

.atv-topic-chip {
	position: relative;
}

/* The radio stays in the accessibility tree and keyboard order; the label is the chip. */
.atv-topic-chip__input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.atv-topic-chip__label {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 var(--spacing-s);
	border: 1px solid var(--color-black-30);
	border-radius: 999px;
	background: var(--color-white);
	color: var(--atv-navy);
	font-family: var(--font-heading);
	font-size: var(--fontsize-body-s);
	font-weight: 700;
	transition:
		background-color var(--atv-motion-fast) var(--atv-motion-ease),
		border-color var(--atv-motion-fast) var(--atv-motion-ease);
}

.atv-topic-chip--none .atv-topic-chip__label {
	border-style: dashed;
	font-weight: 600;
}

.atv-topic-chip__input:hover + .atv-topic-chip__label {
	border-color: var(--atv-navy);
	background: var(--atv-green-light);
}

.atv-topic-chip__input:checked + .atv-topic-chip__label {
	border-color: var(--atv-navy);
	background: var(--atv-navy);
	color: var(--color-white);
}

.atv-topic-chip__input:focus-visible + .atv-topic-chip__label {
	outline: var(--atv-focus-width) solid var(--atv-focus-light);
	outline-offset: var(--atv-focus-offset);
}

/* ---- Accessibility modes --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.atv-contact-tile,
	.atv-contact-tile__link,
	.atv-topic-chip__label {
		transition: none;
	}

	.atv-contact-tile--write:hover,
	.atv-contact-tile--whatsapp:hover,
	.atv-contact-tile:focus-within {
		transform: none;
	}
}

@media (forced-colors: active) {
	.atv-contact-tile,
	.atv-postcard {
		border: 1px solid CanvasText;
	}

	.atv-contact-tile__link:focus-visible {
		outline-color: Highlight;
	}

	.atv-topic-chip__input:checked + .atv-topic-chip__label {
		border-width: 3px;
		forced-color-adjust: none;
		background: Highlight;
		color: HighlightText;
	}
}
