/**
 * NSS Sample Box
 *
 * Everything is driven by the custom properties below, so the theme can
 * restyle the whole component by overriding :root once. Type is inherited
 * from the theme on purpose — this is a component inside someone else's
 * design, not a design of its own.
 *
 * Square 2px corners throughout: fabricated stone has cut edges, and the
 * tray slots read as physical offcuts rather than app chrome.
 */

:root {
	--nss-ink: #1f2320;
	--nss-muted: #6b6f6a;
	--nss-surface: #ffffff;
	--nss-sunken: #f4f4f2;
	--nss-line: rgba( 31, 35, 32, 0.16 );
	--nss-accent: #1f2320;
	--nss-accent-ink: #ffffff;
	--nss-radius: 2px;
	--nss-shadow: 0 6px 28px rgba( 31, 35, 32, 0.16 );
	--nss-z: 9000;
}

/* ---------------------------------------------------------------------
 * Add button
 * ------------------------------------------------------------------ */

.nss-sample-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.55em;
	padding: 0.75em 1.4em;
	border: 1px solid var( --nss-accent );
	border-radius: var( --nss-radius );
	background: var( --nss-accent );
	color: var( --nss-accent-ink );
	font: inherit;
	font-size: 0.95em;
	line-height: 1.2;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.nss-sample-btn:hover,
.nss-sample-btn:focus-visible {
	background: transparent;
	color: var( --nss-accent );
}

.nss-sample-btn:focus-visible {
	outline: 2px solid var( --nss-accent );
	outline-offset: 2px;
}

.nss-sample-btn.is-added {
	background: transparent;
	color: var( --nss-accent );
}

.nss-sample-btn__icon {
	width: 0.85em;
	height: 0.85em;
	border: 1px solid currentColor;
	border-radius: 1px;
	flex: 0 0 auto;
}

.nss-sample-btn.is-added .nss-sample-btn__icon {
	background: currentColor;
	box-shadow: inset 0 0 0 2px var( --nss-surface );
}

.nss-sample-btn-wrap {
	margin: 1.5em 0;
}

/* ---------------------------------------------------------------------
 * Floating tray
 * ------------------------------------------------------------------ */

.nss-sample-tray {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: var( --nss-z );
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font-size: 15px;
}

.nss-sample-tray[hidden] {
	display: none;
}

.nss-sample-tray__pill {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px 8px 10px;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
	color: var( --nss-ink );
	box-shadow: var( --nss-shadow );
	font: inherit;
	cursor: pointer;
}

.nss-sample-tray__pill:focus-visible {
	outline: 2px solid var( --nss-accent );
	outline-offset: 2px;
}

/* The signature: three slots that fill up like a physical sample tray. */
.nss-sample-tray__slots {
	display: inline-flex;
	gap: 4px;
}

.nss-sample-tray__slot {
	width: 26px;
	height: 26px;
	border: 1px dashed var( --nss-line );
	border-radius: 1px;
	background-color: var( --nss-sunken );
	background-size: cover;
	background-position: center;
}

.nss-sample-tray__slot.is-filled {
	border-style: solid;
	border-color: rgba( 31, 35, 32, 0.28 );
}

