/**
 * Sass variables
 */
@use "../variables-site/variables-site";
@use "../mixins/mixins-main";
@use "../mixins/utilities";
@use "../variables-site/structure";

/**
 * Fonts
 */
@font-face {
	font-family: star;
	src: url("../../../plugins/woocommerce/assets/fonts/star.woff") format("woff");
	font-weight: normal;
	font-style: normal;
}

@font-face {
	font-family: WooCommerce;
	src: url("../../../plugins/woocommerce/assets/fonts/WooCommerce.woff") format("woff");
	font-weight: normal;
	font-style: normal;
}

/**
 * Global elements
 */
a.button {
	display: inline-block;
	text-align: center;
	box-sizing: border-box;
	word-break: break-all;
	color: var(--newspack-theme-color-against-secondary);
	text-decoration: none !important;

	&:hover,
	&:visited {
		color: #fff;
	}
}

.woocommerce {
	.content-area {
		.site-main {
			max-width: 100%;
		}
	}

	.page-description {
		font-size: 1em;
	}

	form .form-row {
		.required {
			color: firebrick;
			text-decoration: none;

			&[title] {
				border: 0 !important;
			}
		}

		.optional {
			visibility: visible;
		}

		&.form-row-first {
			clear: left;

			&:last-child {
				width: 100%;
			}

			+ .form-row:not(.form-row-first):not(.form-row-last) {
				clear: left;
			}
		}
	}
}

.woocommerce-breadcrumb {
	display: none;
}

.woocommerce-pagination {
	font-size: 0.8888em;

	ul.page-numbers {
		margin: 0;
		padding: 0;
		display: block;
		font-weight: 700;
		letter-spacing: -0.02em;
		line-height: 1.2;
	}

	span.page-numbers,
	a.page-numbers,
	.next.page-numbers,
	.prev.page-numbers {
		padding: 0 calc(0.5 * 1rem);
		display: inline-block;
	}
}

.onsale {
	position: absolute;
	top: 0;
	left: 0;
	display: inline-block;
	background: var(--newspack-theme-color-primary);
	color: var(--newspack-theme-color-against-primary);
	font-size: 0.7111em;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.2;
	padding: 0.5rem;
	text-transform: uppercase;
	z-index: 1;
}

.price {
	del {
		opacity: 0.5;
		display: inline-block;
	}
	ins {
		display: inline-block;
	}
}

.woocommerce-product-rating {
	font-size: var(--newspack-theme-font-size-sm);
}

.woocommerce-notices-wrapper:not(:empty) {
	margin-bottom: structure.$size__spacing-unit;
	width: 100%;
}

.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
	align-items: center;
	background: var(--newspack-theme-color-bg-pre);
	display: flex;
	flex-wrap: wrap;
	font-size: var(--newspack-theme-font-size-sm);
	list-style: none;
	margin-bottom: 1.5rem;
	padding: #{0.5 * structure.$size__spacing-unit} structure.$size__spacing-unit;
	overflow: hidden;

	.button {
		float: none;
		margin-left: auto;
		order: 2;
	}

	.showcoupon {
		margin-left: 0.5em;
	}
}

.woocommerce-message {
	background: var(--newspack-theme-color-bg-pre);
}

.woocommerce-error {
	background: firebrick;
	color: #fff;

	a {
		color: #fff;

		&:hover {
			color: #fff;
		}

		&.button {
			background: #111;
		}
	}
}

.woocommerce-store-notice {
	background: var(--newspack-theme-color-primary);
	color: var(--newspack-theme-color-against-primary);
	padding: 1rem;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 999;
}

.admin-bar .woocommerce-store-notice {
	top: 32px;
}

.woocommerce-store-notice__dismiss-link {
	float: right;
	color: var(--newspack-theme-color-against-primary);

	&:hover {
		text-decoration: underline;
		color: var(--newspack-theme-color-against-primary);
	}
}

/**
* Tables
*/
.woocommerce,
.woocommerce-page {
	table.shop_table,
	table.shop_attributes {
		td,
		th {
			word-break: normal;
		}

		th {
			text-align: left;
		}
	}

	table.shop_table {
		font-weight: bold;

		thead,
		.recurring-totals {
			th {
				font-weight: normal;
			}
		}
	}
}

/**
 * Shop page
 */
.archive .woocommerce-products-header__title.page-title {
	color: var(--newspack-theme-color-text-main);
}

