/**
 * Component: site footer.
 *
 * One flat grid, so each block can move between the mobile and desktop
 * orders with grid areas while the DOM keeps a logical reading order.
 * Mobile (as in the frame): logo, link-column accordions, newsletter,
 * office, divider, language + social, badges, legal, copyright.
 * From --bp-md: brand and columns side by side, then social/badges and the
 * newsletter, then the bottom row. Values come from assets/css/tokens.css.
 *
 * @package cartrack
 */

.site-footer {
	overflow-x: clip; /* Full-bleed dividers. */
	background-color: var(--footer-bg);
	color: var(--footer-text);
	font-family: var(--font-body);
	font-size: var(--footer-text-size);
	line-height: var(--footer-text-line-height);
}

.site-footer a {
	color: inherit;
	text-decoration: none;
	transition: color var(--transition-fast);
}

.site-footer a:hover {
	color: var(--footer-link-hover);
}

.site-footer a:focus-visible,
.site-footer button:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

.site-footer__inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"brand brand"
		"columns columns"
		"newsletter newsletter"
		"office office"
		"rule-top rule-top"
		"locale social"
		"countries countries"
		"badges badges"
		"meta meta";
	align-items: start;
	max-width: calc(var(--footer-max) + 2 * var(--container-gutter));
	margin-inline: auto;
	padding: var(--footer-padding-top) var(--container-gutter) var(--footer-padding-bottom);
}

.site-footer__brand { grid-area: brand; }
.site-footer__columns { grid-area: columns; }
.site-footer__office { grid-area: office; }
.site-footer__rule--top { grid-area: rule-top; }
.site-footer__social { grid-area: social; }
.site-footer__badges { grid-area: badges; }
.site-footer__newsletter { grid-area: newsletter; }
.site-footer__rule--bottom { grid-area: rule-bottom; }
.site-footer__locale { grid-area: locale; }
.country-panel { grid-area: countries; }
.site-footer__meta { grid-area: meta; }

/* Full-bleed hairline. */
.site-footer__rule {
	width: 100vw;
	height: 1px;
	margin-inline: calc(50% - 50vw);
	background-color: var(--footer-rule);
}

.site-footer__rule--top {
	margin-block: var(--footer-row-gap-small);
}

/* Mobile frame has no divider above the bottom row. */
.site-footer__rule--bottom {
	display: none;
}

/* ---------- Brand ---------- */

.site-footer__logo {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	color: var(--footer-text);
	font-family: var(--font-heading);
	font-size: var(--footer-logo-height);
	font-weight: var(--font-weight-bold);
	line-height: 1;
	letter-spacing: -0.01em;
	text-transform: uppercase;
}

.site-footer__logo-mark {
	width: auto;
	height: 1.05em;
}

.site-footer__logo-image {
	width: auto;
	height: var(--footer-logo-height);
}

/* ---------- Link columns ---------- */

.site-footer__columns {
	margin-top: var(--footer-padding-top);
}

.footer-column {
	border-bottom: 1px solid var(--footer-rule);
}

.footer-column__title {
	margin: 0;
	padding-block: var(--space-sm);
	color: inherit;
	font-family: var(--font-heading);
	font-size: var(--footer-title-size);
	font-weight: var(--font-weight-semibold);
	line-height: var(--footer-heading-line-height);
	letter-spacing: var(--footer-heading-tracking);
}

/* Accordion trigger, added by js/footer.js below --bp-md. */
.footer-column__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-sm);
	width: 100%;
	min-height: var(--footer-accordion-height);
	margin-block: calc(var(--space-sm) * -1);
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: start;
	cursor: pointer;
}

.footer-column__toggle .icon {
	flex: none;
	width: var(--footer-icon-size);
	height: var(--footer-icon-size);
	transition: transform var(--transition-fast);
}

.footer-column__toggle[aria-expanded="true"] .icon {
	transform: rotate(180deg);
}

.footer-column__list {
	display: grid;
	gap: var(--footer-link-gap);
	margin: 0;
	padding: 0 0 var(--space-md);
	list-style: none;
	font-size: var(--footer-link-size);
	line-height: var(--footer-link-line-height);
}

.footer-column__list[hidden] {
	display: none;
}

