/**
 * ODP County Map — Frontend Styles
 *
 * All rules scoped under .odp-map-wrapper to avoid theme conflicts.
 * Colors are driven by CSS custom properties set inline on .odp-map-wrapper
 * by odp-map.js from the settings passed via wp_localize_script.
 * Default values fall back to Altitude Pro theme variables, then hardcoded hex.
 *
 * --odp-fill   : default county fill
 * --odp-hover  : hover fill
 * --odp-active : selected/active fill
 */

/* =========================================================================
   Outer wrapper
   ========================================================================= */

.odp-map-wrapper {
	width: 100%;
	box-sizing: border-box;
	font-family: inherit;
}

/* =========================================================================
   Search bar
   ========================================================================= */

.odp-map-search-bar {
	margin-bottom: 12px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.odp-map-search-bar label {
	font-weight: 600;
	white-space: nowrap;
	color: inherit;
	margin: 0;
}

.odp-map-search-bar .odp-county-search-input {
	flex: 1;
	min-width: 200px;
	max-width: 340px;
	padding: 8px 12px;
	border: 2px solid var(--odp-active, var(--darkblue, #043c49));
	border-radius: 4px;
	font-size: 1rem;
	background: #fff;
	color: inherit;
}

.odp-map-search-bar .odp-county-search-input:focus {
	outline: 3px solid var(--odp-hover, var(--lightblue, #36748c));
	outline-offset: 2px;
}

/* =========================================================================
   Map + sidebar flex container
   ========================================================================= */

.odp-map-container {
	display: flex;
	align-items: flex-start;
	gap: 20px;
	width: 100%;
}

/* Sidebar on the right (default) */
.odp-map-container.odp-sidebar-right {
	flex-direction: row;
}

/* Sidebar on the left */
.odp-map-container.odp-sidebar-left {
	flex-direction: row-reverse;
}

/* =========================================================================
   SVG wrapper
   ========================================================================= */

.odp-map-svg-wrapper {
	flex: 0 0 65%;
	max-width: 65%;
	box-sizing: border-box;
}

.odp-map-svg-wrapper svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

/* =========================================================================
   County paths and groups — visual states
   ========================================================================= */

/* Default fill for all county paths/groups */
.odp-map-svg-wrapper path[data-county],
.odp-map-svg-wrapper g[data-county] path {
	fill:            var(--odp-fill,  var(--lightgrey,  #f2f1ee));
	stroke:          var(--odp-active, var(--darkblue, #043c49));
	stroke-width:    58;   /* SVG coordinate units — scales with viewBox */
	stroke-linejoin: round;
	transition:      fill 0.15s ease;
	cursor:          pointer;
}

/* Hover state — applied by JS via class */
.odp-map-svg-wrapper path.odp-county--hover,
.odp-map-svg-wrapper g.odp-county--hover path {
	fill: var(--odp-hover, var(--darkblue, #043c49));
}

/* Active / selected state — applied by JS via class */
.odp-map-svg-wrapper path.odp-county--active,
.odp-map-svg-wrapper g.odp-county--active path {
	fill: var(--odp-active, var(--red, #c5002f));
}

/* Keyboard focus — JS adds .odp-county--hover on focusin (more reliable
   than :focus-visible on SVG paths cross-browser). The CSS class handles
   the visual. This rule is a belt-and-suspenders fallback. */
.odp-map-svg-wrapper path[data-county]:focus,
.odp-map-svg-wrapper g[data-county]:focus {
	outline: none; /* Managed via fill class instead */
}

/* County text labels — visible, non-interactive */
.odp-map-svg-wrapper .odp-map-labels {
	display: block;
	pointer-events: none; /* clicks pass through to county paths below */
}

.odp-map-svg-wrapper .odp-map-labels text {
	fill:        var(--odp-active, var(--darkblue, #043c49)) !important;
	stroke:      none !important;
	pointer-events: none;
	font-family: 'Roboto Slab', serif !important;
}

/* White label when the matching county is hovered, focused, or selected */
.odp-map-svg-wrapper .odp-map-labels text.odp-label--light {
	fill: #ffffff !important;
}

/* =========================================================================
   Sidebar
   ========================================================================= */

.odp-map-sidebar {
	flex: 1;
	min-width: 0;
	box-sizing: border-box;
	padding: 16px 20px;
	background: var(--lightgrey, #f2f1ee);
	border-left: 4px solid var(--odp-hover, var(--darkblue, #043c49));
	border-radius: 0 4px 4px 0;
	font-size: 0.95rem;
	line-height: 1.6;
}

/* Left sidebar variant — flip the border */
.odp-sidebar-left .odp-map-sidebar {
	border-left:  none;
	border-right: 4px solid var(--odp-hover, var(--darkblue, #043c49));
	border-radius: 4px 0 0 4px;
}

/* Default (empty) state message */
.odp-map-sidebar .odp-sidebar-default {
	color: #666;
	font-style: italic;
}

/* County name heading — override theme h2 styles */
.odp-map-sidebar .odp-sidebar-county-name {
	font-size: 1.4rem;
	font-weight: 700;
	color: var(--odp-hover, var(--darkblue, #043c49));
	margin: 0 0 12px;
	padding: 0;
	border: none;
	line-height: 1.3;
}

/* Field rows */
.odp-sidebar-field {
	margin-bottom: 8px;
}

.odp-sidebar-label {
	font-weight: 600;
	color: var(--darkblue, #043c49);
	margin-right: 4px;
}

/* Address — preserve line breaks */
.odp-sidebar-address {
	white-space: pre-line;
	margin: 0;
}

/* Links */
.odp-map-sidebar a {
	color: var(--odp-hover, var(--darkblue, #043c49));
	text-decoration: underline;
}

.odp-map-sidebar a:hover {
	color: var(--odp-active, var(--red, #c5002f));
}

/* Social icons row */
.odp-sidebar-social {
	display: flex;
	gap: 10px;
	margin-top: 10px;
	align-items: center;
}

.odp-sidebar-social a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--odp-hover, var(--darkblue, #043c49));
	color: #fff;
	text-decoration: none;
	transition: background 0.15s ease;
	flex-shrink: 0;
}

.odp-sidebar-social a:hover {
	background: var(--odp-active, var(--red, #c5002f));
	color: #fff;
}

.odp-sidebar-social svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
}

/* Sample ballot button */
.odp-ballot-btn {
	display: inline-block;
	margin-top: 14px;
	padding: 10px 20px;
	background: var(--odp-active, var(--red, #c5002f));
	color: #fff !important;
	font-weight: 700;
	font-size: 0.95rem;
	text-decoration: none !important;
	border-radius: 4px;
	transition: background 0.15s ease, transform 0.1s ease;
	border: none;
	cursor: pointer;
}

.odp-ballot-btn:hover {
	background: var(--odp-hover, var(--darkblue, #043c49));
	color: #fff !important;
	transform: translateY(-1px);
}

.odp-ballot-btn:focus-visible {
	outline: 3px solid var(--odp-active, var(--red, #c5002f));
	outline-offset: 3px;
}

/* Loading state */
.odp-sidebar-loading {
	color: #666;
	font-style: italic;
}

.odp-sidebar-loading::before {
	content: '';
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid #ccc;
	border-top-color: var(--odp-hover, var(--darkblue, #043c49));
	border-radius: 50%;
	animation: odp-spin 0.6s linear infinite;
	margin-right: 8px;
	vertical-align: middle;
}

@keyframes odp-spin {
	to { transform: rotate(360deg); }
}

/* Error state */
.odp-sidebar-error {
	color: var(--odp-active, var(--red, #c5002f));
	font-style: italic;
}

/* Mobile close button — hidden on desktop */
.odp-sidebar-close {
	display: none;
	float: right;
	background: none;
	border: none;
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	color: #666;
	padding: 0 0 4px 8px;
	margin: -4px -4px 8px 8px;
}

.odp-sidebar-close:hover {
	color: var(--odp-active, var(--red, #c5002f));
}

/* =========================================================================
   Responsive — mobile (≤768px)
   ========================================================================= */

@media ( max-width: 768px ) {

	.odp-map-container,
	.odp-map-container.odp-sidebar-right,
	.odp-map-container.odp-sidebar-left {
		flex-direction: column;
	}

	.odp-map-svg-wrapper {
		flex: none;
		max-width: 100%;
		width: 100%;
	}

	.odp-map-sidebar {
		width: 100%;
		border-left:   none;
		border-right:  none;
		border-top:    4px solid var(--odp-hover, var(--darkblue, #043c49));
		border-radius: 0 0 4px 4px;
	}

	/* Show close button on mobile */
	.odp-sidebar-close {
		display: block;
	}
}

/* =========================================================================
   Max-height on SVG wrapper (set via inline style by shortcode height="" attr)
   ========================================================================= */

/* Applied as inline style="max-height:{n}px" when height attribute is set */
