/* ==========================================================
 * BW SIZE GUIDES — FRONTEND
 * Reusable size guide trigger, modal and table styling.
 * Uses theme colour variables wherever available.
 * ========================================================== */

/* Product page trigger */
.bwsg-product-guide {
	margin-block: 0.75rem;
}

.bwsg-trigger {
	padding: 0;
	color: var(--bw-color-primary, #ed0016);
	background: transparent;
	border: 0;
	font: inherit;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 0.2em;
	cursor: pointer;
}

/* Accessible keyboard focus */
.bwsg-trigger:focus-visible,
.bwsg-dialog__close:focus-visible {
	outline: 3px solid var(--bw-color-primary, #ed0016);
	outline-offset: 3px;
}

/* ==========================================================
 * MODAL — MAIN CONTAINER
 * ========================================================== */

.bwsg-dialog {
	width: min(52rem, calc(100% - 2rem));
	max-height: calc(100dvh - 2rem);
	padding: 0;
	overflow: auto;

	color: var(--bw-color-text, #111);
	background: var(--bw-color-background, #fff);

	border: 1px solid var(--bw-color-border, #e4e4e4);
	border-radius: var(--bw-radius-lg, 0.75rem);

	box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.28);

	font-family: var(
		--wp--preset--font-family--heading,
		"Poppins",
		sans-serif
	);
}

/* Darkened background behind the modal */
.bwsg-dialog::backdrop {
	background: rgba(0, 0, 0, 0.72);
	backdrop-filter: blur(5px);
}

/* Inner modal spacing */
.bwsg-dialog__panel {
	position: relative;
	padding: clamp(1.25rem, 3vw, 2rem);
}

/* Modal heading */
.bwsg-dialog__panel h2 {
	margin: 0 3.5rem 1.5rem 0;

	font-size: clamp(1.25rem, 2vw, 1.6rem);
	font-weight: 800;
	line-height: 1.25;
	letter-spacing: -0.025em;
}

/* ==========================================================
 * CLOSE BUTTON
 * ========================================================== */

.bwsg-dialog__close {
	position: absolute;
	top: 0.9rem;
	right: 0.9rem;

	display: flex;
	align-items: center;
	justify-content: center;

	width: 2.75rem;
	height: 2.75rem;
	padding: 0;

	color: #111;
	background: #fff;

	border: 2px solid var(--bw-color-primary, #ed0016);
	border-radius: 50%;

	font-family: inherit;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1;

	cursor: pointer;
	transition:
		background 180ms ease,
		color 180ms ease,
		transform 180ms ease;
}

.bwsg-dialog__close:hover {
	color: #fff;
	background: var(--bw-color-primary, #ed0016);
	transform: rotate(90deg);
}

/* ==========================================================
 * SIZE TABLE
 * ========================================================== */

/* Allow wide tables to scroll on smaller screens */
.bwsg-table-scroll {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.bwsg-table {
	width: 100%;
	min-width: max-content;
	border-collapse: collapse;

	font-size: 0.875rem;
	line-height: 1.5;
}

/* Shared table cells */
.bwsg-table th,
.bwsg-table td {
	padding: 0.85rem 1rem;
	text-align: left;
	border: 1px solid var(--bw-color-border, #e4e4e4);
}

/* Strong, dark column headings */
.bwsg-table th {
	color: #fff;
	background: var(--bw-color-dark, #111);
	font-weight: 800;
}

/* Alternating row backgrounds */
.bwsg-table tbody tr:nth-child(even) {
	background: var(--bw-color-surface, #f5f5f5);
}

/* Subtle hover feedback */
.bwsg-table tbody tr:hover {
	background: color-mix(
		in srgb,
		var(--bw-color-primary, #ed0016) 6%,
		white
	);
}

/* Size column emphasis */
.bwsg-table tbody td:first-child {
	font-weight: 700;
}

/* ==========================================================
 * NOTES AND FALLBACK CONTENT
 * ========================================================== */

.bwsg-notes {
	margin-top: 1rem;
	white-space: pre-line;
	font-size: 0.875rem;
	line-height: 1.6;
}

.bwsg-unit {
	font-weight: 400;
}

.bwsg-fallback {
	margin-block: 0.75rem;
}

/* ==========================================================
 * MOBILE — CENTRED SIZE GUIDE LIGHTBOX
 * ========================================================== */

@media (max-width: 37.5rem) {
	.bwsg-dialog {
		width: calc(100% - 1.5rem);
		max-width: none;
		max-height: calc(100dvh - 2rem);
		margin: auto;

		border-radius: 0.75rem;
		overflow-y: auto;
	}

	/* Comfortable spacing inside the lightbox */
	.bwsg-dialog__panel {
		padding: 1.25rem;
	}

	/* Mobile heading */
	.bwsg-dialog__panel h2 {
		margin-bottom: 1.25rem;
		font-size: 1.25rem;
	}

	/* Compact table typography */
	.bwsg-table {
		font-size: 0.8rem;
	}

	/* Comfortable table cell spacing */
	.bwsg-table th,
	.bwsg-table td {
		padding: 0.75rem;
	}
}

/* ==========================================================
 * ACCESSIBILITY — REDUCED MOTION
 * ========================================================== */

@media (prefers-reduced-motion: reduce) {
	.bwsg-dialog__close {
		transition: none;
		outline: none;
		box-shadow: none;
	}
}
/* ==========================================================
 * SIZE GUIDE — CLOSE BUTTON FOCUS
 * Keep a single red border for normal interaction.
 * Show a separate focus indicator for keyboard users.
 * ========================================================== */

.bwsg-dialog__close:focus {
    outline: none;
    box-shadow: none;
}

.bwsg-dialog__close:focus-visible {
    outline: 2px solid #111;
    outline-offset: 3px;
}

/* ==========================================================
 * SIZE GUIDE — DIALOG FOCUS OUTLINE
 * Remove the browser outline from the dialog itself.
 * Keyboard focus remains visible on its controls.
 * ========================================================== */

.bwsg-dialog:focus {
    outline: none;
}