.woocommerce-products-header__title.page-title {
	font-size: 1.6875em;
	font-weight: 700;
	text-transform: none;
}

.woocommerce .woocommerce-result-count,
.woocommerce .woocommerce-ordering,
.woocommerce-page .woocommerce-result-count,
.woocommerce-page .woocommerce-ordering {
	float: none;
}

.woocommerce-results-wrapper {
	font-size: var(--newspack-theme-font-size-sm);
	margin-bottom: #{0.5 * structure.$size__spacing-unit};

	@include utilities.media( mobile ) {
		align-items: center;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		> * {
			min-width: 250px;
		}
	}
}

.woocommerce-result-count {
	margin: 0;
}

/**
 * Products
 */
ul.products {
	margin: 0;
	padding: 0;

	li.product {
		list-style: none;
		display: block;

		.woocommerce-loop-product__link {
			display: block;
		}

		.woocommerce-loop-product__title {
			font-size: var(--newspack-theme-font-size-md);
			margin: 0 0 0.5em;

			&::before {
				content: none;
			}
		}

		.star-rating {
			margin-bottom: 0.8rem;
		}

		.price {
			margin-bottom: 1.3rem;
		}

		.price,
		.star-rating {
			display: block;
			font-size: 0.8888em;
		}

		.woocommerce-placeholder {
			border: 1px solid #f2f2f2;
		}

		.button {
			vertical-align: middle;
			word-break: normal;

			&.loading {
				opacity: 0.5;
			}
		}

		.added_to_cart {
			margin-left: 0.5rem;
			font-size: 0.8888em;
		}
	}
}

/* Name your price */
.product .nyp {
	label {
		display: block;
	}
	.nyp-input {
		margin-bottom: 0;
	}
}

.star-rating {
	overflow: hidden;
	position: relative;
	height: 1em;
	line-height: 1;
	font-size: 1em;
	width: 5.4em;
	// stylelint-disable-next-line font-family-no-missing-generic-family-keyword
	font-family: star;

	&::before {
		content: "\73\73\73\73\73";
		float: left;
		top: 0;
		left: 0;
		position: absolute;
	}

	span {
		overflow: hidden;
		float: left;
		top: 0;
		left: 0;
		position: absolute;
		padding-top: 1.5em;
	}

	span::before {
		content: "\53\53\53\53\53";
		top: 0;
		position: absolute;
		left: 0;
	}
}

.product-remove a.remove {
	background: firebrick;
	border-radius: 100%;
	color: #fff;
	display: inline-block;
	font-size: 17px;
	font-weight: 700;
	height: 24px;
	line-height: 22px;
	text-decoration: none !important;
	width: 24px;
	text-align: center;
	text-transform: uppercase;

	&:hover {
		background: #000;
		color: #fff !important;
	}
}

dl.variation,
.wc-item-meta {
	list-style: none outside;

	dt,
	.wc-item-meta-label {
		float: left;
		clear: both;
		margin-right: 0.25rem;
		list-style: none outside;
	}

	dd {
		margin: 0;
	}

	p,
	&:last-child {
		margin-bottom: 0;
	}
}

/**
 * Single product
 */
.single-product {
	div.product {
		position: relative;
	}

	.single-featured-image-header {
		display: none;
	}

	.entry {
		margin-top: 0;
		.entry-title {
			margin-top: 0;
			font-size: 2em;

			&::before {
				margin-top: 0;
			}
		}
	}

	.posted_in {
		font-size: var(--newspack-theme-font-size-sm);
	}

	.woocommerce-product-rating {
		margin-bottom: 2rem;
		line-height: 1;

		.star-rating {
			float: left;
			margin-right: 0.25rem;
		}
	}

	form.cart {
		.quantity {
			float: left;
			margin-right: 0.5rem;
		}

		input {
			width: 5em;
		}
	}

	.woocommerce-variation-add-to-cart {
		.button {
			padding-top: 0.72rem;
			padding-bottom: 0.72rem;
		}

		.button.disabled {
			opacity: 0.2;
		}
	}
}

@include utilities.media( tablet ) {
	.woocommerce #content div.product div.images,
	.woocommerce div.product div.images,
	.woocommerce-page #content div.product div.images,
	.woocommerce-page div.product div.images {
		width: 33%;
	}

	.woocommerce #content div.product div.summary,
	.woocommerce div.product div.summary,
	.woocommerce-page #content div.product div.summary,
	.woocommerce-page div.product div.summary {
		width: 63%;
	}
}

