/**
 * Mobile PDP size summary trigger + slide-up "size" bottom sheet (konte-child).
 *
 * Paired with js/konte-pdp-size-summary.js. On mobile only, the inline Mango-style
 * size list (css/size-selector.css, .kss) is hidden and replaced by a compact
 * trigger row (selected size + "+N sizes" + chevron). Tapping it opens a bottom
 * sheet — model-wearing line, selected colour name + "Measurements and Size Guide"
 * link, the full size list (selected highlighted, out-of-stock greyed), and the
 * fit-summary line. Selecting a size drives the real WCBoost size <li> and closes
 * the sheet, so WooCommerce keeps all variation/price/stock state.
 *
 * Mirrors the colour module's .kcp-* sheet mechanics with dedicated .ksp-* classes.
 * Desktop is untouched — the trigger + sheet live only under the mobile breakpoint.
 *
 * @package Konte Child
 */

/* Trigger hidden on desktop — base rule outside the media query. */
.ksp-trigger {
	display: none;
}

@media (max-width: 767.98px) {
	/* Hide the inline Mango size UI (expanded list + collapsed row) on mobile — the
	   size is chosen via the trigger + slide-up sheet instead. Only display:none, so
	   the real <li>s stay in the DOM and the sheet's taps still select them.
	   !important beats the parent theme's floated `.variations tr{display:block}`
	   and the plugin's own item rules. */

	.woocommerce .wcboost-variation-swatches--default:not(.wcboost-variation-swatches--button) .wcboost-variation-swatches__name
	{
		color: var(--ink_text) !important;
    	position: relative !important;
	}

	.woocommerce .wcboost-variation-swatches--label .wcboost-variation-swatches__name
	{
		color:var(--ink_text) !important;
		font-family: var(--font2);
		font-size: 12px;
		font-style: normal;
		font-weight: 700;
		line-height: normal;
	}
	
	body.konte-variable-pdp .kss {
		display: none !important;
	}

	/* Trigger row — full width, mirrors the look of the old .kss-collapsed-row. */
	body.konte-variable-pdp .ksp-trigger {
		display: flex;
		align-items: center;
		width: 100%;
		min-height: 44px;
		margin: 0;
		padding: 0 14px;
		border-top: 1px solid var(--b_clr);
		border-bottom: 1px solid var(--b_clr);
		background: var(--bg_clr1);
		box-sizing: border-box;
		cursor: pointer;
		font-family: var(--font2);
		font-size: 14px;
		font-weight: 300;
		color: var(--ink_text);
		text-transform: uppercase;
		letter-spacing: 0.02em;
	}

	body.konte-variable-pdp .ksp-trigger__size {
		flex: 0 1 auto;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	/* "+N sizes" indicator — pushed to the right, subtle underlined link look. */
	body.konte-variable-pdp .ksp-trigger__more {
		margin-left: auto;
		color: #6b6b6b;
		font-size: 12px;
		text-transform: none;
		letter-spacing: 0;
		text-decoration: underline;
		white-space: nowrap;
		display:none;
	}

	body.konte-variable-pdp .ksp-trigger__more[hidden] {
		display: none;
	}

	/* Chevron sits after the "+N sizes" text (or hard-right when it is hidden). */
	body.konte-variable-pdp .ksp-trigger__chevron {
		margin-left: auto !important;
		font-size: 1.5rem;
		line-height: 1;
		transform: translateY(-8px);
	}

	body.konte-variable-pdp .ksp-trigger__more[hidden] + .ksp-trigger__chevron {
		margin-left: auto;
	}
}

/* ================================================================== *
 * Slide-up size bottom sheet (opened by JS on mobile).
 * Mirrors the colour sheet (.kcp-*) mechanics with .ksp-* classes.
 * ================================================================== */
.ksp-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.ksp-overlay[hidden] {
	display: none;
}

.ksp-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.ksp-overlay.is-open .ksp-backdrop {
	opacity: 1;
}

.ksp-sheet {
	position: relative;
	width: 100%;
	max-width: 640px;
	max-height: 50vh;
	display: flex;
	flex-direction: column;
	background: var(--bg_clr1);
	border-radius: 16px 16px 0 0;
	padding: 15px 21px 26px;
	transform: translateY(100%);
	transition: transform 0.3s ease;
	will-change: transform;
	outline: none;
	overflow: hidden;
}

.ksp-overlay.is-open .ksp-sheet {
	transform: translateY(0);
}

.ksp-close {
	position: absolute;
	top: 8px;
	right: 10px;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: none;
	color:var(--ink_text);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	z-index: 1;
}

/* Row 1 — model-wearing sentence. */
.ksp-model {
	margin: 0 0 11px;
	padding-right: 28px; /* clear the close button */
	color: var(--ink_text);
	font-size: 12px;
	font-family: var(--font2);
	font-size: 12px;
	font-style: normal;
	font-weight: 300;
	line-height: normal;
}

.ksp-model[hidden] {
	display: none;
}

/* Row 2 — header: colour name (left) + size-guide link (right). */
.ksp-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 4px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--b_clr);
}

