/**
 * Public Frontend Styles
 *
 * Styles for the [interactive_map] shortcode output:
 * responsive image, hotspot markers, pulse animation, modal overlay.
 *
 * Fully namespaced under .ch-map — zero global conflicts.
 *
 * @package CustomHotspot
 * @since   1.0.0
 */

/* -------------------------------------------------------
   1. Map Container
   ------------------------------------------------------- */

.ch-map {
	position: relative;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #1d2327;
	box-sizing: border-box;
}

.ch-map *,
.ch-map *::before,
.ch-map *::after {
	box-sizing: inherit;
}

/* -------------------------------------------------------
   2. Image Wrapper (responsive)
   ------------------------------------------------------- */

.ch-map__image-wrap {
	position: relative;
	display: inline-block;
	width: 100%;
	line-height: 0;
	overflow: hidden;
	border-radius: 4px;
	contain: layout style;
}

.ch-map__image {
	width: 100%;
	height: auto;
	display: block;
}

/* -------------------------------------------------------
   3. Hotspot Buttons (responsive, percentage-based)
   ------------------------------------------------------- */

.ch-map__hotspot {
	position: absolute;
	--hs-pct: 3%;
	--hs-min: 28px;
	--hs-size: max(var(--hs-min), var(--hs-pct));
	width: var(--hs-size);
	height: var(--hs-size);
	aspect-ratio: 1;
	margin-left: calc(var(--hs-size) / -2);
	margin-top: calc(var(--hs-size) / -2);
	border-radius: 50%;
	border: 2px solid #fff;
	background: #3498db;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	z-index: 10;
	transition: transform 200ms ease, box-shadow 200ms ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Colour variants */
.ch-map__hotspot--blue   { background: #3498db; }
.ch-map__hotspot--red    { background: #e74c3c; }
.ch-map__hotspot--green  { background: #2ecc71; }
.ch-map__hotspot--orange { background: #e67e22; }
.ch-map__hotspot--purple { background: #9b59b6; }
.ch-map__hotspot--dark   { background: #2c3e50; }

/* Hover state (desktop) */
.ch-map__hotspot:hover {
	transform: scale(1.2);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* Focus visible (keyboard navigation) */
.ch-map__hotspot:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 2px;
}

/* Size variants — override percentage + minimum */
.ch-map__hotspot--size-sm {
	--hs-pct: 2.2%;
	--hs-min: 22px;
}

.ch-map__hotspot--size-md {
	/* Default — 3% / 28px, inherits base styles */
}

.ch-map__hotspot--size-lg {
	--hs-pct: 4%;
	--hs-min: 36px;
}

/* Touch targets — raise minimum floor for WCAG compliance */
@media ( pointer: coarse ) {
	.ch-map__hotspot          { --hs-min: 44px; }
	.ch-map__hotspot--size-sm { --hs-min: 36px; }
	.ch-map__hotspot--size-lg { --hs-min: 48px; }
}

/* SVG icon — scales proportionally at 45% of hotspot size */
.ch-map__hotspot-icon {
	stroke: #fff;
	fill: none;
	stroke-width: 2;
	width: 45%;
	height: 45%;
	pointer-events: none;
}

/* -------------------------------------------------------
   4. Modal Overlay
   ------------------------------------------------------- */

.ch-map__modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 250ms ease, visibility 250ms ease;
}

.ch-map__modal.is-open {
	opacity: 1;
	visibility: visible;
}

.ch-map__modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
}

/* -------------------------------------------------------
   5. Modal Content
   ------------------------------------------------------- */

.ch-map__modal-content {
	position: relative;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
	max-width: 560px;
	width: 92%;
	max-height: 85vh;
	overflow-y: auto;
	transform: translateY(16px);
	transition: transform 250ms ease;
	z-index: 1;
}

.ch-map__modal.is-open .ch-map__modal-content {
	transform: translateY(0);
}

/* Close button */
.ch-map__modal-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 36px;
	height: 36px;
	border: none;
	background: rgba(255, 255, 255, 0.85);
	font-size: 24px;
	color: #1d2327;
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 150ms ease, background 150ms ease;
	z-index: 2;
	padding: 0;
	line-height: 1;
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}

.ch-map__modal-close:hover {
	color: #000;
	background: rgba(255, 255, 255, 0.95);
}

.ch-map__modal-close:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Featured image */
.ch-map__modal-image {
	border-radius: 8px 8px 0 0;
	overflow: hidden;
	line-height: 0;
}

.ch-map__modal-image img {
	width: 100%;
	height: auto;
	display: block;
	max-height: 300px;
	object-fit: cover;
}

/* Body */
.ch-map__modal-body {
	padding: 24px;
}

.ch-map__modal-title {
	font-size: 20px;
	font-weight: 600;
	margin: 0 0 12px;
	line-height: 1.3;
}

.ch-map__modal-description {
	color: #646970;
	margin: 0 0 16px;
}

.ch-map__modal-description:empty {
	display: none;
}

.ch-map__modal-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: #2271b1;
	text-decoration: none;
	font-weight: 500;
}

.ch-map__modal-link:hover {
	text-decoration: underline;
}

/* Dark card colour — light text for readability */
.ch-map__modal-content--dark-card .ch-map__modal-title {
	color: #f0f0f0;
}

.ch-map__modal-content--dark-card .ch-map__modal-description {
	color: rgba(255, 255, 255, 0.8);
}

.ch-map__modal-content--dark-card .ch-map__modal-link {
	color: #93c5fd;
}

/* -------------------------------------------------------
   6. Accessibility: Reduced Motion
   ------------------------------------------------------- */

@media ( prefers-reduced-motion: reduce ) {
	.ch-map__hotspot-pulse {
		animation: none;
	}

	.ch-map__modal,
	.ch-map__modal-content {
		transition: none;
	}

	.ch-map__hotspot {
		transition: none;
	}
}

/* -------------------------------------------------------
   7. Modal Size Variants
   ------------------------------------------------------- */

.ch-map__modal-content--size-sm {
	max-width: 400px;
}

.ch-map__modal-content--size-sm .ch-map__modal-title {
	font-size: 17px;
}

.ch-map__modal-content--size-sm .ch-map__modal-body {
	padding: 16px;
}

.ch-map__modal-content--size-sm .ch-map__modal-image img {
	max-height: 200px;
}

/* md = default (560px) — no override needed */

.ch-map__modal-content--size-lg {
	max-width: 800px;
}

.ch-map__modal-content--size-lg .ch-map__modal-title {
	font-size: 24px;
}

.ch-map__modal-content--size-lg .ch-map__modal-image img,
.ch-map__modal-content--size-lg .ch-map__carousel-slide img {
	max-height: 450px;
}

/* -------------------------------------------------------
   8. Image-Only Modal
   ------------------------------------------------------- */

.ch-map__modal-content--image-only {
	overflow: hidden;
}

.ch-map__modal-content--image-only .ch-map__modal-image {
	border-radius: 8px;
}

/* -------------------------------------------------------
   9. Carousel
   ------------------------------------------------------- */

.ch-map__carousel {
	position: relative;
	overflow: hidden;
}

.ch-map__carousel-track {
	position: relative;
	width: 100%;
	overflow: hidden;
}

.ch-map__carousel-slide {
	display: none;
	width: 100%;
	line-height: 0;
}

.ch-map__carousel-slide.is-active {
	display: block;
	animation: ch-carousel-fade 400ms ease;
}

@keyframes ch-carousel-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.ch-map__carousel-slide img {
	width: 100%;
	height: auto;
	display: block;
	max-height: 300px;
	object-fit: cover;
	user-select: none;
	-webkit-user-drag: none;
}

.ch-map__carousel-prev,
.ch-map__carousel-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: rgba(0, 0, 0, 0.4);
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 200ms ease;
	z-index: 2;
	padding: 0;
}

.ch-map__carousel:hover .ch-map__carousel-prev,
.ch-map__carousel:hover .ch-map__carousel-next {
	opacity: 1;
}

.ch-map__carousel-prev { left: 8px; }
.ch-map__carousel-next { right: 8px; }

@media ( prefers-reduced-motion: reduce ) {
	.ch-map__carousel-slide.is-active {
		animation: none;
	}
}

/* -------------------------------------------------------
   10. Responsive: Mobile Modal + Carousel
   ------------------------------------------------------- */

@media ( pointer: coarse ) {
	.ch-map__carousel-prev,
	.ch-map__carousel-next {
		opacity: 0.7;
		width: 40px;
		height: 40px;
	}
}

@media ( max-width: 600px ) {
	.ch-map__modal-content,
	.ch-map__modal-content--size-sm,
	.ch-map__modal-content--size-lg {
		max-width: none;
		width: 96%;
		max-height: 90vh;
	}

	.ch-map__modal-body {
		padding: 16px;
	}
}

/* -------------------------------------------------------
   11. Error message (admin-only)
   ------------------------------------------------------- */

.ch-shortcode-error {
	padding: 8px;
	font-size: 13px;
}

.ch-map__modal-title {
  color: #000;
}

.ch-map__hotspot-pulse {
  animation: none;
}

@media (max-width: 767px) {
  .ch-map__hotspot {
    max-width: 20px;
    max-height: 20px;
  }
}

.ch-map__image-wrap {
  max-width: 700px;
  max-height: 700px;
}