/**
 * Landing Pattern Wallpapers gallery ([refcpt_wallpapers]). Layout only; the
 * theme sets the page width and colours. Tune with:
 *   --refcpt-wallpapers-gap          space between photos
 *   --refcpt-wallpapers-column       narrowest column before one is dropped
 *   --refcpt-wallpapers-max-columns  most columns on wide screens
 * The download button and menu come from WallPaper Posted (tiled-gallery.css).
 */

.wallpaper-posted.refcpt-wallpapers {
	--refcpt-wallpapers-gap: 12px;
	--refcpt-wallpapers-column: 300px;
	--refcpt-wallpapers-max-columns: 6;
	--refcpt-wallpapers-placeholder: rgba(127, 127, 127, .14);

	/* Undo the WallPaper Posted mosaic wrapper (flex column); the class stays for its lightbox. */
	display: block;
	gap: 0;
	margin: 0;
	width: 100%;
}

/* Without JavaScript: CSS columns, top to bottom. */
.refcpt-wallpapers-grid {
	column-gap: var(--refcpt-wallpapers-gap);
	column-width: var(--refcpt-wallpapers-column);
}

.refcpt-wallpapers .wallpaper-posted-item {
	aspect-ratio: var(--wallpaper-posted-item-ratio, 1.5);
	background: var(--refcpt-wallpapers-placeholder);
	break-inside: avoid;
	flex: none;
	height: auto;
	margin: 0 0 var(--refcpt-wallpapers-gap);
	min-width: 0;
	width: 100%;
}

/* With JavaScript: masonry, tiles placed by wallpapers.js. */
.refcpt-wallpapers.is-masonry .refcpt-wallpapers-grid {
	columns: auto;
	position: relative;
}

.refcpt-wallpapers.is-masonry .wallpaper-posted-item {
	aspect-ratio: auto;
	left: 0;
	margin: 0;
	position: absolute;
	top: 0;
}

.refcpt-wallpapers.is-masonry .wallpaper-posted-item img {
	opacity: 0;
	transition: opacity .5s ease, transform .6s cubic-bezier(.22, .61, .36, 1);
}

.refcpt-wallpapers.is-masonry .wallpaper-posted-item.is-loaded img { opacity: 1; }

.refcpt-wallpapers .wallpaper-posted-item > a:first-child { border-radius: inherit; overflow: hidden; }
.refcpt-wallpapers .wallpaper-posted-item:hover img { transform: scale(1.03); }

/* The story the photo comes from, along the bottom edge. */
.refcpt-wallpapers .refcpt-wallpaper-source {
	background: linear-gradient(transparent, rgba(0, 0, 0, .72));
	bottom: 0;
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	height: auto;
	left: 0;
	line-height: 1.3;
	opacity: 0;
	overflow: hidden;
	padding: 36px 14px 12px;
	position: absolute;
	right: 0;
	text-decoration: none;
	text-overflow: ellipsis;
	transition: opacity .25s ease;
	white-space: nowrap;
	width: auto;
	z-index: 1;
}

.refcpt-wallpapers .refcpt-wallpaper-source:hover { text-decoration: underline; }

.refcpt-wallpapers .wallpaper-posted-item:is(:hover, :focus-within) .refcpt-wallpaper-source { opacity: 1; }

@media (hover: none) {
	.refcpt-wallpapers .refcpt-wallpaper-source { opacity: 1; }
}

.refcpt-wallpapers .screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	height: 1px;
	overflow: hidden;
	position: absolute;
	width: 1px;
}

/* Foot: "Load more" link (no JavaScript, or after an error), loading pulse, status. */
.refcpt-wallpapers-foot {
	align-items: center;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 1px;
	padding-top: calc(var(--refcpt-wallpapers-gap) * 3);
}

.refcpt-wallpapers.is-auto:not(.has-error) .refcpt-wallpapers-more { display: none; }

.refcpt-wallpapers.is-loading .refcpt-wallpapers-foot::before {
	animation: refcpt-wallpapers-pulse 1s ease-in-out infinite alternate;
	background: currentColor;
	border-radius: 50%;
	content: "";
	height: 10px;
	opacity: .3;
	width: 10px;
}

