/* ------------------------------------------------------------------
   Кнопки покупки в карточке товара: выбор варианта, количество,
   кнопка-значок корзины, «Заказать в 1 клик» и «Смотреть подробнее».
   Подключается из theme-functions/card-arefino.php.

   Разметка приходит из родительского шаблона content-product.php:
   блок .product-action лежит внутри .product-content-outer. Свою
   разметку печатаем отдельным блоком .arefino-card-action на том же
   хуке, поэтому старые правила родительской темы для .product-action
   на неё не действуют.
   ------------------------------------------------------------------ */

/* ---------- контейнер кнопок ---------- */

/* Родительский шаблон content-product.php держит хук
   woocommerce_after_shop_loop_item внутри .product-action — обёртки с
   рамкой сверху, flex-центровкой и правилом «.product-action > * {flex:auto}».
   Наши кнопки лежат в ней, поэтому снимаем оформление обёртки: рамку,
   отступы и центрирование. Других кнопок в этой обёртке нет (плагины
   сравнения и избранного в теме не подключены). */
.woocommerce ul.products li.product .product-action {
	display: block;
	padding: 0;
	border-top: 0;
	text-align: left;
	transition: none;
}

.woocommerce ul.products li.product .arefino-card-action {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 100%;
	margin-top: auto;
	padding: 0;
	border: 0;
	text-align: left;
}

/* ---------- форма покупки ---------- */

.arefino-card-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin: 0;
	width: 100%;
}

/* ---------- выбор варианта: кружки цвета и плитки длины ---------- */

.arefino-card-variation {
	display: flex;
	flex-direction: column;
	gap: 8px;
	position: relative;
	margin: 0;
}

.arefino-card-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
}

.arefino-card-group__label {
	font-size: 11px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: .02em;
	text-transform: uppercase;
	color: #8a8280;
}

.arefino-card-group__options {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.arefino-card-option {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	font-family: inherit;
	background: none;
	border: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: color .18s ease, background-color .18s ease,
		border-color .18s ease, box-shadow .18s ease, opacity .18s ease;
}

/* ---------- кружок цвета ---------- */

.arefino-card-group--color .arefino-card-option {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	box-shadow: inset 0 0 0 1px rgba(24, 24, 24, .16);
}

.arefino-card-group--color .arefino-card-option__swatch {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
}

/* Выбранный цвет — кольцо с отступом вокруг кружка. */
.arefino-card-group--color .arefino-card-option.is-active {
	box-shadow: inset 0 0 0 1px rgba(24, 24, 24, .16),
		0 0 0 2px #fff,
		0 0 0 4px #181818;
}

.arefino-card-group--color .arefino-card-option:not(.is-active):not(:disabled):hover {
	box-shadow: inset 0 0 0 1px rgba(24, 24, 24, .3),
		0 0 0 2px #fff,
		0 0 0 3px rgba(255, 133, 98, .55);
}

.arefino-card-group--color .arefino-card-option:focus-visible {
	outline: 2px solid #ff8562;
	outline-offset: 3px;
}

/* ---------- плитка длины ---------- */

.arefino-card-group:not(.arefino-card-group--color) .arefino-card-option {
	min-width: 44px;
	min-height: 30px;
	padding: 0 9px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.2;
	color: #423735;
	background: #fff;
	border: 1px solid #d9d9d9;
	border-radius: 7px;
	white-space: nowrap;
}

.arefino-card-group:not(.arefino-card-group--color) .arefino-card-option:not(.is-active):not(:disabled):hover {
	border-color: #181818;
}

.arefino-card-group:not(.arefino-card-group--color) .arefino-card-option.is-active {
	color: #fff;
	background: #181818;
	border-color: #181818;
}

.arefino-card-group:not(.arefino-card-group--color) .arefino-card-option:focus-visible {
	outline: 2px solid #ff8562;
	outline-offset: 2px;
}

/* Такого сочетания с уже выбранными атрибутами нет — плитка гаснет. */
.arefino-card-option.is-unavailable {
	opacity: .32;
	cursor: default;
}

.arefino-card-option:disabled {
	pointer-events: none;
}

/* ---------- подсказка под выбором ---------- */

.arefino-card-hint {
	margin: 0;
	font-size: 11.5px;
	line-height: 1.4;
	color: #a09a98;
	transition: color .18s ease;
}

.arefino-card-hint.is-ready {
	font-weight: 600;
	color: #423735;
}

.arefino-card-hint.is-missing {
	color: #d6452f;
}

/* ---------- строка «количество + значок корзины» ---------- */

/* Значок корзины узкий, поэтому всю свободную ширину забирает счётчик
   количества — строка по-прежнему занимает всю ширину карточки. */
.arefino-card-row {
	display: flex;
	gap: 8px;
	align-items: stretch;
}

/* ---------- счётчик количества ---------- */

.arefino-card-qty {
	display: flex;
	flex: 1 1 auto;
	align-items: stretch;
	height: 38px;
	background: #fff;
	border: 1px solid #d9d9d9;
	border-radius: 8px;
	overflow: hidden;
}

.arefino-card-qty__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	padding: 0;
	font-family: inherit;
	font-size: 17px;
	font-weight: 500;
	line-height: 1;
	color: #615454;
	background: #f7f7f7;
	border: 0;
	cursor: pointer;
	transition: background-color .18s ease, color .18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.arefino-card-qty__btn:hover,
.arefino-card-qty__btn:focus-visible {
	background: #ff8562;
	color: #181818;
	outline: none;
}

.arefino-card-qty__btn:disabled {
	color: #c4bfbe;
	background: #f7f7f7;
	cursor: default;
}

.arefino-card-qty__input {
	flex: 1 1 auto;
	width: 40px;
	min-width: 34px;
	padding: 0;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	color: #181818;
	text-align: center;
	background: #fff;
	border: 0;
	border-left: 1px solid #eeedee;
	border-right: 1px solid #eeedee;
	border-radius: 0;
	-moz-appearance: textfield;
}

.arefino-card-qty__input::-webkit-outer-spin-button,
.arefino-card-qty__input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.arefino-card-qty__input:focus {
	outline: none;
	color: #181818;
	background: #fffaf7;
}

/* ---------- кнопка-значок корзины ---------- */

/* Кнопка без текста: квадрат 38×38 со значком корзины. Подпись остаётся
   только для скринридеров (.screen-reader-text), поэтому кнопке задан
   aria-label — визуально надписи нет.

   Почему селектор продублирован с типом и атрибутом: родительская тема
   описывает ВСЕ кнопки отправки правилом `button[type="submit"]`
   (shopire/assets/css/themes.css) со специфичностью 0,1,1. Один класс
   `.arefino-card-add` даёт 0,1,0, поэтому родительское правило выигрывало
   и возвращало кнопке `display: inline-block`, `padding: 1.1rem 2rem`
   (11×20 px) и `border-radius: 10rem`. Из-за `inline-block` переставали
   работать `align-items`/`justify-content`, а 40 px боковых отступов в
   квадрате 38×38 не оставляли места значку: он уезжал влево-вверх и
   обрезался `overflow: hidden`. `button.arefino-card-add[type="submit"]`
   даёт 0,2,1 и перекрывает родительское правило. */
.arefino-card-add,
button.arefino-card-add[type="submit"] {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 38px;
	min-width: 38px;
	height: 38px;
	min-height: 38px;
	padding: 0;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	color: #fff;
	background: #181818;
	border: 1px solid #181818;
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
	-webkit-appearance: none;
	appearance: none;
}

/* Значок корзины наследует цвет кнопки: белый на тёмном, тёмный на
   акцентном фоне при наведении. */
.arefino-card-add__icon {
	display: block;
	width: 20px;
	height: 20px;
	pointer-events: none;
}

.arefino-card-add:hover,
.arefino-card-add:focus-visible {
	background: #ff8562;
	border-color: #ff8562;
	color: #181818;
	outline: none;
}

.arefino-card-add.is-loading {
	opacity: .65;
	cursor: wait;
}

/* «Добавлено»: вместо корзины — галочка, нарисованная псевдоэлементом.
   Сам значок прячем, чтобы не менять разметку в JS. */
.arefino-card-add.is-added {
	background: #199c68;
	border-color: #199c68;
	color: #fff;
}

.arefino-card-add.is-added .arefino-card-add__icon {
	opacity: 0;
}

.arefino-card-add.is-added::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 9px;
	height: 15px;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: translate(-50%, -60%) rotate(45deg);
}

