/**
 * The basket panel, and the two pages behind it.
 *
 * The panel is ours. The pages are WooCommerce's blocks, and what is here for
 * them is only what the brand has to say over the top: a filled button that
 * reads as a button, and a form whose fields are not welded together.
 */

/* -------------------------------------------------------------- the panel */

.diwan-basket {
	inset: 0;
	position: fixed;
	z-index: 9999;
}

/* The admin bar is fixed too, and it is above everything. */
body.admin-bar .diwan-basket {
	inset-block-start: 32px;
}

@media (max-width: 782px) {
	body.admin-bar .diwan-basket {
		inset-block-start: 46px;
	}
}

.diwan-basket[hidden] {
	display: none;
}

.diwan-basket__veil {
	background: rgba(0, 0, 0, 0.4);
	inset: 0;
	position: absolute;
}

/*
 * On the reading edge: the basket opens from the side the page is read towards,
 * which is the right in English and the left in Arabic. One rule, because the
 * offset and the slide are both logical.
 */
.diwan-basket__panel {
	background: var(--diwan-surface, #ffffff);
	block-size: 100%;
	box-shadow: var(--diwan-shadow, 0 8px 28px rgba(0, 0, 0, 0.12));
	display: flex;
	flex-direction: column;
	inline-size: min(420px, 92vw);
	inset-block: 0;
	inset-inline-end: 0;
	position: absolute;
	transform: translateX(0);
	transition: transform 0.25s ease;
}

.diwan-basket.is-closing .diwan-basket__panel,
.diwan-basket.is-opening .diwan-basket__panel {
	transform: translateX(100%);
}

body.rtl .diwan-basket.is-closing .diwan-basket__panel,
body.rtl .diwan-basket.is-opening .diwan-basket__panel {
	transform: translateX(-100%);
}

@media (prefers-reduced-motion: reduce) {
	.diwan-basket__panel {
		transition: none;
	}
}

.diwan-basket__head {
	align-items: center;
	border-block-end: 1px solid var(--diwan-border, #e6e6e6);
	display: flex;
	justify-content: space-between;
	padding: 18px 22px;
}

.diwan-basket__title {
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.06em;
	margin: 0;
	text-transform: uppercase;
}

.diwan-basket__close {
	background: none;
	border: 0;
	cursor: pointer;
	font-size: 26px;
	line-height: 1;
	padding: 0 4px;
}

.diwan-basket__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px 22px;
}

/* WooCommerce's mini basket, in the brand's type. Its own buttons are left out:
   the two at the foot of the panel are the same two, in the language of the
   page and where a thumb can reach them. */
.diwan-basket__body .woocommerce-mini-cart__buttons,
.diwan-basket__body .buttons {
	display: none;
}

.diwan-basket__body ul.cart_list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/*
 * WooCommerce's markup here is a flat list: a remove link, a link holding the
 * cover and the name, and a quantity line. It is laid out rather than rebuilt,
 * because the fragment that refreshes it would undo anything rebuilt.
 */
.diwan-basket__body ul.cart_list li {
	border-block-end: 1px solid var(--diwan-border-soft, #f0f0f0);
	display: flex;
	flex-wrap: wrap;
	gap: 4px 14px;
	padding-block: 14px;
	padding-inline-end: 24px;
	position: relative;
}

.diwan-basket__body ul.cart_list li img {
	border: 1px solid var(--diwan-border, #e6e6e6);
	float: none;
	inline-size: 54px;
	margin: 0;
	order: -1;
}

.diwan-basket__body ul.cart_list li a:not(.remove) {
	align-items: center;
	color: inherit;
	display: flex;
	flex: 1 1 60%;
	font-size: 14px;
	gap: 14px;
	text-decoration: none;
}

.diwan-basket__body ul.cart_list li .quantity {
	color: var(--diwan-text-muted, #6e6e6e);
	flex: 1 1 100%;
	font-size: 13px;
	padding-inline-start: 68px;
}

.diwan-basket__body .remove {
	color: var(--diwan-text-muted, #6e6e6e);
	font-size: 18px;
	inset-block-start: 14px;
	inset-inline-end: 0;
	line-height: 1;
	position: absolute;
	text-decoration: none;
}

.diwan-basket__body .remove:hover {
	color: var(--diwan-danger, #c0392b);
}

.diwan-basket__body .woocommerce-mini-cart__total {
	border-block-start: 1px solid var(--diwan-border, #e6e6e6);
	display: flex;
	font-weight: 600;
	justify-content: space-between;
	margin: 0;
	padding-block: 16px;
}

.diwan-basket__body .woocommerce-mini-cart__empty-message {
	color: var(--diwan-text-muted, #6e6e6e);
	padding-block: 30px;
	text-align: center;
}

.diwan-basket__foot {
	border-block-start: 1px solid var(--diwan-border, #e6e6e6);
	display: grid;
	gap: 10px;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	padding: 18px 22px;
}

.diwan-basket__view,
.diwan-basket__pay {
	border: 1px solid var(--diwan-black, #000000);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.06em;
	padding: 13px 10px;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.diwan-basket__view {
	background: var(--diwan-white, #ffffff);
	color: var(--diwan-black, #000000);
}

.diwan-basket__pay {
	background: var(--diwan-black, #000000);
	color: var(--diwan-white, #ffffff);
}

.diwan-basket__view:hover,
.diwan-basket__view:focus-visible {
	background: var(--diwan-black, #000000);
	color: var(--diwan-white, #ffffff);
}

.diwan-basket__pay:hover,
.diwan-basket__pay:focus-visible {
	background: var(--diwan-blue, #246b8f);
	border-color: var(--diwan-blue, #246b8f);
	color: var(--diwan-white, #ffffff);
}

/* ------------------------------------------------- the basket and checkout */

/*
 * WooCommerce's blocks draw their own buttons, and the theme underlines every
 * link: the checkout button arrived grey with a line through its label and a
 * dark blue hover. Written at the weight the blocks write themselves, plus the
 * element, so this wins without an exclamation mark.
 */
a.wc-block-components-button,
button.wc-block-components-button,
a.wc-block-cart__submit-button,
button.wc-block-cart__submit-button {
	background-color: var(--diwan-black, #000000);
	border-radius: 0;
	color: var(--diwan-white, #ffffff);
	letter-spacing: 0.06em;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 0.2s ease, color 0.2s ease;
}

a.wc-block-components-button:hover,
a.wc-block-components-button:focus,
button.wc-block-components-button:hover,
button.wc-block-components-button:focus,
a.wc-block-cart__submit-button:hover,
a.wc-block-cart__submit-button:focus {
	background-color: var(--diwan-hover, #e0b070);
	color: var(--diwan-hover-text, #3b0f00);
	text-decoration: none;
}

a.wc-block-components-button .wc-block-components-button__text,
button.wc-block-components-button .wc-block-components-button__text {
	color: inherit;
	text-decoration: none;
}

/*
 * The blocks give every text field a gap above it, and the country and state
 * fields are not text fields: they arrived welded to the name above them.
 *
 * Three classes deep because that is how deep WooCommerce's own rule is —
 * .wc-block-components-form .wc-block-components-checkout-step
 * .wc-block-components-country-input { margin-top: 0 } — and a gap has to win
 * against it rather than tie.
 */
.wc-block-components-form .wc-block-components-checkout-step .wc-block-components-address-form > .wc-block-components-country-input,
.wc-block-components-form .wc-block-components-checkout-step .wc-block-components-address-form > .wc-block-components-state-input,
.wc-block-components-form .wc-block-components-checkout-step .wc-block-components-address-form > .wc-block-components-combobox {
	margin-block-start: 12px;
}

/* ------------------------------------------- the basket and checkout pages */

/*
 * WooCommerce's own templates, in the brand's clothes. Its buttons are written
 * with two classes, so these are written with three: one deeper than the thing
 * being answered, which is the same rule the rest of this plugin follows.
 */
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce a.button.alt,
.woocommerce button.button.alt,
.woocommerce input.button.alt {
	background-color: var(--diwan-black, #000000);
	border-radius: 0;
	color: var(--diwan-white, #ffffff);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.06em;
	padding: 13px 22px;
	text-decoration: none;
	text-transform: uppercase;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover,
.woocommerce input.button.alt:hover,
.woocommerce a.button:focus-visible,
.woocommerce button.button:focus-visible,
.woocommerce input.button:focus-visible {
	background-color: var(--diwan-hover, #e0b070);
	color: var(--diwan-hover-text, #3b0f00);
	text-decoration: none;
}

/* The one button on the page that is the point of the page. */
.woocommerce .wc-proceed-to-checkout a.checkout-button {
	display: block;
	font-size: 14px;
	padding: 16px 22px;
	text-align: center;
}

.woocommerce a.button[disabled],
.woocommerce button.button[disabled] {
	background-color: var(--diwan-border-strong, #d5d5d5);
	color: var(--diwan-white, #ffffff);
}

.woocommerce table.shop_table {
	border: 1px solid var(--diwan-border, #e6e6e6);
	border-radius: 0;
}

.woocommerce table.shop_table th {
	font-size: 12px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.woocommerce table.shop_table td.product-name a {
	color: var(--diwan-text, #000000);
	text-decoration: none;
}

.woocommerce table.shop_table td.product-name a:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.woocommerce table.shop_table img {
	inline-size: 54px;
}

/*
 * The basket's covers: the whole jacket, big enough to recognise the book by,
 * in its own two-by-three frame; anything that is not a book in a square with
 * its photograph fitted inside rather than cut. Written past WooCommerce's own
 * rule for the thumbnail cell, which fixes the picture at 32px.
 */
.woocommerce table.shop_table td.product-thumbnail {
	inline-size: 110px;
}

.diwan-basket-cover {
	background: var(--diwan-grey-50, #fafafa);
	display: block;
	inline-size: 88px;
}

.diwan-basket-cover.is-book {
	aspect-ratio: 2 / 3;
}

.diwan-basket-cover.is-thing {
	aspect-ratio: 1 / 1;
}

/* Whole, not cropped: the same rule as every other cover on the site, so a
   jacket of a less usual shape keeps its title and its author's name. */
.woocommerce table.shop_table .diwan-basket-cover img,
.woocommerce-cart table.cart .diwan-basket-cover img {
	block-size: 100%;
	display: block;
	inline-size: 100%;
	max-inline-size: none;
	object-fit: contain;
}

.woocommerce table.shop_table .diwan-basket-cover.is-thing img {
	object-fit: contain;
}

@media (max-width: 768px) {
	/* On a phone WooCommerce stacks each line into a card, and the picture
	   sits at the top of it. WooCommerce hides that cell on a phone with a
	   rule written through the theme's #content, so this one is too. */
	.woocommerce table.shop_table_responsive tr td.product-thumbnail,
	.woocommerce-page #content table.cart tr td.product-thumbnail {
		display: block;
		inline-size: auto;
		text-align: start;
	}

	.woocommerce table.shop_table_responsive tr td.product-thumbnail::before {
		display: none;
	}

	.diwan-basket-cover {
		inline-size: 72px;
	}
}

.woocommerce .quantity input.qty {
	border: 1px solid var(--diwan-border, #e6e6e6);
	padding: 8px;
}

.woocommerce form.woocommerce-checkout input[type="text"],
.woocommerce form.woocommerce-checkout input[type="tel"],
.woocommerce form.woocommerce-checkout input[type="email"],
.woocommerce form.woocommerce-checkout textarea,
.woocommerce form.woocommerce-checkout select,
.woocommerce form .select2-selection {
	border: 1px solid var(--diwan-border, #e6e6e6);
	border-radius: 0;
	font: inherit;
	padding: 11px 12px;
}

/* Every field on the checkout stands clear of the one above it, including the
   ones WooCommerce draws with a select rather than an input. */
.woocommerce form .form-row {
	margin-block-end: 14px;
	padding-block: 0;
}

.woocommerce-billing-fields h3,
.woocommerce-checkout h3,
.woocommerce .cart_totals h2 {
	font-size: 18px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

/* ------------------------------------------------------------ the basket page */

/*
 * Two columns on a wide screen: the books, and the total beside them, kept in
 * view while a long basket scrolls. WooCommerce floats the totals into half the
 * width under the table; here they have their own column.
 */
@media (min-width: 901px) {
	.woocommerce-cart .woocommerce:has(> .woocommerce-cart-form) {
		align-items: start;
		display: grid;
		gap: 36px;
		grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
	}

	.woocommerce-cart .woocommerce:has(> .woocommerce-cart-form) > .woocommerce-notices-wrapper {
		grid-column: 1 / -1;
	}

	/* Under the header, measured by chrome.js while it is stuck; 170px only
	   until then. */
	.woocommerce-cart .woocommerce > .cart-collaterals {
		inset-block-start: var(--diwan-sticky-top, 170px);
		position: sticky;
	}

	.woocommerce-cart .cart-collaterals .cart_totals {
		float: none;
		inline-size: 100%;
	}
}

.woocommerce-cart .cart-collaterals .cart_totals {
	background: var(--diwan-grey-50, #fafafa);
	border: 1px solid var(--diwan-border, #e6e6e6);
	padding: 24px;
}

.woocommerce-cart .cart-collaterals .cart_totals table.shop_table {
	background: var(--diwan-white, #fff);
}

/* Save for later: under the book's name, a quiet line with a heart. */
.diwan-save-later {
	align-items: center;
	color: var(--diwan-text-muted, #6e6e6e);
	display: inline-flex;
	font-size: 12px;
	gap: 5px;
	margin-block-start: 8px;
	text-decoration: none;
}

.woocommerce table.shop_table td.product-name .diwan-save-later {
	color: var(--diwan-text-muted, #6e6e6e);
	display: flex;
	inline-size: fit-content;
}

.woocommerce table.shop_table td.product-name .diwan-save-later:hover,
.woocommerce table.shop_table td.product-name .diwan-save-later:focus-visible {
	color: var(--diwan-wood, #3b0f00);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* The phone's bar: the total and the way on, at the foot of the screen. */
.diwan-cartbar {
	display: none;
}

@media (max-width: 900px) {
	.diwan-cartbar {
		align-items: center;
		background: var(--diwan-white, #fff);
		border-block-start: 1px solid var(--diwan-border, #e6e6e6);
		box-sizing: border-box;
		display: flex;
		gap: 16px;
		inset-block-end: 0;
		inset-inline: 0;
		justify-content: space-between;
		padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
		position: fixed;
		transition: transform 0.2s ease;
		z-index: 90;
	}

	.diwan-cartbar.is-hidden {
		transform: translateY(110%);
	}

	.diwan-cartbar__total {
		display: flex;
		flex-direction: column;
		line-height: 1.25;
	}

	.diwan-cartbar__word {
		color: var(--diwan-text-muted, #6e6e6e);
		font-size: 12px;
	}

	.diwan-cartbar__amount {
		font-size: 17px;
	}

	.diwan-cartbar__go {
		background: var(--diwan-black, #000);
		color: var(--diwan-white, #fff);
		font-size: 14px;
		font-weight: 700;
		letter-spacing: 0.04em;
		padding: 14px 26px;
		text-decoration: none;
		text-transform: uppercase;
	}

	.diwan-cartbar__go:hover,
	.diwan-cartbar__go:focus-visible {
		background: var(--diwan-papyrus, #e0b070);
		color: var(--diwan-wood, #3b0f00);
	}

	/* The WhatsApp button stands clear of the bar rather than on it. */
	body.has-diwan-cartbar {
		--diwan-wa-lift: 72px;
		padding-block-end: 72px;
	}
}

/* A pre-order in the basket (6 October 2026): why only a card is offered. */
.diwan-preorder-notice {
	background: var(--diwan-canvas, #faf7db);
	border-inline-start: 3px solid var(--diwan-success, #1f7a3d);
	color: var(--diwan-text, #000000);
	font-size: 14px;
	line-height: 1.5;
	margin: 0 0 16px;
	padding: 10px 14px;
}
