/* ===== TripTea — Cart popup =============================================
   Figma desktop node: 903:74817 (Cart, 419w, x=1411 y=106 relative to 1920 frame)
   Figma mobile  node: 903:74904 (Cart, 390 fullscreen)

   Desktop: floating panel anchored under the header cart icon — 419 wide, hug
   height, 16px corner radius, soft shadow. Mobile: fullscreen overlay.
   Internal layout is identical (header bar + item rows + footer with totals);
   the breakpoint just changes positioning / size / shadow.
*/

/* Anchor wraps just the cart icon — gives the popup a positioned ancestor so
   top/right values resolve relative to the icon, not the page. On mobile the
   popup is position:fixed (see media query below), so the anchor stops mattering. */
.tt-cart-popup-anchor {
	position: relative;
	display: inline-flex;
}

.tt-cart-popup {
	display: none;
	position: absolute;
	z-index: 2000;
	top: calc(100% + 8px);
	right: 0;
	width: 419px;
	max-width: calc(100vw - 32px);
	/* Constrain to viewport so popups with many items don't fall off the bottom.
	   140px ≈ sticky header (124) + breathing room. Items list scrolls internally. */
	max-height: calc(100vh - 140px);
	background: #FFFFFF;
	border-radius: 16px;
	box-shadow: 0 12px 60px 0 rgba(0, 0, 0, 0.16);
	font-family: 'DM Sans', sans-serif;
	color: #4A3426;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	font-feature-settings: "case", "cpsp";
	flex-direction: column;
	overflow: hidden;
}
.tt-cart-popup.is-open { display: flex; }
.tt-cart-popup *, .tt-cart-popup *::before, .tt-cart-popup *::after { box-sizing: border-box; }

/* ===== Head bar (Frame 4630) ============================================ */

.tt-cart-popup__head {
	flex: 0 0 auto; /* pinned top — never shrinks even when items list takes most space. */
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 24px 16px;
	border-bottom: 1px solid #EAEAEA;
}
.tt-cart-popup__head-left {
	display: flex;
	align-items: center;
	gap: 16px;
	min-width: 0;
}
.tt-cart-popup__icon {
	width: 24px;
	height: 24px;
	color: #4A3426; /* Figma: bag icon stroke #4A3426 (Dark Tea). */
	flex: 0 0 24px;
}
.tt-cart-popup__title-row {
	display: flex;
	align-items: center;
	gap: 16px;
}
.tt-cart-popup__title {
	font-weight: 700;
	font-size: 18px;
	line-height: 130%;
	color: #4A3426;
}

/* Count badge (Frame 4648) — Light Beige pill with Tea Brown number. */
.tt-cart-popup__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 8px;
	min-height: 20px;
	border-radius: 8px;
	background: #F5EFE7;
	color: #8B5E3C;
	font-weight: 600;
	font-size: 10px;
	line-height: 140%;
}

