/**
 * ELANA Stock Exchange Map.
 *
 * Точките се позиционират в проценти от контейнера, така че картата се
 * мащабира свободно — няма фиксирани пиксели и няма JavaScript за
 * разположението.
 */

.esm {
	--esm-open: #00cd44;
	--esm-closed: #B21C2E;
	--esm-break: #f0a400;
	--esm-dot: 12px;

	max-width: 100%;
	margin: 0 auto;
}

/* ----------------------------------------------------------------- карта */

.esm-map {
	position: relative;
	width: 100%;
}

.esm-map img {
	display: block;
	width: 100%;
	height: auto;
}

/* ------------------------------------------------- статус ред, под картата */

.esm-status {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 32px;
	margin: 18px 0 0;
	padding: 0;
	list-style: none;
	text-align: center;
}

.esm-status li {
	margin: 0;
	padding: 0;
	font-size: 24px;
	line-height: 28px;
	list-style: none;
}

.esm-status-label {
	opacity: 0.85;
}

.esm-status-value {
	font-weight: 600;
	color: var(--esm-closed);
}

[data-esm-state="open"] .esm-status-value {
	color: var(--esm-open);
}

[data-esm-state="break"] .esm-status-value {
	color: var(--esm-break);
}

/* ---------------------------------------------------------------- точки */

/*
 * Котвата е с нулев размер, за да седи точно върху координатата. Бутонът се
 * центрира върху нея, а балончето се подравнява спрямо същата точка.
 *
 * Балончето е брат на бутона, не негово дете — вътре в него има бутон „×",
 * а бутон в бутон е невалиден HTML.
 */
.esm-point {
	position: absolute;
	width: 0;
	height: 0;
}

.esm-point:has( .esm-dot[aria-expanded="true"] ) {
	z-index: 10;
}

.esm-dot {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--esm-dot);
	height: var(--esm-dot);
	margin: calc( var(--esm-dot) / -2 ) 0 0 calc( var(--esm-dot) / -2 );
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--esm-closed);
	cursor: pointer;
	transition: background-color .3s ease;
	-webkit-appearance: none;
	appearance: none;
}

[data-esm-state="open"] .esm-dot {
	background: var(--esm-open);
}

[data-esm-state="break"] .esm-dot {
	background: var(--esm-break);
}

.esm-dot:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 3px;
}

/*
 * Пулсът е отделен ::after, за да не се анимира самият бутон — така
 * разположението му остава непокътнато, а вълната не влияе на оформлението.
 */
.esm-dot::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: inherit;
	opacity: 0;
	pointer-events: none;
}

[data-esm-state="open"] .esm-dot::after {
	animation: esm-pulse 2s cubic-bezier( .4, 0, .6, 1 ) infinite;
}

@keyframes esm-pulse {
	0%   { opacity: .55; transform: scale( 1 ); }
	70%  { opacity: 0;   transform: scale( 2.8 ); }
	100% { opacity: 0;   transform: scale( 2.8 ); }
}

@media ( prefers-reduced-motion: reduce ) {
	[data-esm-state="open"] .esm-dot::after {
		animation: none;
	}
}

/* --------------------------------------------------------------- балонче */

.esm-tip {
	position: absolute;
	bottom: calc( var(--esm-dot) / 2 + 9px );
	left: 0;
	/*
	 * Вдига балончето над съседните точки и без `:has()` по-горе — той е само
	 * подсилване за браузъри, които го поддържат.
	 */
	z-index: 5;
	width: max-content;
	max-width: 260px;
	padding: 10px 28px 10px 12px;
	transform: translateX( -50% );
	border-radius: 4px;
	background: #2b3038;
	color: #fff;
	font-size: 13px;
	line-height: 1.45;
	text-align: left;
	white-space: normal;
	opacity: 0;
	visibility: hidden;
	transition: opacity .15s ease;
	pointer-events: none;
}

.esm-tip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border: 5px solid transparent;
	border-top-color: #2b3038;
}

/* Отваря се само с клик — така работи и на тъч устройства. */
.esm-dot[aria-expanded="true"] + .esm-tip {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.esm-tip > * {
	display: block;
}

.esm-tip-close {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 21px;
	height: 21px;
	padding: 0;
	border: 0;
	border-radius: 3px;
	background: none;
	color: #fff;
	font-size: 18px;
	line-height: 21px;
	text-align: center;
	opacity: .55;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.esm-tip-close:hover,
.esm-tip-close:focus-visible {
	opacity: 1;
	background: rgba( 255, 255, 255, .14 );
}

/* Кодът поема цвета на състоянието — същия сигнал като точката. */
.esm-tip-code {
	margin: 0 0 1px;
	color: var(--esm-closed);
	font-weight: 700;
	letter-spacing: .02em;
}

[data-esm-state="open"] .esm-tip-code {
	color: var(--esm-open);
}

[data-esm-state="break"] .esm-tip-code {
	color: var(--esm-break);
}

.esm-tip-name {
	margin-bottom: 5px;
	font-weight: 600;
}

.esm-tip-clock {
	margin-bottom: 3px;
	font-variant-numeric: tabular-nums;
}

.esm-tip-clock-label {
	opacity: .7;
}

.esm-tip-hours {
	font-variant-numeric: tabular-nums;
}

.esm-tip-break {
	margin-top: 3px;
	font-variant-numeric: tabular-nums;
}

.esm-tip-note {
	margin-top: 2px;
	opacity: .62;
	font-size: 11px;
	line-height: 1.35;
}

.esm-tip-hours:empty,
.esm-tip-break:empty,
.esm-tip-note:empty {
	display: none;
}

/*
 * Балончетата на точките в двата края излизат извън картата. Изместват се
 * навътре, вместо да се реже overflow — картата трябва да остане видима.
 */
.esm-point[data-esm-edge="left"] .esm-tip {
	left: calc( var(--esm-dot) / -2 );
	transform: none;
}

.esm-point[data-esm-edge="left"] .esm-tip::after {
	left: var(--esm-dot);
}

.esm-point[data-esm-edge="right"] .esm-tip {
	left: auto;
	right: calc( var(--esm-dot) / -2 );
	transform: none;
}

.esm-point[data-esm-edge="right"] .esm-tip::after {
	left: auto;
	right: calc( var(--esm-dot) / 2 );
}

@media ( max-width: 690px ) {
	.esm {
		--esm-dot: 10px;
	}

	.esm-status {
		gap: 6px 20px;
	}

	.esm-status li {
		font-size: 17px;
		line-height: 22px;
	}

	.esm-tip {
		max-width: 220px;
		font-size: 12px;
	}
}