.nss-sample-tray__pill-text {
	font-size: 0.85em;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.nss-sample-tray__panel {
	width: min( 320px, calc( 100vw - 40px ) );
	padding: 16px;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
	box-shadow: var( --nss-shadow );
}

.nss-sample-tray__panel[hidden] {
	display: none;
}

.nss-sample-tray__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.nss-sample-tray__title {
	margin: 0;
	font-size: 0.95em;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.nss-sample-tray__close {
	padding: 0 4px;
	border: 0;
	background: none;
	color: var( --nss-muted );
	font-size: 1.3em;
	line-height: 1;
	cursor: pointer;
}

.nss-sample-tray__list {
	margin: 0 0 14px;
	padding: 0;
	list-style: none;
}

.nss-sample-tray__item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 0;
	border-bottom: 1px solid var( --nss-line );
}

.nss-sample-tray__item:last-child {
	border-bottom: 0;
}

.nss-sample-tray__item-thumb {
	width: 36px;
	height: 36px;
	flex: 0 0 auto;
	border-radius: 1px;
	background-color: var( --nss-sunken );
	background-size: cover;
	background-position: center;
}

.nss-sample-tray__item-name {
	flex: 1 1 auto;
	font-size: 0.9em;
	line-height: 1.3;
}

.nss-sample-tray__item-remove,
.nss-sample-selections__item-remove {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: none;
	color: var( --nss-muted );
	font-size: 1em;
	line-height: 1;
	cursor: pointer;
}

.nss-sample-tray__item-remove:hover,
.nss-sample-selections__item-remove:hover {
	border-color: var( --nss-ink );
	color: var( --nss-ink );
}

.nss-sample-tray__cta {
	display: block;
	padding: 0.8em 1em;
	background: var( --nss-accent );
	color: var( --nss-accent-ink );
	border-radius: var( --nss-radius );
	text-align: center;
	text-decoration: none;
	font-size: 0.9em;
	letter-spacing: 0.02em;
}

.nss-sample-tray__cta:hover {
	opacity: 0.9;
	color: var( --nss-accent-ink );
}

/* ---------------------------------------------------------------------
 * Toast
 * ------------------------------------------------------------------ */

.nss-sample-toast {
	position: fixed;
	left: 20px;
	bottom: 20px;
	z-index: calc( var( --nss-z ) + 1 );
	width: min( 340px, calc( 100vw - 40px ) );
	padding: 14px 16px;
	border: 1px solid var( --nss-line );
	border-left: 3px solid var( --nss-accent );
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
	box-shadow: var( --nss-shadow );
	opacity: 0;
	transform: translateY( 8px );
	transition: opacity 0.2s ease, transform 0.2s ease;
	font-size: 15px;
}

.nss-sample-toast[hidden] {
	display: none;
}

.nss-sample-toast.is-visible {
	opacity: 1;
	transform: translateY( 0 );
}

.nss-sample-toast__text {
	margin: 0 0 10px;
	font-size: 0.95em;
	line-height: 1.4;
}

.nss-sample-toast__actions {
	display: flex;
	align-items: center;
	gap: 14px;
}

.nss-sample-toast__dismiss {
	padding: 0;
	border: 0;
	background: none;
	color: var( --nss-muted );
	font: inherit;
	font-size: 0.85em;
	text-decoration: underline;
	cursor: pointer;
}

.nss-sample-toast__cta {
	margin-left: auto;
	padding: 0.55em 1em;
	background: var( --nss-accent );
	color: var( --nss-accent-ink );
	border-radius: var( --nss-radius );
	font-size: 0.85em;
	text-decoration: none;
}

/* ---------------------------------------------------------------------
 * Swap modal
 * ------------------------------------------------------------------ */

.nss-sample-modal {
	position: fixed;
	inset: 0;
	z-index: calc( var( --nss-z ) + 2 );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.nss-sample-modal[hidden] {
	display: none;
}

.nss-sample-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 31, 35, 32, 0.5 );
}

.nss-sample-modal__box {
	position: relative;
	width: min( 420px, 100% );
	padding: 24px;
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
	box-shadow: var( --nss-shadow );
}

.nss-sample-modal__title {
	margin: 0 0 8px;
	font-size: 1.15em;
}

.nss-sample-modal__body {
	margin: 0 0 16px;
	color: var( --nss-muted );
	font-size: 0.95em;
	line-height: 1.45;
}

.nss-sample-modal__list {
	margin: 0 0 16px;
	padding: 0;
	list-style: none;
}

.nss-sample-modal__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-top: 1px solid var( --nss-line );
}

.nss-sample-modal__item:last-child {
	border-bottom: 1px solid var( --nss-line );
}

.nss-sample-modal__item-thumb {
	width: 40px;
	height: 40px;
	flex: 0 0 auto;
	border-radius: 1px;
	background-color: var( --nss-sunken );
	background-size: cover;
	background-position: center;
}

.nss-sample-modal__item-name {
	flex: 1 1 auto;
	font-size: 0.95em;
}

.nss-sample-modal__item-swap {
	flex: 0 0 auto;
	padding: 0.5em 0.9em;
	border: 1px solid var( --nss-accent );
	border-radius: var( --nss-radius );
	background: none;
	color: var( --nss-accent );
	font: inherit;
	font-size: 0.85em;
	cursor: pointer;
}

.nss-sample-modal__item-swap:hover {
	background: var( --nss-accent );
	color: var( --nss-accent-ink );
}

.nss-sample-modal__cancel {
	padding: 0;
	border: 0;
	background: none;
	color: var( --nss-muted );
	font: inherit;
	font-size: 0.9em;
	text-decoration: underline;
	cursor: pointer;
}

body.nss-sample-modal-open {
	overflow: hidden;
}

/* ---------------------------------------------------------------------
 * Selections panel on the request page
 * ------------------------------------------------------------------ */

.nss-sample-selections {
	margin: 0 0 2em;
	padding: 20px;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: var( --nss-sunken );
}

.nss-sample-selections__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.nss-sample-selections__title {
	margin: 0;
	font-size: 1em;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.nss-sample-selections__count {
	margin: 0;
	color: var( --nss-muted );
	font-size: 0.85em;
}

.nss-sample-selections__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nss-sample-selections__list[hidden] {
	display: none;
}

.nss-sample-selections__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px;
	margin-bottom: 8px;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
}

