/**
 * Boat Map — front end styles.
 *
 * Deliberately plain: the theme it lands in owns the page, so this only
 * styles what Leaflet and the modal need in order to be usable.
 */

.bm-wrap {
	margin: 0 0 1.5em;
}

.bm-map {
	width: 100%;
	min-height: 320px;
	border-radius: 6px;
	/* Leaflet panes stack above most theme headers without this. */
	z-index: 0;
}

/**
 * Keep the theme's content-image styling off the map.
 *
 * Almost every theme, and most sites' own custom CSS, style images inside
 * post content — `max-width: 100%` so photos never overflow, a border
 * radius, a shadow. Leaflet's tiles and marker icons are images inside post
 * content too, and those rules ruin them. `max-width: 100%` is the dangerous
 * one: a tile is absolutely positioned inside a zero-width container, so
 * 100% resolves to zero and the tile renders at 0px wide. The tiles load
 * fine, nothing errors, and all you see is the grey panel underneath.
 *
 * Leaflet already ships `max-width: none !important` for exactly this, but
 * it only carries two classes of specificity, so a rule like
 * `body:not(.home) .entry-content img { max-width: 100% !important }`
 * outranks it. Hence three classes here — enough to win against the usual
 * offenders without resorting to anything sillier.
 *
 * Only properties with a safe universal value are reset. Width, height,
 * transform and above all MARGIN are left alone: Leaflet owns those.
 * Margin is not a cosmetic property here — it is how Leaflet anchors an
 * icon to its point. A default marker carries
 * `margin-left: -12px; margin-top: -41px` inline so that the tip of the pin,
 * not its top-left corner, lands on the coordinate. Reset those and every
 * pin sits 12px right and 41px below where it belongs; because that offset
 * is in screen pixels while the map is in metres, the pins then appear to
 * drift across the map as you zoom.
 */
.bm-wrap .bm-map .leaflet-pane img,
.bm-wrap .bm-map .leaflet-pane canvas,
.bm-wrap .bm-map .leaflet-control img,
.bm-wrap .bm-map .leaflet-popup img {
	max-width: none !important;
	max-height: none !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	background: none !important;
	filter: none !important;
	clip-path: none !important;
}

/**
 * Popups carry their own colours.
 *
 * Leaflet's popup is a white box, but its text colour is inherited from the
 * page. Drop the map into a dark section — which is where a site like this
 * usually wants it — and the theme's white body text lands on that white
 * box, leaving the boat name invisible. The popup is the plugin's own
 * furniture rather than page content, so it states both ends of the contrast
 * itself instead of trusting whatever it is embedded in.
 */
.bm-wrap .bm-map .leaflet-popup-content-wrapper,
.bm-wrap .bm-map .leaflet-popup-tip {
	background: #fff !important;
	color: #1a1a1a !important;
}

.bm-wrap .bm-map .leaflet-popup-content,
.bm-wrap .bm-map .leaflet-popup-content .bm-popup,
.bm-wrap .bm-map .leaflet-popup-content .bm-popup * {
	color: #1a1a1a !important;
}

.bm-wrap .bm-map .leaflet-popup-close-button {
	color: #6a6a6a !important;
	background: none !important;
}

/* Same reasoning for the attribution and the zoom buttons, which Leaflet
   also draws as white boxes over the map. */
.bm-wrap .bm-map .leaflet-control-attribution {
	background: rgba( 255, 255, 255, 0.8 ) !important;
	color: #1a1a1a !important;
}

.bm-wrap .bm-map .leaflet-control-attribution a {
	color: #0a58ca !important;
}

.bm-wrap .bm-map .leaflet-control-zoom a {
	background: #fff !important;
	color: #1a1a1a !important;
}

.bm-hint {
	margin: 0.6em 0 0;
	font-size: 0.9em;
	opacity: 0.75;
}

.bm-warning--fatal {
	margin: 0 0 0.8em;
	max-width: none;
}

