/* ==========================================================================
   MINI CART DRAWER
   --------------------------------------------------------------------------
   There is no UI Final frame for this state. The UX frame "mini ostukorv" sets
   the structure — a 400px drawer down the right edge over a dimmed page, with
   the added line, the cart's rows, the totals and the two actions — and the
   implemented site supplies every value: its cream, its hairline, its .type-h5
   heading, its buttons, its spacing scale. The frame's own black header bar and
   Inter type are prototype, and are not reproduced.
   ========================================================================== */

.mini-cart {
	position: fixed;
	inset: 0;
	/* Over the sticky header, which sits at 100. A modal that the site header
	   painted across would be a drawer with the page's controls on top of it. */
	z-index: 110;
	display: flex;
	justify-content: flex-end;
	/*
	 * Closed, the drawer is off to the right and the scrim is clear. It stays
	 * a laid-out box the whole time — nothing here is display:none or
	 * visibility:hidden — because a box is what can be slid, and because an
	 * element that has just stopped being hidden cannot be focused in the same
	 * breath. `inert` is what takes a closed drawer out of the reader's reach;
	 * pointer-events is what stops it catching a click meant for the page.
	 */
	pointer-events: none;
	overflow: hidden;
}

.mini-cart.is-open {
	pointer-events: auto;
}

.mini-cart__scrim {
	position: absolute;
	inset: 0;
	/* The weight the header's panels already dim with, on the same ink. */
	background-color: color-mix(in srgb, var(--color-ink) 18%, transparent);
	opacity: 0;
	transition: opacity 260ms linear;
}

.mini-cart.is-open .mini-cart__scrim {
	opacity: 1;
}

/* --------------------------------------------------------------------------
   THE PANEL
   -------------------------------------------------------------------------- */

.mini-cart__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	/* The frame's measure. Below that width the drawer is the viewport, less a
	   strip that keeps the dimmed page visible behind it. */
	max-width: 400px;
	height: 100%;
	background-color: var(--color-cream);
	border-left: 1px solid var(--color-border-nav);
	box-shadow: var(--shadow-md);
	transform: translateX(100%);
	transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mini-cart.is-open .mini-cart__panel {
	transform: none;
}

@media (max-width: 479px) {

	.mini-cart__panel {
		max-width: calc(100% - var(--space-lg));
	}
}

@media (prefers-reduced-motion: reduce) {

	.mini-cart__scrim,
	.mini-cart__panel {
		transition-duration: 1ms;
	}
}

/* --------------------------------------------------------------------------
   HEADER

   The drawer's own title bar, on the panel surface with the nav's hairline
   under it — the header bar's proportions rather than the frame's black band.
   -------------------------------------------------------------------------- */

.mini-cart__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-sm);
	flex-shrink: 0;
	padding: var(--space-md) var(--space-md);
	border-bottom: 1px solid var(--color-border-nav);
}

.mini-cart__title {
	margin: 0;
	/* .type-h5 is Work Sans, and headings are italic Caslon by default. */
	font-style: normal;
}

.mini-cart__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	margin-inline-end: -8px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-text);
	cursor: pointer;
	transition: color var(--transition-base);
}

.mini-cart__close:hover,
.mini-cart__close:focus-visible {
	color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   BODY

   Two parts that behave differently: the rows scroll, the totals do not. The
   body is the flex column that keeps that true at any cart length.
   -------------------------------------------------------------------------- */

.mini-cart__body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.mini-cart__scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: var(--space-md);
}

/* The scrolling region is focusable so a keyboard can reach a long list; it
   should not then draw a box around itself on a mouse click. */
.mini-cart__scroll:focus {
	outline: none;
}

.mini-cart__scroll:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: -2px;
}

/* --------------------------------------------------------------------------
   THE ADDED LINE

   The frame's dashed panel: what went in, and the way to the full cart.
   -------------------------------------------------------------------------- */

.mini-cart__added {
	display: flex;
	flex-direction: column;
	gap: var(--space-xs);
	margin-bottom: var(--space-md);
	padding: 18px;
	border: 1px dashed var(--color-border);
}

.mini-cart__added-text {
	display: flex;
	align-items: flex-start;
	gap: var(--space-xs);
	margin: 0;
	font-family: var(--font-meta);
	font-size: 14px;
	line-height: 20px;
	color: var(--color-ink);
}

