/**
 * Subpage section: Offices (template-parts/sections/subpage/section-offices.php).
 *
 * Measured from design/subpages/contact-us.png at 1920 (TODO: verify in
 * Figma):
 * - On the light band (the section's "light" background), a centred .t-h2
 *   heading ~60px above the accordions, which run ~1220px wide (wider than
 *   the 1064px content column).
 * - Each accordion row ~72px: a ~24px Montserrat 500 title, a
 *   ~10 x 5px dark caret ~24px from the end (down when closed, up when
 *   open), a 1px #dbdddf rule below.
 * - Offices in 4 columns on a ~313px pitch (~32px gaps; here 305px, the gap
 *   being each office's end padding so the hairlines run unbroken), rows divided by
 *   1px #ebebeb hairlines, ~40px above each row's names and ~18px below its
 *   "View in map". Each office: a 20px Roboto 500 name, 17px/24px grey
 *   (#636465) address and numbers, a 14px orange "View in map" with a ~16px
 *   map icon; ~14px between them.
 * - A country heading inside a region (no frame, TODO): 17px Roboto 500.
 * Tablet and mobile (TODO, no frame): 3 columns from --bp-lg, 2 from
 * --bp-sm, 1 below. Tokens are local to the section. Logical properties only.
 *
 * @package cartrack
 */

.offices {
	--offices-max: 76.25rem;              /* ~1220px. */
	--offices-rule: #dbdddf;
	--offices-hairline: #ebebeb;
	--offices-title: var(--color-text);   /* Sampled #202021. */
	--offices-text: var(--color-text-muted); /* Sampled #636465. */
	--offices-link: var(--color-text-accent);
	--offices-row-height: 4.5rem;         /* ~72px. */
	--offices-col-gap: 2rem;              /* ~32px. */
	--offices-row-pad-start: 2.5rem;      /* ~40px. */
	--offices-row-pad-end: 1.125rem;      /* ~18px. */
	--offices-item-gap: 0.875rem;         /* ~14px. */
	--offices-title-size: 1.5rem;         /* ~24px. */
	--offices-icon-size: 1rem;

	max-width: calc(var(--offices-max) + 2 * var(--container-gutter));
}

@media (max-width: 63.99em) { /* below --bp-lg */
	.offices {
		--offices-title-size: 1.25rem;    /* TODO: proposal. */
		--offices-row-height: 4rem;
		--offices-row-pad-start: 1.75rem;
	}
}

.offices__heading {
	margin-block-end: var(--space-xl);
	text-align: center;
	overflow-wrap: anywhere;
}

@media (min-width: 64em) { /* --bp-lg */
	.offices__heading {
		margin-block-end: 3.75rem;        /* ~60px. */
	}
}

.offices > .sp-editor-notice {
	margin-block-end: var(--space-md);
}

/* ---------- Accordion rows ---------- */

.accordion--offices .accordion__item {
	border-block-end: 1px solid var(--offices-rule);
}

.accordion--offices .accordion__trigger {
	min-block-size: var(--offices-row-height);
	padding-block: var(--space-sm);
	padding-inline: 0 var(--space-md);
	color: var(--offices-title);
	font-family: var(--font-heading);
	font-size: var(--offices-title-size);
	font-weight: 500;
	line-height: 1.3;
}

.accordion--offices .accordion__title {
	min-inline-size: 0;
	overflow-wrap: anywhere;
}

/* Down-pointing caret; flips up when open. */
.accordion--offices .accordion__icon {
	flex: none;
	inline-size: 0;
	block-size: 0;
	border-inline: 0.3125rem solid transparent;
	border-block-start: 0.3125rem solid currentColor;
	transition: transform var(--transition-fast);
}

.accordion--offices .accordion__trigger[aria-expanded="true"] .accordion__icon {
	transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
	.accordion--offices .accordion__icon {
		transition: none;
	}
}

.accordion--offices .accordion__panel {
	padding-block-end: var(--space-sm);
}

/* ---------- Countries and offices ---------- */

.offices__country + .offices__country {
	margin-block-start: var(--space-lg);
}

.offices__country-name {
	margin: var(--space-xs) 0 0;
	color: var(--offices-title);
	font-family: var(--t-body-bold-family);
	font-size: var(--t-body-bold-size);
	font-weight: var(--t-body-bold-weight);
	line-height: var(--t-body-bold-line-height);
	overflow-wrap: anywhere;
}

/*
 * Rows are divided by a hairline on each office's top edge, except the first
 * row (whose count follows the columns), which starts ~8px under the title.
 * The column gap is each office's end padding, so the hairlines run unbroken
 * across the row (frame).
 */
.offices__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	margin: 0;
	padding: 0;
	list-style: none;
}

.office:first-child {
	padding-block-start: var(--space-xs);
	border-block-start: 0;
}

@media (min-width: 36em) { /* --bp-sm */
	.offices__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.office:nth-child(-n + 2) {
		padding-block-start: var(--space-xs);
		border-block-start: 0;
	}
}

@media (min-width: 64em) { /* --bp-lg */
	.offices__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.office:nth-child(-n + 3) {
		padding-block-start: var(--space-xs);
		border-block-start: 0;
	}
}

@media (min-width: 80em) { /* --bp-xl */
	.offices__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.office:nth-child(-n + 4) {
		padding-block-start: var(--space-xs);
		border-block-start: 0;
	}
}

.office {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--offices-item-gap);
	min-inline-size: 0;
	padding-block: var(--offices-row-pad-start) var(--offices-row-pad-end);
	padding-inline-end: var(--offices-col-gap);
	border-block-start: 1px solid var(--offices-hairline);
	color: var(--offices-text);
	font-family: var(--t-body-family);
	font-size: var(--t-body-size);
	line-height: var(--t-body-line-height);
	overflow-wrap: anywhere;
}

.office__name {
	margin: 0;
	color: var(--offices-title);
	font-family: var(--t-subtitle-medium-family);
	font-size: var(--t-subtitle-medium-size);
	font-weight: var(--t-subtitle-medium-weight);
	line-height: var(--t-subtitle-medium-line-height);
}

.office__address {
	font-style: normal;
}

.office__phones,
.office__email {
	display: flex;
	flex-direction: column;
	margin: 0;
}

.office__phone {
	color: inherit;
	text-decoration: none;
	unicode-bidi: isolate;              /* Numbers keep their order in right-to-left text. */
}

.office__email a {
	color: var(--offices-link);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.office__map {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
	color: var(--offices-link);
	font-family: var(--t-small-family);
	font-size: var(--t-small-size);
	line-height: var(--t-small-line-height);
	text-decoration: none;
}

.office__map .icon {
	flex: none;
	inline-size: var(--offices-icon-size);
	block-size: var(--offices-icon-size);
}

@media (hover: hover) {
	.office__phone:hover,
	.office__map:hover span {
		text-decoration: underline;
		text-underline-offset: 0.15em;
	}
}

.office__phone:focus-visible,
.office__email a:focus-visible,
.office__map:focus-visible {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: 2px;
	border-radius: 2px;
}