/**
 * Grouped Products
 */
.woocommerce-grouped-product-list {
	white-space: nowrap;

	.suggested-text,
	.suggested-text + .subscription-details {
		font-size: var(--newspack-theme-font-size-sm);
	}

	td .nyp {
		margin-bottom: 0;
	}

	@include utilities.media( mobileonly ) {
		&,
		tbody,
		tr,
		th,
		td {
			display: block;
		}
		td,
		th {
			border: 0;
		}
		tr {
			border-bottom: 1px solid var(--newspack-theme-color-border);
		}
	}
}

table.variations {
	td,
	th {
		border: 0;
		padding-left: 0;
		vertical-align: top;
		word-break: normal;
	}

	label {
		margin: 0;
	}

	select {
		display: block;
		margin-right: 0.5rem;
	}
}

.woocommerce-product-gallery {
	position: relative;
	margin-bottom: 3rem;

	figure {
		margin: 0;
		padding: 0;
	}

	.woocommerce-product-gallery__wrapper {
		margin: 0;
		padding: 0;
	}

	.zoomImg {
		background-color: #fff;
		opacity: 0;
	}

	.woocommerce-product-gallery__image--placeholder {
		border: 1px solid #f2f2f2;
	}

	.woocommerce-product-gallery__image:nth-child(n + 2) {
		width: 25%;
		display: inline-block;
	}

	.flex-control-thumbs {
		li {
			list-style: none;
			cursor: pointer;
			float: left;
		}

		img {
			opacity: 0.5;

			&:hover,
			&.flex-active {
				opacity: 1;
			}
		}
	}

	img {
		display: block;
		height: auto;
	}
}

.woocommerce-product-gallery--columns-3 {
	.flex-control-thumbs li {
		width: 33.3333%;
	}

	.flex-control-thumbs li:nth-child(3n + 1) {
		clear: left;
	}
}

.woocommerce-product-gallery--columns-4 {
	.flex-control-thumbs li {
		width: 25%;
	}

	.flex-control-thumbs li:nth-child(4n + 1) {
		clear: left;
	}
}

.woocommerce-product-gallery--columns-5 {
	.flex-control-thumbs li {
		width: 20%;
	}

	.flex-control-thumbs li:nth-child(5n + 1) {
		clear: left;
	}
}

.woocommerce-product-gallery__trigger {
	position: absolute;
	top: 1rem;
	right: 1rem;
	z-index: 99;
}

.woocommerce-tabs {
	clear: both;
	margin: 2rem 0;

	@include utilities.media( tablet ) {
		margin-top: 0;
	}

	ul {
		border-bottom: 1px solid var(--newspack-theme-color-border);
		margin: 0 0 1.5rem;
		padding: 0;

		li {
			font-size: var(--newspack-theme-font-size-sm);
			margin-right: 1rem;

			a {
				display: inline-block;
				opacity: 0.7;
				padding-bottom: 0.5em;
				text-decoration: none;
			}

			&.active {
				a {
					border-bottom: 4px solid var(--newspack-theme-color-primary);
					opacity: 1;
				}
			}
		}
	}

	.panel {
		> * {
			margin-top: 0 !important;
		}

		h1,
		h2 {
			&::before {
				content: none;
			}
		}

		h2:first-of-type {
			font-size: 1em;
			margin: 0 0 1rem;
		}
	}

	#comments {
		padding-top: 0;
	}

	.comment-reply-title {
		font-size: 1em;
		font-weight: bold;
		margin: 0 0 0.75rem;
		display: block;
	}

	#reviews {
		ol.commentlist {
			padding: 0;
		}

		li.review,
		li.comment {
			list-style: none;
			margin-right: 0;
			margin-bottom: 2.5rem;

			.avatar {
				max-height: 36px;
				width: auto;
				float: right;
			}

			p.meta {
				margin-bottom: 0.5em;
			}
		}

		p.stars {
			margin-top: 0;

			a {
				position: relative;
				height: 1em;
				width: 1em;
				text-indent: -999em;
				display: inline-block;
				text-decoration: none;
				box-shadow: none;

				&::before {
					display: block;
					position: absolute;
					top: 0;
					left: 0;
					width: 1em;
					height: 1em;
					line-height: 1;
					// stylelint-disable-next-line font-family-no-missing-generic-family-keyword
					font-family: WooCommerce;
					content: "\e021";
					text-indent: 0;
				}

				&:hover {
					~ a::before {
						content: "\e021";
					}
				}
			}

			&:hover {
				a {
					&::before {
						content: "\e020";
					}
				}
			}

			&.selected {
				a.active {
					&::before {
						content: "\e020";
					}

					~ a::before {
						content: "\e021";
					}
				}

				a:not(.active) {
					&::before {
						content: "\e020";
					}
				}
			}
		}
	}
}

