/* Prompt Gallery — adapts to the theme: colours come from the text colour and theme button variables. */

.pg-gallery,
.pg-single,
.pg-upload,
.pg-account {
	--pg-accent: var(--wp--custom--elements--button--color--background, var(--wp--preset--color--primary, #2563eb));
	--pg-accent-text: var(--wp--custom--elements--button--color--text, #fff);
	--pg-btn-radius: var(--wp--custom--elements--button--border--radius, 10px);
	--pg-radius: 14px;
	--pg-gap: 18px;
	--pg-border: rgba(127, 127, 127, 0.3);
	--pg-surface: rgba(127, 127, 127, 0.07);
	--pg-success: #1f9d55;
	--pg-danger: #d63638;
	box-sizing: border-box;
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	.pg-gallery,
	.pg-single,
	.pg-upload,
	.pg-account {
		--pg-border: color-mix(in srgb, currentColor 16%, transparent);
		--pg-surface: color-mix(in srgb, currentColor 5%, transparent);
	}
}

.pg-gallery *,
.pg-single *,
.pg-upload *,
.pg-account * {
	box-sizing: border-box;
}

.pg-icon {
	flex: none;
}

.pg-muted {
	opacity: 0.7;
	font-size: 0.85em;
}

/* ---------- Buttons, pills, chips ---------- */

.pg-btn {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45em;
	padding: 0.55em 1em;
	border: 1px solid var(--pg-accent);
	border-radius: var(--pg-btn-radius);
	background: var(--pg-accent);
	color: var(--pg-accent-text);
	font: inherit;
	font-size: 0.85em;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	transition: filter 0.15s, background-color 0.15s, border-color 0.15s;
}

.pg-btn:hover,
.pg-btn:focus-visible {
	filter: brightness(1.12);
	color: var(--pg-accent-text);
}

.pg-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.pg-btn--ghost {
	background: transparent;
	color: inherit;
	border-color: var(--pg-border);
}

.pg-btn--ghost:hover,
.pg-btn--ghost:focus-visible {
	border-color: var(--pg-accent);
	color: inherit;
}

.pg-btn.is-copied {
	background: var(--pg-success);
	border-color: var(--pg-success);
	color: #fff;
}

.pg-btn--lg {
	font-size: 1em;
	padding: 0.75em 1.5em;
}

.pg-textbtn {
	appearance: none;
	background: none;
	border: 0;
	padding: 0.25em 0;
	color: inherit;
	font: inherit;
	font-size: 0.85em;
	opacity: 0.75;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.pg-textbtn:hover {
	opacity: 1;
}

.pg-pill {
	display: inline-block;
	padding: 0.45em 1.1em;
	border: 1px solid var(--pg-border);
	border-radius: 999px;
	color: inherit;
	font-size: 0.9em;
	font-weight: 600;
	text-decoration: none;
	line-height: 1.2;
}

a.pg-pill:hover {
	border-color: var(--pg-accent);
}

.pg-pill.is-active {
	background: var(--pg-accent);
	border-color: var(--pg-accent);
	color: var(--pg-accent-text);
}

.pg-chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.pg-chip {
	appearance: none;
	display: inline-block;
	padding: 0.28em 0.75em;
	border: 1px solid var(--pg-border);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.78em;
	line-height: 1.35;
	text-decoration: none;
	cursor: pointer;
}

.pg-chip:hover {
	border-color: var(--pg-accent);
}

.pg-chip.is-active {
	background: var(--pg-accent);
	border-color: var(--pg-accent);
	color: var(--pg-accent-text);
}

/* ---------- Toolbar ---------- */

.pg-toolbar {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin-bottom: 28px;
}

.pg-toolbar__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px 10px;
}

.pg-toolbar__row:empty {
	display: none;
}

.pg-search {
	display: flex;
	gap: 8px;
	width: 100%;
	max-width: 560px;
	margin: 0;
}

.pg-search input[type="search"] {
	flex: 1;
	min-width: 0;
	padding: 0.6em 1em;
	border: 1px solid var(--pg-border);
	border-radius: var(--pg-btn-radius);
	background: transparent;
	color: inherit;
	font: inherit;
}

.pg-search input[type="search"]:focus {
	outline: 2px solid var(--pg-accent);
	outline-offset: 1px;
}

.pg-tags-panel {
	max-width: 900px;
	width: 100%;
	margin: 0 auto;
	text-align: center;
}

.pg-tags-panel summary {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	cursor: pointer;
	font-size: 0.9em;
	font-weight: 600;
	list-style: none;
	padding: 0.35em 0.9em;
	border: 1px solid var(--pg-border);
	border-radius: 999px;
}

.pg-tags-panel summary::-webkit-details-marker {
	display: none;
}

.pg-tags-panel[open] summary {
	margin-bottom: 12px;
}

.pg-tags-panel .pg-chips {
	justify-content: center;
	max-height: 260px;
	overflow-y: auto;
}

.pg-count {
	opacity: 0.6;
	font-weight: 400;
}

/* ---------- Grid ----------
 * Every card is identical in size: fixed image shape (--pg-ratio), 3 prompt lines,
 * one button row, one tag row. Extra info opens in a panel ON TOP of the card.
 */

.pg-grid--grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(var(--pg-min, 300px), 100%), 1fr));
	gap: var(--pg-gap);
	align-items: start;
}

