/*
 * Map creator — full-window map with a floating panel.
 *
 * The map fills the window on purpose: selecting an area is the whole task, and every pixel
 * of chrome is a pixel of the thing being selected. The panel floats over it and collapses to
 * a bottom sheet on a phone, where a side panel would eat a third of the map.
 *
 * One accent colour, one radius, one shadow — declared here so re-skinning to match the rest
 * of cartograph.eu is a five-line change rather than a search.
 */

:root {
	--mc-accent: #0b7285;
	--mc-accent-dark: #095c6b;
	--mc-bad: #c92a2a;
	--mc-warn: #b45309;
	--mc-ok: #2b8a3e;
	--mc-ink: #1f2937;
	--mc-ink-soft: #6b7280;
	--mc-panel-bg: rgba(255, 255, 255, 0.96);
	--mc-radius: 10px;
	--mc-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--mc-ink);
	/* The map is the page; nothing should ever scroll behind it. */
	overflow: hidden;
}

#mc-map {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	background: #eef1f4;
}

/* While drawing, the cursor says so — the panel text alone is easy to miss when the eye is
   on the map. */
.mc-drawing { cursor: crosshair; }
.mc-drawing .leaflet-interactive { cursor: crosshair; }

/* --- panel ---------------------------------------------------------------------------- */

.mc-panel {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 1000;
	width: 330px;
	max-width: calc(100vw - 24px);
	padding: 14px 16px 16px;
	background: var(--mc-panel-bg);
	border-radius: var(--mc-radius);
	box-shadow: var(--mc-shadow);
	backdrop-filter: blur(6px);
}

.mc-panel h1 {
	margin: 0 0 2px;
	font-size: 17px;
	line-height: 1.25;
	font-weight: 650;
}

.mc-panel .mc-sub {
	margin: 0 0 12px;
	font-size: 12.5px;
	line-height: 1.4;
	color: var(--mc-ink-soft);
}

.mc-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 10px;
}

.mc-btn {
	flex: 1 1 auto;
	min-height: 36px;          /* a comfortable touch target, not a desktop-only button */
	padding: 7px 11px;
	font: inherit;
	font-size: 13.5px;
	color: #fff;
	background: var(--mc-accent);
	border: 0;
	border-radius: 7px;
	cursor: pointer;
}
.mc-btn:hover:not(:disabled) { background: var(--mc-accent-dark); }
.mc-btn:focus-visible { outline: 3px solid rgba(11, 114, 133, 0.4); outline-offset: 1px; }
.mc-btn:disabled { opacity: 0.45; cursor: default; }

.mc-btn--ghost {
	color: var(--mc-accent);
	background: transparent;
	border: 1px solid rgba(11, 114, 133, 0.45);
}
.mc-btn--ghost:hover:not(:disabled) { background: rgba(11, 114, 133, 0.08); }

.mc-hint {
	margin: 0;
	font-size: 13px;
	line-height: 1.45;
	min-height: 2.9em;        /* reserve the space so the panel does not jump per keystroke */
}
.mc-hint--ok   { color: var(--mc-ok); }
.mc-hint--warn { color: var(--mc-warn); }
.mc-hint--bad  { color: var(--mc-bad); }

.mc-readout {
	margin-top: 6px;
	font-size: 12.5px;
	color: var(--mc-ink-soft);
	font-variant-numeric: tabular-nums;
	min-height: 1.2em;
}

.mc-note {
	margin: 12px 0 0;
	padding-top: 10px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	font-size: 11.5px;
	line-height: 1.45;
	color: var(--mc-ink-soft);
}

.mc-banner {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1100;
	padding: 9px 14px;
	font-size: 13px;
	color: #fff;
	background: var(--mc-bad);
	text-align: center;
}

/* --- place search --------------------------------------------------------------------- */

.mc-search {
	position: relative;
	margin-bottom: 8px;
}
.mc-search input {
	width: 100%;
	min-height: 38px;
	padding: 8px 10px;
	font: inherit;
	font-size: 14px;
	color: var(--mc-ink);
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.22);
	border-radius: 7px;
	-webkit-appearance: none;      /* iOS otherwise rounds a search field into a pill */
	appearance: none;
}
.mc-search input:focus-visible {
	outline: 3px solid rgba(11, 114, 133, 0.35);
	outline-offset: 0;
	border-color: var(--mc-accent);
}