.tt-cart-popup__close {
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: transparent;
	padding: 0;
	margin: 0;
	color: #4A3426; /* Figma: close-square stroke #4A3426. */
	cursor: pointer;
	display: inline-flex;
	transition: color 0.15s ease;
}
.tt-cart-popup__close:hover { color: #8B5E3C; }
.tt-cart-popup__close:focus-visible {
	outline: 2px solid #8B5E3C;
	outline-offset: 2px;
	border-radius: 4px;
}

/* ===== Items list (Frame 4636 / 4637 / 4638) ============================ */

.tt-cart-popup__items {
	display: flex;
	flex-direction: column;
	/* Shrinks to fit content; scrolls internally when total height exceeds the
	   popup's max-height (or the fullscreen viewport on mobile). min-height:0 is
	   required so a flex child can shrink past its content size and overflow:auto
	   actually engages. overscroll-behavior:contain prevents wheel/touch scrolls
	   from bubbling to the page once you reach the end of the list. */
	flex: 0 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.tt-cart-popup__item {
	position: relative; /* anchor for the absolutely-positioned remove button. */
	display: flex;
	gap: 16px;
	padding: 16px;
	background: #FFFFFF;
	border-bottom: 1px solid #EAEAEA;
}
.tt-cart-popup__item:last-child { border-bottom: 0; }

/* Placeholder remove-from-cart X — not in Figma yet, designer will redo later.
   Top-right corner, small, neutral so it doesn't compete with the prices. */
.tt-cart-popup__item-remove {
	position: absolute;
	top: 6px;
	right: 6px;
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	background: transparent;
	padding: 4px;
	margin: 0;
	color: #6B6B6B;
	cursor: pointer;
	border-radius: 4px;
	line-height: 0;
	transition: color 0.15s ease, background 0.15s ease;
}
.tt-cart-popup__item-remove:hover {
	color: #8B5E3C;
	background: #F5EFE7;
}
.tt-cart-popup__item-remove:focus-visible {
	outline: 2px solid #8B5E3C;
	outline-offset: 1px;
}

/* Square thumb 72×72 with 11.52 radius (Figma Background frame). */
.tt-cart-popup__item-img {
	flex: 0 0 72px;
	width: 72px;
	height: 72px;
	background-color: #F5EFE7;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	border-radius: 11.52px;
	display: block;
}

/* Frame 4641 — title/meta column + prices column, stacked vertically. */
.tt-cart-popup__item-body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}

/* Frame 4640 — title + meta inner column, gap 7. */
.tt-cart-popup__item-info {
	display: flex;
	flex-direction: column;
	gap: 7px;
}

.tt-cart-popup__item-name {
	font-weight: 700;
	font-size: 16px;
	line-height: 140%;
	color: #4A3426;
	text-decoration: none;
}
.tt-cart-popup__item-name:hover {
	color: #8B5E3C;
	text-decoration: none;
}

/* Frame 4596 — quantity + option row, gap 8. */
.tt-cart-popup__item-meta {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	font-weight: 400;
	font-size: 12px;
	line-height: 150%;
	color: #6B6B6B;
}

/* Option is rendered as label+value in one inline group — label inherits the meta
   gray, value gets Tea Brown (Figma's {ts7} inline override). */
.tt-cart-popup__item-option { white-space: nowrap; }
.tt-cart-popup__item-option-label { color: #6B6B6B; }
.tt-cart-popup__item-option-value { color: #8B5E3C; }

/* Prices stack (Frame 4634): old above new, no gap so they read as a pair. */
.tt-cart-popup__item-prices {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}
.tt-cart-popup__item-old-price {
	font-weight: 400;
	font-size: 14px;
	line-height: 150%;
	color: #4A3426;
	text-decoration: line-through;
	text-decoration-skip-ink: auto;
}
.tt-cart-popup__item-price {
	font-weight: 700;
	font-size: 22px;
	line-height: 130%;
	color: #4A3426;
}

/* ===== Footer (Frame 4632) ============================================== */

.tt-cart-popup__foot {
	flex: 0 0 auto; /* pinned bottom — buttons always reachable regardless of cart length. */
	display: flex;
	flex-direction: column;
	gap: 20px; /* Figma Frame 4637 column gap. */
	padding: 16px;
	background: #FFFFFF;
	border-top: 1px solid #EAEAEA; /* separator between scrolling list and pinned footer. */
}

.tt-cart-popup__total-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.tt-cart-popup__total-label {
	font-weight: 700;
	font-size: 22px;
	line-height: 130%;
	color: #4A3426;
}
.tt-cart-popup__total-value {
	font-weight: 700;
	font-size: 22px;
	line-height: 130%;
	color: #8B5E3C;
}

/* Buttons — both share padding/radius/typography. Primary is solid Tea Brown,
   secondary is outlined Tea Brown. (Figma Frame 4870 / 4872.) */
.tt-cart-popup__btn {
	display: inline-flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	height: 48px; /* Figma fixed height — primary + secondary share spec. */
	border-radius: 8px;
	font-weight: 700;
	font-size: 18px;
	line-height: 130%;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
	border: 1px solid transparent;
}
.tt-cart-popup__btn--primary {
	background: #8B5E3C;
	color: #FFFFFF;
	border-color: #8B5E3C;
}
.tt-cart-popup__btn--primary:hover {
	background: #4A3426;
	border-color: #4A3426;
	color: #FFFFFF;
	text-decoration: none;
}
.tt-cart-popup__btn--secondary {
	background: transparent;
	color: #8B5E3C;
	border-color: #8B5E3C;
}
.tt-cart-popup__btn--secondary:hover {
	background: #F5EFE7;
	color: #8B5E3C;
	border-color: #8B5E3C;
	text-decoration: none;
}

.tt-cart-popup__empty {
	padding: 40px 16px;
	text-align: center;
	color: #6B6B6B;
	font-size: 16px;
	font-weight: 400;
}

/* Filler is no longer needed — items section now flex-grows to fill available
   space on mobile and flex-shrinks to scroll on overflow. Kept hidden in markup
   to avoid touching the template. */
.tt-cart-popup__filler { display: none; }

/* ===== Mobile (Figma 903:74904, 390 fullscreen, no shadow) ============== */
@media (max-width: 768px) {
	.tt-cart-popup {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none; /* override the desktop max-height — fullscreen is intentional. */
		border-radius: 0;
		box-shadow: none;
		margin: 0;
		display: none;
	}
	.tt-cart-popup.is-open { display: flex; }

	/* Items section: grows to fill the space between pinned head/foot. Same
	   overflow:auto + min-height:0 from the base style handles long lists. */
	.tt-cart-popup__items {
		flex: 1 1 auto;
	}
}

/* Lock body scroll when fullscreen popup is open on mobile. */
@media (max-width: 768px) {
	body.tt-cart-popup-open { overflow: hidden; }
}
