/* Delivery options and the parcel locker field in the block checkout (assets/js/locker-picker.js).
   Neutral styles that follow the text colour (currentColor); the colours are the variables below. */

.eldor-rate-list,
.eldor-locker-standalone {
	--eldor-rate-border: #d5d8dc;
	--eldor-rate-accent: currentColor;
	--eldor-rate-selected-bg: #f6f7f7;
	--eldor-rate-muted: color-mix(in srgb, currentColor 65%, transparent);
	--eldor-rate-error: #cc1818;
}

/* WooCommerce's own list is replaced by ours – only while ours is shown. */
.wc-block-checkout__shipping-option:has(.eldor-rate-list) .wc-block-components-shipping-rates-control {
	display: none;
}

/* ---------- Options: one list of cards ---------- */

.eldor-rate-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.eldor-rate {
	background-color: #fff;
	border: 1px solid var(--eldor-rate-border);
	border-radius: 6px;
}

/* Selected: a 2px frame without moving anything (border + inner ring), and the card opens. */
.eldor-rate.is-selected {
	background-color: var(--eldor-rate-selected-bg);
	border-color: var(--eldor-rate-accent);
	box-shadow: inset 0 0 0 1px var(--eldor-rate-accent);
}

/* Logo, radio | name, price | delivery date. Without a logo: name, price, radio | delivery date. */
.eldor-rate__head {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	grid-template-areas:
		"name price radio"
		"meta meta meta";
	column-gap: 16px;
	row-gap: 4px;
	align-items: center;
	margin: 0;
	padding: 16px 20px;
	cursor: pointer;
}

.eldor-rate.has-logo .eldor-rate__head {
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"logo radio"
		"name price"
		"meta meta";
}

.eldor-rate__logo {
	grid-area: logo;
	justify-self: start;
	width: auto;
	max-width: 140px;
	height: 32px;
	margin-bottom: 8px;
	object-fit: contain;
	object-position: left center;
}

/* Unisend's wordmark is wider and heavier than Omniva's: smaller, in the same 40px row, so the
   names below the logos line up from card to card. */
.eldor-rate__logo--unisend {
	height: 24px;
	margin-top: 4px;
	margin-bottom: 12px;
}

.eldor-rate__name {
	grid-area: name;
	font-weight: 600;
	line-height: 1.35;
}

.eldor-rate__price {
	grid-area: price;
	justify-self: end;
	font-weight: 600;
	white-space: nowrap;
}

.eldor-rate__meta {
	grid-area: meta;
	font-size: 0.9375em;
	line-height: 1.35;
	color: var(--eldor-rate-muted);
}

/* The radio button: a circle on the right, filled with a white dot when chosen. */
.eldor-rate__radio {
	grid-area: radio;
	justify-self: end;
	display: grid;
	place-content: center;
	box-sizing: border-box;
	width: 24px;
	height: 24px;
	margin: 0;
	cursor: pointer;
	background-color: #fff;
	border: 1.5px solid var(--eldor-rate-border);
	border-radius: 50%;
	-webkit-appearance: none;
	appearance: none;
}

.eldor-rate__radio::before {
	content: "";
	width: 8px;
	height: 8px;
	background-color: #fff;
	border-radius: 50%;
	transform: scale(0);
	transition: transform 0.12s ease-in-out;
}

.eldor-rate__radio:checked {
	background-color: var(--eldor-rate-accent);
	border-color: var(--eldor-rate-accent);
}

.eldor-rate__radio:checked::before {
	transform: scale(1);
}

.eldor-rate__radio:focus-visible {
	outline: 2px solid var(--eldor-rate-accent);
	outline-offset: 2px;
}

.eldor-rate__radio:disabled {
	cursor: default;
}

/* What the selected option needs – the locker field. */
.eldor-rate__body {
	padding: 0 20px 20px;
}

.eldor-locker-standalone {
	margin-top: 16px;
}

/* ---------- Locker field ---------- */

/* Closed: a select-like box with the chosen locker, or "Izvēlieties pakomātu". */
.eldor-locker-select,
.eldor-locker-search__input {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	width: 100%;
	min-height: 52px;
	margin: 0;
	padding: 12px 16px;
	font: inherit;
	color: inherit;
	text-align: left;
	background-color: #fff;
	border: 1px solid var(--eldor-rate-border);
	border-radius: 6px;
}

