/*
 * Size Guide link + pop-up (inc/size-guide.php, template-parts/size-guide.php).
 * Loaded on the home, shop / collection and product pages.
 */

/* Trigger: underlined link with a ruler, directly under the size options. */
.r-sg-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: var(--tap);
	margin: 2px 0 6px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--c-ink);
	font-family: var(--f-body);
	font-size: 13px;
	cursor: pointer;
}

.r-sg-link[hidden] {
	display: none;
}

.r-sg-link span {
	text-decoration: underline;
	text-underline-offset: 4px;
}

.r-sg-link:hover {
	color: var(--c-olive);
}

/* On the home collection cards and shop / collection product cards: under the Colors | Sizes row. */
:is(.r-col, .r-card) .r-sg-link {
	align-self: flex-start;
	margin: 4px 0 0;
}

@media (max-width: 860px) {
	:is(.r-col, .r-card) .r-sg-link {
		gap: 6px;
		margin-top: 0;
		font-size: 12px;
	}
}

/* Dialog */
.r-sg {
	box-sizing: border-box;
	width: min(1080px, 100vw - 48px);
	max-width: none;
	max-height: calc(100dvh - 48px);
	padding: 0;
	border: 1px solid var(--c-line);
	border-radius: 12px;
	background: var(--c-panel);
	color: var(--c-ink);
	box-shadow: 0 24px 60px rgb(43 36 30 / .18);
}

.r-sg[open] {
	display: flex;
	flex-direction: column;
}

.r-sg::backdrop {
	background: rgb(43 36 30 / .45);
}

.r-sg__inner {
	box-sizing: border-box;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 24px 32px 32px;
}

.r-sg__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding-bottom: 14px;
	margin-bottom: 24px;
	border-bottom: 1px solid var(--c-line);
}

.r-sg__title {
	margin: 0;
	font-family: var(--f-display);
	font-weight: 500;
	font-size: 40px;
	line-height: 1.1;
}

.r-sg__close {
	width: var(--tap);
	height: var(--tap);
	margin-right: -10px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--c-ink);
	display: grid;
	place-items: center;
	cursor: pointer;
}

.r-sg__body {
	display: grid;
	grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
	gap: 24px;
	align-items: start;
}

.r-sg__diagrams {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.r-sg__diagram {
	display: block;
	width: 100%;
	height: auto;
	max-height: 280px;
	object-fit: contain;
	mix-blend-mode: multiply; /* the drawings sit on white; let the panel colour through */
}

.r-sg__tabs {
	display: none; /* phones only */
}

.r-sg__cards {
	display: grid;
	grid-template-columns: repeat(var(--r-sg-cols, 3), minmax(0, 1fr));
	gap: 14px;
}

.r-sg__card {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 12px 0 14px;
	border: 1px solid var(--c-line);
	border-radius: 8px;
	background: var(--c-input);
}

.r-sg__size {
	margin: 0;
	text-align: center;
	font-family: var(--f-display);
	font-weight: 600;
	font-size: 26px;
	line-height: 1.2;
}

.r-sg__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.r-sg__table thead th {
	padding: 8px 12px;
	background: var(--c-surface);
	text-align: left;
	font-family: var(--f-display);
	font-weight: 600;
	font-size: 17px;
}

.r-sg__table tbody th,
.r-sg__table td {
	padding: 7px 12px;
	border-top: 1px solid var(--c-line);
	text-align: left;
	font-weight: 400;
}

.r-sg__table td {
	width: 3.5em;
	border-left: 1px solid var(--c-line);
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.r-sg__comfort {
	margin-top: 24px;
	padding: 18px 24px;
	border-radius: 8px;
	background: var(--c-surface);
	text-align: center;
}

.r-sg__comfort p {
	margin: 0;
}

.r-sg__comfort-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--f-display);
	font-weight: 600;
	font-size: 26px;
	line-height: 1.2;
}

.r-sg__comfort-text {
	max-width: 620px;
	margin: 4px auto 0 !important;
	font-size: 16px;
}

.r-sg__notes {
	max-width: 620px;
	margin: 10px auto 0 !important;
	font-size: 13px;
	color: var(--c-muted);
}

/* Phones: full-screen sheet, drawings side by side, one size card at a time behind S / M / L tabs. */
@media (max-width: 860px) {
	.r-sg {
		width: 100vw;
		height: 100dvh;
		max-height: none;
		border: 0;
		border-radius: 0;
	}

	.r-sg__inner {
		flex: 1;
		padding: 12px 16px 24px;
	}

	.r-sg__head {
		position: sticky;
		top: -12px;
		z-index: 1;
		margin: -12px -16px 16px;
		padding: 12px 16px 10px;
		background: var(--c-panel);
	}

	.r-sg__title {
		font-size: 30px;
	}

	.r-sg__body {
		grid-template-columns: minmax(0, 1fr);
		gap: 16px;
	}

	.r-sg__diagrams {
		flex-direction: row;
		gap: 8px;
	}

	.r-sg__diagram {
		width: calc(50% - 4px);
		max-height: 190px;
	}

	.r-sg__tabs {
		display: flex;
		gap: 10px;
		margin-bottom: 14px;
	}

	.r-sg__tab {
		flex: 1;
		min-height: var(--tap);
		border: 1px solid var(--c-line-2);
		background: transparent;
		color: var(--c-ink);
		font-family: var(--f-body);
		font-size: 15px;
		cursor: pointer;
	}

	.r-sg__tab[aria-pressed="true"] {
		border-color: var(--c-ink);
		background: var(--c-ink);
		color: var(--c-white);
	}

	.r-sg__cards {
		grid-template-columns: minmax(0, 1fr);
	}

	.r-sg__card:not(.is-active) {
		display: none;
	}

	.r-sg__table {
		font-size: 15px;
	}

	.r-sg__comfort {
		margin-top: 16px;
		padding: 16px;
	}

	.r-sg__comfort-title {
		font-size: 22px;
	}

	.r-sg__comfort-text {
		font-size: 15px;
	}
}
