/**
 * County explorer shell — map + sidebar layout (settlements, beaches, walks).
 *
 * @package The_Duchy
 */

.duchy-explorer-page,
.settlements-map-page,
.beaches-explorer-page,
.walks-explorer-page {
	max-width: none;
	padding: 0 0 2rem;
}

.duchy-explorer-page__header,
.settlements-map-page__header,
.beaches-explorer-page__header,
.walks-explorer-page__header,
.explorer-map-page__header {
	/* Map-first: keep h1 for a11y/SEO, free the first viewport for the map. */
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.duchy-explorer-page__intro,
.settlements-map-page__intro,
.beaches-explorer-page__intro,
.walks-explorer-page__intro,
.explorer-map-page__intro {
	margin: 0;
	color: #5f6368;
	max-width: 52ch;
	font-size: 0.95rem;
	line-height: 1.5;
}

/* Intro copy relocated to sidebar / panel foot. */
.duchy-explorer-blurb,
.explorer-panel__blurb {
	margin: 1rem 0 0;
	padding-top: 0.85rem;
	border-top: 1px solid rgba(0, 0, 0, 0.12);
	color: #5f6368;
	font-size: 0.82rem;
	line-height: 1.45;
	font-weight: 500;
}

.duchy-explorer-sidebar__body .duchy-explorer-blurb {
	margin-top: 1.25rem;
	padding: 0.85rem 0 0.25rem;
}

/* Shared Walks-style float title card over explorer canvases. */
.duchy-explorer-float {
	position: absolute;
	top: 1rem;
	left: 1rem;
	z-index: 500;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	pointer-events: none;
	max-width: min(300px, calc(100% - 2rem));
}

.duchy-explorer-float__card {
	pointer-events: none;
	background: rgba(255, 255, 255, 0.42);
	border: 2px solid rgba(0, 0, 0, 0.45);
	box-shadow: none;
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
	padding: 0.75rem 0.95rem;
}

.duchy-explorer-float__kicker {
	display: block;
	font-size: 0.65rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	margin-bottom: 0.25rem;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

.duchy-explorer-float__h {
	display: block;
	font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
	font-weight: 800;
	font-size: 1.25rem;
	line-height: 1.15;
	text-transform: none;
	letter-spacing: normal;
	color: #111;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.duchy-explorer-float__sub {
	display: block;
	margin-top: 0.35rem;
	font-size: 0.78rem;
	font-weight: 600;
	color: #334155;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

.duchy-explorer--towns .duchy-explorer-float__kicker { color: var(--xnav-towns-fg, #0f4038); }
.duchy-explorer--settlements .duchy-explorer-float__kicker { color: var(--xnav-settlements-fg, #2d1f4a); }
.duchy-explorer--beaches .duchy-explorer-float__kicker { color: var(--xnav-beaches-fg, #0f2d5c); }
.duchy-explorer--walks .duchy-explorer-float__kicker,
.duchy-explorer--walks .walks-hub__float-kicker { color: var(--xnav-walks-fg, #0f3d24); }

@media (max-width: 900px) {
	.duchy-explorer-float {
		display: none;
	}
}

/* County explorer cross-nav — tab strip (matches town section tabs) with
 * per-section colour so Towns / Settlements / Beaches / Walks read at a glance.
 * Sticky under fixed header + category strip (same stack as sd-town-tabs).
 * Short labels: uppercase OK at weight 800 (readable-typography rule).
 */
.duchy-explorer-cross-nav-sentinel {
	height: 1px;
	margin: 0;
	pointer-events: none;
}

.duchy-explorer-cross-nav {
	--xnav-towns: var(--ch-sd-cyan, #5dd9d0);
	--xnav-towns-fg: var(--ch-sd-cyan-fg, #0f4038);
	--xnav-settlements: var(--ch-sd-purple, #c4a8f0);
	--xnav-settlements-fg: var(--ch-sd-purple-fg, #2d1f4a);
	--xnav-beaches: var(--ch-sd-blue, #5baeff);
	--xnav-beaches-fg: var(--ch-sd-blue-fg, #0f2d5c);
	--xnav-walks: var(--ch-sd-green, #5ed991);
	--xnav-walks-fg: var(--ch-sd-green-fg, #0f3d24);

	position: sticky;
	top: var(--duchy-xnav-pin-top, var(--duchy-sticky-subheader, 144px));
	z-index: 9997;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	border-bottom: 3px solid #000;
	box-sizing: border-box;
	box-shadow: 0 4px 0 rgba(0, 0, 0, 0.06);
}

.duchy-explorer-cross-nav.is-pinned {
	position: fixed;
	left: 0;
	right: 0;
	top: var(--duchy-xnav-pin-top, var(--duchy-sticky-subheader, 144px));
	width: 100%;
}

.duchy-explorer-cross-nav-spacer {
	display: block;
	height: 0;
}

.duchy-explorer-cross-nav__inner {
	display: flex;
	align-items: stretch;
	justify-content: stretch;
	flex-wrap: nowrap;
	gap: 0;
	width: 100%;
	max-width: 1440px;
	margin: 0 auto;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.duchy-explorer-cross-nav__inner::-webkit-scrollbar {
	display: none;
}

.duchy-explorer-cross-nav__label {
	display: none;
}

.duchy-explorer-cross-nav__link {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0.85rem 0.75rem;
	border: 0;
	border-right: 2px solid #e2e8f0;
	border-bottom: 4px solid transparent;
	border-radius: 0;
	background: #fff;
	color: #475569;
	font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
	font-weight: 800;
	font-size: 0.78rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	text-decoration: none;
	text-align: center;
	white-space: nowrap;
	line-height: 1.2;
	transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.duchy-explorer-cross-nav__link:last-child {
	border-right: 0;
}

.duchy-explorer-cross-nav__link--towns {
	--xnav-accent: var(--xnav-towns);
	--xnav-fg: var(--xnav-towns-fg);
	background: color-mix(in srgb, var(--xnav-towns) 22%, #fff);
	color: var(--xnav-towns-fg);
}
.duchy-explorer-cross-nav__link--settlements {
	--xnav-accent: var(--xnav-settlements);
	--xnav-fg: var(--xnav-settlements-fg);
	background: color-mix(in srgb, var(--xnav-settlements) 22%, #fff);
	color: var(--xnav-settlements-fg);
}
.duchy-explorer-cross-nav__link--beaches {
	--xnav-accent: var(--xnav-beaches);
	--xnav-fg: var(--xnav-beaches-fg);
	background: color-mix(in srgb, var(--xnav-beaches) 22%, #fff);
	color: var(--xnav-beaches-fg);
}
.duchy-explorer-cross-nav__link--walks {
	--xnav-accent: var(--xnav-walks);
	--xnav-fg: var(--xnav-walks-fg);
	background: color-mix(in srgb, var(--xnav-walks) 22%, #fff);
	color: var(--xnav-walks-fg);
}

.duchy-explorer-cross-nav__link:hover,
.duchy-explorer-cross-nav__link:focus-visible {
	color: var(--xnav-fg, #0f172a);
	background: color-mix(in srgb, var(--xnav-accent, #5dd9d0) 45%, #fff);
	border-bottom-color: var(--xnav-accent, #5dd9d0);
	outline: none;
}

.duchy-explorer-cross-nav__link.is-current {
	color: var(--xnav-fg, #0f172a);
	background: var(--xnav-accent, #5dd9d0);
	border-bottom-color: #000;
	pointer-events: none;
}

.duchy-explorer-cross-nav__link.is-disabled {
	opacity: 0.45;
	pointer-events: none;
}

@media (max-width: 720px) {
	.duchy-explorer-cross-nav__inner {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	.duchy-explorer-cross-nav__link {
		flex: none;
		font-size: 0.72rem;
		padding: 0.7rem 0.5rem;
		letter-spacing: 0.03em;
		border-right: 2px solid #e2e8f0;
		border-bottom: 2px solid #e2e8f0;
	}

	.duchy-explorer-cross-nav__link:nth-child(2n) {
		border-right: 0;
	}

	.duchy-explorer-cross-nav__link:nth-last-child(-n+2) {
		border-bottom: 4px solid transparent;
	}

	.duchy-explorer-cross-nav__link.is-current {
		border-bottom-color: #000;
	}

	.duchy-explorer-cross-nav__link:hover,
	.duchy-explorer-cross-nav__link:focus-visible {
		border-bottom-color: var(--xnav-accent, #5dd9d0);
	}

	.duchy-explorer-cross-nav__link.is-current:hover,
	.duchy-explorer-cross-nav__link.is-current:focus-visible {
		border-bottom-color: #000;
	}
}

@media (min-width: 721px) and (max-width: 960px) {
	.duchy-explorer-cross-nav__link {
		font-size: 0.74rem;
		padding: 0.75rem 0.55rem;
	}
}

.duchy-explorer-wrap,
.settlements-map-wrap,
.beaches-explorer-wrap,
.walks-explorer-wrap {
	display: flex;
	flex-direction: row;
	/* Keep map + chrome (Layers BL / stack BR) in the first viewport. */
	height: min(78vh, 720px);
	max-height: calc(100dvh - 11rem);
	min-height: 420px;
	border-top: 1px solid #dadce0;
	border-bottom: 1px solid #dadce0;
	background: #e8f0fe;
}

.duchy-explorer--beaches .duchy-explorer-wrap,
.duchy-explorer--beaches .beaches-explorer-wrap {
	background: #e0f2f1;
}

.duchy-explorer-canvas,
.settlements-map-canvas,
.beaches-explorer-canvas,
.walks-explorer-canvas {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 0;
	height: 100%;
	position: relative;
}

#settlements-map,
#beaches-explorer-map,
#walks-explorer-map {
	width: 100%;
	height: 100%;
	min-height: 0;
}

.duchy-explorer-sidebar,
.settlements-map-sidebar,
.beaches-explorer-sidebar,
.walks-explorer-sidebar {
	flex: 0 0 320px;
	width: 320px;
	background: #f8f9fa;
	border-left: 2px solid #dee2e6;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	min-height: 0;
}

.duchy-explorer--settlements .duchy-explorer-sidebar__head,
.duchy-explorer--settlements .settlements-map-sidebar__head,
.settlements-map-sidebar__head {
	background: #1a237e;
	color: #fff;
}

.duchy-explorer--beaches .duchy-explorer-sidebar__head,
.duchy-explorer--beaches .beaches-explorer-sidebar__head,
.beaches-explorer-sidebar__head {
	background: #00695c;
	color: #fff;
}

.duchy-explorer-sidebar__head,
.settlements-map-sidebar__head,
.beaches-explorer-sidebar__head {
	padding: 0.9rem 1rem;
	flex-shrink: 0;
}

.duchy-explorer-sidebar__head h2,
.settlements-map-sidebar__head h2,
.beaches-explorer-sidebar__head h2 {
	margin: 0 0 0.15rem;
	font-size: 1.05rem;
	font-weight: 700;
}

.duchy-explorer-sidebar__sub,
.settlements-map-sidebar__sub,
.beaches-explorer-sidebar__sub {
	font-size: 0.78rem;
	opacity: 0.85;
}

.duchy-explorer-sidebar__body,
.settlements-map-sidebar__body,
.beaches-explorer-sidebar__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 0.75rem;
	min-height: 0;
	overscroll-behavior: contain;
}

/*
 * Short detail cards: one page scroll only.
 * Overview lists keep the sidebar scroller; detail mode lets the panel grow
 * with the page so the browser scrollbar is the only one.
 */
@media (min-width: 901px) {
	.duchy-explorer-wrap.is-showing-detail,
	.settlements-map-wrap.is-showing-detail,
	.beaches-explorer-wrap.is-showing-detail,
	.walks-explorer-wrap.is-showing-detail,
	.walks-hub__wrap.is-showing-detail {
		height: auto !important;
		max-height: none !important;
		min-height: min(70vh, 720px);
		align-items: start;
	}

	.duchy-explorer-wrap.is-showing-detail .duchy-explorer-canvas,
	.duchy-explorer-wrap.is-showing-detail .settlements-map-canvas,
	.duchy-explorer-wrap.is-showing-detail .beaches-explorer-canvas,
	.duchy-explorer-wrap.is-showing-detail .walks-explorer-canvas,
	.settlements-map-wrap.is-showing-detail .settlements-map-canvas,
	.beaches-explorer-wrap.is-showing-detail .beaches-explorer-canvas,
	.walks-explorer-wrap.is-showing-detail .walks-explorer-canvas,
	.walks-hub__wrap.is-showing-detail .walks-hub__map {
		height: min(70vh, 720px);
		min-height: min(70vh, 720px);
		position: sticky;
		top: calc(var(--duchy-xnav-pin-top, var(--nav-stack, var(--duchy-sticky-subheader, 148px))) + 0.25rem);
		align-self: start;
	}

	.duchy-explorer-sidebar.is-showing-detail,
	.settlements-map-sidebar.is-showing-detail,
	.beaches-explorer-sidebar.is-showing-detail,
	.walks-explorer-sidebar.is-showing-detail,
	.walks-hub__sidebar.is-showing-detail {
		height: auto !important;
		align-self: start;
		overflow: visible;
	}

	.duchy-explorer-sidebar.is-showing-detail .duchy-explorer-sidebar__body,
	.duchy-explorer-sidebar.is-showing-detail .settlements-map-sidebar__body,
	.duchy-explorer-sidebar.is-showing-detail .beaches-explorer-sidebar__body,
	.duchy-explorer-sidebar.is-showing-detail .walks-explorer-sidebar__body,
	.settlements-map-sidebar.is-showing-detail .settlements-map-sidebar__body,
	.beaches-explorer-sidebar.is-showing-detail .beaches-explorer-sidebar__body,
	.walks-explorer-sidebar.is-showing-detail .walks-explorer-sidebar__body,
	.walks-hub__sidebar.is-showing-detail .walks-explorer-sidebar__body {
		overflow: visible !important;
		flex: none;
		min-height: 0;
	}
}

@media (max-width: 900px) {
	.duchy-explorer-sidebar.is-showing-detail .duchy-explorer-sidebar__body,
	.settlements-map-sidebar.is-showing-detail .settlements-map-sidebar__body,
	.beaches-explorer-sidebar.is-showing-detail .beaches-explorer-sidebar__body,
	.walks-explorer-sidebar.is-showing-detail .walks-explorer-sidebar__body,
	.walks-hub__sidebar.is-showing-detail .walks-explorer-sidebar__body {
		overflow: visible !important;
		flex: none;
	}
}

.duchy-explorer-layers,
.settlements-map-layers,
.beaches-explorer-layers,
.walks-explorer-layers {
	/* Data toggles top-left — leave bottom-left for Google Layers chrome. */
	position: absolute;
	left: 10px;
	top: 10px;
	bottom: auto;
	z-index: 500;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.duchy-explorer-layers__btn,
.settlements-map-layers__btn,
.beaches-explorer-layers__btn {
	border: 2px solid #1a237e;
	background: #fff;
	color: #1a237e;
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 6px 10px;
	border-radius: 999px;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.duchy-explorer--beaches .duchy-explorer-layers__btn,
.duchy-explorer--beaches .beaches-explorer-layers__btn {
	border-color: #00695c;
	color: #00695c;
}

.duchy-explorer-layers__btn.is-on,
.settlements-map-layers__btn.is-on,
.beaches-explorer-layers__btn.is-on {
	background: #1a237e;
	color: #fff;
}

.duchy-explorer--beaches .duchy-explorer-layers__btn.is-on,
.duchy-explorer--beaches .beaches-explorer-layers__btn.is-on {
	background: #00695c;
	border-color: #00695c;
}

.duchy-explorer-layers__btn:not(.is-on),
.settlements-map-layers__btn:not(.is-on),
.beaches-explorer-layers__btn:not(.is-on) {
	opacity: 0.72;
}

.duchy-explorer-back,
.settlements-map-back,
.beaches-explorer-back {
	display: none;
	width: 100%;
	margin-top: 0.35rem;
	padding: 0.5rem;
	background: #1a237e;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 0.85rem;
	font-weight: 600;
}

.duchy-explorer--beaches .duchy-explorer-back,
.duchy-explorer--beaches .beaches-explorer-back {
	background: #00695c;
}

.duchy-explorer-detail.is-open .duchy-explorer-back,
.settlements-map-parish-detail.is-open .settlements-map-back,
.beaches-explorer-detail.is-open .beaches-explorer-back {
	display: block;
}

.duchy-explorer-back:hover,
.settlements-map-back:hover,
.beaches-explorer-back:hover {
	filter: brightness(1.08);
}

@media (max-width: 900px) {
	.duchy-explorer-wrap,
	.settlements-map-wrap,
	.beaches-explorer-wrap,
	.walks-explorer-wrap {
		flex-direction: column;
		height: auto;
		max-height: none;
		min-height: 0;
	}

	/* Phones: the page title + intro pushed the map below the fold. Only the
	   sticky tab strip stays above it; the h1 remains in the DOM for search
	   engines and screen readers. */
	.duchy-explorer-page__header,
	.settlements-map-page__header,
	.beaches-explorer-page__header,
	.walks-explorer-page__header,
	.walks-explorer-page__header.walks-hub__header {
		padding: 0;
	}

	.duchy-explorer-page__header h1,
	.settlements-map-page__header h1,
	.beaches-explorer-page__header h1,
	.walks-explorer-page__header h1 {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
		border: 0;
	}

	/* Page-scoped selectors: the per-explorer stylesheets load after this one
	   and would otherwise win on equal specificity. */
	.duchy-explorer-page__intro,
	.settlements-map-page__intro,
	.beaches-explorer-page__intro,
	.walks-explorer-page__intro,
	.explorer-map-page .explorer-map-page__intro,
	.walks-explorer-page__header .walks-hub__eyebrow {
		display: none;
	}

	.duchy-explorer-canvas,
	.settlements-map-canvas,
	.beaches-explorer-canvas,
	.walks-explorer-canvas {
		height: min(72dvh, 640px);
		min-height: 320px;
		order: 1;
	}

	#settlements-map,
	#beaches-explorer-map,
	#walks-explorer-map {
		min-height: 0;
		height: 100%;
	}

	.duchy-explorer-sidebar,
	.settlements-map-sidebar,
	.beaches-explorer-sidebar,
	.walks-explorer-sidebar {
		flex: none;
		width: 100%;
		border-left: none;
		border-top: 2px solid #dee2e6;
		max-height: 42vh;
		order: 2;
	}
}