.pg-grid--masonry {
	columns: var(--pg-min, 300px);
	column-gap: var(--pg-gap);
}

.pg-grid--masonry > .pg-card {
	break-inside: avoid;
	margin-bottom: var(--pg-gap);
}

.pg-card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	border: 1px solid var(--pg-border);
	border-radius: var(--pg-radius);
	background: var(--pg-surface);
	overflow: hidden;
}

.pg-card__media {
	position: relative;
	aspect-ratio: var(--pg-ratio, 2 / 3);
	overflow: hidden;
	background: rgba(127, 127, 127, 0.12);
}

.pg-card__link {
	display: block;
	width: 100%;
	height: 100%;
}

.pg-card__img,
.pg-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: var(--pg-fit, cover);
	transition: transform 0.35s ease;
}

.pg-card:hover .pg-card__img {
	transform: scale(1.03);
}

/* Masonry keeps each image's natural shape. */
.pg-grid--masonry .pg-card__media {
	aspect-ratio: auto;
}

.pg-grid--masonry .pg-card__img,
.pg-grid--masonry .pg-card__media img {
	height: auto;
}

.pg-card__zoom {
	position: absolute;
	top: 10px;
	right: 10px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s;
	backdrop-filter: blur(4px);
}

.pg-card:hover .pg-card__zoom,
.pg-card__zoom:focus-visible {
	opacity: 1;
}

@media (hover: none) {
	.pg-card__zoom {
		opacity: 1;
	}
}

.pg-card__body {
	--pg-line: 1.5em;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 16px 16px;
	font-size: 0.88em;
}