.eldor-locker-select {
	justify-content: space-between;
	gap: 12px;
	cursor: pointer;
}

.eldor-locker-select:hover {
	border-color: color-mix(in srgb, currentColor 45%, transparent);
}

.eldor-locker-select:focus-visible,
.eldor-locker-search__input:focus {
	border-color: var(--eldor-rate-accent);
	outline: none;
	box-shadow: 0 0 0 1px var(--eldor-rate-accent);
}

.eldor-locker-select.has-error,
.eldor-locker-search__input.has-error {
	border-color: var(--eldor-rate-error);
}

.eldor-locker-select__value {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.eldor-locker-select__name {
	font-weight: 600;
	line-height: 1.35;
}

.eldor-locker-select__address {
	font-size: 0.875em;
	line-height: 1.35;
	color: var(--eldor-rate-muted);
}

.eldor-locker-select__chevron {
	flex: 0 0 auto;
}

/* Open: the search field and the results under it. The results float over the page
   (absolute), so opening them never moves the rest of the checkout. */
.eldor-locker-search {
	position: relative;
}

.eldor-locker-search__input {
	display: block;
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
	/* With the keyboard up the field scrolls to the top (locker-picker.js); keep a gap above it. */
	scroll-margin-top: 12px;
}

.eldor-locker-search__dropdown {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	z-index: 30;
	background-color: #fff;
	border: 1px solid var(--eldor-rate-border);
	border-top: 0;
	border-radius: 0 0 6px 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.eldor-locker-search__list {
	max-height: 320px;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
}

.eldor-locker-search__list:empty {
	display: none;
}

.eldor-locker-search__option {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
	padding: 10px 16px;
	cursor: pointer;
	border-top: 1px solid color-mix(in srgb, currentColor 10%, transparent);
}

.eldor-locker-search__option:first-child {
	border-top: 0;
}

.eldor-locker-search__option.is-active {
	background-color: color-mix(in srgb, currentColor 7%, transparent);
}

.eldor-locker-search__name {
	font-weight: 600;
	line-height: 1.35;
}

.eldor-locker-search__address {
	font-size: 0.875em;
	line-height: 1.35;
	color: var(--eldor-rate-muted);
}

/* Distance from the customer's postcode, after the address (locker-picker.js: lockerDistance()). */
.eldor-locker-search__distance {
	white-space: nowrap;
}

.eldor-locker-search__distance::before {
	content: " · ";
}

/* "Sakārtoti pēc attāluma no pasta indeksa …" above the list. */
.eldor-locker-search__heading {
	margin: 0;
	padding: 8px 16px;
	font-size: 0.875em;
	color: var(--eldor-rate-muted);
	border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent);
}

.eldor-locker-search__status {
	margin: 0;
	padding: 8px 16px;
	font-size: 0.875em;
	color: var(--eldor-rate-muted);
	border-top: 1px solid color-mix(in srgb, currentColor 10%, transparent);
}

.eldor-locker-search__list:empty + .eldor-locker-search__status {
	border-top: 0;
}

/* ---------- Phone field: "+371" in front of the number ---------- */

/* Only while the field is in use (WooCommerce's .is-active: focused or filled), when the label sits
   above the number; the script sets data-eldor-prefix for Latvian addresses. Lined up with the
   number in WooCommerce's text field (24px from the top, 8.5px from the left). */
.wc-block-components-text-input.is-active:has(> input[data-eldor-prefix])::before {
	content: "+371";
	position: absolute;
	top: 24px;
	left: 9.5px;
	z-index: 1;
	font-size: 16px;
	line-height: 17px;
	pointer-events: none;
}

.wc-block-components-text-input.is-active > input[data-eldor-prefix] {
	padding-left: 48px !important;
}

@media (max-width: 480px) {
	.eldor-rate__head {
		padding: 14px 16px;
	}

	.eldor-rate__body {
		padding: 0 16px 16px;
	}

	.eldor-rate__logo {
		height: 28px;
	}

	.eldor-rate__logo--unisend {
		height: 21px;
		margin-top: 3px;
		margin-bottom: 12px;
	}
}
