/*
 * Service Map styles — rendered into the `blocks` cascade layer to fit
 * the order declared in assets/css/layers.css.
 *
 * Uses theme tokens from theme.json (navy/amber/white-alpha) so the map
 * surfaces match the dark navy site theme rather than the bright source.
 */

@layer blocks {
	.caravan-service-map {
		display: grid;
		grid-template-columns: 1fr;
		background: var(--wp--preset--color--navy-800);
		border: 1px solid var(--wp--preset--color--white-alpha-15);
		border-radius: var(--wp--custom--radius--lg);
		overflow: hidden;
		box-shadow: var(--wp--preset--shadow--lifted);
		color: var(--wp--preset--color--white);
		position: relative;
		z-index: 0;
	}

	@media (min-width: 1024px) {
		.caravan-service-map {
			grid-template-columns: minmax(280px, 1fr) 2fr;
		}
	}

	/* ----- Sidebar ----- */
	.caravan-service-map__sidebar {
		border-bottom: 1px solid var(--wp--preset--color--white-alpha-15);
	}

	@media (min-width: 1024px) {
		.caravan-service-map__sidebar {
			border-bottom: none;
			border-right: 1px solid var(--wp--preset--color--white-alpha-15);
		}
	}

	.caravan-service-map__sidebar-header {
		background: var(--wp--preset--color--navy-700);
		padding: 1rem;
	}

	.caravan-service-map__sidebar-title {
		margin: 0;
		font-size: 1.125rem;
		font-weight: 700;
		color: var(--wp--preset--color--white);
	}

	.caravan-service-map__sidebar-subtitle {
		margin: 0.25rem 0 0;
		font-size: 0.875rem;
		color: var(--wp--preset--color--white-alpha-65);
	}

	.caravan-service-map__list {
		list-style: none;
		margin: 0;
		padding: 0;
		max-height: 500px;
		overflow-y: auto;
	}

	.caravan-service-map__list > li + li {
		border-top: 1px solid var(--wp--preset--color--white-alpha-15);
	}

	.caravan-service-map__list-item {
		width: 100%;
		display: flex;
		gap: 0.75rem;
		align-items: flex-start;
		padding: 1rem;
		background: transparent;
		color: inherit;
		border: 0;
		border-left: 4px solid transparent;
		text-align: left;
		font: inherit;
		cursor: pointer;
		transition:
			background-color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--ease--out),
			border-color     var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--ease--out);
	}

	.caravan-service-map__list-item:hover {
		background: var(--wp--preset--color--white-alpha-5);
	}

	.caravan-service-map__list-item.is-active {
		background: var(--wp--preset--color--amber-500-alpha-10);
		border-left-color: var(--wp--preset--color--amber-500);
	}

	.caravan-service-map__list-icon {
		flex-shrink: 0;
		width: 36px;
		height: 36px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		border-radius: var(--wp--custom--radius--md);
		background: var(--wp--preset--color--blue-500-alpha-10);
		color: var(--wp--preset--color--amber-400);
	}

	.caravan-service-map__list-icon--headquarters {
		background: var(--wp--preset--color--amber-500-alpha-20);
		color: var(--wp--preset--color--amber-500);
	}

	.caravan-service-map__list-body {
		display: flex;
		flex-direction: column;
		gap: 0.25rem;
		min-width: 0;
		flex: 1;
	}

	.caravan-service-map__list-heading {
		display: flex;
		gap: 0.5rem;
		align-items: center;
		flex-wrap: wrap;
	}

	.caravan-service-map__list-name {
		font-weight: 600;
		color: var(--wp--preset--color--white);
	}

	.caravan-service-map__list-type {
		font-size: 0.7rem;
		text-transform: uppercase;
		letter-spacing: 0.04em;
		padding: 0.125rem 0.5rem;
		background: var(--wp--preset--color--white-alpha-15);
		border-radius: var(--wp--custom--radius--xs);
		color: var(--wp--preset--color--white-alpha-65);
	}

	.caravan-service-map__list-address {
		font-size: 0.875rem;
		color: var(--wp--preset--color--white-alpha-65);
		line-height: 1.35;
	}

	.caravan-service-map__list-phone {
		display: inline-flex;
		align-items: center;
		gap: 0.25rem;
		font-size: 0.8rem;
		color: var(--wp--preset--color--white-alpha-65);
	}

	/* ----- Map area ----- */
	.caravan-service-map__main {
		display: flex;
		flex-direction: column;
		z-index: 0;
	}

	.caravan-service-map__destination {
		display: grid;
		gap: 0.875rem;
		padding: 1rem;
		background: var(--wp--preset--color--navy-900);
		border-bottom: 1px solid var(--wp--preset--color--white-alpha-15);
	}

	@media (min-width: 780px) {
		.caravan-service-map__destination {
			grid-template-columns: minmax(0, 1fr) minmax(320px, 1.3fr);
			align-items: end;
		}
	}

	.caravan-service-map__destination-copy {
		display: grid;
		gap: 0.25rem;
	}

	.caravan-service-map__destination-label {
		font-size: 0.875rem;
		font-weight: 700;
		color: var(--wp--preset--color--white);
	}

	.caravan-service-map__destination-help,
	.caravan-service-map__destination-status {
		margin: 0;
		font-size: 0.8125rem;
		line-height: 1.4;
		color: var(--wp--preset--color--white-alpha-65);
	}

	.caravan-service-map__destination-controls {
		display: grid;
		grid-template-columns: 1fr;
		gap: 0.625rem;
	}

	@media (min-width: 560px) {
		.caravan-service-map__destination-controls {
			grid-template-columns: minmax(0, 1fr) auto;
		}
	}

	.caravan-service-map__destination-input {
		width: 100%;
		min-height: 44px;
		padding: 0.625rem 0.75rem;
		border: 1px solid var(--wp--preset--color--white-alpha-35);
		border-radius: var(--wp--custom--radius--sm);
		background: var(--wp--preset--color--white);
		color: var(--wp--preset--color--navy-900);
		font: inherit;
	}

	.caravan-service-map__destination-input[aria-invalid="true"] {
		border-color: var(--wp--preset--color--amber-500);
		outline: 2px solid var(--wp--preset--color--amber-500-alpha-20);
		outline-offset: 2px;
	}

	.caravan-service-map__destination-submit {
		min-height: 44px;
		padding: 0.625rem 1rem;
		border: 1px solid var(--wp--preset--color--amber-500);
		border-radius: var(--wp--custom--radius--sm);
		background: var(--wp--preset--color--amber-500);
		color: var(--wp--preset--color--navy-950);
		font: inherit;
		font-weight: 700;
		cursor: pointer;
		transition:
			background-color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--ease--out),
			border-color     var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--ease--out);
	}

	.caravan-service-map__destination-submit:hover,
	.caravan-service-map__destination-submit:focus-visible {
		background: var(--wp--preset--color--amber-400);
		border-color: var(--wp--preset--color--amber-400);
	}

	.caravan-service-map__destination-status {
		color: var(--wp--preset--color--amber-300);
	}

	.caravan-service-map__destination-status.is-error {
		color: var(--wp--preset--color--amber-400);
	}

	/* Positioning context for the floating legend + instructions overlay,
	 * scoped to the canvas so it pins to the map, not the column. */
	.caravan-service-map__canvas-frame {
		position: relative;
		z-index: 0;
	}

	.caravan-service-map__canvas {
		width: 100%;
		height: 400px;
		background: var(--wp--preset--color--navy-900);
	}

	@media (min-width: 1024px) {
		.caravan-service-map__canvas {
			height: 500px;
		}
	}

	.caravan-service-map__instructions {
		position: absolute;
		top: 1rem;
		left: 50%;
		transform: translateX(-50%);
		background: var(--wp--preset--color--white-alpha-92);
		color: var(--wp--preset--color--navy-700);
		padding: 0.5rem 1rem;
		border-radius: var(--wp--custom--radius--pill);
		font-size: 0.875rem;
		box-shadow: var(--wp--preset--shadow--chip);
		display: inline-flex;
		align-items: center;
		gap: 0.5rem;
		z-index: 400;
		max-width: calc(100% - 2rem);
	}

	.caravan-service-map__instructions svg {
		color: var(--wp--preset--color--amber-500);
	}

	.caravan-service-map__legend {
		position: absolute;
		right: 1rem;
		bottom: 1rem;
		background: var(--wp--preset--color--white-alpha-92);
		color: var(--wp--preset--color--navy-700);
		padding: 0.75rem 0.875rem;
		border-radius: var(--wp--custom--radius--md);
		font-size: 0.75rem;
		box-shadow: var(--wp--preset--shadow--chip);
		z-index: 400;
	}

	.caravan-service-map__legend-title {
		margin: 0 0 0.5rem;
		font-weight: 600;
	}

	.caravan-service-map__legend-list {
		list-style: none;
		padding: 0;
		margin: 0;
		display: flex;
		flex-direction: column;
		gap: 0.375rem;
	}

	.caravan-service-map__legend-list li {
		display: flex;
		align-items: center;
		gap: 0.5rem;
		color: var(--wp--preset--color--navy-700-alpha-75);
	}

	.caravan-service-map__legend-swatch {
		display: inline-block;
		width: 0.875rem;
		height: 0.875rem;
		border-radius: 50%;
		opacity: 0.75;
	}

	.caravan-service-map__legend-hint {
		margin: 0.5rem 0 0;
		font-size: 0.625rem;
		color: var(--wp--preset--color--navy-700-alpha-55);
	}

	/* ----- Estimate panel ----- */
	.caravan-service-map__estimate {
		background: var(--wp--preset--color--navy-700);
		color: var(--wp--preset--color--white);
		padding: 1rem;
	}

	.caravan-service-map__estimate-title {
		margin: 0 0 0.75rem;
		font-size: 1.125rem;
		font-weight: 700;
	}

	.caravan-service-map__estimate-grid {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 1rem;
	}

	@media (min-width: 640px) {
		.caravan-service-map__estimate-grid {
			grid-template-columns: repeat(4, 1fr);
		}
	}

	.caravan-service-map__estimate-label {
		margin: 0 0 0.25rem;
		font-size: 0.6875rem;
		text-transform: uppercase;
		letter-spacing: 0.06em;
		color: var(--wp--preset--color--white-alpha-65);
	}

	.caravan-service-map__estimate-value {
		margin: 0;
		font-size: 0.95rem;
		font-weight: 600;
		color: var(--wp--preset--color--white);
	}

	.caravan-service-map__estimate-value--accent {
		font-size: 1.125rem;
		color: var(--wp--preset--color--amber-500);
	}

	.caravan-service-map__estimate-phone {
		color: var(--wp--preset--color--white);
		text-decoration: none;
		transition: color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--ease--out);
	}

	.caravan-service-map__estimate-phone:hover,
	.caravan-service-map__estimate-phone:focus-visible {
		color: var(--wp--preset--color--amber-400);
	}

	/* ----- Selected terminal details ----- */
	.caravan-service-map__details {
		background: var(--wp--preset--color--navy-800);
		border-top: 1px solid var(--wp--preset--color--white-alpha-15);
		padding: 1rem;
	}

	.caravan-service-map__details-title {
		margin: 0 0 0.5rem;
		font-size: 1.125rem;
		font-weight: 700;
		color: var(--wp--preset--color--amber-400);
	}

	.caravan-service-map__details-grid {
		display: grid;
		grid-template-columns: 1fr;
		gap: 1rem;
		font-size: 0.875rem;
		color: var(--wp--preset--color--white-alpha-65);
	}

	@media (min-width: 640px) {
		.caravan-service-map__details-grid {
			grid-template-columns: 1fr 1fr;
		}
	}

	.caravan-service-map__details-address {
		font-style: normal;
		line-height: 1.4;
	}

	.caravan-service-map__details-contact {
		display: flex;
		flex-direction: column;
		gap: 0.375rem;
	}

	.caravan-service-map__details-contact a {
		color: var(--wp--preset--color--white-alpha-65);
		text-decoration: none;
		transition: color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--ease--out);
	}

	.caravan-service-map__details-contact a:hover,
	.caravan-service-map__details-contact a:focus-visible {
		color: var(--wp--preset--color--amber-400);
	}

	.caravan-service-map__details-services {
		margin-top: 0.75rem;
	}

	.caravan-service-map__details-services-label {
		font-size: 0.6875rem;
		text-transform: uppercase;
		letter-spacing: 0.06em;
		color: var(--wp--preset--color--white-alpha-65);
	}

	.caravan-service-map__details-services-list {
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
		margin-top: 0.25rem;
	}

	.caravan-service-map__service-tag {
		font-size: 0.75rem;
		padding: 0.25rem 0.5rem;
		background: var(--wp--preset--color--blue-500-alpha-10);
		color: var(--wp--preset--color--amber-400);
		border-radius: var(--wp--custom--radius--xs);
	}

	.caravan-service-map__a11y-note {
		margin: 0;
		padding: 0.5rem 1rem;
		font-size: 0.75rem;
		color: var(--wp--preset--color--white-alpha-35);
		background: var(--wp--preset--color--navy-900);
		border-top: 1px solid var(--wp--preset--color--white-alpha-15);
	}

	/* ----- Leaflet overrides — keep popups readable on the dark theme ----- */
	.leaflet-popup-content-wrapper {
		border-radius: var(--wp--custom--radius--md);
	}

	.leaflet-popup-content {
		margin: 0.5rem 0.75rem;
	}

	.caravan-service-map .leaflet-container {
		font-family: inherit;
	}

	.screen-reader-text {
		clip: rect(1px, 1px, 1px, 1px);
		clip-path: inset(50%);
		height: 1px;
		width: 1px;
		overflow: hidden;
		position: absolute !important;
		white-space: nowrap;
		word-wrap: normal;
	}
}
