/**
 * Claridge - Request A Sample
 *
 * Scoped to .csr and .csr-panel so nothing here can reach the rest of the theme.
 * Colors are neutral greys plus the theme's own text color; no brand colors are
 * hard-coded, so this does not fight the parent theme.
 */

.csr {
	--csr-line: #d8d8d8;
	--csr-ink: #222;
	--csr-muted: #666;
	--csr-accent: #111;
	--csr-radius: 4px;
	box-sizing: border-box;
}

.csr *,
.csr *::before,
.csr *::after,
.csr-panel *,
.csr-panel *::before,
.csr-panel *::after {
	box-sizing: inherit;
}

/*
 * The script hides and shows things with el.hidden. Several of the rules below
 * set an explicit display, which would otherwise beat the user agent's
 * [hidden] rule and leave the element on screen.
 */
.csr [hidden],
.csr-panel [hidden],
.csr-panel[hidden] {
	display: none !important;
}

/* ---------- Intro and notices ---------- */

.csr-intro-lead {
	font-size: 1.05rem;
	margin: 0 0 0.5em;
}

/*
 * The filter notice is the only thing telling a visitor who arrived from a
 * product page why they are seeing four swatches instead of two hundred, and as
 * a pale grey strip it sat directly above a much louder section heading and got
 * skipped. It is an object now: a rule down the side, a funnel, the product name
 * given weight, the count spelled out, and a real button to leave the filter.
 * Still no brand colour - the two sites' accents differ (Calyx gold, Products
 * green), so this stays in the component's own neutrals.
 */
.csr-filter {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	margin: 0 0 1.35em;
	padding: 0.8rem 1rem;
	background: #fff;
	border: 1px solid var(--csr-line);
	border-left: 4px solid var(--csr-accent);
	border-radius: var(--csr-radius);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

.csr-filter-icon {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	color: var(--csr-accent);
}

.csr-filter-body {
	flex: 1 1 auto;
	margin: 0;
	line-height: 1.3;
}

.csr-filter-label {
	display: block;
	font-size: 0.78em;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--csr-muted);
}

.csr-filter-product {
	font-size: 1.1em;
	font-weight: 700;
	color: var(--csr-ink);
}

.csr-filter-count {
	color: var(--csr-muted);
}

.csr-filter-count::before {
	content: " \00b7  ";
}

/* The escape hatch reads as a control, not as body text with an underline. */
.csr-filter .csr-filter-clear {
	flex: 0 0 auto;
	padding: 0.5em 1.1em;
	border: 1px solid var(--csr-line);
	border-radius: 999px;
	background: #fff;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.csr-filter .csr-filter-clear:hover,
.csr-filter .csr-filter-clear:focus-visible {
	border-color: var(--csr-accent);
	background: #f4f4f4;
}

@media (max-width: 600px) {
	.csr-filter {
		flex-wrap: wrap;
		gap: 0.6rem 0.75rem;
	}

	.csr-filter-body {
		flex: 1 1 60%;
	}

	/* Narrow enough that "Name · 7 of 210 swatches" breaks mid-phrase, so give
	   the count its own line and drop the separator that went with it. */
	.csr-filter-count {
		display: block;
	}

	.csr-filter-count::before {
		content: none;
	}

	.csr-filter .csr-filter-clear {
		flex: 1 1 100%;
		text-align: center;
	}
}

.csr-filter-clear,
.csr-empty-filter button {
	background: none;
	border: 0;
	padding: 0;
	color: var(--csr-ink);
	text-decoration: underline;
	cursor: pointer;
	font: inherit;
}

/*
 * The notice is fixed to the viewport, not parked at the top of a 10,000px
 * page where nobody halfway down would ever see it. It stays an aria-live
 * region; this only changes where it appears.
 */
.csr-notice {
	position: fixed;
	left: 50%;
	bottom: 1.5rem;
	z-index: 950;
	margin: 0;
	/*
	 * `width` is needed as well as `max-width`. A fixed box with `left: 50%`
	 * and no width shrinks to fit the space to the RIGHT of that 50% line, so
	 * it can never be wider than half the viewport and `max-width` below that
	 * is unreachable. Above ~896px the 28rem cap binds first and it looks
	 * right; at phone widths the toast came out half-width and five lines tall.
	 * `max-content` lets `max-width` do the capping instead.
	 */
	width: max-content;
	max-width: min(28rem, calc(100vw - 2rem));
	padding: 0.7em 1.1em;
	border-radius: var(--csr-radius);
	background: #222;
	color: #fff;
	text-align: center;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
	opacity: 0;
	transform: translate(-50%, 0.75rem);
	transition: opacity 0.18s ease, transform 0.18s ease;
	pointer-events: none;
}

.csr-notice:empty {
	display: none;
}

.csr-notice.is-shown {
	opacity: 1;
	transform: translate(-50%, 0);
}

.csr-notice.is-strong {
	background: #a3341f;
	font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
	.csr-notice {
		transition: none;
	}
}

/* ---------- Layout ---------- */

.csr-layout {
	display: flex;
	align-items: flex-start;
	gap: 2rem;
}

.csr-main {
	flex: 1 1 auto;
	min-width: 0;
}

.csr-section {
	margin: 0 0 2.5rem;
}

.csr-section-title {
	margin: 0 0 1rem;
	padding-bottom: 0.4rem;
	border-bottom: 1px solid var(--csr-line);
}

.csr-group {
	margin: 0 0 2rem;
}

.csr-group-title {
	margin: 0 0 0.75rem;
	font-size: 1.1rem;
}

.csr-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 1rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.csr-cell {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ---------- Swatch buttons ---------- */

.csr-swatch {
	display: block;
	width: 100%;
	padding: 0;
	background: none;
	border: 0;
	font: inherit;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.csr-swatch-media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border: 1px solid var(--csr-line);
	border-radius: var(--csr-radius);
	background: #eee;
}

.csr-swatch-media img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: cover;
}

.csr-swatch-tick {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--csr-accent);
	opacity: 0;
	transform: scale(0.6);
	transition: opacity 0.12s ease, transform 0.12s ease;
}

