/* ==========================================================================
   OFFICE LOCATION CARDS
   Layered over the base card in main.css (section 15). Every hover from
   there is kept -- the city photo fading in and settling, the lift, the
   green border, the text easing right -- and refined: the photo now sits
   behind a veil so the address stays readable over it.

   Added: a gradient border that turns on hover, a pointer-following glow
   and tilt (js/office-locations.js sets --mx/--my/--rx/--ry), an outlined
   country code, a phone icon and a filled map button.

   Selectors lead with .locations-grid so they outrank main.css, and the
   copies of it merged into the service-page bundles, without !important.
   ========================================================================== */

@property --loc-angle {
	syntax: "<angle>";
	inherits: false;
	initial-value: 0deg;
}

.locations-grid {
	--loc-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--loc-accent-text: #139c57; /* 3.5:1+ on white; the brand green is 2:1 */
	gap: clamp(1rem, 1.6vw, 1.5rem);
	perspective: 1400px;
}
[data-theme="dark"] .locations-grid { --loc-accent-text: var(--color-accent); }

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.locations-grid .location-card {
	isolation: isolate;
	min-height: 300px;
	padding: 28px 26px 26px;
	gap: 18px;
	border-radius: 22px;
	box-shadow:
		0 1px 2px rgba(var(--ink-rgb), 0.04),
		0 22px 44px -30px rgba(var(--ink-rgb), 0.35);
	transform: translateY(0) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
	transition:
		opacity 0.7s var(--loc-ease),
		transform 0.6s var(--loc-ease),
		border-color 0.5s var(--loc-ease),
		box-shadow 0.5s var(--loc-ease);
	will-change: transform;
}
/* Before reveal: main.js adds .is-visible as the section scrolls in. */
.locations-grid .location-card.reveal-item:not(.is-visible) {
	transform: translateY(28px) scale(0.98);
}
/* Once revealed, drop the stagger so hover answers immediately. */
.locations-grid .location-card.loc-settled { transition-delay: 0s; }

.locations-grid .location-card:hover {
	border-color: transparent;
	transform: translateY(-8px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
	box-shadow:
		0 2px 4px rgba(var(--ink-rgb), 0.04),
		0 40px 70px -34px rgba(var(--color-accent-rgb), 0.55);
}

/* Gradient border, spinning slowly while hovered. */
.locations-grid .location-card::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	padding: 1.5px;
	border-radius: inherit;
	background: conic-gradient(from var(--loc-angle), #26d07c, #00a499, rgba(var(--color-accent-rgb), 0.15), #26d07c);
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
	opacity: 0;
	transition: opacity 0.5s var(--loc-ease);
	animation: loc-spin 6s linear infinite paused;
	pointer-events: none;
}
.locations-grid .location-card:hover::before {
	opacity: 1;
	animation-play-state: running;
}
@keyframes loc-spin { to { --loc-angle: 360deg; } }

/* Glow under the pointer. */
.locations-grid .location-card::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	border-radius: inherit;
	background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 0%), rgba(var(--color-accent-rgb), 0.16), transparent 60%);
	opacity: 0;
	transition: opacity 0.4s var(--loc-ease);
	pointer-events: none;
}
.locations-grid .location-card:hover::after { opacity: 1; }

/* City photo: fades in and settles on hover, as before, now under a veil
   that clears the top of the card and keeps the text area solid. */
.locations-grid .location-card .loc-bg {
	background-image:
		linear-gradient(180deg,
			color-mix(in srgb, var(--card-bg) 10%, transparent) 0%,
			color-mix(in srgb, var(--card-bg) 78%, transparent) 32%,
			color-mix(in srgb, var(--card-bg) 95%, transparent) 55%,
			var(--card-bg) 100%),
		var(--city-bg);
	opacity: 0;
	transform: scale(1.12);
	filter: saturate(0.9);
}
.locations-grid .location-card:hover .loc-bg {
	opacity: 1;
	transform: scale(1);
	filter: saturate(1.1) contrast(1.05);
}

/* Outlined country code, bottom right. */
.locations-grid .loc-code {
	position: absolute;
	right: 18px;
	bottom: 8px;
	z-index: 1;
	font-size: 76px;
	font-weight: 800;
	line-height: 1;
	letter-spacing: -0.05em;
	color: transparent;
	-webkit-text-stroke: 1px rgba(var(--ink-rgb), 0.1);
	transition: transform 0.7s var(--loc-ease), -webkit-text-stroke-color 0.5s var(--loc-ease), color 0.5s var(--loc-ease);
	pointer-events: none;
	user-select: none;
}
[data-theme="dark"] .locations-grid .loc-code { -webkit-text-stroke-color: rgba(255, 255, 255, 0.1); }
.locations-grid .location-card:hover .loc-code {
	color: rgba(var(--color-accent-rgb), 0.07);
	-webkit-text-stroke-color: rgba(var(--color-accent-rgb), 0.55);
	transform: translate3d(-6px, -6px, 0);
}

/* --------------------------------------------------------------------------
   Top row: flag
   -------------------------------------------------------------------------- */
.locations-grid .loc-top {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.locations-grid .loc-flag {
	width: 46px;
	height: 31px;
	border-radius: 7px;
	box-shadow:
		0 0 0 1px rgba(var(--ink-rgb), 0.08),
		0 8px 18px -8px rgba(var(--ink-rgb), 0.45);
	transform-origin: left center;
	transition: transform 0.5s var(--loc-ease), box-shadow 0.5s var(--loc-ease);
}
/* A light sheen crosses the flag on hover. */
.locations-grid .loc-flag::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
	transform: translateX(-120%);
	pointer-events: none;
}
.locations-grid .location-card:hover .loc-flag {
	transform: scale(1.08) rotate(-3deg);
	box-shadow:
		0 0 0 1px rgba(var(--ink-rgb), 0.06),
		0 12px 24px -8px rgba(var(--ink-rgb), 0.5);
}
.locations-grid .location-card:hover .loc-flag::after {
	transform: translateX(120%);
	transition: transform 0.9s var(--loc-ease);
}