/**
 * Related products
 */
.woocommerce .related {
	clear: both;

	h2 {
		font-size: var(--newspack-theme-font-size-md);
	}
}

/**
 * Widgets
 */
.widget.woocommerce {
	ul {
		padding-left: 0;

		li {
			list-style: none;
		}
	}
}

.widget .product_list_widget,
.site-footer .widget .product_list_widget {
	margin-bottom: 1.5rem;

	a {
		display: block;
		box-shadow: none;

		&:hover {
			box-shadow: none;
		}
	}

	li {
		padding: 0.5rem 0;

		a.remove {
			float: left;
			margin-top: 7px;
			line-height: 20px;
			color: #fff;
			margin-right: 0.5rem;
		}
	}

	img {
		display: none;
	}
}

.widget_shopping_cart {
	.buttons {
		a {
			display: inline-block;
			margin: 0 0.5rem 0 0;
		}
	}
}

.widget_layered_nav {
	.chosen {
		&::before {
			content: "×";
			display: inline-block;
			width: 16px;
			height: 16px;
			line-height: 16px;
			font-size: 16px;
			text-align: center;
			border-radius: 100%;
			border: 1px solid black;
			margin-right: 0.25rem;
		}
	}
}

.widget_price_filter {
	.price_slider {
		margin-bottom: 1rem;
	}

	.price_slider_amount {
		text-align: right;
		line-height: 2.4;
		font-size: 0.8751em;

		.button {
			float: left;
			padding: 0.4rem 1rem;
		}
	}

	.ui-slider {
		position: relative;
		text-align: left;
		margin-left: 0.5rem;
		margin-right: 0.5rem;
	}

	.ui-slider .ui-slider-handle {
		position: absolute;
		z-index: 2;
		width: 1em;
		height: 1em;
		background-color: #000;
		border-radius: 1em;
		cursor: ew-resize;
		outline: none;
		top: -0.3em;
		margin-left: -0.5em;
	}

	.ui-slider .ui-slider-range {
		position: absolute;
		z-index: 1;
		font-size: 0.7em;
		display: block;
		border: 0;
		border-radius: 1em;
		background-color: #000;
	}

	.price_slider_wrapper .ui-widget-content {
		border-radius: 1em;
		background-color: #666;
		border: 0;
	}

	.ui-slider-horizontal {
		height: 0.5em;
	}

	.ui-slider-horizontal .ui-slider-range {
		top: 0;
		height: 100%;
	}

	.ui-slider-horizontal .ui-slider-range-min {
		left: -1px;
	}

	.ui-slider-horizontal .ui-slider-range-max {
		right: -1px;
	}
}

.widget_rating_filter {
	li {
		text-align: right;

		.star-rating {
			float: left;
			margin-top: 0.3rem;
		}
	}
}

.widget_product_search {
	form {
		position: relative;
	}

	.search-field {
		padding-right: 100px;
	}

	input[type="submit"] {
		position: absolute;
		top: 0.5rem;
		right: 0.5rem;
		padding-left: 1rem;
		padding-right: 1rem;
	}
}

/**
 * Account section
 */
.woocommerce-account {
	.woocommerce-MyAccount-navigation {
		margin: 0 0 2rem;

		ul {
			margin: 0;
			padding: 0;
		}

		li {
			list-style: none;
			padding: 0.5rem 0;
			border-bottom: 1px solid var(--newspack-theme-color-border);

			&:first-child {
				padding-top: 0;
			}

			a {
				box-shadow: none;
				text-decoration: none;
				font-weight: 700;

				&:hover {
					color: var(--newspack-theme-color-primary);
					text-decoration: underline;
				}
			}

			&.is-active {
				a {
					background: var(--newspack-theme-color-primary);
					color: var(--newspack-theme-color-against-primary);
					text-decoration: underline;
				}
			}
		}
	}

	table.account-orders-table {
		.button {
			margin: 0 0.35rem 0.35rem 0;
		}
	}
}

