/*
	Markers on the map, shared by the main screen and by the example scene on the front page.
	The ring's "status-ring" twin, used in the status bar, is turned the same way here so the two always agree.
*/

/* Markers on the map. Each is a round sign with a ring; the ring is in the colour of the intent and empties as time runs out. */

/* The map library positions each marker itself, so no position is set here: doing so would knock markers out of place. */
.pin {
	display: grid;
	justify-items: center;
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-ink);
	font: inherit;
	cursor: pointer;
}

.pin:focus-visible {
	outline: none;
}

.pin:focus-visible .pin-sign {
	outline: 3px solid var(--color-focus);
	outline-offset: 2px;
}

.pin-sign {
	position: relative;
	z-index: 1;
	width: 46px;
	height: 46px;
	border-radius: var(--radius-round);
	background: var(--color-surface);
	box-shadow: 0 1px 2px rgb(20 33 61 / 0.25), 0 6px 16px rgb(20 33 61 / 0.22);
	transition: transform 160ms cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 160ms;
}

/* The marker of the person on the card is larger, and ringed in navy. */
.pin.is-selected {
	z-index: 5;
}

.pin.is-selected .pin-sign {
	box-shadow: 0 0 0 4px var(--color-ink), 0 10px 26px rgb(20 33 61 / 0.4);
	transform: scale(1.2);
	transform-origin: 50% 100%;
}

.pin-area + .pin-sign {
	transform-origin: 50% 50%;
}

.pin:hover .pin-sign {
	transform: scale(1.08);
}

.pin:active .pin-sign {
	transform: scale(0.96);
}

.pin-ring,
.status-ring {
	transform: rotate(-90deg);
}