.csr-swatch-tick::after {
	content: "";
	position: absolute;
	left: 8px;
	top: 4px;
	width: 6px;
	height: 12px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.csr-swatch.is-selected .csr-swatch-media {
	outline: 3px solid var(--csr-accent);
	outline-offset: 1px;
}

.csr-swatch.is-selected .csr-swatch-tick {
	opacity: 1;
	transform: scale(1);
}

.csr-swatch:focus-visible .csr-swatch-media {
	outline: 3px solid #1a73e8;
	outline-offset: 2px;
}

.csr-swatch-name {
	display: block;
	margin-top: 0.4em;
	font-size: 0.9rem;
	line-height: 1.3;
}

.csr-swatch-number {
	display: block;
	font-size: 0.75rem;
	color: var(--csr-muted);
}

/* ---------- Cart panel ---------- */

/*
 * Bridge sets overflow:hidden on .wrapper_inner, which makes that box the
 * scroll container for anything sticky inside it - so the cart would scroll
 * away with the page instead of following it.
 *
 * `visible` alone fixes the cart but exposes what the theme was hiding:
 * WPBakery rows carry -15px side gutters, so the page gains a 15px horizontal
 * scroll. `clip` clips the same overflow WITHOUT becoming a scroll container,
 * so sticky keeps working and nothing scrolls sideways. The `visible`
 * declaration above it is the fallback for browsers without `clip`.
 */
body.csr-swatch-page .wrapper_inner {
	overflow: visible;
	overflow-x: clip;
}

/*
 * --csr-sticky-top is the bottom of the theme's fixed site header plus a
 * gutter, measured at runtime (sample-cart.js). Pinning to a literal 1.5rem
 * puts the panel's heading - and the "6 of 6" count - behind that header.
 * The fallback only applies before the script runs.
 */
.csr-cart {
	flex: 0 0 290px;
	position: sticky;
	top: var(--csr-sticky-top, 1.5rem);
	max-height: calc(100vh - var(--csr-sticky-top, 1.5rem) - 1.5rem);
	overflow-y: auto;
}

/*
 * Same header, same problem: anything scrolled to by the product filter or the
 * cart's View link would otherwise land underneath it.
 */
.csr-filter,
.csr-section,
.csr-group,
.csr-swatch {
	scroll-margin-top: var(--csr-sticky-top, 1.5rem);
}

.csr-cart-inner {
	border: 1px solid var(--csr-line);
	border-radius: var(--csr-radius);
	padding: 1rem;
	background: #fff;
}

.csr-cart-title {
	margin: 0 0 0.75rem;
	font-size: 1rem;
	display: flex;
	justify-content: space-between;
	gap: 0.5rem;
}

.csr-cart-count {
	color: var(--csr-muted);
	font-weight: 400;
}

.csr-cart-list,
.csr-panel .csr-cart-list {
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
}

.csr-line {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 0;
	border-top: 1px solid var(--csr-line);
}

.csr-line:first-child {
	border-top: 0;
}

.csr-line-img {
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 3px;
	border: 1px solid var(--csr-line);
}

.csr-line-text {
	flex: 1 1 auto;
	min-width: 0;
}

.csr-line-name {
	display: block;
	font-size: 0.9rem;
	line-height: 1.2;
}

.csr-line-group {
	display: block;
	font-size: 0.75rem;
	color: var(--csr-muted);
}

/* The theme styles every select as a full-width block form control, which in a
   cart line makes a 1-4 picker as wide as the panel. Scoped and forced, because
   the theme's selector wins on specificity otherwise. */
.csr .csr-qty,
.csr-panel .csr-qty {
	flex: 0 0 auto;
	display: inline-block !important;
	width: auto !important;
	min-width: 3.2rem !important;
	max-width: 4.5rem !important;
	height: auto !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0.2em 0.3em !important;
	font-size: 0.85rem !important;
	line-height: 1.3 !important;
	background-image: none;
}

.csr-line-actions {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.1em;
}

.csr-line-view,
.csr-line-remove {
	background: none;
	border: 0;
	padding: 0.15em 0;
	font-size: 0.75rem;
	font-family: inherit;
	color: var(--csr-muted);
	text-decoration: underline;
	cursor: pointer;
}

.csr-line-view:hover,
.csr-line-remove:hover {
	color: var(--csr-ink);
}

/* Where the View link lands. */
.csr-swatch.is-flashing .csr-swatch-media {
	animation: csr-flash 1.6s ease-out 1;
}

@keyframes csr-flash {
	0%, 100% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0); }
	15%, 60% { box-shadow: 0 0 0 5px rgba(26, 115, 232, 0.75); }
}