/**
 * Cart
 */
.page-template-single-wide.woocommerce-cart .woocommerce {
	@include utilities.media( desktop ) {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		.woocommerce-notices-wrapper {
			width: 100%;
		}

		.woocommerce-cart-form {
			width: 62%;
		}

		.cart-collaterals {
			background: var(--newspack-theme-color-bg-pre);
			padding: 0 structure.$size__spacing-unit structure.$size__spacing-unit;
			width: 35%;

			.cart_totals {
				float: none;
				width: 100%;
			}
		}

		.woocommerce-shipping-calculator {
			width: 200px;
		}
	}
}

.woocommerce-cart-form {
	.product-thumbnail {
		text-align: center;
		width: 42px;
	}

	img {
		max-width: 42px;
		height: auto;
		display: block;
	}

	dl.variation {
		margin-top: 0;

		p,
		&:last-child {
			margin-bottom: 0;
		}
	}

	.product-remove {
		text-align: center;
	}

	.actions {
		div {
			display: flex;
			align-items: center;

			@include utilities.media( tablet ) {
				width: 50%;
			}
		}
		.input-text {
			margin-right: 4%;
			min-width: 48%;
		}
	}

	.quantity {
		input {
			width: 4rem;
			padding: 0.35rem;
		}
	}
}

.cart_totals {
	th,
	td {
		vertical-align: top;
	}

	th {
		padding-right: 1rem;
	}

	.woocommerce-shipping-destination {
		margin-bottom: 0;
	}

	h2 {
		font-size: var(--newspack-theme-font-size-md);
	}
}

.shipping-calculator-button {
	margin-top: 0.5rem;
	display: inline-block;
}

.shipping-calculator-form {
	margin: 1rem 0 0;
}

.woocommerce-cart .woocommerce-shipping-calculator {
	@include utilities.media( tablet ) {
		display: block;
		width: 200px;
	}
	@include utilities.media( desktop ) {
		width: 320px;
	}
}

// Small screen styles
.woocommerce table.shop_table_responsive,
.woocommerce-page table.shop_table_responsive {
	tbody tr {
		margin-bottom: 0.25em;
	}
	tr:nth-child(2n) td {
		background: transparent;
	}
}

// stylelint-disable-next-line selector-id-pattern
.woocommerce-shipping-totals #shipping_method {
	list-style: none;
	margin: 0;
	padding: 0;

	li {
		margin-bottom: 0.5rem;

		input {
			display: inline;
			margin-right: 0.5em;
		}

		label {
			// stylelint-disable-next-line declaration-property-unit-allowed-list
			line-height: 1.5rem;
		}
	}
}

.checkout-button {
	display: block;

	&::after {
		content: "→";
		margin-left: 0.5rem;
	}
}

/**
 * Checkout
 */
#ship-to-different-address {
	font-size: 1em;
	display: inline-block;
	margin: 1.41rem 0;

	label {
		font-weight: 300;
		cursor: pointer;

		span {
			font-weight: bold;
			display: inline-block;
			padding-right: 45px;
			position: relative;

			&::before {
				content: "";
				display: block;
				height: 16px;
				width: 30px;
				border: 2px solid #bbb;
				background: #bbb;
				border-radius: 13rem;
				box-sizing: content-box;
				transition: all ease-in-out 0.3s;
				position: absolute;
				top: 2px;
				right: 0;
			}

			&::after {
				content: "";
				display: block;
				width: 14px;
				height: 14px;
				background: white;
				position: absolute;
				top: 5px;
				right: 17px;
				border-radius: 13rem;
				transition: all ease-in-out 0.3s;
			}
		}

		input[type="checkbox"] {
			display: none;
		}

		input[type="checkbox"]:checked + span::after {
			right: 3px;
		}

		input[type="checkbox"]:checked + span::before {
			border-color: var(--newspack-theme-color-secondary-against-white);
			background: var(--newspack-theme-color-secondary-against-white);
		}
	}
}

/**
 * One-page checkout
 */
/* stylelint-disable selector-id-pattern  */
#order_review .opc_order_review {
	.product-name {
		align-items: center;
		display: flex;
		height: 100%;
	}

	.product-remove {
		float: none;
		margin-right: #{0.25 * structure.$size__spacing-unit};
		order: -1;
	}

	.product-quantity {
		margin: 0 structure.$size__spacing-unit 0 auto;

		@include utilities.media( tablet ) {
			margin-right: #{3 * structure.$size__spacing-unit};
		}
	}
}
/* stylelint-enable */