/* "We're hiring!" chip (menu item Badge field). */
.footer-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2xs);
	margin-inline-start: var(--space-xs);
	padding: 0.0625rem var(--space-2xs);
	border: 1px solid var(--footer-chip-border);
	border-radius: var(--radius-sm);
	font-size: var(--footer-chip-size);
	line-height: var(--line-height-snug);
	vertical-align: middle;
	white-space: nowrap;
}

.footer-chip .icon {
	width: 1.1em;
	height: 1.1em;
}

/* ---------- Office ---------- */

.site-footer__office {
	margin-top: var(--footer-row-gap-small);
}

.site-footer__heading {
	margin: 0 0 var(--space-xs);
	color: inherit;
	font-family: var(--font-heading);
	font-size: var(--footer-heading-size);
	font-weight: var(--font-weight-semibold);
	line-height: var(--footer-heading-line-height);
	letter-spacing: var(--footer-heading-tracking);
}

.site-footer__address-block {
	font-style: normal;
}

.site-footer__address,
.site-footer__hours {
	margin: 0;
}

.site-footer__hours {
	margin-top: var(--space-sm);
	color: var(--footer-text-muted);
}

.site-footer__contact {
	display: grid;
	gap: var(--space-xs);
	margin: var(--space-md) 0 0;
	padding: 0;
	list-style: none;
}

.site-footer__contact-link {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
}

.site-footer__contact-link .icon {
	flex: none;
	width: var(--footer-icon-size);
	height: var(--footer-icon-size);
}

/* ---------- Social and app badges ---------- */

.site-footer__social {
	display: flex;
	align-items: center;
	gap: var(--space-sm);
	align-self: center;
	justify-self: end;
}

/* Not in the mobile frame. */
.site-footer__social-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.footer-social {
	display: flex;
	align-items: center;
	gap: var(--footer-social-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.footer-social__link {
	display: block;
}

.footer-social__icon {
	display: block;
	width: var(--footer-social-size);
	height: var(--footer-social-size);
}

.site-footer__badges {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--footer-badge-gap);
	margin: var(--space-lg) 0 0;
	padding: 0;
	list-style: none;
}

.app-badge {
	display: block;
}

.app-badge__image {
	display: block;
	width: auto;
	height: var(--footer-badge-height);
}

/* ---------- Newsletter ---------- */

/* The form keeps its earlier inherited size and line-height (its text stays as it is); the title sets its own. */
.site-footer__newsletter {
	margin-top: var(--footer-row-gap-small);
	font-size: var(--footer-newsletter-text-size);
	line-height: var(--footer-newsletter-line-height);
}

/* Not in the mobile frame (the placeholder carries the message). */
.site-footer__newsletter-title {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------- Bottom row ---------- */

.site-footer__locale {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	align-self: center;
	gap: var(--space-xs) var(--space-md);
	color: var(--footer-text-muted);
}

.country-toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
	padding: var(--space-2xs) 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

span.country-toggle {
	cursor: default;
}

.country-toggle .icon {
	flex: none;
	width: var(--footer-icon-size);
	height: var(--footer-icon-size);
}

.country-toggle .icon--caret {
	transition: transform var(--transition-fast);
}

.country-toggle[aria-expanded="true"] .icon--caret {
	transform: rotate(180deg);
}

.country-toggle:hover {
	color: var(--footer-text);
}

/* TranslatePress shortcode switcher: keep it on the footer palette. */
.site-footer__language .trp-language-switcher {
	color: inherit;
}

/* Country panel (visible without JS; js/footer.js hides it on load). */
.country-panel {
	margin-top: var(--space-md);
	padding: var(--space-lg) 0;
	border-block: 1px solid var(--footer-rule);
}

.country-panel[hidden] {
	display: none;
}

.country-panel__regions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-lg) var(--space-md);
}

.country-panel__title {
	margin: 0 0 var(--space-sm);
	color: inherit;
	font-family: var(--font-heading);
	font-size: var(--footer-heading-size);
	font-weight: var(--font-weight-semibold);
	line-height: var(--footer-heading-line-height);
	letter-spacing: var(--footer-heading-tracking);
}

