/* ============================================================
   Baker Donelson - Autonomous Vehicle State Guide (v2, second revision)
   Built to fill the height of its iframe exactly. No vh units
   are used inside this file - inside a frame, vh resolves
   against the frame, not the device.

   Recommended embed:
   <iframe src="av-state-guide-v2.html" width="95%" height="760"
           scrolling="no" frameborder="0"
           style="width:95%;height:clamp(560px,88vh,900px);border:0"></iframe>
   ============================================================ */

html,
body {
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden; /* the panel is the only scroll context */
	background: #ffffff;
}

.av-guide {
	--av-teal: #006983;
	--av-teal-dark: #00566b;
	--av-red: #d51b1e;
	--av-ink: #22272b;
	--av-muted: #5c6670;
	--av-rule: #d6dbdf;
	--av-panel-bg: #ffffff;
	--av-stroke: #ffffff;
	--av-font: Arial, Helvetica, "Helvetica Neue", sans-serif;

	font-family: var(--av-font);
	color: var(--av-ink);
	line-height: 1.5;
	box-sizing: border-box;
	height: 100%;
	max-width: 1180px;
	margin: 0 auto;
	padding: 10px;
	display: flex;
	flex-direction: column;
	position: relative; /* anchor for the mobile sheet */
}

.av-guide *,
.av-guide *::before,
.av-guide *::after {
	box-sizing: inherit;
}

/* ---------- Two-column shell ---------- */

.av-layout {
	flex: 1 1 auto;
	min-height: 0; /* lets children shrink instead of overflowing */
	display: grid;
	grid-template-columns: minmax(0, 1.75fr) minmax(330px, 1fr);
	grid-template-rows: auto minmax(0, 1fr);
	/* Explicit areas. The picker is a direct child of the grid so it
	   can move above the map on small screens, which means placement
	   must be stated - auto-placement would push the panel to row 2. */
	grid-template-areas:
		"map picker"
		"map panel";
	column-gap: 22px;
	row-gap: 10px;
	align-items: stretch;
}

/* ---------- Left column: map ---------- */

.av-map-col {
	grid-area: map;
	min-width: 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
}

.av-map-wrap {
	flex: 0 1 auto;
	min-height: 0;
	display: flex;
}

/* The SVG scales to whatever box it is given, in both axes. */
.av-map-wrap svg {
	width: 100%;
	height: auto;
	max-height: 100%;
	display: block;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	touch-action: manipulation;
}

.av-state {
	fill: var(--av-fill, var(--av-teal));
	stroke: var(--av-stroke);
	stroke-width: 0.8;
	stroke-linejoin: round;
	cursor: pointer;
	outline: none;
	transition: fill 120ms ease-in-out;
}

.av-state:hover {
	fill: var(--av-fill-over, var(--av-red));
}

.av-state.is-selected {
	fill: var(--av-fill-over, var(--av-red));
	stroke-width: 1.4;
}

.av-state:focus-visible {
	stroke: #ffd400;
	stroke-width: 2.2;
}

.av-label {
	fill: #ffffff;
	font-family: var(--av-font);
	font-size: 10px;
	font-weight: bold;
	text-anchor: middle;
	dominant-baseline: middle;
	pointer-events: none;
}

.av-map-hint {
	flex: 0 0 auto;
	color: var(--av-muted);
	font-size: 12px;
	margin: 8px 2px 0;
}

/* ---------- Right column: detail panel ---------- */

.av-panel-col {
	grid-area: panel;
	min-width: 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.av-picker {
	grid-area: picker;
	flex: 0 0 auto;
	align-self: end;
}

.av-picker label {
	display: block;
	font-size: 12px;
	font-weight: bold;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--av-muted);
	margin-bottom: 4px;
}

.av-picker select {
	width: 100%;
	font-family: var(--av-font);
	font-size: 14px;
	color: var(--av-ink);
	padding: 7px 9px;
	border: 1px solid var(--av-rule);
	background: #fff;
	border-radius: 0;
}

.av-picker select:focus-visible {
	outline: 2px solid var(--av-teal);
	outline-offset: 1px;
}

.av-panel {
	flex: 1 1 auto;
	min-height: 0;
	border: 1px solid var(--av-rule);
	background: var(--av-panel-bg);
	display: flex;
	flex-direction: column;
}