.pin-ring {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.pin-ring-track,
.pin-ring-arc {
	fill: none;
	stroke-width: 4;
}

.pin-ring-track {
	stroke: #e3e7e5;
}

.pin-ring-arc {
	stroke: var(--intent-color, var(--color-ink));
	/* The ring is redrawn in steps; this turns the steps into a steady movement. */
	transition: stroke-dasharray 300ms linear;
}

.pin-face {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

/* A person's picture sits inside the ring, which stays visible around it. */
.pin-face img {
	width: 36px;
	height: 36px;
	border-radius: var(--radius-round);
	object-fit: cover;
}

.pin-letters {
	position: absolute;
	right: -7px;
	bottom: -5px;
	display: flex;
}

.pin-letters .roundel {
	width: 20px;
	height: 20px;
	margin-left: -5px;
	box-shadow: 0 0 0 2px var(--color-surface);
	font-size: 0.6875rem;
}

/* The label that marks a simulated person, on the marker itself. */
.pin-tag {
	position: absolute;
	top: -6px;
	left: -10px;
	z-index: 2;
	padding: 1px 5px 0;
	border: 1px solid var(--color-line);
	border-radius: 4px;
	background: var(--color-surface);
	color: var(--color-ink-soft);
	font-size: 0.625rem;
	font-weight: 700;
	line-height: 1.4;
}

/*
	The small plate that names a marker: who is there and for how long. It appears for the marker that is chosen or pointed at.
	A plan always shows when it starts, since a hollow marker alone does not say.
*/
.pin-label {
	position: absolute;
	bottom: calc(100% + 16px);
	left: 50%;
	z-index: 3;
	display: none;
	align-items: center;
	gap: 8px;
	height: 28px;
	padding: 1px 10px 0;
	border-radius: 6px;
	background: var(--color-ink);
	color: var(--color-surface);
	box-shadow: var(--shadow-float);
	font-size: 0.78125rem;
	transform: translateX(-50%);
	white-space: nowrap;
	pointer-events: none;
}

.pin-label b {
	font-weight: 700;
}

.pin-label i {
	color: rgb(255 255 255 / 0.76);
	font-style: normal;
}

.pin:hover,
.pin:focus-visible {
	z-index: 4;
}

.pin:hover .pin-label,
.pin:focus-visible .pin-label,
.pin.is-selected .pin-label {
	display: inline-flex;
}

.pin.is-selected .pin-label {
	bottom: calc(100% + 26px);
}

.pin-upcoming:not(:hover):not(:focus-visible):not(.is-selected) .pin-label {
	top: calc(100% + 4px);
	bottom: auto;
	display: inline-flex;
	height: 22px;
	padding: 1px 7px 0;
	background: var(--color-surface);
	box-shadow: 0 1px 4px rgb(20 33 61 / 0.2);
	font-size: 0.71875rem;
}

.pin-upcoming:not(:hover):not(:focus-visible):not(.is-selected) .pin-label b {
	display: none;
}

.pin-upcoming:not(:hover):not(:focus-visible):not(.is-selected) .pin-label i {
	color: var(--color-ink);
	font-weight: 700;
}

/* The stem that points at the exact place. Markers for approximate areas have none. */
.pin-stem {
	width: 3px;
	height: 10px;
	margin-top: -1px;
	border-radius: 0 0 2px 2px;
	background: var(--color-ink);
}

/* An approximate area: a soft disc the true size of the area, so the eye reads "somewhere in here" and not "exactly here". */
.pin-area {
	position: absolute;
	top: 50%;
	left: 50%;
	width: calc(2 * var(--area-radius, 30px));
	height: calc(2 * var(--area-radius, 30px));
	border: 1.5px dashed var(--intent-color, var(--color-ink));
	border-radius: var(--radius-round);
	background: color-mix(in srgb, var(--intent-color, var(--color-ink)) 20%, transparent);
	transform: translate(-50%, -50%);
	pointer-events: none;
}

/* A plan that has not started yet is drawn hollow: a dashed ring, a paler face. */
.pin-upcoming .pin-sign {
	background: rgb(255 255 255 / 0.82);
	box-shadow: 0 2px 8px rgb(20 33 61 / 0.14);
}

.pin-upcoming .pin-ring-track {
	stroke: transparent;
}

.pin-upcoming .pin-ring-arc {
	stroke-width: 3;
}

.pin-upcoming .pin-face img {
	opacity: 0.78;
	filter: saturate(0.6);
}

/* A marker that appears while the map is being watched pulses once. */
.pin-new .pin-sign {
	animation: pin-arrive 1.4s ease-out 1;
}

@keyframes pin-arrive {
	0% {
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--intent-color, var(--color-ink)) 70%, transparent), var(--shadow-float);
		transform: scale(0.6);
	}

	40% {
		transform: scale(1.1);
	}

	100% {
		box-shadow: 0 0 0 22px transparent, var(--shadow-float);
		transform: scale(1);
	}
}

/* A marker whose status has ended fades and shrinks away. The time matches LEAVE_MS in js/app/markers.js. */
.pin-leaving {
	opacity: 0;
	pointer-events: none;
	transition: opacity 280ms ease-in;
}

.pin-leaving .pin-sign {
	transform: scale(0.6);
	transition: transform 280ms ease-in;
}

/* The person's own position: signal yellow, which is used for nothing else on the map. */
.pin-self {
	box-sizing: border-box;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 4px solid var(--color-ink);
	border-radius: var(--radius-round);
	background: var(--color-signal);
	box-shadow: 0 0 0 3px var(--color-surface), 0 0 0 10px rgb(255 196 0 / 0.32), 0 4px 12px rgb(20 33 61 / 0.3);
}

/* On the main screen the person's own marker is a button that shows their status. It is small, so the area that answers to a finger reaches a little beyond what is drawn. */
button.pin-self {
	/* Above other people's markers, so that the person can always find and choose their own. It is small enough to hide very little. */
	z-index: 2;
	cursor: pointer;
}

button.pin-self::after {
	content: "";
	position: absolute;
	inset: -15px;
	border-radius: var(--radius-round);
}

button.pin-self:hover {
	box-shadow: 0 0 0 3px var(--color-surface), 0 0 0 12px rgb(255 196 0 / 0.48), 0 4px 12px rgb(20 33 61 / 0.3);
}

button.pin-self:focus-visible {
	outline: 3px solid var(--color-focus);
	outline-offset: 9px;
}
