/* === RIACO Size Guide — Frontend === */

/* ---- Shared table styles ---- */

.riaco-sgfw-size-chart {
	overflow-x: auto;
}

.riaco-sgfw-size-chart table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9em;
}

.riaco-sgfw-size-chart th,
.riaco-sgfw-size-chart td {
	border: 1px solid #ddd;
	padding: 8px 12px;
	text-align: left;
}

.riaco-sgfw-size-chart thead th {
	background: #f5f5f5;
	font-weight: 600;
}

.riaco-sgfw-size-chart tbody tr:nth-child(even) td {
	background: #fafafa;
}

/* ---- Intro text (CPT editor content) ---- */

.riaco-sgfw-chart-intro {
	margin-bottom: 12px;
}

.riaco-sgfw-chart-intro > *:last-child {
	margin-bottom: 0;
}

/* ---- Featured image ---- */

.riaco-sgfw-chart-image {
	margin: 12px 0;
}

.riaco-sgfw-chart-image img.riaco-sgfw-chart-img {
	max-width: 100%;
	height: auto;
	display: block;
	border-radius: 2px;
}

/* ---- Inline display ---- */

.riaco-sgfw-inline {
	margin: 12px 0;
	overflow-x: auto;
}

/* ---- Popup trigger button ---- */

button.riaco-sgfw-popup-trigger {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 8px 0;
	cursor: pointer;
}

.riaco-sgfw-btn-icon {
	width: 1em;
	height: 1em;
	flex-shrink: 0;
	display: block;
}

/* ---- Modal overlay ---- */

.riaco-sgfw-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 99999;
	align-items: center;
	justify-content: center;
}

.riaco-sgfw-modal.riaco-sgfw-open {
	display: flex;
}

.riaco-sgfw-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	cursor: pointer;
}

.riaco-sgfw-modal-inner {
	position: relative;
	background: #fff;
	border-radius: 4px;
	width: min(600px, 90vw);
	max-height: 85vh;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 24px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
	z-index: 1;
}

.riaco-sgfw-modal-close-btn {
	position: absolute;
	top: 10px;
	right: 12px;
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	color: #555;
}

.riaco-sgfw-modal-close-btn:hover {
	color: #000;
}

.riaco-sgfw-modal-close-btn:focus-visible,
button.riaco-sgfw-popup-trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.riaco-sgfw-modal-heading {
	margin: 0 0 16px;
	padding-right: 32px;
	font-size: 1.2em;
}

.riaco-sgfw-modal-body {
	overflow-x: auto;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
	.riaco-sgfw-modal-inner {
		padding: 16px;
		max-width: 96vw;
	}

	.riaco-sgfw-size-chart th,
	.riaco-sgfw-size-chart td {
		padding: 6px 8px;
		font-size: 0.85em;
	}
}

/* Stacked card layout for headed tables on small screens */

@media (max-width: 480px) {
	.riaco-sgfw-size-chart table.riaco-sgfw-has-header {
		display: block;
		border: none;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header tbody,
	.riaco-sgfw-size-chart table.riaco-sgfw-has-header tr {
		display: block;
		width: 100%;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header tr {
		border: 1px solid #ddd;
		border-radius: 3px;
		margin-bottom: 8px;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header td {
		display: flex;
		justify-content: space-between;
		align-items: center;
		border: none;
		border-bottom: 1px solid #eee;
		padding: 7px 10px;
		text-align: right;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header tr td:last-child {
		border-bottom: none;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header td[data-label]::before {
		content: attr(data-label);
		font-weight: 600;
		text-align: left;
		margin-right: 8px;
		flex-shrink: 0;
	}

	.riaco-sgfw-size-chart table.riaco-sgfw-has-header tbody tr:nth-child(even) td {
		background: #fafafa;
	}
}