/* --------------------------------------------------------------------------
   Body
   -------------------------------------------------------------------------- */
.locations-grid .loc-body {
	z-index: 2;
	flex: 1 1 auto;
	gap: 0.6rem;
}
.locations-grid .loc-body h3 {
	position: relative;
	margin: 0;
	padding-bottom: 0.55rem;
	font-size: 1.22rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}
/* Accent rule that draws out under the name. */
.locations-grid .loc-body h3::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 22px;
	height: 2px;
	border-radius: 2px;
	background: linear-gradient(90deg, #26d07c, #00a499);
	transition: width 0.6s var(--loc-ease);
}
.locations-grid .location-card:hover .loc-body h3::after { width: 64px; }

.locations-grid .loc-body p {
	margin: 0;
	font-size: 0.86rem;
	line-height: 1.6;
}

/* Optional "Details" line from the Office Locations block: a quieter second line under the address. */
.locations-grid .loc-body .loc-details {
	margin-top: -0.35rem;
	font-size: 0.86em;
	opacity: 0.85;
}
.locations-grid .loc-body .loc-details a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.locations-grid .loc-phone {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	width: fit-content;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--loc-accent-text);
	text-decoration: none;
	transition: color 0.3s var(--loc-ease), transform 0.4s var(--loc-ease);
}
.locations-grid .loc-phone::before {
	content: "";
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background:
		rgba(var(--color-accent-rgb), 0.12)
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23139c57' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8 9.9a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2z'/%3E%3C/svg%3E")
		center / 13px no-repeat;
	transition: background-color 0.3s var(--loc-ease), transform 0.4s var(--loc-ease);
}
.locations-grid .loc-phone:hover { color: var(--color-text); }
.locations-grid .loc-phone:hover::before {
	background-color: rgba(var(--color-accent-rgb), 0.28);
	transform: rotate(-14deg) scale(1.08);
}

/* Map button: pinned to the bottom so the four line up, and filled with the
   brand gradient on hover. */
.locations-grid .loc-map-btn {
	position: relative;
	overflow: hidden;
	isolation: isolate;
	margin-top: auto;
	padding: 0.6rem 1rem;
	border-radius: 999px;
	background: color-mix(in srgb, var(--card-bg) 85%, transparent);
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--color-text);
	text-decoration: none;
	transition: color 0.35s var(--loc-ease), border-color 0.35s var(--loc-ease), box-shadow 0.35s var(--loc-ease), transform 0.4s var(--loc-ease);
}
.locations-grid .loc-map-btn::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(135deg, #26d07c, #00a499);
	transform: translateX(-101%);
	transition: transform 0.45s var(--loc-ease);
}
.locations-grid .loc-map-btn::after {
	content: "";
	width: 12px;
	height: 12px;
	margin-left: -14px;
	background: currentColor;
	opacity: 0;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: opacity 0.35s var(--loc-ease), margin 0.35s var(--loc-ease);
}
.locations-grid .loc-map-btn:hover {
	color: #ffffff;
	border-color: transparent;
	background: color-mix(in srgb, var(--card-bg) 85%, transparent);
	box-shadow: 0 12px 26px -12px rgba(var(--color-accent-rgb), 0.8);
}
.locations-grid .loc-map-btn:hover::before { transform: translateX(0); }
.locations-grid .loc-map-btn:hover::after { opacity: 1; margin-left: 2px; }
.locations-grid .loc-map-btn:focus-visible {
	outline: 3px solid rgba(var(--color-accent-rgb), 0.5);
	outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Reduced motion: keep the colour changes, drop the movement
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   Five offices (Vietnam added Oct 2026)

   Five across on wide screens, with slightly tighter cards. Narrower, the
   cards sit on a doubled grid (each spans two tracks) so the short last row
   is centred instead of hanging off the left.
   -------------------------------------------------------------------------- */
@media (min-width: 1200px) {
	.locations-grid:has(> .location-card:nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
	.locations-grid:has(> .location-card:nth-child(5):last-child) .location-card { padding: 26px 22px 22px; }
}
@media (min-width: 1100px) and (max-width: 1199px) {
	.locations-grid:has(> .location-card:nth-child(5):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
	.locations-grid:has(> .location-card:nth-child(5):last-child) .location-card { grid-column: span 2; }
	.locations-grid:has(> .location-card:nth-child(5):last-child) .location-card:nth-child(4) { grid-column: 2 / span 2; }
}
@media (min-width: 601px) and (max-width: 1099px) {
	.locations-grid:has(> .location-card:nth-child(5):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.locations-grid:has(> .location-card:nth-child(5):last-child) .location-card { grid-column: span 2; }
	.locations-grid:has(> .location-card:nth-child(5):last-child) .location-card:nth-child(5) { grid-column: 2 / span 2; }
}

@media (prefers-reduced-motion: reduce) {
	.locations-grid .location-card,
	.locations-grid .location-card:hover,
	.locations-grid .location-card.reveal-item:not(.is-visible) { transform: none; }
	.locations-grid .location-card::before { animation: none; }
	.locations-grid .location-card:hover .loc-flag,
	.locations-grid .location-card:hover .loc-code,
	.locations-grid .loc-phone:hover::before { transform: none; }
}