.mini-cart__added-mark {
	display: inline-flex;
	flex-shrink: 0;
	/* Optical: the mark sits on the first line's baseline, not its box top. */
	margin-top: 2px;
	color: var(--color-primary);
}

.mini-cart__added-link {
	align-self: flex-end;
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--color-primary);
	text-decoration: underline;
	text-underline-offset: 3px;
	transition: color var(--transition-base);
}

.mini-cart__added-link:hover {
	color: var(--color-primary-dark);
}

/* --------------------------------------------------------------------------
   ITEMS
   -------------------------------------------------------------------------- */

.mini-cart__items {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mini-cart__item {
	display: flex;
	align-items: flex-start;
	gap: var(--space-sm);
	padding-block: var(--space-sm);
	border-bottom: 1px solid var(--color-border);
}

.mini-cart__item-media {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 60px;
	/* The frame's bottle plate: taller than it is wide, on the light surface
	   the catalogue card already stands its bottles on. */
	aspect-ratio: 2 / 3;
	padding: 1px;
	background-color: var(--color-surface-light);
	border: 1px solid var(--color-border);
	overflow: hidden;
}

.mini-cart__item-image {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.mini-cart__item-body {
	flex: 1 1 auto;
	min-width: 0;
}

.mini-cart__item-title {
	margin: 0;
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 15px;
	line-height: 22px;
	color: var(--color-ink);
	overflow-wrap: anywhere;
}

.mini-cart__item-title a {
	color: inherit;
	text-decoration: none;
	transition: color var(--transition-base);
}

.mini-cart__item-title a:hover {
	color: var(--color-primary);
}

.mini-cart__item-origin {
	margin: 4px 0 0;
	font-family: var(--font-heading);
	font-style: italic;
	font-size: 14px;
	line-height: 20px;
	color: var(--color-text);
}

/* The unit price and the unit deposit under the name (usertest 31.10, 21). */
.mini-cart__item-unit {
	margin: var(--space-xs) 0 0;
	font-family: var(--font-ui);
	font-size: 14px;
	line-height: 20px;
	color: var(--color-text);
}

/* Line notes (verified discount, registered-customer benefit), styled like the deposit line. */
.mini-cart__item-deposit,
.mini-cart__item-note {
	margin: 0;
	font-family: var(--font-ui);
	font-size: 12px;
	line-height: 18px;
	color: var(--color-text-secondary);
}

/* The quantity on the left, the line total on the right of the same row. */
.mini-cart__item-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-sm);
	margin-top: var(--space-xs);
}

.mini-cart__item-row .mini-cart__qty {
	margin-top: 0;
}

.mini-cart__item-total {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	margin: 0;
	padding-top: 5px;
	text-align: end;
}

.mini-cart__item-total-value {
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 15px;
	line-height: 22px;
	color: var(--color-ink);
	white-space: nowrap;
}

.mini-cart__item-total-deposit {
	font-family: var(--font-ui);
	font-size: 12px;
	line-height: 18px;
	color: var(--color-text-secondary);
	white-space: nowrap;
}

/* The VAT in the total, once, and where delivery comes in. */
.mini-cart__total-note {
	margin: 4px 0 0;
	font-family: var(--font-ui);
	font-size: 12px;
	line-height: 18px;
	color: var(--color-text-secondary);
}

/* --------------------------------------------------------------------------
   QUANTITY STEPPER
   -------------------------------------------------------------------------- */

.mini-cart__qty {
	display: inline-flex;
	align-items: center;
	margin-top: var(--space-xs);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-button);
}

.mini-cart__qty-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-text);
	cursor: pointer;
	transition: color var(--transition-base);
}

.mini-cart__qty-button:hover:not(:disabled) {
	color: var(--color-primary);
}

.mini-cart__qty-button:disabled {
	color: color-mix(in srgb, var(--color-text) 40%, transparent);
	cursor: not-allowed;
}

.mini-cart__qty-value {
	min-width: 28px;
	text-align: center;
	font-family: var(--font-ui);
	font-size: 14px;
	line-height: 20px;
	color: var(--color-ink);
}

/*
 * A finger is not a cursor. Where the pointer is coarse the stepper grows to a
 * tappable size — the same control, drawn at the size the hand using it needs.
 */
@media (pointer: coarse) {

	.mini-cart__qty-button {
		width: 44px;
		height: 44px;
	}
}

/* While a change is in flight the stepper reads as busy rather than broken. */
.mini-cart.is-busy .mini-cart__qty {
	opacity: 0.5;
}

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */

