/**
 * TripThis Offers — filterable archive.
 *
 * A sticky filter bar (free-text search + a category radio group + a 1/2-column
 * switch) over a stack of full-width [tripthis_offer_card] cards. Styling is
 * matched to the TripThis Search bar (white rounded 30px surfaces, soft shadow,
 * #dedede borders, deep-teal #02819e accents, mint #31cec1 highlights, muted
 * #5e6d77 input text). Front end is Latvian.
 *
 * All interactive controls are spans/divs (role + tabindex), never <button>s,
 * so the theme's global Elementor button styling can't leak into the bar.
 */

.tof {
	--tof-primary: #02819e;
	--tof-mint: #31cec1;
	--tof-mint-dark: #24b3a7;
	--tof-ink: #232323;
	--tof-muted: #5e6d77;
	--tof-line: #e9edef;
	--tof-border: #dedede;
	--tof-panel: #e6edef;
	--tof-radius: 30px;
	--tof-shadow: 0 6px 24px rgba(16, 44, 53, 0.1);
	--tof-gap: 24px;
	--tof-maxw: 1400px;
	--tof-sticky-offset: 16px; /* Overridden from JS to clear the fixed header. */

	box-sizing: border-box;
	width: 100%;
	max-width: var(--tof-maxw);
	margin-inline: auto;
	color: var(--tof-ink);
	font-size: 14px;
	font-family: var(--e-global-typography-primary-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
}

.tof *,
.tof *::before,
.tof *::after {
	box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Sticky filter bar
   ═══════════════════════════════════════════════════════════════════════════ */

.tof-filter {
	position: sticky;
	/* Sit below the site's fixed header (offset measured in JS). */
	top: var(--tof-sticky-offset, 16px);
	z-index: 30;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 14px clamp(12px, 3vw, 18px);
	margin-bottom: var(--tof-gap);
	border-radius: var(--tof-radius);
	/* Match the offer card's surface (Elementor globals, with fallbacks). */
	background: var(--e-global-color-06772f1, #fff);
	border: 1px solid var(--e-global-color-e6eb376, var(--tof-border));
	box-shadow: var(--tof-shadow);
	transition: background-color 0.25s ease, box-shadow 0.25s ease, backdrop-filter 0.25s ease;
}

/* On scroll: fade to translucent and lift with a blur so content reads through. */
.tof-filter.is-scrolled {
	background: rgba(255, 255, 255, 0.82);
	box-shadow: 0 10px 30px rgba(16, 44, 53, 0.16);
	-webkit-backdrop-filter: saturate(1.4) blur(10px);
	backdrop-filter: saturate(1.4) blur(10px);
}

.tof-filter__row {
	display: flex;
	align-items: center;
	gap: 14px;
}

.tof-filter__row--top {
	flex-wrap: wrap;
	justify-content: space-between;
}

/* ── Search (matched to the TripThis Search destination field) ──────────── */

.tof-search {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 260px;
	min-width: 0;
	padding: 10px 16px;
	background: #fff;
	border: 1px solid var(--tof-line);
	border-radius: 999px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tof-search:focus-within {
	border-color: var(--tof-primary);
	box-shadow: 0 0 0 3px rgba(2, 129, 158, 0.14);
}

.tof-search__icon {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--tof-primary);
	pointer-events: none;
}

.tof-search__input {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0;
	font-size: 16px  !important;
	line-height: 1.4;
	color: var(--tof-muted);
	background: transparent;
	border: none !important;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}

.tof-search__input::placeholder {
	color: var(--tof-muted);
	opacity: 0.8;
}

/* Hide the native search clear; we render our own. */
.tof-search__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.tof-search__clear {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	font-size: 20px;
	line-height: 1;
	color: var(--tof-muted);
	border-radius: 50%;
	cursor: pointer;
	user-select: none;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.tof-search__clear:hover {
	color: var(--tof-ink);
	background: rgba(16, 44, 53, 0.06);
}

.tof-search__clear[hidden] {
	display: none;
}

/* ── Counter ────────────────────────────────────────────────────────────── */

.tof-counter {
	flex: 0 0 auto;
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--tof-primary);
	white-space: nowrap;
}

/* ── Category radio group (matched to the search pills) ─────────────────── */

.tof-filter__row--cats {
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.tof-cats {
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	gap: 8px;
	min-width: 0;
}

.tof-cat {
	flex: 0 0 auto;
	padding: 7px 16px;
	font-size: 14px;
	font-weight: 600;
	color: var(--tof-muted);
	background: var(--tof-panel);
	border: 1px solid transparent;
	border-radius: 999px;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
	transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.tof-cat:hover {
	color: var(--tof-primary);
}

.tof-cat.is-active {
	color: #fff;
	background: var(--tof-primary);
	border-color: var(--tof-primary);
}

.tof-cat:focus-visible,
.tof-cols__btn:focus-visible,
.tof-search__clear:focus-visible,
.tof-more__btn:focus-visible {
	outline: 2px solid var(--tof-primary);
	outline-offset: 2px;
}

/* ── Grid layout switch (1 / 2 columns) ─────────────────────────────────── */

.tof-cols {
	display: inline-flex;
	flex: 0 0 auto;
	gap: 3px;
	padding: 3px;
	background: var(--tof-panel);
	border: 1px solid var(--tof-line);
	border-radius: 999px;
}

.tof-cols__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 30px;
	color: var(--tof-muted);
	border-radius: 999px;
	cursor: pointer;
	user-select: none;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.tof-cols__btn:hover {
	color: var(--tof-ink);
}

.tof-cols__btn.is-active {
	color: #fff;
	background: var(--tof-primary);
}

/* ── Mobile offcanvas filter (all hidden on desktop) ────────────────────── */

.tof-fab,
.tof-backdrop,
.tof-filter__head,
.tof-filter__apply {
	display: none;
}

/* Lock the page behind the open mobile popup. */
body.tof-noscroll {
	overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Grid + cards
   ═══════════════════════════════════════════════════════════════════════════ */

.tof-body {
	position: relative;
}

.tof-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--tof-gap);
	transition: opacity 0.2s ease, filter 0.2s ease;
}

/* Full-reload dimming while the shimmer is shown on top. */
.tof-grid.is-loading {
	opacity: 0.35;
	filter: saturate(0.6);
	pointer-events: none;
}

/* Each card is the offer-card plugin's `.toc` wrapper. */
.tof-grid > .toc {
	margin: 0;
}

/* Two-column layout: widen the archive so the (wide, two-pane) cards still
   have room, and lay the grid and its shimmer out in two columns. */
.tof.is-cols-2 {
	--tof-maxw: 1400px;
}

.tof.is-cols-2 .tof-grid,
.tof.is-cols-2 .tof-shimmer {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ═══════════════════════════════════════════════════════════════════════════
   Shimmer / skeletons
   ═══════════════════════════════════════════════════════════════════════════ */

.tof-shimmer {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--tof-gap);
	pointer-events: none;
}

/* The bound `hidden` attribute must beat display:grid above. */
.tof-shimmer[hidden] {
	display: none;
}

.tof-skel {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 24px;
	min-height: 260px;
	background: #fff;
	border: 1px solid var(--tof-line);
	border-radius: var(--tof-radius);
	overflow: hidden;
}

.tof-skel__media {
	border-radius: var(--tof-radius);
	background: var(--tof-panel);
}

.tof-skel__lines {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 16px;
	padding: 28px 28px 28px 0;
}

.tof-skel__line {
	height: 16px;
	width: 100%;
	border-radius: 8px;
	background: var(--tof-panel);
}

.tof-skel__line--short {
	width: 55%;
}

.tof-skel__line--btn {
	height: 44px;
	width: 140px;
	border-radius: 999px;
	margin-top: 12px;
}

/* The light travelling-highlight animation. */
.tof-shimmer-anim {
	position: relative;
	overflow: hidden;
	background: #eef2f4;
}

.tof-shimmer-anim::after {
	content: "";
	position: absolute;
	inset: 0;
	transform: translateX(-100%);
	background: linear-gradient(
		90deg,
		transparent,
		rgba(255, 255, 255, 0.7),
		transparent
	);
	animation: tof-shimmer 1.4s ease-in-out infinite;
}

@keyframes tof-shimmer {
	100% {
		transform: translateX(100%);
	}
}

/* ═══════════════════════════════════════════════════════════════════════════
   Empty state + load more
   ═══════════════════════════════════════════════════════════════════════════ */

.tof-empty {
	margin: 40px 0;
	padding: 32px;
	text-align: center;
	font-size: 15px;
	color: var(--tof-muted);
	background: var(--tof-panel);
	border-radius: var(--tof-radius);
}

.tof-empty[hidden] {
	display: none;
}

.tof-more {
	display: flex;
	justify-content: center;
	margin-top: 32px;
}

.tof-more[hidden] {
	display: none;
}

.tof-more__btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 34px;
	font-size: 15px;
	font-weight: 600;
	color: #fff;
	background: var(--tof-mint);
	border-radius: var(--tof-radius);
	cursor: pointer;
	user-select: none;
	transition: background-color 0.18s ease, opacity 0.18s ease;
}

.tof-more__btn:hover {
	background: var(--tof-mint-dark);
}

.tof-more__btn.is-loading {
	opacity: 0.7;
	pointer-events: none;
}

.tof-more__spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: tof-spin 0.7s linear infinite;
}

.tof-more__btn.is-loading .tof-more__spinner {
	display: inline-block;
}

@keyframes tof-spin {
	100% {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.tof-shimmer-anim::after,
	.tof-more__spinner {
		animation: none;
	}
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

/* Below this the wide two-pane cards can't sit side by side, so collapse to a
   single column and drop the (now pointless) layout switch. */
@media (max-width: 900px) {
	.tof.is-cols-2 {
		--tof-maxw: 980px;
	}

	.tof.is-cols-2 .tof-grid,
	.tof.is-cols-2 .tof-shimmer {
		grid-template-columns: 1fr;
	}

	.tof-cols {
		display: none;
	}
}

@media (max-width: 640px) {
	.tof-filter__row--top {
		gap: 10px;
	}

	.tof-counter {
		order: -1;
		width: 100%;
	}

	/* Match the offer card's own stacked layout on narrow screens. */
	.tof-skel {
		grid-template-columns: 1fr;
		min-height: 0;
	}

	.tof-skel__media {
		aspect-ratio: 16 / 10;
	}

	.tof-skel__lines {
		padding: 0 20px 24px;
	}
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile: filter moves into a fullscreen offcanvas popup, opened by a floating
   filter button. (Last so its rules win over the narrow-screen tweaks above.)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

	/* Floating filter trigger (FAB). */
	.tof-fab {
		position: fixed;
		right: 18px;
		bottom: 18px;
		z-index: 70;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 56px;
		height: 56px;
		border-radius: 50%;
		color: #fff;
		background: var(--tof-primary);
		box-shadow: 0 10px 26px rgba(2, 129, 158, 0.42);
		cursor: pointer;
		user-select: none;
	}

	.tof-fab__dot {
		position: absolute;
		top: 12px;
		right: 12px;
		width: 12px;
		height: 12px;
		border-radius: 50%;
		background: var(--tof-mint);
		border: 2px solid #fff;
		transform: scale(0);
		transition: transform 0.18s ease;
	}

	.tof-fab.has-filters .tof-fab__dot {
		transform: scale(1);
	}

	/* Dimmed backdrop behind the popup (also cleared of the fixed header). */
	.tof-backdrop {
		display: block;
		position: fixed;
		inset: var(--tof-sticky-offset, 0) 0 0 0;
		z-index: 90;
		background: rgba(16, 44, 53, 0.5);
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.3s ease, visibility 0.3s ease;
	}

	.tof.is-filter-open .tof-backdrop {
		opacity: 1;
		visibility: visible;
	}

	/* The filter bar becomes a popup sliding up from the bottom. It starts below
	   the site's fixed header (--tof-sticky-offset) so its header stays visible. */
	.tof-filter {
		position: fixed;
		inset: var(--tof-sticky-offset, 0) 0 0 0;
		z-index: 100;
		margin: 0;
		gap: 16px;
		padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
		border: 0;
		border-radius: 0;
		box-shadow: none;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		transform: translateY(100%);
		opacity: 0;
		visibility: hidden;
		transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
	}

	.tof.is-filter-open .tof-filter {
		transform: translateY(0);
		opacity: 1;
		visibility: visible;
	}

	/* No scroll-translucency inside the popup. */
	.tof-filter.is-scrolled {
		background: var(--e-global-color-06772f1, #fff);
		box-shadow: none;
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
	}

	/* Popup header (title + close). */
	.tof-filter__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding-bottom: 12px;
		border-bottom: 1px solid var(--tof-line);
	}

	.tof-filter__title {
		font-size: 18px;
		font-weight: 700;
		color: var(--tof-ink);
	}

	.tof-filter__close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 38px;
		height: 38px;
		font-size: 26px;
		line-height: 1;
		color: var(--tof-ink);
		border-radius: 50%;
		cursor: pointer;
		user-select: none;
	}

	.tof-filter__close:hover {
		background: rgba(16, 44, 53, 0.06);
	}

	/* Rows stack full-width inside the popup. */
	.tof-filter__row--top,
	.tof-filter__row--cats {
		flex-direction: column;
		align-items: stretch;
	}

	/* In a column flex row, flex-basis maps to height — so reset the search's
	   `flex: 1 1 260px` (which otherwise makes it 260px tall) to size to content. */
	.tof-search {
		flex: 0 0 auto;
		width: 100%;
		padding: 9px 14px;
	}

	.tof-search__input {
		font-size: 15px;
	}

	.tof-counter {
		order: 0;
		width: 100%;
	}

	/* Apply/close bar pinned to the bottom of the popup. */
	.tof-filter__apply {
		display: block;
		margin-top: auto;
		padding-top: 8px;
	}

	.tof-apply-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		padding: 15px;
		border-radius: var(--tof-radius);
		background: var(--tof-mint);
		color: #fff;
		font-size: 15px;
		font-weight: 700;
		cursor: pointer;
		user-select: none;
	}

	.tof-apply-btn:hover {
		background: var(--tof-mint-dark);
	}
}