.av-panel-head {
	flex: 0 0 auto;
	background: var(--av-teal);
	color: #fff;
	padding: 11px 14px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.av-panel-heading {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: baseline;
	gap: 9px;
}

.av-panel-abbr {
	flex: 0 0 auto;
	font-size: 12px;
	font-weight: bold;
	letter-spacing: 0.08em;
	opacity: 0.75;
}

.av-panel-title {
	font-size: 19px;
	font-weight: bold;
	margin: 0;
	line-height: 1.2;
	color: #fff;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.av-panel-btn {
	flex: 0 0 auto;
	font-family: var(--av-font);
	font-size: 12px;
	line-height: 1;
	color: #fff;
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.5);
	padding: 7px 9px;
	cursor: pointer;
	border-radius: 2px;
}

.av-panel-btn:hover {
	background: rgba(255, 255, 255, 0.15);
}

.av-panel-btn:focus-visible {
	outline: 2px solid #ffd400;
	outline-offset: 1px;
}

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

.av-panel-close {
	display: none; /* mobile sheet only */
	font-size: 15px;
	padding: 7px 11px;
}

.av-panel-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 15px 17px 20px;
	font-size: 14px;
	scrollbar-gutter: stable;
	scrollbar-color: #a8b4bb #eef1f2;
	scrollbar-width: thin;
}

.av-panel-body::-webkit-scrollbar {
	width: 12px;
}

.av-panel-body::-webkit-scrollbar-track {
	background: #eef1f2;
}

.av-panel-body::-webkit-scrollbar-thumb {
	background: #a8b4bb;
	border: 3px solid #eef1f2;
	border-radius: 6px;
}

.av-panel-body::-webkit-scrollbar-thumb:hover {
	background: var(--av-teal);
}

.av-panel-body p {
	margin: 0 0 14px;
}

.av-panel-body p:last-child {
	margin-bottom: 0;
}

.av-panel-body strong {
	color: var(--av-teal-dark);
}

.av-panel-body p + p {
	border-top: 1px solid var(--av-rule);
	padding-top: 14px;
}

.av-panel-empty {
	color: var(--av-muted);
	font-size: 14px;
}

.av-panel-empty p {
	margin: 0 0 10px;
}

.av-panel-empty strong {
	display: block;
	color: var(--av-ink);
	font-size: 16px;
	margin-bottom: 6px;
}

.av-sr-status {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------- Mobile: panel becomes a sheet over the map ---------- */

@media (max-width: 860px) {
	.av-guide {
		padding: 8px;
	}

	.av-layout {
		grid-template-columns: 1fr;
		grid-template-rows: auto minmax(0, 1fr);
		grid-template-areas:
			"picker"
			"map";
		column-gap: 0;
		row-gap: 10px;
	}

	/* The dropdown is the real interface at this width, so it
	   sits above the map rather than beside it. */
	.av-picker {
		align-self: auto;
	}

	.av-map-col {
		min-height: 0;
	}

	.av-map-hint {
		display: none;
	}

	.av-panel-col {
		position: absolute;
		inset: 0;
		z-index: 5;
		background: #fff;
		padding: 8px;
		transform: translateY(101%);
		visibility: hidden;
		transition: transform 220ms ease-out, visibility 0s linear 220ms;
	}

	.av-panel-col.is-open {
		transform: translateY(0);
		visibility: visible;
		transition: transform 220ms ease-out, visibility 0s;
	}

	.av-panel-close {
		display: block;
	}

	.av-panel-title {
		font-size: 18px;
	}

	.av-panel-body {
		font-size: 16px;
		line-height: 1.6;
		padding: 16px 16px 24px;
	}

	/* 16px stops iOS Safari zooming the frame on focus */
	.av-picker select {
		font-size: 16px;
		padding: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.av-state {
		transition: none;
	}

	.av-panel-col {
		transition: none;
	}
}

/* ---------- Print ---------- */

@media print {
	html,
	body {
		height: auto;
		overflow: visible;
	}

	.av-guide {
		height: auto;
	}

	.av-layout {
		grid-template-columns: 1fr;
	}

	.av-panel-col {
		position: static;
		transform: none;
		visibility: visible;
	}

	.av-panel-body {
		overflow: visible;
	}

	.av-picker,
	.av-map-hint,
	.av-panel-btn {
		display: none;
	}
}