.mini-cart__footer {
	flex-shrink: 0;
	padding: 25px var(--space-md) var(--space-md);
	background-color: var(--color-surface-light);
	border-top: 1px solid var(--color-border-nav);
}

.mini-cart__totals {
	margin: 0;
}

.mini-cart__total-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-sm);
}

.mini-cart__total-row + .mini-cart__total-row {
	margin-top: var(--space-xs);
}

.mini-cart__total-label,
.mini-cart__total-value {
	margin: 0;
	font-family: var(--font-ui);
	font-size: 16px;
	line-height: 24px;
	color: var(--color-ink);
}

.mini-cart__total-row--grand .mini-cart__total-label {
	font-weight: 600;
}

.mini-cart__total-row--grand .mini-cart__total-value {
	font-weight: 600;
	font-size: 20px;
	line-height: 28px;
}

.mini-cart__actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	margin-top: var(--space-md);
}

.mini-cart__continue {
	display: block;
	width: 100%;
	margin-top: var(--space-sm);
	padding: 0;
	border: 0;
	background: none;
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	text-align: center;
	color: var(--color-text);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
	transition: color var(--transition-base);
}

.mini-cart__continue:hover {
	color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   WHEN A CHANGE DOES NOT LAND
   -------------------------------------------------------------------------- */

.mini-cart__error {
	margin: var(--space-md) var(--space-md) 0;
	padding: 12px 16px;
	background-color: color-mix(in srgb, var(--color-primary) 8%, transparent);
	font-family: var(--font-meta);
	font-size: 14px;
	line-height: 20px;
	color: var(--color-primary-dark);
}

/* --------------------------------------------------------------------------
   EMPTY
   -------------------------------------------------------------------------- */

.mini-cart__empty {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-md);
	padding: var(--space-md);
}

.mini-cart__empty-text {
	margin: 0;
}

/* --------------------------------------------------------------------------
   THE CONTROL

   The header's cart action, saying the drawer it opened is open — the same way
   the magnifier says it about the search panel.
   -------------------------------------------------------------------------- */

.site-header__action--cart[aria-expanded='true'] {
	color: var(--color-primary);
}

/*
 * A finger's targets in the drawer (A4 V21): the close button, the two
 * buttons and "Jätka ostlemist" are at least 44 px where the pointer is
 * coarse; the drawer looks the same, the tappable area grows.
 */
@media (pointer: coarse) {

	.mini-cart__close {
		width: 44px;
		height: 44px;
	}

	.mini-cart__actions .btn {
		min-height: 44px;
	}

	.mini-cart__continue {
		min-height: 44px;
		margin-top: 4px;
	}
}

/*
 * A short screen (320×568, 375×667 and the like): the notice and the totals footer
 * left no room for the product itself (A4 V37). There the notice is drawn
 * tighter and the whole drawer body scrolls as one, the footer after the
 * lines, so the first product is on the first screen; the drawer's look is
 * the same (21.7).
 */
@media (max-height: 700px) {

	.mini-cart__header {
		padding-block: var(--space-sm);
	}

	.mini-cart__body {
		overflow-y: auto;
	}

	.mini-cart__scroll {
		flex: 0 0 auto;
		overflow: visible;
		padding-block: var(--space-sm);
	}

	.mini-cart__added {
		margin-bottom: var(--space-sm);
		padding: 12px;
	}

	.mini-cart__footer {
		padding-block-start: var(--space-sm);
	}
}

/* The narrowest drawer (a 320 px phone): the line total goes under the
   stepper when the two do not fit side by side, never past the edge. */
@media (max-width: 359px) {

	.mini-cart__item-row {
		flex-wrap: wrap;
	}

	.mini-cart__item-total {
		margin-inline-start: auto;
	}
}

/* Opened by the page or by a pointer: focus is on the close button for
   keyboard and screen reader users, without the ring (mini-cart.js; audit
   01.11, A2a-11). Any key press removes the class and the ring returns. */
.mini-cart.is-pointer-opened .mini-cart__close:focus-visible:not(:hover) {
	outline: none;
	box-shadow: none;
	color: var(--color-text); /* its resting colour, not the hover red (audit 01.11, V2-06) */
}

.mini-cart.is-pointer-opened .mini-cart__close:focus-visible:hover {
	outline: none;
	box-shadow: none;
}