.nss-sample-selections__item-thumb {
	width: 52px;
	height: 52px;
	flex: 0 0 auto;
	border-radius: 1px;
	background-color: var( --nss-sunken );
	background-size: cover;
	background-position: center;
}

.nss-sample-selections__item-name {
	flex: 1 1 auto;
	font-size: 0.95em;
	line-height: 1.3;
}

.nss-sample-selections__empty {
	padding: 4px 0 12px;
}

.nss-sample-selections__empty[hidden] {
	display: none;
}

.nss-sample-selections__empty-title {
	margin: 0 0 4px;
	font-weight: 600;
}

.nss-sample-selections__empty-body {
	margin: 0 0 12px;
	color: var( --nss-muted );
	font-size: 0.9em;
	line-height: 1.45;
}

.nss-sample-selections__browse {
	font-size: 0.9em;
}

.nss-sample-selections__noscript {
	margin: 12px 0 0;
	color: var( --nss-muted );
	font-size: 0.9em;
}

/* ---------------------------------------------------------------------
 * Typeahead
 * ------------------------------------------------------------------ */

.nss-sample-search {
	position: relative;
	margin-top: 14px;
}

.nss-sample-selections.is-full .nss-sample-search {
	opacity: 0.55;
}

.nss-sample-search__label {
	display: block;
	margin-bottom: 6px;
	font-size: 0.85em;
	letter-spacing: 0.02em;
	color: var( --nss-muted );
}

.nss-sample-search__input {
	width: 100%;
	padding: 0.7em 0.9em;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
	font: inherit;
	font-size: 0.95em;
}

.nss-sample-search__input:focus-visible {
	outline: 2px solid var( --nss-accent );
	outline-offset: 1px;
}

.nss-sample-search__results {
	position: absolute;
	z-index: 5;
	left: 0;
	right: 0;
	margin: 4px 0 0;
	padding: 0;
	max-height: 280px;
	overflow-y: auto;
	list-style: none;
	border: 1px solid var( --nss-line );
	border-radius: var( --nss-radius );
	background: var( --nss-surface );
	box-shadow: var( --nss-shadow );
}

.nss-sample-search__results[hidden] {
	display: none;
}

.nss-sample-search__result {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	cursor: pointer;
	font-size: 0.9em;
}

.nss-sample-search__result.is-active,
.nss-sample-search__result:hover {
	background: var( --nss-sunken );
}

.nss-sample-search__result.is-added {
	color: var( --nss-muted );
	cursor: default;
}

.nss-sample-search__result-thumb {
	width: 32px;
	height: 32px;
	flex: 0 0 auto;
	border-radius: 1px;
	background-color: var( --nss-sunken );
	background-size: cover;
	background-position: center;
}

.nss-sample-search__result-name {
	flex: 1 1 auto;
}

.nss-sample-search__result-flag {
	font-size: 0.8em;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.nss-sample-search__status {
	margin: 6px 0 0;
	min-height: 1.2em;
	color: var( --nss-muted );
	font-size: 0.85em;
}

/* ---------------------------------------------------------------------
 * Small screens and preferences
 * ------------------------------------------------------------------ */

@media ( max-width: 600px ) {
	.nss-sample-tray {
		right: 12px;
		bottom: 12px;
		left: 12px;
		align-items: stretch;
	}

	.nss-sample-tray__panel {
		width: auto;
	}

	.nss-sample-tray__pill {
		justify-content: center;
	}

	/* Clear the tray, which sits full width along the bottom on small screens. */
	.nss-sample-toast {
		left: 12px;
		right: 12px;
		bottom: 76px;
		width: auto;
	}

	.nss-sample-selections {
		padding: 16px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.nss-sample-btn,
	.nss-sample-toast {
		transition: none;
	}
}

/* ---------------------------------------------------------------------
 * Missing swatch placeholder
 *
 * A worktop with no surface image should not read as a blank white tile.
 * A fine diagonal rule says "image pending" rather than "empty product".
 * ------------------------------------------------------------------ */

.nss-sample-tray__slot.is-empty,
.nss-sample-tray__item-thumb.is-empty,
.nss-sample-selections__item-thumb.is-empty,
.nss-sample-modal__item-thumb.is-empty,
.nss-sample-search__result-thumb.is-empty {
	position: relative;
	background-color: var( --nss-sunken );
	background-image: repeating-linear-gradient(
		135deg,
		transparent,
		transparent 5px,
		rgba( 31, 35, 32, 0.07 ) 5px,
		rgba( 31, 35, 32, 0.07 ) 6px
	);
}

/* The worktop's initial, so two blank tiles are still tellable apart. */
.nss-sample-tray__item-thumb.is-empty::after,
.nss-sample-selections__item-thumb.is-empty::after {
	content: attr( data-nss-initial );
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var( --nss-muted );
	font-size: 1.1em;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}