/* ---------- «Итого» ---------- */

.arefino-card-total {
	margin: 0;
	font-size: 12px;
	line-height: 1.4;
	color: #8a8280;
}

.arefino-card-total span {
	font-size: 13px;
	font-weight: 700;
	color: #181818;
	white-space: nowrap;
}

/* ---------- «Заказать в 1 клик» ---------- */

.arefino-card-oneclick {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 38px;
	padding: 0 14px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	color: #181818;
	background: #fff;
	border: 1px solid #181818;
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.arefino-card-oneclick:hover,
.arefino-card-oneclick:focus-visible {
	background: #181818;
	color: #fff;
	outline: none;
}

.arefino-card-oneclick:disabled {
	opacity: .6;
	cursor: wait;
}

/* ---------- «Смотреть подробнее» ---------- */

.woocommerce ul.products li.product .arefino-card-more {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 34px;
	padding: 0 12px;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	color: #615454;
	background: transparent;
	border: 1px dashed #d9d9d9;
	border-radius: 8px;
	transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

.woocommerce ul.products li.product .arefino-card-more:hover,
.woocommerce ul.products li.product .arefino-card-more:focus-visible {
	color: #181818;
	background: #fafafa;
	border-color: #181818;
	outline: none;
}

/* ---------- нет в наличии ---------- */

.arefino-card-out {
	margin: 0;
	padding: 8px 0;
	font-size: 12px;
	font-weight: 600;
	text-align: center;
	color: #8a8280;
}

/* ---------- адаптив ---------- */

@media (max-width: 560px) {
	.arefino-card-qty,
	.arefino-card-add,
	.arefino-card-oneclick {
		min-height: 40px;
	}

	/* Кружки и плитки на узких карточках чуть крупнее — по ним попадают
	   пальцем, а не курсором. */
	.arefino-card-group--color .arefino-card-option {
		width: 28px;
		height: 28px;
	}

	.arefino-card-group:not(.arefino-card-group--color) .arefino-card-option {
		min-width: 46px;
		min-height: 34px;
		font-size: 12.5px;
	}

	.arefino-card-qty__input {
		width: 36px;
	}

	/* Значок корзины остаётся квадратным — на узких карточках его
	   не растягиваем, иначе он съест место у счётчика.
	   Селектор с типом и атрибутом повторяет основной (см. комментарий
	   выше): без этого правило проиграло бы по специфичности и на телефоне
	   кнопка осталась бы 38×38. */
	.arefino-card-add,
	button.arefino-card-add[type="submit"] {
		width: 40px;
		min-width: 40px;
		height: 40px;
		padding: 0;
	}
}
