/* ============================================================
   Homepage "What's nearby": four places on a dotted trail with gold
   pins; the trail draws itself on when it scrolls into view
   (assets/js/main.js). Below 961px the trail gives way to a list with a
   dotted rule under each place. (prototype: .nearby, .trail, .place)
   ============================================================ */

.nearby__inner {
	padding-block: var(--space-section);
}

.trail {
	--trail-top: 256px;
	--trail-band: 180px;
	position: relative;
	margin-top: 10px;
}

.trail__line,
.trail__steps {
	display: none;
}

.trail__places {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 30px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.trail__place {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 0 0 28px;
	background: radial-gradient(circle, var(--color-text) 1px, transparent 1.3px) left bottom / 8px 3px repeat-x;
}

.trail__text {
	display: grid;
	align-content: start;
	gap: 10px;
	text-decoration: none;
}

.trail__title {
	font-size: 34px;
	line-height: 1.05;
	transition: color 0.4s;
}

.trail__text:focus-visible .trail__title {
	color: var(--color-accent);
}

.trail__desc {
	font-size: 14px;
	line-height: 1.7;
}

.trail__pin {
	order: -1;
	color: var(--color-accent);
	transition: transform 0.5s var(--ease);
}

@media (hover: hover) {
	.trail__text:hover .trail__title {
		color: var(--color-accent);
	}

	.trail__place:hover .trail__pin {
		transform: translateY(-5px);
	}
}

@media (min-width: 481px) {
	.trail__places {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 40px 48px;
	}
}

/* The trail: four equal columns with no gap, so each column's left edge
   lands on a turn of the line (0, 25, 50, 75%). Odd places sit above the
   line, even ones below. */
@media (min-width: 961px) {
	.trail__line {
		position: absolute;
		top: var(--trail-top);
		left: 0;
		display: block;
		width: 100%;
		height: var(--trail-band);
		overflow: visible;
	}

	.trail__dots {
		fill: none;
		stroke: var(--color-text);
		stroke-width: 1.6;
		stroke-dasharray: 1.5 7;
		stroke-linecap: round;
	}

	.trail__mask-path {
		fill: none;
		stroke: var(--color-mask-show);
		stroke-width: 8;
		stroke-dasharray: var(--trail-len, 1400);
		stroke-dashoffset: 0;
	}

	.trail.is-armed .trail__mask-path {
		stroke-dashoffset: var(--trail-len, 1400);
	}

	/* Fallback only (assets/js/trail.js did not run): the dotted line draws
	   one stretch at a time, pausing at each pin. The four bends of the path
	   mirror each other, so each stretch is exactly a quarter of its length. */
	.trail.is-armed.is-in:not(.has-steps) .trail__mask-path {
		animation: tlo-trail-draw 4.05s ease-in-out both;
	}

	/* Footsteps (assets/js/trail.js): drawn on one canvas over the trail -
	   round, crisp dots at any display scaling, and light on the browser (an
	   earlier version animated ~160 separate elements and could lag). The
	   path stays as their geometry but is no longer drawn. */
	.trail.has-steps .trail__line {
		visibility: hidden;
	}

	.trail__steps {
		position: absolute;
		top: 0;
		left: 0;
		display: block;
		pointer-events: none;
	}

	.trail__places {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 0;
	}

	/* Rows: above the line (fixed, so the odd places' text sits on it), the
	   line's band, then the even places' text (only as tall as it is, so the
	   section ends one --space-section below the last words). */
	.trail__place {
		display: grid;
		grid-template-rows: var(--trail-top) var(--trail-band) auto;
		gap: 0;
		padding: 0 24px 0 0;
		background: none;
	}

	.trail__text {
		grid-row: 1;
		align-content: end;
		padding-bottom: 30px;
	}

	.trail__place:nth-child(even) .trail__text {
		grid-row: 3;
		align-content: start;
		padding-bottom: 0;
	}

	.trail__title {
		font-size: clamp(30px, 2.6vw, 38px);
	}

	.trail__desc {
		max-width: 250px;
	}

	.trail__pin {
		grid-row: 2;
		order: 0;
		align-self: start;
		margin-top: calc(var(--trail-band) * 0.127 - 20px);
		margin-left: -8px;
	}

	.trail__place:nth-child(even) .trail__pin {
		margin-top: calc(var(--trail-band) * 0.873 - 20px);
	}
}

@media (min-width: 1181px) {
	.trail {
		--trail-top: 236px;
	}

	.trail__place {
		padding-right: 32px;
	}
}

/* ============================================================
   The entry story (Miles 2026-11-24). assets/js/main.js arms the trail
   (.is-armed) only when it starts below the fold and motion is welcome,
   and adds .is-in once it is well in view. Until then the places and pins
   wait unseen; content is never hidden without JS or under reduced motion.

   Desktop: Warton Crag's text rises in (0s) and its pin drops (0.225s);
   from 0.45s footsteps (assets/js/trail.js, on a canvas: a dot every 9px,
   14ms apart, each landing over 0.32s) walk to the 2nd stop, whose pin pops
   as the last step lands, then its text; a 0.16s pause and on to the 3rd
   and 4th; the walk then runs off to the edge (about 3.5s at 1440).
   Phones and tablets (no trail line): the four places come in one after
   another, 0.2s apart.
   ============================================================ */

.trail.is-armed .trail__text,
.trail.is-armed .trail__pin .icon {
	opacity: 0;
}

.trail.is-armed.is-in .trail__text {
	animation: tlo-place-in 0.5s var(--ease) both;
}

/* The pin drops in from just above with a small bounce (the span keeps its
   own hover lift; only the drawing moves). */
.trail.is-armed.is-in .trail__pin .icon {
	transform-origin: 50% 100%;
	animation: tlo-pin-drop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.trail.is-armed.is-in .trail__place:nth-child(2) .trail__text,
.trail.is-armed.is-in .trail__place:nth-child(2) .trail__pin .icon {
	animation-delay: 0.2s;
}

.trail.is-armed.is-in .trail__place:nth-child(3) .trail__text,
.trail.is-armed.is-in .trail__place:nth-child(3) .trail__pin .icon {
	animation-delay: 0.4s;
}

.trail.is-armed.is-in .trail__place:nth-child(4) .trail__text,
.trail.is-armed.is-in .trail__place:nth-child(4) .trail__pin .icon {
	animation-delay: 0.6s;
}

/* Desktop: each place's pin and text wait for the walk. With footsteps the
   times come from assets/js/trail.js (--pin-delay / --text-delay on each
   place, so the pin pops as the last step of its stretch lands); the
   fallback times match the fallback drawn line. */
@media (min-width: 961px) {
	.trail.is-armed.is-in .trail__place:nth-child(1) .trail__pin .icon {
		animation-delay: var(--pin-delay, 0.35s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(1) .trail__text {
		animation-delay: var(--text-delay, 0s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(2) .trail__pin .icon {
		animation-delay: var(--pin-delay, 1.3s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(2) .trail__text {
		animation-delay: var(--text-delay, 1.4s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(3) .trail__pin .icon {
		animation-delay: var(--pin-delay, 2.25s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(3) .trail__text {
		animation-delay: var(--text-delay, 2.35s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(4) .trail__pin .icon {
		animation-delay: var(--pin-delay, 3.2s);
	}

	.trail.is-armed.is-in .trail__place:nth-child(4) .trail__text {
		animation-delay: var(--text-delay, 3.3s);
	}
}


@keyframes tlo-place-in {
	from {
		opacity: 0;
		transform: translateY(14px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes tlo-pin-drop {
	from {
		opacity: 0;
		transform: translateY(-14px) scale(0.4);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* Holds where a pin pops: 0.7s, 1.3-1.65s, 2.25-2.6s, 3.2-3.55s of 4.05s. */
@keyframes tlo-trail-draw {
	0%,
	17.28% {
		stroke-dashoffset: var(--trail-len, 1400);
	}

	32.1%,
	40.74% {
		stroke-dashoffset: calc(var(--trail-len, 1400) * 0.75);
	}

	55.56%,
	64.2% {
		stroke-dashoffset: calc(var(--trail-len, 1400) * 0.5);
	}

	79.01%,
	87.65% {
		stroke-dashoffset: calc(var(--trail-len, 1400) * 0.25);
	}

	100% {
		stroke-dashoffset: 0;
	}
}
