/*
 * Ranger Rick Photo Contest
 * Low-specificity, scoped styles. All selectors use :where() so a theme
 * can override freely without fighting specificity.
 * Customize via CSS custom properties on .rrpc-root (see --rrpc-* below).
 */

:where(.rrpc-root) {
	/*
	 * Ranger Rick brand palette (from the official hex guide):
	 *   Backpack Green   #6bb540
	 *   Flame Orange     #f16521
	 *   Forest Green     #007236
	 *   Lake Blue        #0088c6
	 *   Goldenrod Yellow #ffcd5b
	 */
	--rrpc-backpack: #6bb540;
	--rrpc-flame: #f16521;
	--rrpc-forest: #007236;
	--rrpc-lake: #0088c6;
	--rrpc-goldenrod: #ffcd5b;

	/* Semantic tokens used by the plugin. Override these to re-skin. */
	/* Primary CTA — Flame Orange to match the theme's primary button.
	   Prefers the theme's orange preset if exposed; falls back to brand Flame. */
	--rrpc-accent: var(--wp--preset--color--orange, var(--rrpc-flame));
	--rrpc-accent-dark: #c44e0f;
	--rrpc-sunny: var(--rrpc-goldenrod);
	--rrpc-sunny-dark: #f2b72d;
	--rrpc-text: #1a1a1a;
	--rrpc-muted: #666;
	--rrpc-border: #e2e2e2;
	--rrpc-border-selected: var(--rrpc-accent);
	--rrpc-radius: 12px;
	--rrpc-gap: 1.25rem;
	--rrpc-bg: #fff;
	--rrpc-bg-muted: #f6f6f6;
	--rrpc-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	--rrpc-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
	--rrpc-focus: var(--rrpc-lake);

	display: block;
	color: var(--rrpc-text);
	font-family: inherit;
	line-height: 1.4;
	margin: 0 auto;
	max-width: 1100px;
}

:where(.rrpc-root *) {
	box-sizing: border-box;
}

:where(.rrpc-root .rrpc-heading) {
	font-size: 1.5rem;
	margin: 0 0 0.75rem;
	text-align: center;
}

/* High-specificity + !important because some themes hide nested
   paragraphs/text blocks on specific page templates. */
.rrpc-root .rrpc-instructions {
	color: var(--rrpc-muted) !important;
	display: block !important;
	font-size: 1rem !important;
	margin: 0 0 1rem !important;
	opacity: 1 !important;
	text-align: center !important;
	visibility: visible !important;
}

:where(.rrpc-root .rrpc-empty) {
	color: var(--rrpc-muted);
	font-style: italic;
	padding: 2rem 1rem;
	text-align: center;
}

:where(.rrpc-root .rrpc-status) {
	min-height: 1.25rem;
	margin: 0 0 0.75rem;
	text-align: center;
	font-size: 0.9375rem;
}

:where(.rrpc-root .rrpc-status--error) {
	color: #b5371a;
}

:where(.rrpc-root .rrpc-status--success) {
	color: var(--rrpc-accent-dark);
}

:where(.rrpc-root .rrpc-grid) {
	display: grid;
	gap: var(--rrpc-gap);
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	list-style: none;
	margin: 0;
	padding: 0;
}

