/**
 * Delivery option cards in the cart and at checkout.
 * Markup: woocommerce/cart/cart-shipping.php. Content: inc/delivery-cards.php.
 *
 * A card is a grid of two columns and two rows. The logo fills the first column over both rows,
 * the name and price share the first row of the second column, and the description sits under them.
 */

/* The row is one cell as wide as the table, with the heading above the cards */
.shop_table tr.gf-dcards-row > td {
	padding-inline: 0;
	text-align: start;
}

/* On phones the cart table prints the cell's name before it; the heading already says it */
table.shop_table tr.gf-dcards-row > td[colspan]::before {
	content: none;
	display: none;
}

.gf-dcards-row .gf-dcards-title {
	margin-bottom: 12px;
	font-weight: 600;
	color: var(--wd-title-color, #242424);
}

.gf-dcards-row ul.gf-dcards {
	display: grid;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
	text-align: start;
}

.gf-dcards-row ul.gf-dcards > li.gf-dcard {
	position: relative;
	display: block;
	margin: 0;
	padding: 0;
}

/* The radio button stays for keyboards and screen readers; the card shows the choice */
.gf-dcards .gf-dcard > input.shipping_method[type="radio"] {
	position: absolute;
	top: 50%;
	left: 24px;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

.gf-dcards .gf-dcard > .gf-dcard__body {
	--gf-dcard-icon: 52px;
	--gf-dcard-icon-radius: 12px;
	display: grid;
	grid-template-columns: var(--gf-dcard-icon) minmax(0, 1fr);
	grid-template-rows: auto auto;
	column-gap: 14px;
	row-gap: 3px;
	align-items: center;
	float: none;
	width: auto;
	margin: 0;
	padding: 12px 14px;
	border: 1px solid rgba(0, 0, 0, .12);
	border-radius: 12px;
	background-color: #fff;
	font-size: inherit;
	font-weight: 400;
	line-height: 1.4;
	text-align: start;
	color: var(--wd-text-color, #767676);
	cursor: pointer;
	transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.gf-dcards .gf-dcard > .gf-dcard__body:hover {
	border-color: rgba(0, 0, 0, .3);
}

/* Chosen option; an only option is sent as a hidden field */
.gf-dcards .gf-dcard > input:checked + .gf-dcard__body,
.gf-dcards .gf-dcard > input[type="hidden"] + .gf-dcard__body {
	border-color: var(--wd-primary-color, #575656);
	box-shadow: inset 0 0 0 1px var(--wd-primary-color, #575656);
	background-color: #fafafa;
}

.gf-dcards .gf-dcard > input[type="hidden"] + .gf-dcard__body {
	cursor: default;
}

.gf-dcards .gf-dcard > input:focus-visible + .gf-dcard__body {
	outline: 2px solid var(--wd-primary-color, #575656);
	outline-offset: 2px;
}

/* Column 1, both rows: the logo */
.gf-dcards .gf-dcard__icon {
	position: relative;
	grid-column: 1;
	grid-row: 1 / span 2;
	display: flex;
	flex-wrap: wrap;
	align-content: center;
	justify-content: center;
	gap: 2px;
	box-sizing: border-box;
	width: var(--gf-dcard-icon);
	height: var(--gf-dcard-icon);
	border-radius: var(--gf-dcard-icon-radius);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
	background-color: #fff;
}

/* A plugin's own wrapper around its logos */
.gf-dcards .gf-dcard__icon > span {
	display: contents;
}

.gf-dcards .gf-dcard__icon img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: var(--gf-dcard-icon-radius);
	box-shadow: none;
	object-fit: contain;
	vertical-align: top;
}

/* Several logos for one option (Bolt, Uber, Yango) share the square */
.gf-dcards .gf-dcard__icon img:not(:only-child) {
	width: calc(50% - 4px);
	height: calc(50% - 4px);
	border-radius: 5px;
}

/* No logo: a line drawing on the theme colour */
.gf-dcards .gf-dcard__icon:has(> .gf-dcard__glyph) {
	box-shadow: none;
	background-color: var(--wd-primary-color, #575656);
	color: #fff;
}

.gf-dcards .gf-dcard__glyph {
	width: 54%;
	height: 54%;
}

/* A tick on the logo of the chosen option */
.gf-dcards .gf-dcard > input:checked + .gf-dcard__body .gf-dcard__icon::after,
.gf-dcards .gf-dcard > input[type="hidden"] + .gf-dcard__body .gf-dcard__icon::after {
	content: "";
	position: absolute;
	right: -6px;
	bottom: -6px;
	width: 20px;
	height: 20px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--wd-primary-color, #575656) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.4l2.6 2.6L12 5.4'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
	box-sizing: border-box;
}

/* Column 2, row 1: name on the left, price on the right */
.gf-dcards .gf-dcard__head {
	grid-column: 2;
	grid-row: 1;
	align-self: end;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	min-width: 0;
}

/* No description: the name and price are centred on the logo */
.gf-dcards .gf-dcard__head:last-child {
	grid-row: 1 / span 2;
	align-self: center;
}

.gf-dcards .gf-dcard__name {
	min-width: 0;
	font-weight: 600;
	line-height: 1.3;
	color: var(--wd-title-color, #242424);
	overflow-wrap: anywhere;
}

.gf-dcards .gf-dcard__price {
	flex: none;
	margin-inline-start: auto;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	color: var(--wd-title-color, #242424);
}

.gf-dcards .gf-dcard__price .amount {
	font-weight: inherit;
	color: inherit;
}

/* "Free" and "Pay Later" where there is no price */
.gf-dcards .gf-dcard__price-note {
	display: inline-block;
	padding: 2px 9px;
	border-radius: 999px;
	background-color: rgba(0, 0, 0, .06);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.5;
	color: var(--wd-text-color, #767676);
}

/* Column 2, row 2: description */
.gf-dcards .gf-dcard__desc {
	grid-column: 2;
	grid-row: 2;
	align-self: start;
	display: block;
	font-size: 13px;
	line-height: 1.45;
}

.gf-dcards .gf-dcard__desc > * {
	display: block;
	margin: 0;
	font-size: inherit;
	line-height: inherit;
	opacity: 1;
}

.gf-dcards .gf-dcard__desc > * + * {
	margin-top: 2px;
}

/* Cart page: the lines under the cards */
.gf-dcards-row .woocommerce-shipping-destination,
.gf-dcards-row .woocommerce-shipping-calculator {
	margin-top: 12px;
	text-align: start;
}

@media (max-width: 575px) {
	.gf-dcards .gf-dcard > .gf-dcard__body {
		--gf-dcard-icon: 44px;
		--gf-dcard-icon-radius: 10px;
		column-gap: 12px;
		padding: 10px 12px;
	}
}
