/*
 * Spectator guide on Race Details (includes/nhm-spectators.php).
 * Uses the redesign's --nhm-* tokens when present; the fallbacks are the
 * live site's colours, so it also reads on the current design.
 */

.nhm-spec {
	--spec-ink: var(--nhm-ink, #222);
	--spec-dark: var(--nhm-navy, #394a53);
	--spec-accent: var(--nhm-gold, #ffc120);
	--spec-accent-ink: var(--nhm-gold-ink, #8a5b0c);
	--spec-soft: var(--nhm-cream, #f7f7f4);
	--spec-line: var(--nhm-line, #e2e2dc);
	--spec-muted: var(--nhm-steel-ink, #5b6870);
	--spec-r: var(--nhm-r-lg, 10px);
	--spec-display: var(--nhm-display, inherit);
	container-type: inline-size;
	margin: 8px 0 40px;
	color: var(--spec-ink);
}

.nhm-spec__head { margin-bottom: 16px; }

.nhm-spec .nhm-spec__title {
	margin: 0 0 6px;
	font-family: var(--spec-display);
}

.nhm-spec__lede {
	margin: 0;
	max-width: 62ch;
}

.nhm-spec__proto {
	margin: 0 0 16px;
	padding: 10px 14px;
	border-left: 4px solid var(--spec-accent);
	border-radius: 4px;
	background: var(--spec-soft);
	font-size: .9em;
}

/* ---------- controls ---------- */

.nhm-spec__controls {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 12px 28px;
	margin-bottom: 16px;
}

.nhm-spec__controls[hidden],
.nhm-spec__map[hidden],
.nhm-spec.nhm-spec .nhm-spec__actions button.nhm-spec__show[hidden] { display: none !important; }

.nhm-spec__races {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.nhm-spec__label {
	display: block;
	margin: 0 0 6px;
	padding: 0;
	font-size: .8em;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--spec-muted);
}

.nhm-spec__seg {
	display: inline-flex;
	border: 2px solid var(--spec-dark);
	border-radius: 999px;
	overflow: hidden;
}

.nhm-spec__seg-opt {
	position: relative;
	margin: 0;
	cursor: pointer;
}

.nhm-spec__seg-opt input {
	position: absolute;
	opacity: 0;
	inset: 0;
	margin: 0;
	cursor: pointer;
}

.nhm-spec__seg-opt span {
	display: block;
	padding: 7px 16px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	color: var(--spec-dark);
}

.nhm-spec__seg-opt + .nhm-spec__seg-opt span { border-left: 2px solid var(--spec-dark); }

.nhm-spec__seg-opt input:checked + span {
	background: var(--spec-dark);
	color: #fff;
}

.nhm-spec__seg-opt input:focus-visible + span {
	outline: 3px solid var(--spec-accent);
	outline-offset: -5px;
}

.nhm-spec__pace-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.nhm-spec .nhm-spec__pace input {
	width: 5.5em;
	margin: 0;
	padding: 7px 10px;
	border: 2px solid var(--spec-line);
	border-radius: 6px;
	font: inherit;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	text-align: center;
}

.nhm-spec .nhm-spec__pace input:focus {
	border-color: var(--spec-dark);
	outline: none;
}

.nhm-spec .nhm-spec__pace input[aria-invalid="true"] { border-color: #b3261e; }

.nhm-spec__finish {
	flex-basis: 100%;
	margin: 0;
	font-size: .9em;
	color: var(--spec-muted);
}

/* ---------- map + list ---------- */

.nhm-spec__body {
	display: grid;
	gap: 16px;
}

.nhm-spec__map {
	height: min(70vw, 420px);
	min-height: 300px;
	border-radius: var(--spec-r);
	border: 1px solid var(--spec-line);
	z-index: 0; /* keep Leaflet panes under the sticky header */
	background: #dfe8ea;
}

.entry-content .nhm-spec__list,
.nhm-spec__list {
	display: grid;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.entry-content .nhm-spec .nhm-spec__vp {
	display: flex;
	gap: 12px;
	margin: 0;
	padding: 12px 14px;
	border: 1px solid var(--spec-line);
	border-radius: var(--spec-r);
	background: #fff;
	transition: border-color .15s, box-shadow .15s, opacity .15s;
}

.nhm-spec__vp.is-active {
	border-color: var(--spec-dark);
	box-shadow: 0 0 0 1px var(--spec-dark);
}

.nhm-spec__vp.is-off { opacity: .55; }

.nhm-spec__num {
	flex: none;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--spec-dark);
	color: #fff;
	font-weight: 700;
	font-size: 14px;
}

.nhm-spec__vp.is-active .nhm-spec__num {
	background: var(--spec-accent);
	color: var(--spec-ink);
}

.nhm-spec__info { min-width: 0; }

/* beats .nhm-has-page-hero .entry-content h3 { margin-top: 1.4em } */
body .entry-content .nhm-spec .nhm-spec__name {
	margin: 2px 0 2px;
	font-size: 1.15rem;
	line-height: 1.25;
}

.nhm-spec__est {
	margin-left: 4px;
	padding: 1px 6px;
	border-radius: 999px;
	background: var(--spec-soft);
	border: 1px solid var(--spec-line);
	font-size: .7em;
	font-weight: 600;
	letter-spacing: .03em;
	color: var(--spec-muted);
	vertical-align: middle;
}

.nhm-spec__when {
	margin: 0;
	font-variant-numeric: tabular-nums;
}

.nhm-spec__note {
	margin: 4px 0 0;
	font-size: .9em;
	color: var(--spec-muted);
}

.nhm-spec__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 16px;
	margin: 6px 0 0;
	font-size: .9em;
}

/* A text link that happens to be a <button>: undo Mai's button styling.

   It is also excluded from the redesign's catch-all button rule by name — see
   :not(.nhm-spec__show) in assets/css/nhm-redesign.css — and that is the only
   place that fight can be won: every :not() argument counts, so the redesign's
   rule is as specific as this one and nhm-redesign.css prints AFTER this file
   (wp_head 120 vs wp_enqueue_scripts 30), so ties go to the redesign. Before it
   was excluded, the redesign's 48px uppercase navy button rendered until the
   pointer arrived: :is(:hover…) tipped this selector over the tie, the text link
   took over, the row collapsed around the cursor, and a list of nine strobed.
   Same trap as the course map's .nhm-cm__fit: if this control grows back into a
   chunky button, or changes size on hover, look in nhm-redesign.css, not here. */
.nhm-spec.nhm-spec .nhm-spec__actions button.nhm-spec__show.nhm-spec__show,
.nhm-spec.nhm-spec .nhm-spec__actions button.nhm-spec__show.nhm-spec__show:is(:hover, :focus, :focus-visible, :active) {
	display: inline;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0 !important;
	border-radius: 0;
	background: none !important;
	box-shadow: none !important;
	font: inherit !important;
	font-weight: 700 !important;
	letter-spacing: 0 !important;
	text-transform: none;
	color: var(--spec-dark) !important;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* Colour only — nothing here may change the box. */
.nhm-spec.nhm-spec .nhm-spec__actions button.nhm-spec__show.nhm-spec__show:hover { color: var(--spec-ink) !important; }
.nhm-spec.nhm-spec .nhm-spec__actions button.nhm-spec__show.nhm-spec__show:focus-visible { outline: 2px solid var(--spec-dark); outline-offset: 2px; }

.nhm-spec .nhm-spec__dir {
	font-weight: 700;
	color: var(--spec-dark);
	text-underline-offset: 3px;
}

.nhm-spec__foot {
	margin: 14px 0 0;
	font-size: .9em;
	color: var(--spec-muted);
}

.nhm-spec__foot a { font-weight: 700; }

@container (min-width: 560px) {
	.nhm-spec__list { grid-template-columns: 1fr 1fr; }
}

@container (min-width: 960px) {
	.nhm-spec__body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
	.nhm-spec__map { height: 560px; }
	.nhm-spec__list {
		grid-template-columns: 1fr;
		grid-auto-rows: max-content; /* a theme rule gives li min-height:0, which lets rows squash to fit 560px */
		max-height: 560px;
		overflow-y: auto;
		align-content: start;
		padding-right: 4px; /* room for the scrollbar */
	}
}

/* ---------- Leaflet bits ---------- */

.nhm-spec .nhm-spec-course { stroke: var(--spec-dark); }

.nhm-spec-pin span {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	box-sizing: border-box;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--spec-dark);
	color: #fff;
	font: 700 14px/1 var(--nhm-text, system-ui, sans-serif);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
	transition: transform .15s;
}

.nhm-spec-pin.is-active span {
	background: var(--spec-accent);
	color: var(--spec-ink);
	transform: scale(1.2);
}

.nhm-spec-pin.is-off span {
	background: #9aa3a7;
}

.nhm-spec-pin:focus-visible { outline: none; }
.nhm-spec-pin:focus-visible span { outline: 3px solid var(--spec-accent); outline-offset: 2px; }

.nhm-spec-mile {
	display: none !important;
	place-items: center;
	box-sizing: border-box;
	border: 1.5px solid var(--spec-dark);
	border-radius: 50%;
	background: #fff;
	color: var(--spec-dark);
	font: 700 9px/1 var(--nhm-text, system-ui, sans-serif);
}

.nhm-spec-map--miles .nhm-spec-mile { display: grid !important; }

/* Start/finish: a dot on the point, the label hung to its left (start) or right (finish). */
.leaflet-marker-icon.nhm-spec-flag {
	width: auto !important;
	height: auto !important;
	margin: 0 !important;
	font: 700 11px/1 var(--nhm-text, system-ui, sans-serif);
	letter-spacing: .04em;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--spec-ink);
	text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

.nhm-spec-flag::before {
	content: "";
	position: absolute;
	top: 50%;
	width: 12px;
	height: 12px;
	margin-top: -6px;
	box-sizing: border-box;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--spec-accent);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

.nhm-spec-flag--start { padding-right: 10px; translate: -100% -50%; }
.nhm-spec-flag--start::before { right: -6px; }
.nhm-spec-flag--finish { padding-left: 10px; translate: 0 -50%; }
.nhm-spec-flag--finish::before { left: -6px; background: var(--spec-ink); }

.nhm-spec__pop strong { display: block; margin-bottom: 4px; font-size: 1.05em; }
.nhm-spec__pop p { margin: 0 0 6px !important; }
.nhm-spec__pop-est { color: var(--spec-muted); font-size: .9em; }
.nhm-spec__pop a { font-weight: 700; }

.nhm-spec .leaflet-container { font: inherit; font-size: 14px; }
.nhm-spec .leaflet-container a.leaflet-popup-close-button { box-shadow: none; }

/* ---------- spacing guard ----------
   The theme's .entry-content p / h3 margins (and the redesign's
   .nhm-has-page-hero .entry-content h3, 0,3,1, loaded later) leak into the
   cards; pin the card's own rhythm at 0,4,0. */
.nhm-spec.nhm-spec .nhm-spec__info > * { margin: 0; }
.nhm-spec.nhm-spec .nhm-spec__info > .nhm-spec__name { margin: 3px 0 2px; }
.nhm-spec.nhm-spec .nhm-spec__info > .nhm-spec__note { margin-top: 4px; }
.nhm-spec.nhm-spec .nhm-spec__info > .nhm-spec__actions { margin-top: 8px; }
.nhm-spec.nhm-spec .nhm-spec__controls p { margin: 0; }