.refcpt-wallpapers-status {
	clip: rect(1px, 1px, 1px, 1px);
	height: 1px;
	margin: 0;
	overflow: hidden;
	position: absolute;
	width: 1px;
}

.refcpt-wallpapers.has-error .refcpt-wallpapers-status { clip: auto; height: auto; position: static; width: auto; }

@keyframes refcpt-wallpapers-pulse {
	to { opacity: .9; transform: scale(1.4); }
}

@media (prefers-reduced-motion: reduce) {
	.refcpt-wallpapers .wallpaper-posted-item img,
	.refcpt-wallpapers.is-loading .refcpt-wallpapers-foot::before { animation: none; transition: none; }
	.refcpt-wallpapers .wallpaper-posted-item:hover img { transform: none; }
}

/* Tag search ----------------------------------------------------------------
   Colours follow the theme's variables (--surface, --line, --ink, --accent…)
   with neutral fallbacks, so it suits light and dark pages. */

.refcpt-wallpapers-search {
	--refcpt-search-bg: var(--surface, #f4f5f7);
	--refcpt-search-line: var(--line-strong, #c9ced6);
	--refcpt-search-ink: var(--ink, #171c23);
	--refcpt-search-muted: var(--muted, #6b7280);
	--refcpt-search-accent: var(--accent, #2563eb);
	--refcpt-search-hover: var(--tint, rgba(127, 127, 127, .12));

	align-items: center;
	display: flex;
	flex-direction: column;
	gap: 18px;
	margin: 0 auto clamp(28px, 4vw, 44px);
	max-width: 760px;
	min-width: 0;
}

.refcpt-wallpapers-form {
	position: relative;
	width: 100%;
}

.refcpt-wallpapers-field {
	align-items: center;
	background: var(--refcpt-search-bg);
	border: 1px solid var(--refcpt-search-line);
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	min-height: 56px;
	padding: 6px 6px 6px 16px;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.refcpt-wallpapers-field:focus-within {
	border-color: var(--refcpt-search-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--refcpt-search-accent) 22%, transparent);
}

.refcpt-wallpapers-icon {
	color: var(--refcpt-search-muted);
	flex: none;
	margin-right: 4px;
}

.refcpt-wallpapers-chosen {
	display: contents;
}

.refcpt-wallpapers .refcpt-wallpapers-input,
.refcpt-wallpapers .refcpt-wallpapers-input:focus {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 0;
	box-shadow: none;
	color: var(--refcpt-search-ink);
	flex: 1 1 180px;
	font-size: 16px;
	min-height: 42px;
	min-width: 0;
	outline: none;
	padding: 0 6px;
}

.refcpt-wallpapers-input::placeholder { color: var(--refcpt-search-muted); opacity: 1; }
.refcpt-wallpapers-input::-webkit-search-cancel-button { cursor: pointer; }

.refcpt-wallpapers .refcpt-wallpapers-submit {
	background: var(--refcpt-search-ink);
	border: 0;
	border-radius: 0;
	color: var(--paper, #fff);
	cursor: pointer;
	flex: none;
	font-family: var(--font-ui, inherit);
	font-size: 14px;
	font-weight: 500;
	min-height: 42px;
	padding: 0 20px;
	transition: background-color .2s ease;
}

.refcpt-wallpapers .refcpt-wallpapers-submit:hover { background: var(--refcpt-search-accent); }

/* Suggestions under the field. */
.refcpt-wallpapers-suggest {
	background: var(--refcpt-search-bg);
	border: 1px solid var(--refcpt-search-line);
	box-shadow: 0 24px 48px -20px rgba(0, 0, 0, .55);
	left: 0;
	list-style: none;
	margin: 6px 0 0;
	max-height: 340px;
	overflow-y: auto;
	padding: 6px;
	position: absolute;
	right: 0;
	top: 100%;
	z-index: 20;
}

.refcpt-wallpapers-suggest [role="option"] {
	align-items: center;
	color: var(--refcpt-search-ink);
	cursor: pointer;
	display: flex;
	font-size: 15px;
	gap: 12px;
	justify-content: space-between;
	margin: 0;
	padding: 10px 12px;
}

.refcpt-wallpapers-suggest [role="option"]:hover,
.refcpt-wallpapers-suggest [aria-selected="true"] {
	background: var(--refcpt-search-hover);
	color: var(--refcpt-search-accent);
}

/* Tag chips: chosen tags (in the field) and popular tags (below). */
.refcpt-wallpapers-popular {
	align-items: center;
	max-width: 100%;
	min-width: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.refcpt-wallpapers-popular-label {
	color: var(--refcpt-search-muted);
	font-family: var(--font-ui, inherit);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .08em;
	margin-right: 4px;
	text-transform: uppercase;
}

.refcpt-wallpapers .refcpt-wallpapers-chip {
	align-items: center;
	background: transparent;
	border: 1px solid var(--line, #dde1e6);
	border-radius: 0;
	color: var(--ink-2, var(--refcpt-search-ink));
	cursor: pointer;
	display: inline-flex;
	font-family: var(--font-ui, inherit);
	font-size: 13px;
	font-weight: 500;
	gap: 8px;
	line-height: 1;
	min-height: 34px;
	padding: 0 12px;
	text-decoration: none;
	transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.refcpt-wallpapers .refcpt-wallpapers-chip:hover {
	border-color: var(--refcpt-search-ink);
	color: var(--refcpt-search-ink);
}

.refcpt-wallpapers .refcpt-wallpapers-chip.is-selected {
	background: var(--refcpt-search-ink);
	border-color: var(--refcpt-search-ink);
	color: var(--paper, #fff);
}

.refcpt-wallpapers .refcpt-wallpapers-chip.is-selected:hover {
	background: var(--refcpt-search-accent);
	border-color: var(--refcpt-search-accent);
}

/* Chosen tags inside the field: tighter, with the × to remove. */
.refcpt-wallpapers-field .refcpt-wallpapers-chip { min-height: 32px; padding: 0 8px 0 12px; }
.refcpt-wallpapers-chip > span[aria-hidden] { font-size: 16px; opacity: .7; }

.refcpt-wallpapers-count {
	color: var(--refcpt-search-muted);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

.refcpt-wallpapers-chip.is-selected .refcpt-wallpapers-count { color: inherit; opacity: .7; }

/* What is shown, and "Clear search". */
.refcpt-wallpapers-summary {
	color: var(--refcpt-search-muted);
	font-size: 15px;
	margin: 0;
	text-align: center;
}

.refcpt-wallpapers-summary-text { color: var(--refcpt-search-ink); }

.refcpt-wallpapers .refcpt-wallpapers-clear {
	color: var(--refcpt-search-accent);
	margin-left: 10px;
	text-decoration: none;
}

.refcpt-wallpapers .refcpt-wallpapers-clear:hover { text-decoration: underline; }

/* Fade the photos while a new search loads. */
.refcpt-wallpapers.is-searching .refcpt-wallpapers-grid { opacity: .45; transition: opacity .2s ease; }

@media (max-width: 600px) {
	.refcpt-wallpapers-field { padding-left: 12px; }
	.refcpt-wallpapers .refcpt-wallpapers-submit { padding: 0 14px; }

	/* Popular tags: one row that scrolls sideways, edge to edge. */
	.refcpt-wallpapers-popular {
		flex-wrap: nowrap;
		justify-content: flex-start;
		margin-inline: calc(-1 * var(--gutter, 20px));
		overflow-x: auto;
		padding-inline: var(--gutter, 20px);
		align-self: stretch;
		max-width: none;
		scrollbar-width: none;
	}
	.refcpt-wallpapers-popular::-webkit-scrollbar { display: none; }
	.refcpt-wallpapers .refcpt-wallpapers-popular .refcpt-wallpapers-chip { flex: none; white-space: nowrap; }
	.refcpt-wallpapers-popular-label { flex: none; }
}
