/*
 * Simple Size Guide
 *
 * No fonts or brand colours are hard-coded: everything inherits from the
 * theme. Lines and tints are derived from the current text colour, the modal
 * background and corner radius are read from the page by the script.
 * Classes are doubled (.ssg-x.ssg-x) to win over generic theme selectors
 * such as ".woocommerce button".
 */

.ssg {
	margin: 0 0 1em;
}

.ssg.ssg--moved {
	margin: 0;
}

/*
 * Button: a small tinted label in the theme's own type. The script copies the
 * size dropdown's background and corners into --ssg-btn-bg / --ssg-btn-radius.
 */
.ssg-trigger.ssg-trigger {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	width: auto;
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0 0.125em;
	border: 0;
	border-radius: var(--ssg-btn-radius, 0);
	background: var(--ssg-btn-bg, color-mix(in srgb, currentColor 8%, transparent));
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	line-height: inherit;
	text-transform: none;
	text-decoration: none;
	vertical-align: middle;
	white-space: nowrap;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

/* Size dropdown with the button underneath, wrapped by the script. */
.ssg-field {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5em;
}

.ssg-field > .ssg-trigger.ssg-trigger {
	flex: none;
}

.ssg-trigger.ssg-trigger:hover {
	opacity: 0.6;
}

.ssg-trigger.ssg-trigger:focus-visible,
.ssg-modal__close.ssg-modal__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Modal */
.ssg-modal.ssg-modal {
	--ssg-line: color-mix(in srgb, currentColor 15%, transparent);
	--ssg-tint: color-mix(in srgb, currentColor 6%, transparent);
	--ssg-muted: color-mix(in srgb, currentColor 60%, transparent);
	--ssg-r: min(var(--ssg-radius, 0px), 16px);

	box-sizing: border-box;
	width: min(36rem, calc(100vw - 2rem));
	max-width: none;
	max-height: calc(100dvh - 2rem);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: var(--ssg-r);
	background: var(--ssg-bg, #fff);
	color: inherit;
	font: inherit;
	text-align: start;
	box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.18);
	overflow: hidden;
}

.ssg-modal.ssg-modal[open] {
	display: flex;
	flex-direction: column;
	animation: ssg-in 0.2s ease-out;
}

.ssg-modal::backdrop {
	background: rgba(0, 0, 0, 0.4);
}

html:has(.ssg-modal[open]) {
	overflow: hidden;
}

.ssg-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.25rem 1.5rem;
	background: var(--ssg-head-bg, var(--ssg-tint));
}

/* Keeps the theme's heading family and weight, just sized for a modal. */
.ssg-modal .ssg-modal__title {
	margin: 0;
	padding: 0;
	font-size: 1.25em;
	line-height: 1.2;
}

.ssg-modal__close.ssg-modal__close {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 2.5rem;
	height: 2.5rem;
	min-height: 0;
	margin: -0.5rem -0.75rem -0.5rem 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.ssg-modal__close.ssg-modal__close:hover {
	opacity: 0.6;
}

.ssg-modal__body {
	padding: 0.5rem 1.5rem 1.5rem;
	overflow: auto;
	overscroll-behavior: contain;
}

/* Table */
.ssg-table-wrap {
	overflow-x: auto;
}

.ssg-modal .ssg-table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	background: none;
	color: inherit;
	font: inherit;
	font-variant-numeric: tabular-nums;
}

.ssg-modal .ssg-table th,
.ssg-modal .ssg-table td {
	padding: 0.85em 0.5em;
	border: 0;
	border-bottom: 1px solid var(--ssg-line);
	background: none;
	color: inherit;
	font: inherit;
	text-align: end;
	vertical-align: middle;
	white-space: nowrap;
}

.ssg-modal .ssg-table th:first-child {
	padding-inline-start: 0;
	text-align: start;
}

.ssg-modal .ssg-table th:last-child,
.ssg-modal .ssg-table td:last-child {
	padding-inline-end: 0;
}

.ssg-modal .ssg-table thead th {
	color: var(--ssg-muted);
	font-size: 0.875em;
}

.ssg-modal .ssg-table tbody tr.is-selected > * {
	background: var(--ssg-tint);
}

.ssg-modal .ssg-table tbody tr.is-selected > :first-child {
	padding-inline-start: 0.5em;
}

.ssg-modal .ssg-table tbody tr.is-selected > :last-child {
	padding-inline-end: 0.5em;
}

.ssg-modal .ssg-meta,
.ssg-modal .ssg-note {
	margin: 1em 0 0;
	color: var(--ssg-muted);
	font-size: 0.875em;
}

.ssg-modal .ssg-meta + .ssg-note {
	margin-top: 0.25em;
}

/* Mobile: bottom sheet */
@media (max-width: 600px) {
	.ssg-modal.ssg-modal {
		width: 100%;
		max-height: 85dvh;
		margin: auto 0 0;
		border-radius: var(--ssg-r) var(--ssg-r) 0 0;
	}

	.ssg-modal.ssg-modal[open] {
		animation-name: ssg-up;
		animation-duration: 0.25s;
	}

	.ssg-modal__header {
		padding: 1rem;
	}

	.ssg-modal__body {
		padding: 0.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
	}
}

@keyframes ssg-in {
	from {
		opacity: 0;
		transform: translateY(0.5rem);
	}
}

@keyframes ssg-up {
	from {
		transform: translateY(100%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ssg-modal.ssg-modal[open] {
		animation: none;
	}
}