.ksp-colorname {
	color: var(--ink_text);
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-family: var(--font2);
	font-size: 12px;
	font-style: normal;
	font-weight: 700;
	line-height: normal;
}

.ksp-sizeguide {
	flex: 0 0 auto;
	background: none;
	border: 0;
	padding: 0;
	color: var(--ink_text);
	letter-spacing: 0.02em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	font-family: var(--font2);
	font-size: 12px;
	font-style: normal;
	font-weight: 700;
	line-height: normal;
}

.ksp-sizeguide[hidden] {
	display: none;
}

/* Row 3 — the size list; fills remaining height and scrolls if needed. */
.ksp-sizes {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: transparent transparent;
}

.ksp-sizes::-webkit-scrollbar {
	width: 4px;
}

.ksp-sizes::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.3);
	border-radius: 4px;
}

/* Cloned WCBoost size group rendered as a full-width vertical list (mirrors the
   expanded .kss list from css/size-selector.css but scoped to the sheet, which
   lives outside the .woocommerce scope). */
.ksp-sizes .wcboost-variation-swatches__wrapper {
	display: flex;
	flex-direction: column;
	flex-wrap: nowrap;
	align-items: stretch;
	gap: 0;
	width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ksp-sizes .wcboost-variation-swatches__item {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	text-align: left;
	width: 100%;
	max-width: none;
	min-height: 48px;
	margin: 0;
	padding: 0 4px;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	cursor: pointer;
	box-sizing: border-box;
	font-size: 0.95rem;
	color: var(--ink_text);
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.ksp-sizes .wcboost-variation-swatches__item + .wcboost-variation-swatches__item {
	border-top: 1px solid #eee;
}

.ksp-sizes .wcboost-variation-swatches__name {
	margin: 0;
	border: 0;
	outline: none !important;
	font-size: 0.95rem;
	line-height: 1.2;
}

/* Selected size — highlighted row (matches the mockup's MEDIUM row). */
.ksp-sizes .wcboost-variation-swatches__item.selected {
	background: var(--bg_clr2);
	font-weight: 500;
}

/* Stock label (cloned from the real list), pushed right. */
.ksp-sizes .kss-stock {
	margin-left: auto;
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #c0392b;
	white-space: nowrap;
}

.ksp-sizes .kss-stock--out {
	color: #999;
}

/* Out-of-stock rows — greyed, not selectable. */
.ksp-sizes .wcboost-variation-swatches__item.kss-oos {
	color: #b3b3b3;
	cursor: not-allowed;
}

/* Kill the plugin's hover tooltip / ring inside the sheet. */
.ksp-sizes .wcboost-variation-swatches__item::before,
.ksp-sizes .wcboost-variation-swatches__item::after {
	display: none !important;
	content: none !important;
}

/* Row 4 — fit-summary line. */
.ksp-fit {
	margin: 12px 0 0;
	padding-top: 12px;
	border-top: 1px solid #e5e5e5;
	color: var(--ink_text);
	font-size: 12px;
	line-height: normal;
}

.ksp-fit[hidden] {
	display: none;
}

.ksp-fit .konte-fit-summary__lead {
	font-weight: 700;
	text-transform: uppercase;
}

/* Lock the page behind the open sheet. */
body.ksp-open {
	overflow: hidden;
}