.woocommerce-no-js {
	form.woocommerce-form-login,
	form.woocommerce-form-coupon {
		display: block !important;
	}
	.woocommerce-form-login-toggle,
	.woocommerce-form-coupon-toggle,
	.showcoupon,
	.woocommerce-tabs ul {
		display: none !important;
	}
}

.woocommerce-terms-and-conditions {
	border: 1px solid rgba(0, 0, 0, 0.2);
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
	background: rgba(0, 0, 0, 0.05);
}

.woocommerce-terms-and-conditions-link {
	display: inline-block;

	&::after {
		content: "";
		display: inline-block;
		border-style: solid;
		margin-bottom: 2px;
		margin-left: 0.25rem;
		border-width: 6px 6px 0;
		border-color: currentcolor transparent transparent;
	}
	&.woocommerce-terms-and-conditions-link--open::after {
		border-width: 0 6px 6px;
		border-color: transparent transparent currentcolor;
	}
}

.woocommerce-checkout {
	h3 {
		font-size: var(--newspack-theme-font-size-md);
		margin-bottom: structure.$size__spacing-unit;
		margin-top: 2 * structure.$size__spacing-unit;
	}

	.woocommerce-billing-fields,
	.woocommerce-account-fields,
	.woocommerce-shipping-fields,
	.woocommerce-additional-fields {
		label {
			font-size: var(--newspack-theme-font-size-sm);
		}
	}

	.woocommerce-billing-fields {
		h3 {
			margin-bottom: 0;
		}
	}

	.woocommerce-input-wrapper {
		.description {
			background: royalblue;
			color: #fff;
			border-radius: 3px;
			padding: 1rem;
			margin: 0.5rem 0 0;
			clear: both;
			display: none;
			position: relative;

			a {
				color: #fff;
				text-decoration: underline;
				border: 0;
				box-shadow: none;
			}

			&::before {
				left: 50%;
				top: 0%;
				margin-top: -4px;
				transform: translateX(-50%) rotate(180deg);
				content: "";
				position: absolute;
				border-width: 4px 6px 0;
				border-style: solid;
				border-color: royalblue transparent transparent;
				z-index: 100;
				display: block;
			}
		}
	}

	.select2-choice,
	.select2-choice:hover {
		box-shadow: none !important;
	}
	.select2-choice {
		padding: 0.7rem 0 0.7rem 0.7rem;
	}
	.select2-container .select2-selection--single {
		height: 48px;
	}
	.select2-container .select2-selection--single .select2-selection__rendered {
		line-height: 48px;
	}
	.select2-container--default .select2-selection--single .select2-selection__arrow {
		height: 46px;
	}
	.select2-container--focus .select2-selection {
		border-color: black;
	}
}

.woocommerce-checkout-review-order-table,
table.woocommerce-table--order-details.shop_table,
.my_account_orders,
.woocommerce-product-attributes,
.woocommerce-grouped-product-list.group_table,
.woocommerce-cart-form .woocommerce-cart-form__contents,
.cart-collaterals .shop_table_responsive,
.woocommerce-table--order-downloads {
	border-top: 1px solid var(--newspack-theme-color-border);

	thead {
		th,
		td {
			background-color: var(--newspack-theme-color-bg-pre);
			font-weight: bold;
		}
	}

	td {
		font-weight: normal;
	}

	td,
	th {
		border-color: var(--newspack-theme-color-border);
		border-width: 0 0 1px;
		padding: 0.5rem;
	}

	tfoot th {
		font-weight: normal;
	}
}

.woocommerce-checkout-review-order-table,
table.woocommerce-table--order-details.shop_table,
.my_account_orders {
	dl.variation {
		margin: 0;

		p {
			margin: 0;
		}
	}

	.recurring-totals {
		th,
		td {
			background-color: var(--newspack-theme-color-bg-pre);
			font-weight: bold;
		}
	}

	.cart-subtotal,
	.woocommerce-shipping-totals.shipping,
	.shipping.recurring-total {
		th,
		td {
			// stylelint-disable-next-line function-calc-no-invalid
			font-size: calc(var(--newspack-theme-font-size-sm));
			font-weight: normal;
			vertical-align: middle;
		}
	}

	.cart-subtotal.recurring-total {
		font-weight: bold;
	}
}