.country-panel__list {
	display: grid;
	gap: var(--space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

.country-panel__link {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
}

.country-panel__flag {
	flex: none;
	width: var(--footer-flag-width);
	height: auto;
	border-radius: 1px;
}

.site-footer__meta {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-lg);
	margin-top: var(--space-lg);
	text-align: center;
}

/* Mobile frame: legal links above the copyright. */
.site-footer__copyright {
	order: 1;
	margin: 0;
	font-size: var(--footer-text-font-size);
}

.footer-legal {
	display: grid;
	gap: var(--space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ==========================================================================
   From --bp-md: columns open, two-column rows
   ========================================================================== */

@media (min-width: 48em) { /* --bp-md */
	.site-footer {
		background-color: var(--footer-bg-desktop);
		font-size: var(--footer-text-size-desktop);
	}

	.site-footer__inner {
		grid-template-columns: minmax(0, var(--footer-brand-width)) minmax(0, 1fr) auto;
		grid-template-areas:
			"brand columns columns"
			"office columns columns"
			"rule-top rule-top rule-top"
			"social . newsletter"
			"badges . newsletter"
			"countries countries countries"
			"rule-bottom rule-bottom rule-bottom"
			"locale meta meta";
		grid-template-rows: auto minmax(0, 1fr); /* Office sits under the logo; the tall columns stretch row 2. */
		padding-top: var(--footer-padding-top-desktop);
		padding-bottom: var(--footer-padding-bottom-desktop);
	}

	.site-footer__logo {
		font-size: var(--footer-logo-height-desktop);
	}

	.site-footer__logo-image {
		height: var(--footer-logo-height-desktop);
	}

	.site-footer__columns {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--space-xl) var(--footer-column-gap);
		margin-top: 0;
	}

	.footer-column {
		border-bottom: 0;
	}

	.footer-column__title {
		margin-bottom: var(--footer-title-gap);
		padding: 0;
		font-size: var(--footer-title-size-desktop);
	}

	.footer-column__list {
		gap: var(--footer-link-gap-desktop);
		padding: 0;
		font-size: var(--footer-link-size-desktop);
	}

	.site-footer__office {
		margin-top: var(--space-lg);
		padding-inline-end: var(--space-lg);
	}

	.site-footer__heading {
		font-size: var(--footer-heading-size-desktop);
	}

	.site-footer__rule--top {
		margin-block: var(--footer-row-gap) var(--footer-row-gap-small);
	}

	.site-footer__social {
		align-self: start;
		justify-self: start;
	}

	.site-footer__social-label {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip-path: none;
		margin: 0;
		font-family: var(--font-heading);
		font-size: var(--footer-heading-size-desktop);
		font-weight: var(--font-weight-semibold);
		line-height: var(--footer-heading-line-height);
		letter-spacing: var(--footer-heading-tracking);
	}

	.footer-social__icon {
		width: var(--footer-social-size-desktop);
		height: var(--footer-social-size-desktop);
	}

	/* Bottom-aligned with the newsletter, as in the frame. */
	.site-footer__badges {
		align-self: end;
		justify-content: flex-start;
		margin-top: var(--space-md);
	}

	.app-badge__image {
		height: var(--footer-badge-height-desktop);
	}

	.site-footer__newsletter {
		width: min(var(--footer-newsletter-width), 100%);
		margin-top: 0;
		justify-self: end;
		font-size: var(--footer-newsletter-text-size-desktop);
	}

	.site-footer__newsletter-title {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip-path: none;
		margin-bottom: var(--space-sm);
		white-space: normal;
	}

	.site-footer__rule--bottom {
		display: block;
		margin-block: var(--footer-row-gap-small) var(--space-md);
	}

	.country-panel {
		margin-top: var(--footer-row-gap-small);
		padding-bottom: 0;
		border-bottom: 0;
	}

	.country-panel__regions {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.site-footer__meta {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: flex-end;
		gap: var(--space-xs) var(--footer-legal-gap);
		margin-top: 0;
		text-align: start;
	}

	.site-footer__copyright {
		order: 0;
		font-size: inherit;
	}

	.footer-legal {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-xs) var(--footer-legal-gap);
	}

	.site-footer__meta {
		align-self: center;
	}
}

/* ==========================================================================
   From --bp-lg: four link columns
   ========================================================================== */

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

@media (prefers-reduced-motion: reduce) {
	.footer-column__toggle .icon,
	.country-toggle .icon--caret {
		transition: none;
	}
}
