/*
 * happymonday/cart — badge + slide-out drawer styles.
 *
 * Tokens used (from assets/tokens.css / theme.json):
 *   --wp--preset--color--accent-1  → orange (#EA6C2F) — badge background, CTA highlights
 *   --wp--preset--color--bg-1      → cream (#FFF9F1)  — badge text, drawer background
 *   --wp--preset--color--ink       → black (#000000)  — borders, text
 *   --hm-* semantic aliases are available via tokens.css on the front end.
 *
 * z-index convention:
 *   .hm-nav  → z-index: 40   (style.css)
 *   overlay  → 200
 *   drawer   → 201
 */

/* =========================================================================
   BADGE
   ========================================================================= */

.hm-nav__cart {
	position: relative;
}

/* The cart icon wrapper is a <button> + adjacent noscript <a>. The badge
   sits absolutely inside .hm-cart-toggle. */
.hm-cart-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0.3rem;
	color: inherit;
	line-height: 1;
}

.hm-cart-toggle svg {
	display: block;
}

.hm-cart-toggle:focus-visible {
	outline: 3px solid var(--hm-ink, #000);
	outline-offset: 2px;
	border-radius: var(--hm-radius-sm, 6px);
}

.hm-cart-badge {
	position: absolute;
	top: -6px;
	right: -8px;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	background: var(--wp--preset--color--accent-1, #EA6C2F);
	color: var(--wp--preset--color--bg-1, #FFF9F1);
	font-size: 0.68rem;
	font-weight: 700;
	font-family: var(--hm-font-body, sans-serif);
	line-height: 18px;
	text-align: center;
	border-radius: var(--hm-radius-pill, 999px);
	pointer-events: none;
	/* Settle badge above the icon. */
	z-index: 1;
}

/* =========================================================================
   OVERLAY
   ========================================================================= */

.hm-cart-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	z-index: 200;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.hm-cart-overlay.is-visible {
	opacity: 1;
	pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
	.hm-cart-overlay {
		transition: none;
	}
}

/* =========================================================================
   DRAWER
   ========================================================================= */

#hm-cart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(360px, 90vw);
	background: var(--hm-bg-1, #FFF9F1);
	z-index: 201;
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
	/* Keep the drawer scrollable when items overflow. */
	overflow: hidden;
}

#hm-cart-drawer.is-open {
	transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
	#hm-cart-drawer {
		transition: none;
	}
}

.hm-cart-drawer__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}

/* ----- header row -------------------------------------------------------- */

.hm-cart-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1.1rem var(--hm-sp-2, 1.2rem);
	border-bottom: 1px solid var(--hm-line, rgba(0, 0, 0, 0.12));
	flex-shrink: 0;
}

.hm-cart-drawer__title {
	font-family: var(--hm-font-head, serif);
	font-weight: 600;
	font-size: var(--hm-fs-lg, 1.25rem);
	color: var(--hm-ink, #000);
	line-height: 1;
}

.hm-cart-drawer__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	cursor: pointer;
	color: var(--hm-ink, #000);
	padding: 0.35rem;
	border-radius: var(--hm-radius-sm, 6px);
	transition: background 0.15s ease;
}

.hm-cart-drawer__close:hover {
	background: var(--hm-bg-1-deep, #f0ece3);
}

.hm-cart-drawer__close:focus-visible {
	outline: 3px solid var(--hm-ink, #000);
	outline-offset: 2px;
}

/* ----- item list --------------------------------------------------------- */

.hm-cart-drawer__items {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: var(--hm-sp-2, 1.2rem);
}

.hm-cart-drawer__empty {
	color: var(--hm-text-muted, rgba(0, 0, 0, 0.62));
	font-size: var(--hm-fs-sm, 0.9rem);
	margin: 0;
	text-align: center;
	padding-top: var(--hm-sp-2, 1.2rem);
}

.hm-cart-drawer__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.hm-cart-drawer__item {
	display: grid;
	/* [thumb] [title] [price] [remove] — thumb column collapses when absent */
	grid-template-columns: auto 1fr auto auto;
	align-items: center;
	gap: 0.5rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--hm-line, rgba(0, 0, 0, 0.1));
}

.hm-cart-drawer__item:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

.hm-cart-drawer__item.is-unavailable {
	opacity: 0.55;
}

/* Thumbnail link wrapper (decorative — aria-hidden, tabindex=-1) */
.hm-cart-drawer__item-thumb-link {
	display: block;
	line-height: 0;
	flex-shrink: 0;
}

/* Thumbnail image */
.hm-cart-drawer__item-thumb {
	display: block;
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: var(--hm-radius, 8px);
	background: var(--hm-line, rgba(0, 0, 0, 0.08));
}

.hm-cart-drawer__item-title {
	font-size: var(--hm-fs-sm, 0.9rem);
	font-weight: 600;
	color: var(--hm-ink, #000);
	line-height: 1.35;
	text-decoration: none;
}

a.hm-cart-drawer__item-title:hover,
a.hm-cart-drawer__item-title:focus {
	text-decoration: underline;
}

.hm-cart-drawer__item-price {
	font-size: var(--hm-fs-sm, 0.9rem);
	color: var(--hm-text-muted, rgba(0, 0, 0, 0.62));
	white-space: nowrap;
}

.hm-cart-drawer__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	cursor: pointer;
	color: var(--hm-text-muted, rgba(0, 0, 0, 0.55));
	padding: 0.2rem;
	border-radius: var(--hm-radius-sm, 6px);
	transition: color 0.15s ease;
	flex-shrink: 0;
}

.hm-cart-drawer__remove:hover {
	color: var(--hm-ink, #000);
}

.hm-cart-drawer__remove:focus-visible {
	outline: 3px solid var(--hm-ink, #000);
	outline-offset: 2px;
}

/* ----- totals ------------------------------------------------------------ */

.hm-cart-drawer__totals {
	padding: var(--hm-sp-1, 0.7rem) var(--hm-sp-2, 1.2rem);
	border-top: 1px solid var(--hm-line, rgba(0, 0, 0, 0.12));
	flex-shrink: 0;
}

.hm-cart-drawer__totals-inner {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.hm-cart-drawer__total-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	font-size: var(--hm-fs-sm, 0.9rem);
	color: var(--hm-text-muted, rgba(0, 0, 0, 0.62));
}

.hm-cart-drawer__total-row--discount {
	color: var(--wp--preset--color--accent-1, #EA6C2F);
}

.hm-cart-drawer__total-row--total {
	font-weight: 700;
	font-size: var(--hm-fs-base, 1rem);
	color: var(--hm-ink, #000);
}

/* ----- action buttons ---------------------------------------------------- */

.hm-cart-drawer__actions {
	padding: var(--hm-sp-1, 0.7rem) var(--hm-sp-2, 1.2rem) var(--hm-sp-2, 1.2rem);
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	flex-shrink: 0;
	border-top: 1px solid var(--hm-line, rgba(0, 0, 0, 0.12));
}

/* Override the .hm-btn tilt-hover when inside the drawer — too much motion
   in a constrained panel. */
.hm-cart-drawer__actions .hm-btn:hover {
	transform: none;
}

.hm-cart-drawer__actions .hm-btn:active {
	transform: scale(0.98);
}