.mc-search-results {
	position: absolute;
	z-index: 20;
	left: 0;
	right: 0;
	margin: 4px 0 0;
	padding: 0;
	list-style: none;
	background: #fff;
	border-radius: 8px;
	box-shadow: var(--mc-shadow);
	overflow: hidden;
	max-height: 46vh;
	overflow-y: auto;
}
.mc-search-results li {
	padding: 9px 11px;
	font-size: 13px;
	line-height: 1.35;
	cursor: pointer;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.mc-search-results li:last-child { border-bottom: 0; }
.mc-search-results li:hover,
.mc-search-results li[aria-selected="true"] { background: rgba(11, 114, 133, 0.08); }
.mc-search-results .mc-search-attr {
	padding: 6px 11px;
	font-size: 10.5px;
	color: var(--mc-ink-soft);
	cursor: default;
	background: rgba(0, 0, 0, 0.02);
}
.mc-search-results .mc-search-empty { color: var(--mc-ink-soft); cursor: default; }

.mc-note--links a { color: var(--mc-accent); }

/* --- the quote ------------------------------------------------------------------------ */

.mc-quote {
	margin-top: 10px;
	padding: 11px 12px;
	border-radius: 8px;
	background: rgba(11, 114, 133, 0.07);
	border: 1px solid rgba(11, 114, 133, 0.18);
}
.mc-quote--warn { background: rgba(180, 83, 9, 0.08);  border-color: rgba(180, 83, 9, 0.25); }
.mc-quote--bad  { background: rgba(201, 42, 42, 0.07); border-color: rgba(201, 42, 42, 0.25); }
.mc-quote--free { background: rgba(43, 138, 62, 0.08); border-color: rgba(43, 138, 62, 0.25); }

.mc-quote-price {
	font-size: 22px;
	font-weight: 650;
	line-height: 1.15;
	font-variant-numeric: tabular-nums;
}
.mc-quote-size {
	margin-top: 2px;
	font-size: 13px;
	color: var(--mc-ink-soft);
	font-variant-numeric: tabular-nums;
}
.mc-quote-line {
	font-size: 15px;
	font-weight: 600;
}
.mc-quote-sub {
	margin-top: 6px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--mc-ink-soft);
}
.mc-quote-todo {
	margin-top: 8px;
	padding-top: 7px;
	border-top: 1px dashed rgba(0, 0, 0, 0.12);
	font-size: 11.5px;
	color: var(--mc-ink-soft);
}

/* --- the order form ------------------------------------------------------------------- */

.mc-order {
	margin-top: 10px;
}

.mc-field {
	display: block;
	margin-bottom: 8px;
}
.mc-field span {
	display: block;
	margin-bottom: 3px;
	font-size: 12px;
	color: var(--mc-ink-soft);
}
.mc-field input {
	width: 100%;
	min-height: 38px;          /* comfortable on a phone, where this is typed one-handed */
	padding: 8px 10px;
	font: inherit;
	font-size: 14px;
	color: var(--mc-ink);
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.22);
	border-radius: 7px;
}
.mc-field input:focus-visible {
	outline: 3px solid rgba(11, 114, 133, 0.35);
	outline-offset: 0;
	border-color: var(--mc-accent);
}
.mc-field--bad input { border-color: var(--mc-bad); }

.mc-order .mc-btn { width: 100%; margin-top: 4px; }

.mc-consent {
	margin: 8px 0 0;
	font-size: 11px;
	line-height: 1.45;
	color: var(--mc-ink-soft);
}

/* --- the standalone pages (verify, download errors) ------------------------------------ */

body.mc-plain {
	overflow: auto;
	background: #f5f7f8;
	padding: 28px 20px 60px;
}
.mc-card {
	max-width: 34em;
	margin: 0 auto;
	padding: 22px 24px 26px;
	background: #fff;
	border-radius: var(--mc-radius);
	box-shadow: var(--mc-shadow);
}
.mc-card h1 {
	margin: 0 0 8px;
	font-size: 20px;
	line-height: 1.25;
}
.mc-card-sub {
	margin: 0 0 16px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--mc-ink-soft);
}
.mc-btn--inline {
	display: inline-block;
	width: auto;
	text-decoration: none;
	line-height: 1.4;
}

/* --- editing handles ------------------------------------------------------------------ */

.mc-handle {
	background: #fff;
	border: 2px solid var(--mc-accent);
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
	cursor: move;
}
.mc-handle--mid {
	border-style: dashed;
	border-width: 1.5px;
	opacity: 0.75;
}

/* --- phone ---------------------------------------------------------------------------- */

@media (max-width: 640px) {
	.mc-panel {
		top: auto;
		bottom: 0;
		left: 0;
		right: 0;
		width: auto;
		max-width: none;
		border-radius: var(--mc-radius) var(--mc-radius) 0 0;
		padding-bottom: max(14px, env(safe-area-inset-bottom));
		/* ⚠️ The sheet grows: search box, then a quote, then an e-mail form. Left unbounded it
		   ends up covering the map on a small screen -- and the map is the thing being worked
		   on. Cap it and let it scroll instead. */
		max-height: 62vh;
		overflow-y: auto;
		overscroll-behavior: contain;   /* scrolling the sheet must not drag the page behind it */
	}
	.mc-panel h1 { font-size: 16px; }
	/* The sub-line repeats what the buttons say; the notes do not, so they stay -- one of
	   them is the link to the app these maps are for. */
	.mc-panel .mc-sub { display: none; }
	.mc-note { font-size: 11px; }
	/* Leaflet's own controls must not sit under the sheet. */
	.leaflet-bottom.leaflet-left, .leaflet-bottom.leaflet-right { bottom: 190px; }
	/* A dropdown inside a scrolling sheet cannot overflow it, so keep it short enough to fit. */
	.mc-search-results { max-height: 34vh; }
}