.woocommerce-checkout-review-order {
	ul {
		margin: 2rem 0 1rem;
		padding-left: 0;
	}
}

.wc_payment_methods {
	padding-left: 0;
}

.wc_payment_method {
	list-style: none;

	.payment_box {
		padding: 1rem;
		background: var(--newspack-theme-color-bg-pre);
		font-size: var(--newspack-theme-font-size-sm);

		ul,
		ol {
			&:last-of-type {
				margin-bottom: 0;
			}
		}

		fieldset {
			padding: 0;
			border: 0;
		}

		li {
			list-style: none;
		}

		p {
			&:first-child {
				margin-top: 0;
			}

			&:last-child {
				margin-bottom: 0;
			}
		}
	}

	> label:first-of-type {
		display: block;
		margin: 1rem 0;

		img {
			max-height: 24px;
			max-width: 200px;
			float: right;
		}
	}

	label {
		cursor: pointer;
	}

	input.input-radio[name="payment_method"] {
		display: none;

		+ label {
			&::before {
				content: "";
				display: inline-block;
				width: 16px;
				height: 16px;
				border: 2px solid white;
				box-shadow: 0 0 0 2px black;
				background: white;
				margin-left: 4px;
				margin-right: 0.5rem;
				border-radius: 100%;
				transform: translateY(2px);
			}
		}

		&:checked + label {
			&::before {
				background: black;
			}
		}
	}
}

.woocommerce-order-overview {
	margin-bottom: 2rem;
}

.woocommerce-table--order-details {
	margin-bottom: 2rem;
}

.woocommerce-terms-and-conditions-wrapper {
	font-size: var(--newspack-theme-font-size-sm);
	margin-bottom: 2 * structure.$size__spacing-unit;

	input[type="checkbox"] {
		margin-right: 0.5 * structure.$size__spacing-unit;
	}
}

/**
 * Layout stuff
 */
@media only screen and ( max-width: 768px ) {
	.woocommerce,
	.woocommerce-page {
		table.shop_table_responsive {
			tr {
				margin: 0 0 1.5rem;

				&:last-child {
					margin-bottom: 0;
				}

				td {
					border-bottom-width: 0;

					&:last-child {
						border-bottom-width: 1px;
					}
				}
			}
		}
	}

	.woocommerce-product-gallery__trigger {
		right: 1rem;
	}
}

@media only screen and ( min-width: 768px ) {
	/**
	* Shop page
	*/
	.woocommerce-products-header__title.page-title {
		font-size: 2.25em;
	}

	.woocommerce-pagination {
		span.page-numbers,
		a.page-numbers,
		.next.page-numbers,
		.prev.page-numbers {
			padding: 1rem;
		}
	}

	/**
	* Account section
	*/
	.woocommerce-account {
		.woocommerce-MyAccount-navigation {
			float: none;
			width: 100%;
			margin-bottom: 1.5rem;

			li {
				display: inline-block;
				margin: 0 1rem 0 0;
				padding: 0;
				border-bottom: 0;

				&:last-child {
					margin-right: 0;
				}
			}
		}

		.woocommerce-MyAccount-content {
			float: none;
			width: 100%;
		}
	}

	/**
	* Checkout
	*/
	#ship-to-different-address {
		display: block;
	}

	/**
	* Layout stuff
	*/
	.single-product {
		.entry {
			.entry-content,
			.entry-summary {
				max-width: none;
				margin: 0 0 3rem;
				padding: 0;

				> * {
					max-width: none;
				}
			}
		}
	}
}

.cart-summary-header {
	align-items: center;
	display: flex;
	justify-content: space-between;

	h3 {
		margin-top: 1rem;
	}
}

#toggle-order-details {
	align-items: center;
	background: transparent;
	color: var(--newspack-theme-color-text-main);
	display: flex;
	padding: 0;

	&:hover {
		background: transparent;
		color: var(--newspack-theme-color-text-light);
	}

	svg {
		transform: rotate(90deg);
	}

	&.order-details-hidden svg {
		transform: rotate(-90deg);
	}
}

#order-details-wrapper {
	h3 {
		margin-top: 3rem;
	}
}

.order-details-hidden {
	display: none;
}

.order-details-summary {
	h4 {
		font-size: 0.95em;
		font-weight: normal;

		> span {
			color: var(--newspack-theme-color-text-light);
			display: block;
		}
	}
}

