/**
 * Bugg World Map - country profile page.
 *
 * Scoped to elements this plugin injects, so it cannot restyle the theme.
 */

/* ---------- two-column hero ---------- */

.bwm-hero {
	display: grid;
	gap: 1.6em 2em;
	margin: 0 0 2em;
	align-items: start;
}

/*
 * Split only where there is room. Below 782px the columns stack, which also
 * puts the image above the prayer button on a phone rather than beside it.
 */
@media (min-width: 783px) {
	.bwm-hero--split {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}
}

.bwm-hero__media {
	margin: 0;
}

/*
 * Fixed 16:9 regardless of how the source image was cropped, so a row of
 * country pages lines up instead of each one setting its own height.
 * object-fit crops to fill rather than distorting; object-position keeps the
 * centre of the frame, which is where the subject usually sits.
 */
.bwm-hero__img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--bwm-hero-ratio, 16 / 9);
	object-fit: cover;
	object-position: center;
	border-radius: 4px;
	background: rgba(22, 36, 42, 0.06);
}

.bwm-panel {
	--bwm-band: #bcc8cb;
	display: flex;
	flex-direction: column;
	gap: 1.2em;
}

.bwm-panel__band {
	position: relative;
	height: 10px;
	border-radius: 3px;
	background: var(--bwm-band);
	overflow: hidden;
}

/*
 * The band repeats the country's map pattern so the page reads as the same
 * object that was clicked. Drawn as a CSS gradient rather than the SVG pattern:
 * there is no SVG on this page to hang a <pattern> definition off.
 */
.bwm-panel__band.bwm-pattern-vertical::after,
.bwm-panel__band.bwm-pattern-horizontal::after,
.bwm-panel__band.bwm-pattern-diagonal::after {
	content: "";
	position: absolute;
	inset: 0;
	opacity: 0.55;
}

.bwm-panel__band.bwm-pattern-vertical::after {
	background: repeating-linear-gradient(90deg, rgba(255,255,255,0.85) 0 1px, transparent 1px 5px);
}

.bwm-panel__band.bwm-pattern-horizontal::after {
	background: repeating-linear-gradient(0deg, rgba(255,255,255,0.85) 0 1px, transparent 1px 4px);
}

.bwm-panel__band.bwm-pattern-diagonal::after {
	background: repeating-linear-gradient(45deg, rgba(255,255,255,0.85) 0 1px, transparent 1px 6px);
}

/* ---------- severity ---------- */

.bwm-severity__label,
.bwm-types-block__label {
	margin: 0 0 0.45em;
	font-size: 0.72em;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	opacity: 0.65;
}

.bwm-severity__figure {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 10px;
}

.bwm-severity__value {
	font-size: 2.4em;
	font-weight: 700;
	line-height: 1;
}

.bwm-severity__of {
	font-size: 0.42em;
	font-weight: 400;
	opacity: 0.6;
	margin-left: 2px;
}

.bwm-severity__band {
	display: inline-block;
	padding: 4px 11px;
	border-radius: 3px;
	background: var(--bwm-band);
	color: #fff;
	font-size: 0.76em;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

/* ---------- types ---------- */

.bwm-types {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bwm-types__item {
	display: flex;
	align-items: center;
	gap: 7px;
	margin: 0;
	font-size: 0.85em;
}

.bwm-types__icon,
.bwm-icon {
	width: 28px;
	height: 28px;
	flex: none;
}

/* ---------- details ---------- */

.bwm-profile-details {
	margin: 2em 0 0;
	padding: 1.1em 1.3em;
	border: 1px solid rgba(22, 36, 42, 0.14);
	border-radius: 4px;
}

.bwm-profile-details__list {
	margin: 0;
}

.bwm-profile-details__row {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 16px;
	padding: 0.55em 0;
	border-bottom: 1px solid rgba(22, 36, 42, 0.08);
}

.bwm-profile-details__row:last-child {
	border-bottom: 0;
}

.bwm-profile-details__row dt {
	flex: 1 1 12em;
	margin: 0;
	font-weight: 600;
}

.bwm-profile-details__row dd {
	flex: 1 1 10em;
	margin: 0;
}

.bwm-profile-provenance {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 18px;
	margin: 1em 0 0;
	font-size: 0.8em;
	opacity: 0.75;
}

.bwm-profile-provenance a {
	word-break: break-word;
}

/* ---------- back link ---------- */

.bwm-back {
	margin: 2em 0 0;
}

.bwm-back__link {
	display: inline-block;
	padding: 0.5em 1.1em;
	border: 1.5px solid currentColor;
	border-radius: 3px;
	font-size: 0.82em;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	text-decoration: none;
}

@media (max-width: 600px) {
	.bwm-profile-score__value {
		font-size: 1.7em;
	}

	.bwm-back__link {
		display: block;
		text-align: center;
	}
}

/* ---------- type icons ---------- */

/*
 * Built-in icons are inline SVG using currentColor, so they follow the
 * surrounding text colour and work on light or dark themes alike. Uploaded
 * icons are bitmaps and simply render as supplied.
 */
.bwm-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
}

.bwm-icon--builtin svg {
	width: 100%;
	height: 100%;
	display: block;
}

.bwm-icon--custom {
	object-fit: contain;
}

/* ---------- prayer counter ---------- */

.bwm-pray {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 16px;
	margin: 0;
}

/* Stack inside the narrow hero column rather than fighting for one line. */
@media (min-width: 783px) {
	.bwm-hero--split .bwm-pray {
		display: block;
	}

	.bwm-hero--split .bwm-pray__button {
		width: 100%;
	}

	.bwm-hero--split .bwm-pray__total {
		margin-top: 0.6em;
	}
}

.bwm-pray__button {
	padding: 0.7em 1.4em;
	border: 0;
	border-radius: 4px;
	background: var(--bwm-band, #16242a);
	color: #fff;
	font: inherit;
	font-size: 0.92em;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
	text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.bwm-pray__button:hover {
	filter: brightness(1.12);
}

.bwm-pray__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bwm-pray__button.is-busy {
	opacity: 0.6;
	cursor: progress;
}

.bwm-pray__button:disabled {
	opacity: 1;
	cursor: default;
	background: transparent;
	color: inherit;
	border: 1.5px solid currentColor;
	text-shadow: none;
	padding: calc(0.7em - 1.5px) calc(1.4em - 1.5px);
}

.bwm-pray__total {
	margin: 0;
	font-size: 0.88em;
	opacity: 0.8;
}

/*
 * The count starts as a placeholder and is filled in by the browser, so it is
 * held back until the real number arrives rather than flashing a wrong one.
 */
.bwm-pray:not(.is-loaded) .bwm-pray__label {
	visibility: hidden;
}

.bwm-pray__count {
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
	.bwm-pray {
		flex-direction: column;
		align-items: stretch;
		text-align: center;
	}

	.bwm-pray__button {
		width: 100%;
	}
}