@media (prefers-reduced-motion: reduce) {
	.csr-swatch.is-flashing .csr-swatch-media {
		animation: none;
		outline: 3px solid #1a73e8;
		outline-offset: 2px;
	}
}

.csr-cart-empty {
	margin: 0 0 1rem;
	font-size: 0.9rem;
	color: var(--csr-muted);
}

.csr-cart-go {
	display: block;
	text-align: center;
	padding: 0.7em 1em;
	background: var(--csr-accent);
	color: #fff;
	border-radius: var(--csr-radius);
	text-decoration: none;
}

.csr-cart-go:hover,
.csr-cart-go:focus {
	color: #fff;
	opacity: 0.88;
}

/* ---------- Phone: the cart becomes a bottom bar ---------- */

.csr-bar {
	display: none;
}

@media (max-width: 900px) {
	.csr-layout {
		display: block;
	}

	/* Clear the bottom bar. */
	.csr-notice {
		bottom: 4.75rem;
	}

	.csr-cart {
		position: fixed;
		left: 0;
		right: 0;
		/* The desktop rule sets `top`. Leaving it set here would over-constrain
		   the box, `bottom` would be ignored, and the closed panel would sit in
		   the middle of the screen instead of below it. */
		top: auto;
		bottom: 0;
		z-index: 900;
		flex: none;
		max-height: 60vh;
		overflow-y: auto;
		transform: translateY(100%);
		transition: transform 0.18s ease;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	.csr.is-cart-open .csr-cart {
		transform: translateY(0);
	}

	.csr-cart-inner {
		border-radius: var(--csr-radius) var(--csr-radius) 0 0;
		box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
		/* Room for the bar, which stays on top so it can still be tapped to
		   close the panel. */
		padding-bottom: 4.5rem;
	}

	.csr-bar {
		display: block;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 901;
		padding-bottom: env(safe-area-inset-bottom, 0px);
		background: var(--csr-accent);
	}

	/* Six lines are taller than the panel, so the panel scrolls. Keep the
	   primary action pinned above the bar rather than below the fold. */
	.csr-cart-go {
		position: sticky;
		bottom: 3.4rem;
		box-shadow: 0 0 10px 10px #fff;
	}

	.csr-bar-toggle {
		display: flex;
		justify-content: space-between;
		width: 100%;
		padding: 0.9em 1.1em;
		background: none;
		border: 0;
		color: #fff;
		font: inherit;
		cursor: pointer;
	}

	.csr-bar-view {
		text-decoration: underline;
	}

	.csr-main {
		padding-bottom: 4.5rem;
	}

	.csr-grid {
		grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
		gap: 0.75rem;
	}
}

/* ==================================================================
 * The form page
 * ============================================================== */

/* The Selected Samples textarea holds the value; the panel is what people edit. */
.csr-field-managed textarea {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.csr-panel {
	border: 1px solid #d8d8d8;
	border-radius: 4px;
	padding: 1rem;
	margin: 0 0 1rem;
	background: #fafafa;
}

.csr-panel-title {
	margin: 0 0 0.5rem;
	font-weight: 600;
}

.csr-panel-empty p {
	margin: 0 0 0.5rem;
}

.csr-panel-browse,
.csr-panel-more {
	display: inline-block;
	text-decoration: underline;
}

/* ==================================================================
 * Visible labels on form 3 (the form carries the class csr-labels)
 * ============================================================== */

.csr-labels .gfield_label,
.csr-labels .gform_fields .gfield > label {
	display: block !important;
	visibility: visible !important;
	position: static !important;
	width: auto !important;
	height: auto !important;
	clip: auto !important;
	margin: 0 0 0.35em !important;
	overflow: visible !important;
	font-weight: 600;
}

/* ==================================================================
 * The free-text note
 * ============================================================== */

/* Gravity Forms draws its own counter; ours reads the way Trent asked for. */
.csr-notes .ginput_counter {
	display: none !important;
}

.csr-count {
	margin: 0.35em 0 0;
	font-size: 0.8rem;
	color: #666;
}

.csr-count.is-full {
	color: #a3341f;
	font-weight: 600;
}