.woocommerce-customer-details {
	border-top: 1px solid var(--newspack-theme-color-border);
	padding-top: structure.$size__spacing-unit;
	address {
		font-size: 90%;
		font-style: normal;
	}
}

/**
* Card.
*/

.woocommerce-buttons-card {
	display: flex;
	flex-wrap: wrap;
	gap: 0.8em;
	justify-content: flex-end;
}

.woocommerce-card {
	a {
		align-items: center;
		border: 1px solid var(--newspack-theme-color-border-light);
		border-radius: 5px;
		display: flex;
		gap: 0.8em;
		padding: 0.8em;
		text-decoration: none;

		&::after {
			background-image: url('data:image/svg+xml,%3Csvg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" fill="%23111" /%3E%3C/svg%3E');
			content: "";
			display: block;
			flex: 0 0 24px;
			height: 24px;
			transition: all 125ms ease-in-out;
			width: 24px;
		}

		&:hover {
			border-color: var(--newspack-theme-color-text-main);

			&::after {
				transform: translateX(0.4em);
			}
		}
	}

	&__content {
		display: flex;
		flex: 1 1 auto;
		flex-wrap: wrap;
		gap: 0.4em;

		span {
			display: block;
			flex: 1 1 100%;
		}
	}

	&__title {
		color: var(--newspack-theme-color-text-main);
		font-size: 1em;
		line-height: 1.6;
		margin: 0;

		.is-destructive & {
			color: var(--newspack-theme-color-alert-red);
		}
	}

	&__description {
		color: var(--newspack-theme-color-text-light);
		font-size: 0.8em;
		line-height: 1.2;
	}

	& + & {
		margin-top: 1rem;
	}
}

/**
 * My Account Page.
 */

.logged-in.page-template-single-wide.woocommerce-account,
.logged-in.page-template-single-feature.woocommerce-account {
	.entry-header {
		display: none;
	}

	.woocommerce-MyAccount-navigation {
		border: 1px solid var(--newspack-theme-color-border-light);
		padding: 0.8em;
		border-radius: 6px;
		ul {
			li {
				border: 0;
				display: block;
				margin: 0;
				padding: 0;
				a {
					@include utilities.button-transition;

					background: var(--newspack-theme-color-bg-body);
					border: none;
					border-radius: 5px;
					box-sizing: border-box;
					display: block;
					color: inherit;
					font-size: var(--newspack-theme-font-size-sm);
					font-weight: 700;
					line-height: var(--newspack-theme-font-line-height-heading);
					outline: none;
					padding: ( structure.$size__spacing-unit * 0.76 ) structure.$size__spacing-unit;
					text-decoration: none;
					vertical-align: bottom;

					&:hover,
					&:hover:visited {
						background: var(--newspack-theme-color-bg-body);
						color: var(--newspack-theme-color-primary-against-white);
						cursor: pointer;
					}

					&:visited {
						color: inherit;
						text-decoration: none;
					}

					&:focus-visible {
						background: var(--newspack-theme-color-bg-body);
						color: inherit;
						outline: var(--newspack-theme-color-border) thin solid;
						outline-offset: -1px;
					}
				}
				&.is-active {
					a {
						background: var(--newspack-theme-color-primary);
						color: var(--newspack-theme-color-against-primary);

						&:focus-visible {
							outline-color: var(--newspack-theme-color-bg-body);
							outline-offset: -4px;
						}
					}
				}
			}
		}
	}

	.woocommerce-form-row,
	p {
		&.mt0 {
			margin-top: 0;
		}
	}

	.woocommerce-Button {
		&.ma0 {
			margin: 0;
		}
	}

	@include utilities.media( tablet ) {
		.entry-content .woocommerce {
			align-items: start;
			display: grid;
			gap: 3.2rem;
			grid-template-columns: 1fr 2fr;
		}

		.woocommerce-MyAccount-content {
			.woocommerce-notices-wrapper + *,
			.woocommerce-account-my-memberships :first-child,
			.woocommerce_account_subscriptions :first-child {
				margin-top: 0;
			}
		}

		.wcs-gifting-recipient-details-content {
			grid-column: 1/-1;
		}
	}
}

// Membership appearance
.wc-memberships-member-discount-message {
	margin-top: 1rem;

	a:not(:hover) {
		text-decoration: underline;
	}
}

.woocommerce span.onsale.wc-memberships-member-discount {
	left: 0;
}