:where(.rrpc-root .rrpc-entry) {
	background: var(--rrpc-bg);
	border: 2px solid var(--rrpc-border);
	border-radius: var(--rrpc-radius);
	box-shadow: var(--rrpc-shadow);
	overflow: hidden;
	position: relative;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

:where(.rrpc-root .rrpc-entry:hover) {
	box-shadow: var(--rrpc-shadow-hover);
}

:where(.rrpc-root .rrpc-entry--selected) {
	border-color: var(--rrpc-border-selected);
	box-shadow: 0 0 0 2px var(--rrpc-accent), var(--rrpc-shadow-hover);
}

:where(.rrpc-root .rrpc-entry--locked) {
	opacity: 0.55;
}

:where(.rrpc-root .rrpc-entry__label) {
	cursor: pointer;
	display: block;
	margin: 0;
}

:where(.rrpc-root .rrpc-entry--locked .rrpc-entry__label) {
	cursor: not-allowed;
}

:where(.rrpc-root .rrpc-entry__input) {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 1px;
	height: 1px;
}

:where(.rrpc-root .rrpc-entry__input:focus-visible + .rrpc-entry__media) {
	outline: 3px solid var(--rrpc-focus);
	outline-offset: 2px;
}

:where(.rrpc-root .rrpc-entry__media) {
	background: var(--rrpc-bg-muted);
	display: block;
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

.rrpc-root .rrpc-entry__image {
	display: block !important;
	height: 100% !important;
	max-height: 100% !important;
	max-width: 100% !important;
	object-fit: contain !important;
	object-position: center !important;
	width: 100% !important;
}

:where(.rrpc-root .rrpc-entry__image--placeholder) {
	background: linear-gradient(135deg, #eee, #ccc);
	height: 100%;
	width: 100%;
}

:where(.rrpc-root .rrpc-entry__check) {
	align-items: center;
	background: var(--rrpc-accent);
	border-radius: 999px;
	color: #fff;
	display: flex;
	height: 36px;
	justify-content: center;
	opacity: 0;
	position: absolute;
	right: 10px;
	top: 10px;
	transform: scale(0.7);
	transition: opacity 0.15s ease, transform 0.15s ease;
	width: 36px;
	z-index: 2;
}

:where(.rrpc-root .rrpc-entry--selected .rrpc-entry__check) {
	opacity: 1;
	transform: scale(1);
}

/*
 * Zoom affordance: small yellow circle magnifier button in the lower-right
 * of the card body, opposite the photo credit. Lives OUTSIDE the label so
 * clicking it doesn't trigger the vote. !important on visual properties
 * guards against theme <button> resets.
 */
.rrpc-root .rrpc-entry__body-top {
	align-items: center;
	display: flex;
	gap: 0.5rem;
	justify-content: space-between;
	min-height: 36px;
}

.rrpc-root .rrpc-entry__credit-placeholder {
	display: block;
	flex: 1 1 auto;
}

.rrpc-root .rrpc-entry__zoom {
	align-items: center !important;
	background: var(--rrpc-sunny) !important;
	border: 2px solid #fff !important;
	border-radius: 999px !important;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.08) !important;
	color: var(--rrpc-accent-dark) !important;
	cursor: pointer !important;
	display: inline-flex !important;
	flex-shrink: 0 !important;
	height: 36px !important;
	justify-content: center !important;
	margin: 0 !important;
	opacity: 1 !important;
	padding: 0 !important;
	position: relative !important;
	transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
	visibility: visible !important;
	width: 36px !important;
}

.rrpc-root .rrpc-entry__zoom:hover,
.rrpc-root .rrpc-entry__zoom:focus-visible {
	background: var(--rrpc-sunny-dark) !important;
	transform: scale(1.08) rotate(-4deg);
}

.rrpc-root .rrpc-entry__zoom:focus-visible {
	outline: 3px solid var(--rrpc-focus) !important;
	outline-offset: 2px !important;
}

.rrpc-root .rrpc-entry__zoom:active {
	transform: scale(0.96);
}

.rrpc-root .rrpc-entry__zoom-icon {
	display: block !important;
	fill: currentColor !important;
	flex-shrink: 0 !important;
	height: 20px !important;
	pointer-events: none;
	width: 20px !important;
}

.rrpc-root .rrpc-entry__zoom-tip {
	background: #fff;
	border: 2px solid var(--rrpc-accent);
	border-radius: 999px;
	bottom: calc(100% + 8px);
	color: var(--rrpc-accent-dark);
	font-size: 0.8125rem;
	font-weight: 700;
	line-height: 1;
	opacity: 0;
	padding: 0.35rem 0.7rem;
	pointer-events: none;
	position: absolute;
	right: 0;
	transform: translateY(4px);
	transition: opacity 0.15s ease, transform 0.15s ease;
	white-space: nowrap;
	z-index: 4;
}

.rrpc-root .rrpc-entry__zoom:hover .rrpc-entry__zoom-tip,
.rrpc-root .rrpc-entry__zoom:focus-visible .rrpc-entry__zoom-tip {
	opacity: 1;
	transform: translateY(0);
}

:where(.rrpc-root .rrpc-entry__body) {
	display: block;
	padding: 0.75rem 1rem 0.875rem;
}

:where(.rrpc-root .rrpc-entry__credit) {
	color: var(--rrpc-text);
	display: block;
	flex: 1 1 auto;
	font-size: 0.9375rem;
	font-weight: 600;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

:where(.rrpc-root .rrpc-entry__caption) {
	color: var(--rrpc-muted);
	display: block;
	font-size: 0.875rem;
	margin-top: 0.5rem;
}

:where(.rrpc-root .rrpc-entry__caption p) {
	margin: 0 0 0.25rem;
}

:where(.rrpc-root .rrpc-entry__votes) {
	color: var(--rrpc-muted);
	display: block;
	font-size: 0.8125rem;
	margin-top: 0.375rem;
}

/* Footer + counter + submit: high-specificity + !important so that theme
   resets (e.g. "button { background: transparent }", nth-child hiders,
   or template-level page wrappers) can't suppress the vote submit UI. */
.rrpc-root .rrpc-footer {
	align-items: center !important;
	display: flex !important;
	flex-direction: column !important;
	gap: 0.75rem !important;
	margin-top: 1.5rem !important;
	opacity: 1 !important;
	text-align: center !important;
	visibility: visible !important;
}

.rrpc-root .rrpc-counter {
	color: var(--rrpc-muted) !important;
	display: block !important;
	font-size: 0.9375rem !important;
	margin: 0 !important;
	opacity: 1 !important;
	visibility: visible !important;
}

/* Submit button — visual styles come from the theme via the .wp-block-button__link
   and .wp-element-button classes added in the shortcode. The plugin only adds
   behavior-specific tweaks below (cursor, active feedback, loading state).
   This keeps the button visually consistent with the kids site stylebook and
   inherits any future theme updates automatically. */
.rrpc-root .rrpc-submit-wrap {
	display: inline-block;
	margin: 0;
}

.rrpc-root .rrpc-submit {
	cursor: pointer;
	transition: transform 0.05s ease;
}

.rrpc-root .rrpc-submit:active:not(:disabled) {
	transform: translateY(1px);
}

.rrpc-root .rrpc-submit:disabled {
	cursor: not-allowed;
}

.rrpc-root .rrpc-submit--loading {
	position: relative;
}

:where(.rrpc-root .rrpc-done) {
	background: var(--rrpc-bg-muted);
	border-radius: var(--rrpc-radius);
	color: var(--rrpc-accent-dark);
	font-size: 1.125rem;
	font-weight: 600;
	padding: 2.5rem 1rem;
	text-align: center;
}

/* Lightbox */

.rrpc-no-scroll {
	overflow: hidden;
}

:where(.rrpc-root .rrpc-lightbox) {
	align-items: center;
	display: flex;
	inset: 0;
	justify-content: center;
	padding: 1rem;
	position: fixed;
	z-index: 10000;
}

:where(.rrpc-root .rrpc-lightbox[hidden]) {
	display: none;
}

:where(.rrpc-root .rrpc-lightbox__backdrop) {
	background: rgba(10, 20, 12, 0.82);
	cursor: pointer;
	inset: 0;
	position: absolute;
}

:where(.rrpc-root .rrpc-lightbox__panel) {
	background: #fff;
	border-radius: calc(var(--rrpc-radius) + 4px);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 2rem);
	max-width: min(1100px, calc(100vw - 2rem));
	overflow: hidden;
	position: relative;
	width: 100%;
}

.rrpc-root .rrpc-lightbox__close {
	align-items: center;
	background: var(--rrpc-sunny);
	border: 3px solid #fff;
	border-radius: 999px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	color: var(--rrpc-text);
	cursor: pointer;
	display: inline-flex;
	height: 44px;
	justify-content: center;
	padding: 0;
	position: absolute;
	right: 12px;
	top: 12px;
	transition: transform 0.12s ease, background 0.12s ease;
	width: 44px;
	z-index: 3;
}

.rrpc-root .rrpc-lightbox__close:hover,
.rrpc-root .rrpc-lightbox__close:focus-visible {
	background: var(--rrpc-sunny-dark);
	transform: scale(1.06) rotate(6deg);
}

.rrpc-root .rrpc-lightbox__close:focus-visible {
	outline: 3px solid var(--rrpc-focus);
	outline-offset: 2px;
}

.rrpc-root .rrpc-lightbox__nav {
	align-items: center;
	background: rgba(255, 255, 255, 0.95);
	border: 2px solid var(--rrpc-border);
	border-radius: 999px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	color: var(--rrpc-text);
	cursor: pointer;
	display: inline-flex;
	height: 52px;
	justify-content: center;
	padding: 0;
	position: absolute;
	top: 40%;
	transform: translateY(-50%);
	transition: transform 0.12s ease, background 0.12s ease;
	width: 52px;
	z-index: 3;
}

.rrpc-root .rrpc-lightbox__nav--prev {
	left: 12px;
}

.rrpc-root .rrpc-lightbox__nav--next {
	right: 12px;
}

.rrpc-root .rrpc-lightbox__nav:hover,
.rrpc-root .rrpc-lightbox__nav:focus-visible {
	background: var(--rrpc-sunny);
}

.rrpc-root .rrpc-lightbox__nav:focus-visible {
	outline: 3px solid var(--rrpc-focus);
	outline-offset: 2px;
}

.rrpc-root .rrpc-lightbox__nav:active {
	transform: translateY(-50%) scale(0.96);
}

:where(.rrpc-root .rrpc-lightbox__stage) {
	align-items: center;
	background: #0f1410;
	display: flex;
	flex: 1 1 auto;
	justify-content: center;
	min-height: 50vh;
	overflow: hidden;
	padding: 1rem;
}

:where(.rrpc-root .rrpc-lightbox__image) {
	display: block;
	max-height: 70vh;
	max-width: 100%;
	object-fit: contain;
	opacity: 0;
	transition: opacity 0.2s ease;
}

:where(.rrpc-root .rrpc-lightbox__image.is-loaded) {
	opacity: 1;
}

:where(.rrpc-root .rrpc-lightbox__info) {
	padding: 1rem 1.25rem 0.5rem;
}

:where(.rrpc-root .rrpc-lightbox__credit) {
	color: var(--rrpc-text);
	font-size: 1rem;
	font-weight: 700;
	margin: 0 0 0.25rem;
}

:where(.rrpc-root .rrpc-lightbox__credit[hidden]) {
	display: none;
}

:where(.rrpc-root .rrpc-lightbox__caption) {
	color: var(--rrpc-muted);
	font-size: 0.9375rem;
}

:where(.rrpc-root .rrpc-lightbox__caption[hidden]) {
	display: none;
}

:where(.rrpc-root .rrpc-lightbox__caption p) {
	margin: 0 0 0.375rem;
}

:where(.rrpc-root .rrpc-lightbox__footer) {
	align-items: center;
	border-top: 1px solid var(--rrpc-border);
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.25rem;
	justify-content: space-between;
	padding: 1rem 1.25rem;
}

.rrpc-root .rrpc-lightbox__vote {
	align-items: center;
	background: var(--rrpc-accent);
	border: none;
	border-radius: 999px;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	font-size: 1rem;
	font-weight: 700;
	gap: 0.5rem;
	padding: 0.75rem 1.5rem;
	transition: background 0.15s ease, transform 0.05s ease;
}

.rrpc-root .rrpc-lightbox__vote:hover:not(:disabled) {
	background: var(--rrpc-accent-dark);
}

.rrpc-root .rrpc-lightbox__vote:active:not(:disabled) {
	transform: translateY(1px);
}

.rrpc-root .rrpc-lightbox__vote:focus-visible {
	outline: 3px solid var(--rrpc-focus);
	outline-offset: 2px;
}

.rrpc-root .rrpc-lightbox__vote:disabled {
	background: var(--rrpc-bg-muted);
	color: var(--rrpc-muted);
	cursor: not-allowed;
}

:where(.rrpc-root .rrpc-lightbox__vote-check) {
	display: none;
}

:where(.rrpc-root .rrpc-lightbox__vote--selected) {
	background: var(--rrpc-accent-dark);
}

:where(.rrpc-root .rrpc-lightbox__vote--selected .rrpc-lightbox__vote-check) {
	display: inline-block;
}

:where(.rrpc-root .rrpc-lightbox__counter) {
	color: var(--rrpc-muted);
	font-size: 0.9375rem;
	margin: 0;
}

@media (max-width: 640px) {
	:where(.rrpc-root .rrpc-lightbox__nav) {
		height: 44px;
		width: 44px;
	}

	:where(.rrpc-root .rrpc-lightbox__nav--prev) {
		left: 8px;
	}

	:where(.rrpc-root .rrpc-lightbox__nav--next) {
		right: 8px;
	}

	:where(.rrpc-root .rrpc-lightbox__image) {
		max-height: 55vh;
	}

	:where(.rrpc-root .rrpc-lightbox__footer) {
		justify-content: center;
		text-align: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	:where(.rrpc-root .rrpc-entry),
	:where(.rrpc-root .rrpc-entry__check),
	:where(.rrpc-root .rrpc-entry__zoom),
	:where(.rrpc-root .rrpc-entry__zoom-tip),
	:where(.rrpc-root .rrpc-submit),
	:where(.rrpc-root .rrpc-lightbox__close),
	:where(.rrpc-root .rrpc-lightbox__nav),
	:where(.rrpc-root .rrpc-lightbox__vote),
	:where(.rrpc-root .rrpc-lightbox__image) {
		transition: none;
	}
}
