/* ============================================
   MINI-CART DRAWER — Krem.no
   Slide-in cart drawer triggered by the header cart icon.
   Uses aria-hidden for state, CSS transform for animation.
   All values use CSS variables from theme.json.
   ============================================ */

/* --- Overlay backdrop --- */
.mini-cart-overlay {
	position: fixed;
	inset: 0;
	z-index: 1098;
	background-color: rgba(26, 26, 26, 0.48);
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--wp--custom--transition);
}

.mini-cart-overlay[aria-hidden="false"] {
	opacity: 1;
	pointer-events: auto;
}

/* --- Drawer panel --- */
.mini-cart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 420px;
	max-width: 100vw;
	z-index: 1099;
	background-color: var(--wp--preset--color--background);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform var(--wp--custom--transition);
	overflow: hidden;
}

.mini-cart-drawer[aria-hidden="false"] {
	transform: translateX(0);
}

/* Admin bar offset */
body.admin-bar .mini-cart-drawer,
body.admin-bar .mini-cart-overlay {
	top: var(--wp-admin--admin-bar--height, 32px);
}

/* --- Drawer header --- */
.mini-cart-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--wp--custom--spacing--md) var(--wp--custom--spacing--lg);
	border-bottom: 1px solid var(--wp--preset--color--border);
	flex-shrink: 0;
}

.mini-cart-drawer__title {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	color: var(--wp--preset--color--text);
	margin: 0;
}

/* Close button — matches .site-nav__icon styling */
.mini-cart-drawer__close {
	width: var(--wp--custom--icon-size--touch);
	height: var(--wp--custom--icon-size--touch);
	border-radius: 50%;
	background: none;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--text);
	transition: all var(--wp--custom--transition);
	padding: 0;
}

.mini-cart-drawer__close:hover {
	background-color: var(--wp--preset--color--cream);
	color: var(--wp--preset--color--primary);
}

.mini-cart-drawer__close svg {
	width: var(--wp--custom--icon-size--md);
	height: var(--wp--custom--icon-size--md);
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* --- Scrollable content area --- */
.krem-mini-cart__inner {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
}

/* ============================================
   ITEM LIST
   ============================================ */

.mini-cart-items {
	list-style: none;
	margin: 0;
	padding: var(--wp--custom--spacing--md) var(--wp--custom--spacing--lg);
	display: flex;
	flex-direction: column;
	gap: var(--wp--custom--spacing--md);
	flex: 1;
}

.mini-cart-item {
	display: grid;
	grid-template-columns: 72px 1fr 28px;
	gap: var(--wp--custom--spacing--sm);
	align-items: start;
	padding-bottom: var(--wp--custom--spacing--md);
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.mini-cart-item:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

/* Item thumbnail */
.mini-cart-item__thumb img {
	width: 72px;
	height: 72px;
	object-fit: cover;
	border-radius: var(--wp--custom--border-radius--default);
	display: block;
}

.mini-cart-item__thumb a {
	display: block;
	line-height: 0;
}

/* Item info (name + qty × price) */
.mini-cart-item__info {
	display: flex;
	flex-direction: column;
	gap: var(--wp--custom--spacing--xs);
	min-width: 0;
}

.mini-cart-item__name {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	color: var(--wp--preset--color--text);
	text-decoration: none;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

a.mini-cart-item__name:hover {
	color: var(--wp--preset--color--primary);
}

/* Qty + price row */
.mini-cart-item__qty-row {
	display: flex;
	align-items: center;
	gap: var(--wp--custom--spacing--sm);
	margin-top: var(--wp--custom--spacing--xs);
}

.mini-cart-item__price {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	color: var(--wp--preset--color--primary);
	white-space: nowrap;
}

/* ============================================
   QUANTITY SELECTOR (scaled-down cart pattern)
   ============================================ */

.mini-cart-qty {
	display: flex;
	align-items: center;
	border: 2px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--border-radius--pill);
	overflow: hidden;
	width: fit-content;
	flex-shrink: 0;
}

.mini-cart-qty__btn {
	width: 32px;
	height: 32px;
	border: none;
	background: var(--wp--preset--color--background-alt);
	font-size: 1rem;
	font-weight: 700;
	color: var(--wp--preset--color--text);
	cursor: pointer;
	line-height: 1;
	transition: background var(--wp--custom--transition);
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.mini-cart-qty__btn:hover {
	background: var(--wp--preset--color--cream);
}

.mini-cart-qty__input {
	width: 36px;
	height: 32px;
	border: none;
	text-align: center;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	color: var(--wp--preset--color--text);
	background: transparent;
	padding: 0;
	-moz-appearance: textfield;
}

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

/* Variation data */
.mini-cart-item__info .variation {
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--text-muted);
	margin: 0;
}

.mini-cart-item__info .variation dt,
.mini-cart-item__info .variation dd {
	display: inline;
	margin: 0;
}

.mini-cart-item__info .variation dt::after {
	content: ': ';
}

/* Remove button — red circle with white × */
.mini-cart-item__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	min-width: 28px;
	border-radius: 50%;
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	text-decoration: none;
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1;
	transition: background-color var(--wp--custom--transition);
	align-self: start;
	margin-top: var(--wp--custom--spacing--xs);
}

.mini-cart-item__remove:hover {
	background-color: var(--wp--preset--color--primary-dark);
	color: var(--wp--preset--color--white);
	text-decoration: none;
}

/* ============================================
   FOOTER (subtotal + action buttons)
   ============================================ */

.mini-cart-drawer__footer {
	border-top: 2px solid var(--wp--preset--color--border);
	padding: var(--wp--custom--spacing--lg);
	flex-shrink: 0;
}

.mini-cart-drawer__subtotal {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: var(--wp--custom--spacing--md);
}

.mini-cart-drawer__subtotal > span:first-child {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--wp--preset--color--text);
}

.mini-cart-drawer__subtotal > span:last-child {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

.mini-cart-drawer__actions {
	display: flex;
	flex-direction: column;
	gap: var(--wp--custom--spacing--sm);
}

.mini-cart-drawer__actions .btn {
	width: 100%;
	text-align: center;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.mini-cart-drawer__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: var(--wp--custom--spacing--xl) var(--wp--custom--spacing--lg);
	gap: var(--wp--custom--spacing--lg);
	flex: 1;
}

.mini-cart-drawer__empty p {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.1rem;
	color: var(--wp--preset--color--text-muted);
	margin: 0;
}

/* ============================================
   CART ICON BUTTON RESET
   Button replaces the former <a> — ensure it
   looks identical to the other .site-nav__icon links.
   ============================================ */

button.site-nav__icon {
	background: none;
	border: none;
	font: inherit;
	padding: 0;
	cursor: pointer;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
	.mini-cart-drawer,
	.mini-cart-overlay {
		transition-duration: 0s;
	}
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
	.mini-cart-drawer {
		width: 100vw;
	}

	.mini-cart-drawer__header {
		padding: var(--wp--custom--spacing--md);
	}

	.mini-cart-items {
		padding: var(--wp--custom--spacing--md);
	}

	.mini-cart-drawer__footer {
		padding: var(--wp--custom--spacing--md);
	}
}