.bm-warning {
	max-width: 16em;
	padding: 0.5em 0.7em;
	border-left: 3px solid #d63638;
	border-radius: 3px;
	background: #fff;
	color: #1a1a1a;
	font-size: 0.85em;
	box-shadow: 0 1px 5px rgba( 0, 0, 0, 0.4 );
}

/* Popups ---------------------------------------------------------------- */

.bm-popup {
	display: flex;
	flex-direction: column;
	gap: 0.25em;
	min-width: 12em;
}

.bm-popup__name {
	font-size: 1.05em;
}

.bm-popup__number {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	letter-spacing: 0.03em;
}

.bm-popup__admin {
	display: flex;
	flex-direction: column;
	gap: 0.15em;
	margin-top: 0.5em;
	padding-top: 0.5em;
	border-top: 1px solid rgba( 0, 0, 0, 0.12 );
}

.bm-popup__adminlabel {
	font-size: 0.75em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	opacity: 0.6;
}

.bm-popup__empty {
	opacity: 0.6;
	font-style: italic;
}

/* Modal ----------------------------------------------------------------- */

.bm-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba( 0, 0, 0, 0.5 );
	overflow-y: auto;
}

.bm-modal__box {
	width: min( 28rem, 100% );
	/* The whole form has to fit a phone in landscape without the Confirm
	   button falling below the fold, so the box is deliberately compact and
	   scrolls internally rather than growing. */
	max-height: 92vh;
	overflow-y: auto;
	padding: 1.2rem 1.3rem;
	border-radius: 8px;
	background: #fff;
	color: #1a1a1a;
	font-size: 15px;
	line-height: 1.35;
	box-shadow: 0 12px 40px rgba( 0, 0, 0, 0.3 );
}

.bm-modal__title {
	margin: 0 0 0.1em;
	font-size: 1.15rem;
	line-height: 1.2;
}

.bm-modal__coords {
	margin: 0 0 0.8em;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.8em;
	opacity: 0.6;
}

.bm-field {
	margin: 0 0 0.6em;
}

.bm-field label {
	display: block;
	margin-bottom: 0.15em;
	font-weight: 600;
	font-size: 0.85em;
	line-height: 1.3;
}

.bm-field input {
	width: 100%;
	box-sizing: border-box;
	padding: 0.4em 0.55em;
	border: 1px solid #b9b9b9;
	border-radius: 4px;
	font-size: 1em;
	background: #fff;
	color: inherit;
}

.bm-field input:focus {
	outline: 2px solid #2271b1;
	outline-offset: 1px;
	border-color: #2271b1;
}

.bm-req {
	font-weight: 400;
	opacity: 0.6;
}

.bm-fieldset {
	margin: 0.9em 0 0;
	padding: 0.5em 0.8em 0.1em;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
}

.bm-fieldset legend {
	padding: 0 0.4em;
	font-weight: 600;
	font-size: 0.85em;
}

.bm-notice {
	margin: 0 0 0.7em;
	padding: 0.4em 0.6em;
	border-left: 3px solid #2271b1;
	background: #f0f6fc;
	font-size: 0.8em;
	line-height: 1.35;
}

.bm-form__error {
	margin: 0.7em 0 0;
	padding: 0.45em 0.65em;
	border-left: 3px solid #d63638;
	background: #fcf0f1;
	font-size: 0.85em;
}

.bm-form__actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.6em;
	margin-top: 0.9em;
}

.bm-btn {
	padding: 0.5em 1.1em;
	border: 1px solid transparent;
	border-radius: 4px;
	font-size: 0.95em;
	font-weight: 600;
	cursor: pointer;
}

.bm-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.bm-btn--primary {
	background: #2271b1;
	color: #fff;
}

.bm-btn--primary:hover:not( :disabled ) {
	background: #135e96;
}

.bm-btn--danger {
	background: #fff;
	border-color: #d63638;
	color: #d63638;
}

.bm-btn--danger:hover:not( :disabled ) {
	background: #d63638;
	color: #fff;
}

.bm-popup .bm-btn--danger {
	margin-top: 0.6em;
	width: 100%;
}