.pg-card__title {
	margin: 0;
	font-size: 1.05em;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pg-card__title a {
	color: inherit;
	text-decoration: none;
}

/* Fixed: always exactly 3 lines tall, even for short or empty prompts. */
.pg-prompt {
	margin: 0 0 10px;
	height: calc(var(--pg-line) * 3);
	line-height: var(--pg-line);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.pg-card__actions {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 12px;
	min-height: 2.4em;
}

.pg-card__actions .pg-btn {
	font-size: 0.95em;
}

.pg-card__actions .pg-more {
	margin-left: auto;
	white-space: nowrap;
}

/* Fixed: one row of tags, fades out if there are more (all tags are in "Show more"). */
.pg-card__tags {
	flex-wrap: nowrap;
	height: 1.9em;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to right, #000 80%, transparent);
	mask-image: linear-gradient(to right, #000 80%, transparent);
}

.pg-card__tags .pg-chip {
	flex: none;
}

/* ---------- "Show more" panel (covers the card, never resizes it) ---------- */

.pg-card__panel {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 16px 16px;
	background: rgb(18, 18, 22);
	color: #f2f2f5;
	font-size: 0.88em;
	backdrop-filter: blur(8px);
	animation: pg-panel-in 0.16s ease-out;
}

.pg-card__panel[hidden] {
	display: none;
}

@keyframes pg-panel-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.pg-card__panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.pg-card__close {
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.pg-card__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.pg-card__panel-scroll {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding-right: 4px;
	scrollbar-width: thin;
}

.pg-panel-sec__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 6px;
}

.pg-panel-label {
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.7;
}

.pg-panel-text {
	margin: 0;
	line-height: 1.55;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.pg-card__panel .pg-btn--ghost {
	color: #fff;
	border-color: rgba(255, 255, 255, 0.3);
}

.pg-card__panel .pg-chip {
	color: #fff;
	border-color: rgba(255, 255, 255, 0.28);
}

.pg-card__panel .pg-chip.is-active {
	color: var(--pg-accent-text);
	border-color: var(--pg-accent);
}

.pg-card__open {
	width: 100%;
}

.pg-load-more-wrap {
	display: flex;
	justify-content: center;
	margin-top: 28px;
}

.pg-load-more {
	font-size: 0.95em;
	padding: 0.7em 2em;
}

.pg-empty {
	text-align: center;
	opacity: 0.75;
	padding: 40px 0;
}

/* ---------- Lightbox ---------- */

.pg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.92);
}

.pg-lightbox.is-open {
	display: flex;
}

.pg-lightbox img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.pg-lightbox__close {
	position: absolute;
	top: 12px;
	right: 16px;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

html.pg-noscroll {
	overflow: hidden;
}

/* ---------- Single image page ---------- */

.pg-single {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.pg-single__figure {
	margin: 0;
}

.pg-single__figure a {
	display: block;
	cursor: zoom-in;
}

.pg-single__figure img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--pg-radius);
}

.pg-box {
	padding: 16px 18px;
	border: 1px solid var(--pg-border);
	border-radius: var(--pg-radius);
	background: var(--pg-surface);
}

.pg-box__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 10px;
}

.pg-box__title {
	margin: 0;
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.75;
}

.pg-box__text {
	margin: 0;
	font-size: 0.95em;
	line-height: 1.6;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.pg-single__terms {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* ---------- Upload form ---------- */

.pg-upload {
	max-width: 760px;
}

.pg-upload__form {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.pg-field {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.pg-label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
	padding: 0;
}

.pg-req {
	color: var(--pg-danger);
}

.pg-upload input[type="text"],
.pg-upload textarea,
.pg-account input[type="text"],
.pg-account input[type="email"],
.pg-account input[type="password"] {
	display: block;
	width: 100%;
	padding: 0.65em 0.85em;
	border: 1px solid var(--pg-border);
	border-radius: 10px;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.5;
}

.pg-upload input[type="text"]:focus,
.pg-upload textarea:focus,
.pg-account input:focus {
	outline: 2px solid var(--pg-accent);
	outline-offset: 1px;
}

.pg-hint {
	margin: 6px 0 0;
	font-size: 0.82em;
	opacity: 0.7;
}

.pg-dropzone {
	padding: 20px;
	border: 2px dashed var(--pg-border);
	border-radius: var(--pg-radius);
	text-align: center;
}

.pg-dropzone__preview {
	display: block;
	max-width: 100%;
	max-height: 360px;
	margin: 0 auto 14px;
	border-radius: 10px;
}

.pg-checks {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 18px;
}

.pg-check {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}

.pg-tag-suggest {
	margin-top: 10px;
}

.pg-notice {
	margin: 0 0 20px;
	padding: 12px 16px;
	border: 1px solid var(--pg-border);
	border-left-width: 4px;
	border-radius: 10px;
}

.pg-notice p {
	margin: 0;
}

.pg-notice--success {
	border-left-color: var(--pg-success);
}

.pg-notice--error {
	border-left-color: var(--pg-danger);
}

/* ---------- Upvotes ---------- */

.pg-vote {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	padding: 0.4em 0.75em;
	border: 1px solid var(--pg-border);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.85em;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.pg-vote:hover:not(:disabled),
.pg-vote:focus-visible {
	border-color: var(--pg-accent);
	color: inherit;
}

.pg-vote:active:not(:disabled) {
	transform: scale(0.94);
}

.pg-vote:disabled {
	cursor: default;
	opacity: 0.75;
}

.pg-vote.is-voted {
	background: var(--pg-accent);
	border-color: var(--pg-accent);
	color: var(--pg-accent-text);
}

/* On the card: a pill on the image, so the card size never changes. */
.pg-vote--card {
	position: absolute;
	left: 10px;
	bottom: 10px;
	z-index: 2;
	border-color: transparent;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	backdrop-filter: blur(4px);
}

.pg-vote--card:hover:not(:disabled),
.pg-vote--card:focus-visible {
	color: #fff;
}

.pg-vote--big {
	font-size: 1em;
	padding: 0.55em 1.1em;
}

.pg-single__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

/* ---------- Sort switch ---------- */

.pg-sort {
	display: inline-flex;
	padding: 3px;
	border: 1px solid var(--pg-border);
	border-radius: 999px;
}

.pg-sort__opt {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	padding: 0.45em 1em;
	border-radius: 999px;
	color: inherit;
	font-size: 0.85em;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
}

.pg-sort__opt:hover {
	color: inherit;
	background: var(--pg-surface);
}

.pg-sort__opt.is-active {
	background: var(--pg-accent);
	color: var(--pg-accent-text);
}

/* ---------- Account page ---------- */

.pg-account__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
	gap: 24px;
	align-items: start;
}

.pg-account--single .pg-account__grid {
	max-width: 480px;
}

.pg-account__card {
	padding: 24px;
	border: 1px solid var(--pg-border);
	border-radius: var(--pg-radius);
	background: var(--pg-surface);
}

.pg-account__title {
	margin: 0 0 16px;
	font-size: 1.4em;
	line-height: 1.25;
}

.pg-account__lead {
	margin: -8px 0 16px;
}

.pg-form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.pg-form__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px;
	margin: 4px 0 0;
}

/* Honeypot for bots: hidden from people. */
.pg-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.pg-account__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 28px;
}

.pg-account__head .pg-account__title {
	margin: 0;
}

.pg-account__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.pg-account__section {
	margin-bottom: 36px;
}

.pg-account__section .pg-box__title {
	margin-bottom: 14px;
}

.pg-mini-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pg-mini {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
	margin: 0;
}

.pg-mini a,
.pg-mini > div {
	display: flex;
	flex-direction: column;
	gap: 6px;
	color: inherit;
	text-decoration: none;
}

.pg-mini__img {
	display: block;
	aspect-ratio: 2 / 3;
	overflow: hidden;
	border-radius: 10px;
	background: rgba(127, 127, 127, 0.12);
}

.pg-mini__img img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.pg-mini__title {
	font-size: 0.82em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pg-mini__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	font-size: 0.78em;
}

.pg-mini__votes {
	display: inline-flex;
	align-items: center;
	gap: 0.25em;
	opacity: 0.8;
}

.pg-mini__votes .pg-icon {
	width: 13px;
	height: 13px;
}

.pg-badge {
	display: inline-block;
	padding: 0.2em 0.6em;
	border-radius: 999px;
	font-weight: 600;
	line-height: 1.3;
	border: 1px solid var(--pg-border);
}

.pg-badge--ok {
	background: rgba(31, 157, 85, 0.18);
	border-color: rgba(31, 157, 85, 0.5);
}

.pg-badge--wait {
	background: rgba(219, 166, 23, 0.18);
	border-color: rgba(219, 166, 23, 0.55);
}

.pg-badge--no {
	background: rgba(214, 54, 56, 0.18);
	border-color: rgba(214, 54, 56, 0.55);
}

.pg-notice .pg-btn {
	margin-left: 8px;
}

@media (max-width: 600px) {
	.pg-gallery {
		--pg-gap: 12px;
	}

	.pg-search .pg-btn span {
		display: none;
	}
}

.pg-vote .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}
