/**
 * ShelterSync for ShelterManager — Public Front-end Styles
 *
 * All rules scoped to .sheltermgr-container (SM-TMP-001).
 * CSS class hook convention uses sheltermgr- prefix (SM-TMP-002).
 * Loaded only on pages where plugin output is present (NFR-02-01).
 *
 * Class hooks (stable across minor plugin updates):
 *
 *  Container:
 *    .sheltermgr-container          — root wrapper for all plugin output
 *
 *  Listing grid:
 *    .sheltermgr-listing            — outer grid wrapper
 *    .sheltermgr-filter-bar         — filter controls bar
 *    .sheltermgr-filter-group       — single filter dimension wrapper
 *    .sheltermgr-filter-label       — filter dimension heading
 *    .sheltermgr-filter-option      — individual filter checkbox/label
 *    .sheltermgr-filter-clear       — clear individual filter button
 *    .sheltermgr-filter-clear-all   — clear all filters button
 *    .sheltermgr-filter-active      — state: filter dimension has active selections
 *    .sheltermgr-grid               — animal card grid
 *    .sheltermgr-animal-card        — individual animal card
 *    .sheltermgr-animal-photo       — card photo element
 *    .sheltermgr-animal-name        — animal name
 *    .sheltermgr-animal-meta        — species / breed / age / sex line
 *    .sheltermgr-no-results         — zero-match message
 *    .sheltermgr-unavailable        — API unavailable message
 *
 *  Detail overlay:
 *    .sheltermgr-overlay-open       — state class on <body> when overlay is open
 *    .sheltermgr-overlay            — overlay backdrop
 *    .sheltermgr-overlay-inner      — overlay content panel
 *    .sheltermgr-overlay-close      — close button
 *    .sheltermgr-detail-photo       — primary photo
 *    .sheltermgr-detail-gallery     — photo gallery (PLUS)
 *    .sheltermgr-detail-name        — animal name in detail view
 *    .sheltermgr-detail-meta        — species / breed / age / sex
 *    .sheltermgr-detail-description — animal description/notes
 *    .sheltermgr-detail-attributes  — icon attribute row
 *    .sheltermgr-attr-item          — single attribute icon + label
 *    .sheltermgr-attr-positive      — state: attribute is positive
 *    .sheltermgr-attr-negative      — state: attribute is negative
 *    .sheltermgr-attr-unknown       — state: attribute is unknown
 *    .sheltermgr-bonded-label       — bonded pair/group/litter badge
 *    .sheltermgr-days-on-shelter    — days on shelter display
 *    .sheltermgr-cta                — call to action button
 *
 * Data attributes:
 *    data-animal-id                 — on .sheltermgr-animal-card
 *
 * @package ShelterSync
 * @since   0.2.0
 */

/* ── Scoped CSS reset (SM-TMP-001) ─────────────────────────────────────────
   Defends against aggressive theme resets bleeding in.
   Targets only elements within .sheltermgr-container.           */

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

.sheltermgr-container {
	/* Establish a clean stacking context */
	position: relative;
	/* Reset font to a known baseline — theme will still show through
	   for unset properties, but box model is normalised */
	font-size: 1rem;
	line-height: 1.5;
}

.sheltermgr-container img {
	max-width: 100%;
	height: auto;
	display: block;
}

.sheltermgr-container button {
	cursor: pointer;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.sheltermgr-listing {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */

/* ── Filter trigger button ───────────────────────────────────────────────── */

.sheltermgr-filter-trigger-wrap {
	display: flex;
	align-items: center;
}

.sheltermgr-filter-trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.45rem 1rem;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	background: #fff;
	color: var(--sheltermgr-text, #333);
	font-size: 0.875rem;
	line-height: 1.4;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.sheltermgr-filter-trigger:hover {
	background: #f5f5f5;
	border-color: #999;
}

.sheltermgr-filter-trigger-icon {
	font-size: 1rem;
}

.sheltermgr-filter-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.25rem;
	height: 1.25rem;
	padding: 0 0.3rem;
	border-radius: 99px;
	background: var(--sheltermgr-primary, #1a73e8);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1;
}

/* ── Filter overlay popup ────────────────────────────────────────────────── */

.sheltermgr-filter-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: rgba(0,0,0,0.45);
}

.sheltermgr-filter-overlay--open {
	display: flex;
	align-items: flex-start;
	justify-content: flex-end;
}

.sheltermgr-filter-overlay-inner {
	display: flex;
	flex-direction: column;
	width: 320px;
	max-width: 92vw;
	height: 100vh;
	background: #fff;
	box-shadow: -4px 0 24px rgba(0,0,0,0.18);
	overflow: hidden;
}

/* Offset below WordPress admin bar when present */
body.admin-bar .sheltermgr-filter-overlay-inner {
	height: calc( 100vh - 32px );
	margin-top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar .sheltermgr-filter-overlay-inner {
		height: calc( 100vh - 46px );
		margin-top: 46px;
	}
}

.sheltermgr-filter-overlay-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.75rem 1.25rem;
	border-bottom: 1px solid #e0e0e0;
	flex-shrink: 0;
	flex-wrap: wrap;
}

.sheltermgr-filter-overlay-title {
	font-weight: 700;
	font-size: 1rem;
	flex-shrink: 0;
}

.sheltermgr-filter-overlay-header-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex: 1;
	justify-content: flex-end;
}

.sheltermgr-filter-overlay-close {
	background: none;
	border: none;
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	color: #555;
	padding: 0.2rem 0.4rem;
	flex-shrink: 0;
}

.sheltermgr-filter-overlay-close:hover {
	color: #000;
}

.sheltermgr-filter-show-all {
	font-size: 0.8rem;
	padding: 0.3rem 0.65rem;
	border: 1px solid var(--sheltermgr-primary, #1a73e8);
	border-radius: 4px;
	background: var(--sheltermgr-primary, #1a73e8);
	color: #fff;
	cursor: pointer;
	white-space: nowrap;
	transition: filter 0.15s;
}

.sheltermgr-filter-show-all:hover {
	filter: brightness(0.88);
}

/* Filter bar content inside overlay — stacks vertically, scrollable */
.sheltermgr-filter-overlay .sheltermgr-filter-bar {
	flex: 1;
	overflow-y: auto;
	padding: 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	background: #fff;
	border: none;
	border-radius: 0;
}

.sheltermgr-filter-group {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.sheltermgr-filter-label {
	font-weight: 600;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #444;
	margin: 0;
}

/* Label wraps checkbox + text — must stay flex and never wrap */
.sheltermgr-filter-option {
	display: flex !important;
	align-items: center;
	flex-wrap: nowrap;
	gap: 0.4rem;
	font-size: 0.9rem;
	color: #333;
	cursor: pointer;
}

/* Checkbox must stay inline — defend against theme display:block resets */
.sheltermgr-filter-option input[type="checkbox"] {
	display: inline-block !important;
	flex-shrink: 0;
	width: auto !important;
	height: auto !important;
	margin: 0;
	padding: 0;
	cursor: pointer;
	accent-color: #1a73e8;
	vertical-align: middle;
	float: none !important;
}

.sheltermgr-filter-controls {
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	margin-top: auto;
}

.sheltermgr-filter-clear {
	font-size: 0.8rem;
	padding: 0.25rem 0.6rem;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	color: #555;
	transition: background 0.15s, border-color 0.15s;
}

.sheltermgr-filter-clear:hover {
	background: #f0f0f0;
	border-color: #999;
}

.sheltermgr-filter-clear-all {
	font-size: 0.8rem;
	padding: 0.3rem 0.65rem;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	color: #555;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s;
}

.sheltermgr-filter-clear-all:hover {
	background: #f0f0f0;
}

.sheltermgr-filter-done {
	padding: 0.3rem 0.65rem;
	border: none;
	border-radius: 4px;
	background: #888;
	color: #fff;
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s;
}

.sheltermgr-filter-done:hover {
	background: #666;
}

.sheltermgr-filter-active .sheltermgr-filter-label::after {
	content: " \2022";
	color: #1a73e8;
}

.sheltermgr-filter-active .sheltermgr-filter-label {
	color: #1a73e8;
}

/* ── CSS custom properties — defaults (overridden by SM-TMP-007 PLUS config) ─ */

.sheltermgr-container {
	--sheltermgr-primary:        #1a73e8;
	--sheltermgr-secondary:      #f0f4ff;
	--sheltermgr-text:           #333333;
	--sheltermgr-heading:        #111111;
	--sheltermgr-border:         #e0e0e0;
	--sheltermgr-badge-positive: #1E7A4D;
	--sheltermgr-badge-negative: #B32D2E;
	--sheltermgr-badge-unknown:  #888888;
	--sheltermgr-body-font:      inherit;
	--sheltermgr-heading-font:   inherit;
	--sheltermgr-radius:         6px;
	--sheltermgr-columns:        3;
	--sheltermgr-shadow:         none;
}

/* ── Animal grid ────────────────────────────────────────────────────────── */

.sheltermgr-grid {
	display: grid;
	grid-template-columns: repeat( var(--sheltermgr-columns, 3), 1fr );
	gap: 1.25rem;
}

/* Responsive: collapse to fewer columns on smaller screens */
@media ( max-width: 480px ) {
	.sheltermgr-grid { grid-template-columns: 1fr; }
}

@media ( min-width: 481px ) and ( max-width: 767px ) {
	.sheltermgr-grid {
		grid-template-columns: repeat( min( var(--sheltermgr-columns, 3), 2 ), 1fr );
	}
}

@media ( min-width: 768px ) and ( max-width: 1024px ) {
	.sheltermgr-grid {
		grid-template-columns: repeat( min( var(--sheltermgr-columns, 3), 3 ), 1fr );
	}
}

/* ── Animal card ────────────────────────────────────────────────────────── */

.sheltermgr-animal-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--sheltermgr-border, #e0e0e0);
	border-radius: var(--sheltermgr-radius, 6px);
	overflow: hidden;
	background: #fff;
	cursor: pointer;
	transition: box-shadow 0.2s, transform 0.15s;
	text-decoration: none;
	color: inherit;
	box-shadow: var(--sheltermgr-shadow, none);
}

.sheltermgr-animal-card:hover {
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.12 );
	transform: translateY( -2px );
}

.sheltermgr-animal-photo {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	background: #f0f0f0;
}

.sheltermgr-animal-card-body {
	padding: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	flex: 1;
	font-family: var(--sheltermgr-body-font, inherit);
	color: var(--sheltermgr-text, #333);
}

.sheltermgr-animal-name {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.35rem;
	flex-wrap: wrap;
	font-size: 1.05rem;
	font-weight: 600;
	margin: 0;
	color: var(--sheltermgr-heading, #111);
	font-family: var(--sheltermgr-heading-font, inherit);
}

/* Name text occupies available space; badge stays right-aligned. */
.sheltermgr-animal-name__text {
	flex: 1 1 auto;
	min-width: 0;
}

/* ── Bonded badge (SM-LST-009) ───────────────────────────────────────────── */

.sheltermgr-bonded-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	flex-shrink: 0;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--sheltermgr-primary, #1a73e8);
	border: 1px solid currentColor;
	border-radius: var(--sheltermgr-radius, 4px);
	padding: 0.15rem 0.45rem 0.15rem 0.3rem;
	line-height: 1.3;
	white-space: nowrap;
}

.sheltermgr-bonded-badge .dashicons {
	font-size: 0.85rem;
	width: 0.85rem;
	height: 0.85rem;
	flex-shrink: 0;
}

.sheltermgr-animal-meta {
	font-size: 0.85rem;
	color: var(--sheltermgr-text, #666);
	margin: 0;
	line-height: 1.5;
}

/* Each field on its own line — prevents awkward mid-value line breaks.
   display:block with !important defends against aggressive theme resets. */
.sheltermgr-animal-meta .sheltermgr-meta-species,
.sheltermgr-animal-meta .sheltermgr-meta-breed,
.sheltermgr-animal-meta .sheltermgr-meta-age,
.sheltermgr-animal-meta .sheltermgr-meta-sex {
	display: block !important;
	line-height: 1.4;
}

.sheltermgr-meta-species {
	font-weight: 500;
	color: #444;
}

.sheltermgr-meta-label {
	font-weight: 600;
	color: #666;
	font-size: 0.8em;
}

/* ── No results / unavailable ───────────────────────────────────────────── */

.sheltermgr-no-results,
.sheltermgr-unavailable {
	padding: 2rem 1rem;
	text-align: center;
	color: #666;
	font-size: 1rem;
	border: 1px dashed #ccc;
	border-radius: 6px;
	background: #fafafa;
}

/* ── Detail overlay ─────────────────────────────────────────────────────── */

.sheltermgr-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba( 0, 0, 0, 0.55 );
	z-index: 99998;
	overflow-y: auto;
	padding: 2rem 1rem;
}

.sheltermgr-overlay.sheltermgr-overlay-visible {
	display: flex;
	align-items: flex-start;
	justify-content: center;
}

/* Prevent body scroll when overlay is open */
body.sheltermgr-overlay-open {
	overflow: hidden;
}

.sheltermgr-overlay-inner {
	position: relative;
	background: #fff;
	border-radius: var(--sheltermgr-radius, 6px);
	border: 1px solid var(--sheltermgr-border, #e0e0e0);
	width: 100%;
	max-width: 680px;
	overflow: hidden;
	margin: auto;
}

.sheltermgr-overlay-close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	width: 2rem;
	height: 2rem;
	background: rgba( 0, 0, 0, 0.5 );
	border: none;
	border-radius: 50%;
	color: #fff;
	font-size: 1.2rem;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1;
	transition: background 0.15s;
}

.sheltermgr-overlay-close:hover {
	background: rgba( 0, 0, 0, 0.75 );
}

.sheltermgr-detail-photo {
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	background: #f0f0f0;
	display: block;
}

.sheltermgr-detail-body {
	padding: 1.25rem 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.sheltermgr-detail-name {
	font-size: 1.5rem;
	font-weight: 700;
	margin: 0;
	color: var(--sheltermgr-heading, #111);
	font-family: var(--sheltermgr-heading-font, inherit);
}

.sheltermgr-detail-meta {
	font-size: 0.95rem;
	color: var(--sheltermgr-text, #555);
	margin: 0;
}

.sheltermgr-detail-description {
	font-size: 0.95rem;
	color: #333;
	line-height: 1.65;
	white-space: pre-line;
	margin: 0;
}

/* ── Key attributes (SM-DTL-005) ────────────────────────────────────────── */

.sheltermgr-detail-attributes {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.25rem;
	padding: 1rem;
	background: #ffffff !important;
	border-radius: 6px;
}

/* ── Icon wrapper and state badge (SM-TMP-008a) ──────────────────────────── */

.sheltermgr-icon-wrap {
	position: relative;
	display: inline-block;
	width: 48px;
	height: 48px;
}

.sheltermgr-attr-icon {
	width: 48px;
	height: 48px;
	display: block;
	background: transparent !important;
	box-shadow: none !important;
	border: none !important;
}

/* State badge — positioned bottom-right at ~33% of icon size */
.sheltermgr-badge {
	position: absolute;
	bottom: -3px;
	right: -3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	border: 2px solid #fff;
}

.sheltermgr-badge::before {
	display: block;
}

.sheltermgr-badge--positive {
	background: var(--sheltermgr-badge-positive, #1E7A4D);
	color: #fff;
}
.sheltermgr-badge--positive::before { content: '\2713'; }

.sheltermgr-badge--negative {
	background: var(--sheltermgr-badge-negative, #B32D2E);
	color: #fff;
}
.sheltermgr-badge--negative::before { content: '\2715'; }

.sheltermgr-badge--unknown {
	background: var(--sheltermgr-badge-unknown, #888888);
	color: #fff;
}
.sheltermgr-badge--unknown::before { content: '?'; }

/* Screen-reader-only state text (NFR-05-04) */
.sheltermgr-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	border: 0;
}

.sheltermgr-attr-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35rem;
	min-width: 64px;
}

.sheltermgr-attr-label {
	font-size: 0.75rem;
	text-align: center;
	color: var(--sheltermgr-text, #444);
	line-height: 1.2;
}

/* State modifier — opacity on unknown, label colour hints */
.sheltermgr-attr-unknown  .sheltermgr-icon-wrap { opacity: 0.6; }

.sheltermgr-attr-positive .sheltermgr-attr-label { color: #1a6e1c; }
.sheltermgr-attr-negative .sheltermgr-attr-label { color: #a01a1a; }
.sheltermgr-attr-unknown  .sheltermgr-attr-label { color: #777;    }

/* ── Bonded badge ────────────────────────────────────────────────────────── */

.sheltermgr-bonded-label {
	display: inline-block;
	padding: 0.3rem 0.75rem;
	background: var(--sheltermgr-secondary, #fff3cd);
	border: 1px solid var(--sheltermgr-border, #ffc107);
	border-radius: 20px;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--sheltermgr-text, #7a5800);
}

/* ── Days on shelter ─────────────────────────────────────────────────────── */

.sheltermgr-days-on-shelter {
	font-size: 0.875rem;
	color: #666;
}

/* ── Call to action ─────────────────────────────────────────────────────── */

.sheltermgr-container .sheltermgr-cta,
.sheltermgr-container a.sheltermgr-cta {
	display: inline-block;
	padding: 0.7rem 1.5rem;
	background: var(--sheltermgr-primary, #1a73e8) !important;
	color: #fff !important;
	border: none;
	border-radius: var(--sheltermgr-radius, 6px);
	font-size: 1rem;
	font-weight: 600;
	text-decoration: none !important;
	text-align: center;
	cursor: pointer;
	transition: background 0.2s;
	align-self: flex-start;
}

.sheltermgr-container .sheltermgr-cta:hover,
.sheltermgr-container a.sheltermgr-cta:hover {
	filter: brightness(0.88);
	color: #fff !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media ( max-width: 600px ) {
	.sheltermgr-grid {
		grid-template-columns: repeat( auto-fill, minmax( 160px, 1fr ) );
		gap: 0.75rem;
	}

	.sheltermgr-filter-bar {
		flex-direction: column;
		gap: 0.75rem;
	}

	.sheltermgr-overlay {
		padding: 0;
	}

	.sheltermgr-overlay-inner {
		border-radius: 0;
		min-height: 100vh;
	}

	.sheltermgr-detail-attributes {
		gap: 0.5rem 0.75rem;
	}

	.sheltermgr-attr-item {
		min-width: 52px;
	}

	.sheltermgr-attr-icon {
		width: 40px;
		height: 40px;
	}
}

@media ( min-width: 601px ) and ( max-width: 900px ) {
	.sheltermgr-grid {
		grid-template-columns: repeat( auto-fill, minmax( 190px, 1fr ) );
	}
}

/* ── Overlay ──────────────────────────────────────────────────────────────── */

.sheltermgr-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(0, 0, 0, 0.72);
	overflow-y: auto;
	padding: 2rem 1rem;
	box-sizing: border-box;
}

.sheltermgr-overlay.sheltermgr-overlay-visible {
	display: flex;
	align-items: flex-start;
	justify-content: center;
}

body.sheltermgr-overlay-open {
	overflow: hidden;
}

.sheltermgr-overlay-inner {
	position: relative;
	background: #fff;
	border-radius: 8px;
	width: 100%;
	max-width: 720px;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
	overflow: hidden;
}

.sheltermgr-overlay-close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	z-index: 2;
	width: 2rem;
	height: 2rem;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
}

.sheltermgr-overlay-close:hover,
.sheltermgr-overlay-close:focus {
	background: rgba(0, 0, 0, 0.8);
	outline: 2px solid #fff;
}

.sheltermgr-overlay-content {
	display: block;
}

/* ── Detail layout: sticky photo left, scrollable content right ─────────── */

.sheltermgr-detail-layout {
	display: flex;
	align-items: flex-start;
	min-height: 0;
}

.sheltermgr-detail-photo-col {
	position: sticky;
	top: 0;
	flex: 0 0 45%;
	max-width: 45%;
	align-self: flex-start;
}

.sheltermgr-detail-photo {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 280px;
	max-height: calc(100dvh - 4rem);
	object-fit: cover;
}

.sheltermgr-detail-scroll {
	flex: 1 1 0;
	overflow-y: auto;
	max-height: calc(100dvh - 4rem);
}

/* ── Detail body ──────────────────────────────────────────────────────────── */

.sheltermgr-detail-body {
	padding: 1.25rem 1.5rem 1.5rem;
}

/* ── Gallery at bottom — collage layout ──────────────────────────────────── */

.sheltermgr-detail-gallery {
	columns: 3 120px;
	column-gap: 0.35rem;
	padding: 0 1rem 1.25rem;
	background: #fff;
}

.sheltermgr-gallery-thumb {
	display: block;
	width: 100%;
	height: auto;
	margin-bottom: 0.35rem;
	break-inside: avoid;
	border-radius: 4px;
	cursor: pointer;
	border: 2px solid transparent;
	transition: border-color 0.15s, opacity 0.15s;
}

.sheltermgr-gallery-thumb:hover,
.sheltermgr-gallery-thumb:focus {
	border-color: #1a73e8;
	opacity: 0.88;
	outline: none;
}

.sheltermgr-detail-name {
	font-size: 1.6rem;
	font-weight: 700;
	margin: 0 0 0.35rem;
	color: var(--sheltermgr-heading, #111);
	font-family: var(--sheltermgr-heading-font, inherit);
}

.sheltermgr-detail-meta {
	font-size: 0.95rem;
	color: #555;
	margin: 0 0 0.75rem;
}

/* ── Bonded badge ─────────────────────────────────────────────────────────── */

.sheltermgr-bonded-label {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3em;
	background: var(--sheltermgr-primary, #1a73e8);
	color: #fff;
	font-size: 0.82rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 0.3em 0.75em;
	border-radius: 3px;
	margin-bottom: 1rem;
}

.sheltermgr-bonded-link {
	background: none;
	border: 1px solid rgba(255,255,255,0.6);
	color: #fff;
	font: inherit;
	font-size: 0.9em;
	text-transform: none;
	letter-spacing: 0;
	padding: 0.1em 0.45em;
	border-radius: 2px;
	cursor: pointer;
	transition: background 0.15s;
}

.sheltermgr-bonded-link:hover,
.sheltermgr-bonded-link:focus {
	background: rgba(255,255,255,0.2);
	outline: none;
}

/* ── Attribute icons ──────────────────────────────────────────────────────── */

/* Attribute icon grid — dual-position:
   Desktop: shown in photo column below photo (.sheltermgr-attr-desktop)
   Mobile:  shown in scroll column just before gallery (.sheltermgr-attr-mobile) */

/* Desktop wrapper — visible above mobile breakpoint */
.sheltermgr-attr-desktop { display: block; }
.sheltermgr-attr-mobile  { display: none;  }

.sheltermgr-detail-attributes {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
	padding: 0.75rem;
	background: #f2f2f2;
	border-top: 1px solid #e0e0e0;
}

.sheltermgr-attr-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.3rem;
	padding: 0.4rem 0.2rem;
}

.sheltermgr-attr-icon {
	width: 52px;
	height: 52px;
	flex-shrink: 0;
}

.sheltermgr-attr-label {
	font-size: 0.75rem;
	font-weight: 500;
	color: #444;
	line-height: 1.2;
}

/* Icon colour is baked into PNG artwork — tint label text only */
.sheltermgr-attr-item.sheltermgr-attr-positive .sheltermgr-attr-label { color: #2e7d32; font-weight: 600; }
.sheltermgr-attr-item.sheltermgr-attr-negative .sheltermgr-attr-label { color: #c62828; font-weight: 600; }
.sheltermgr-attr-item.sheltermgr-attr-unknown  .sheltermgr-attr-label { color: #888; }

.sheltermgr-attr-label {
	line-height: 1.2;
}

/* ── Description & info ───────────────────────────────────────────────────── */

.sheltermgr-detail-description {
	font-size: 0.95rem;
	line-height: 1.65;
	color: #333;
	margin: 1rem 0;
}

.sheltermgr-days-on-shelter,
.sheltermgr-entry-reason {
	font-size: 0.875rem;
	color: #555;
	margin: 0.4rem 0;
}

/* Generic PLUS overlay field (date fields, codes, weight, etc.) */
.sheltermgr-detail-field {
	font-size: 0.875rem;
	color: var(--sheltermgr-text, #555);
	margin: 0.25rem 0;
}

/* ── CTA button ───────────────────────────────────────────────────────────── */

.sheltermgr-cta {
	display: inline-block;
	margin-top: 1.25rem;
	padding: 0.75em 1.75em;
	background: #1a73e8;
	color: #fff !important;
	font-size: 1rem;
	font-weight: 600;
	text-decoration: none;
	border-radius: 5px;
	transition: background 0.2s;
}

.sheltermgr-cta:hover,
.sheltermgr-cta:focus {
	background: #1557b0;
	outline: 2px solid #1a73e8;
	outline-offset: 2px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.sheltermgr-overlay {
		padding: 0;
		align-items: flex-end;
	}

	.sheltermgr-overlay-inner {
		border-radius: 12px 12px 0 0;
		max-width: 100%;
		max-height: 92dvh;
		overflow-y: auto;
	}

	/* Close button fixed so it stays visible while scrolling on mobile */
	.sheltermgr-overlay-visible .sheltermgr-overlay-close {
		position: fixed;
		top: 0.6rem;
		right: 0.6rem;
		z-index: 100001;
	}

	/* Stack photo above content on mobile */
	.sheltermgr-detail-layout {
		flex-direction: column;
	}

	.sheltermgr-detail-photo-col {
		/* Sticky at top — icons inside photo-col scroll with it then stick */
		position: sticky;
		top: 0;
		z-index: 1;
		flex: none;
		max-width: 100%;
		width: 100%;
	}

	.sheltermgr-detail-photo {
		min-height: unset;
		max-height: 200px;
	}

	/* Swap icon positions on mobile */
	.sheltermgr-attr-desktop { display: none;  }
	.sheltermgr-attr-mobile  { display: block; }

	.sheltermgr-detail-attributes {
		/* 3-col grid makes better use of full mobile width */
		grid-template-columns: repeat(3, 1fr);
		border-top: none;
		border-bottom: 1px solid #e0e0e0;
		margin-bottom: 0.5rem;
	}

	.sheltermgr-attr-icon {
		width: 44px;
		height: 44px;
	}

	.sheltermgr-detail-scroll {
		max-height: unset;
		overflow-y: visible;
	}

	.sheltermgr-detail-body {
		padding: 1rem;
	}

	.sheltermgr-detail-name {
		font-size: 1.3rem;
	}

	.sheltermgr-detail-gallery {
		columns: 3 80px;
		padding: 0 0.75rem 1rem;
	}
}

/* ── Attribution footer (SM-TMP-009) ─────────────────────────────────────── */

.sheltermgr-attribution-footer {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem 0;
	margin-top: 1rem;
	border-top: 1px solid var(--sheltermgr-border, #e0e0e0);
}

.sheltermgr-attribution-footer--overlay {
	padding: 0.5rem 1rem;
	margin-top: 0;
	border-top: 1px solid var(--sheltermgr-border, #e0e0e0);
	justify-content: flex-start;
}

.sheltermgr-attribution-text {
	font-size: 0.75rem;
	color: #888;
}

.sheltermgr-attribution-link {
	display: inline-flex;
	align-items: center;
	text-decoration: none !important;
}

.sheltermgr-attribution-logo {
	width: 200px;
	height: 40px;
	display: block;
	object-fit: contain;
}

/* ── Sort control (SM-LST-005) ──────────────────────────────────────────── */

.sheltermgr-sort-bar {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.sheltermgr-sort-select {
	font-size: 0.875rem;
	line-height: 1.4;
	padding: 0.45rem 0.6rem;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	background: #fff;
	color: var(--sheltermgr-text, #333);
	cursor: pointer;
}

.sheltermgr-sort-dir {
	background: #fff;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	padding: 0.45rem 0.65rem;
	font-size: 1rem;
	line-height: 1.4;
	cursor: pointer;
	color: var(--sheltermgr-text, #333);
	transition: background 0.15s, border-color 0.15s;
}

.sheltermgr-sort-dir:hover,
.sheltermgr-sort-dir:focus {
	background: #f0f0f0;
	border-color: #999;
	outline: 2px solid var(--sheltermgr-primary, #1a73e8);
	outline-offset: 1px;
}

/* ── Custom fields in overlay (SM-FLD-001) ───────────────────────────────── */

.sheltermgr-custom-field {
	font-size: 0.9rem;
	margin: 0.35rem 0;
	color: #333;
	line-height: 1.4;
}

.sheltermgr-custom-field-label {
	font-weight: 600;
	color: #555;
}

/* ── Section dividers in overlay (Sprint 9) ─────────────────────────────── */

.sheltermgr-section-divider {
	margin: 1rem 0 0.5rem;
	padding-bottom: 0.25rem;
	border-bottom: 2px solid var(--sheltermgr-border, #e0e0e0);
}

.sheltermgr-section-divider-label {
	display: block;
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--sheltermgr-heading, #555);
	font-family: var(--sheltermgr-heading-font, inherit);
}

/* ── Controls bar — search (left) | sort + filter (right) ──────────────── */

.sheltermgr-controls-bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.sheltermgr-search-wrap {
	display: flex;
	align-items: center;
	position: relative;
	flex: 1 1 180px;
	min-width: 140px;
	max-width: 360px;
}

/* Suppress native browser search clear button (issue 4) */
.sheltermgr-search-input::-webkit-search-cancel-button,
.sheltermgr-search-input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

/* Scoped under container so CSS vars resolve correctly (issue 2) */
.sheltermgr-container .sheltermgr-search-input {
	width: 100%;
	padding: 0.5rem 2rem 0.5rem 0.75rem;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	font-size: 0.875rem;
	line-height: 1.4;
	box-sizing: border-box;
	background: #fff;
	color: inherit;
	-webkit-appearance: none;
	appearance: none;
}

.sheltermgr-container .sheltermgr-search-input:focus {
	border-color: var(--sheltermgr-primary, #1a73e8);
	outline: 2px solid transparent;
	box-shadow: 0 0 0 2px rgba(var(--sheltermgr-primary-rgb, 26,115,232), 0.25);
}

.sheltermgr-search-clear {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	cursor: pointer;
	font-size: 1.1rem;
	line-height: 1;
	color: #72777c;
	padding: 4px;
	border-radius: 50%;
	z-index: 1;
}

.sheltermgr-search-clear:hover {
	color: #1d2327;
	background: rgba(0,0,0,0.07);
}

/* Right-side group: sort bar then filter trigger */
.sheltermgr-controls-right {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-left: auto;
	flex-shrink: 0;
}

/* ── Pagination + per-page wrap ──────────────────────────────────────────── */

.sheltermgr-pagination-wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 1.25rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--sheltermgr-border, #ccc);
}

.sheltermgr-per-page-wrap {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.875rem;
	flex-shrink: 0;
}

.sheltermgr-per-page-label {
	color: #50575e;
	white-space: nowrap;
}

.sheltermgr-container .sheltermgr-per-page-selector {
	padding: 4px 8px;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	font-size: 0.875rem;
	background: #fff;
	color: inherit;
	cursor: pointer;
}

.sheltermgr-pagination {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	flex-wrap: wrap;
	gap: 4px;
}

.sheltermgr-container .sheltermgr-page-btn {
	min-width: 34px;
	height: 34px;
	padding: 0 10px;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	background: #fff;
	color: inherit;
	font-size: 0.875rem;
	cursor: pointer;
	line-height: 1;
}

.sheltermgr-container .sheltermgr-page-btn:hover:not(:disabled) {
	border-color: var(--sheltermgr-primary, #1a73e8);
	color: var(--sheltermgr-primary, #1a73e8);
}

.sheltermgr-container .sheltermgr-page-btn.sheltermgr-page-current {
	background: var(--sheltermgr-primary, #1a73e8);
	border-color: var(--sheltermgr-primary, #1a73e8);
	color: #fff;
	font-weight: 600;
	cursor: default;
}

.sheltermgr-page-ellipsis {
	min-width: 24px;
	text-align: center;
	color: #72777c;
	font-size: 0.875rem;
	line-height: 34px;
}

/* ── LFS type badge (SM-LFS-001a) ───────────────────────────────────────── */

.sheltermgr-animal-type-badge {
	display: inline-block;
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	padding: 2px 8px;
	border-radius: 3px;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #fff;
	background: var(--sheltermgr-primary, #1a73e8);
	z-index: 1;
	pointer-events: none;
}

.sheltermgr-animal-type-badge--lost  { background: #b32d2e; }
.sheltermgr-animal-type-badge--found { background: #1a7a3f; }
.sheltermgr-animal-type-badge--stray { background: #7a5c00; }

/* Reserved badge — top-right photo overlay (SM-LST-010) */
.sheltermgr-reserved-badge {
	display: inline-block;
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	padding: 2px 8px;
	border-radius: 3px;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #fff;
	background: var(--sheltermgr-reserved-badge-bg, #1a7a3f);
	z-index: 1;
	pointer-events: none;
}

/* Reserved notice — replaces CTA in overlay when hide_reserved is enabled (SM-LST-014, PLUS) */
.sheltermgr-reserved-notice {
	display: block;
	width: 100%;
	padding: 10px 16px;
	border-radius: var(--sheltermgr-radius, 6px);
	background: var(--sheltermgr-reserved-badge-bg, #1a7a3f);
	color: #fff;
	font-size: 0.9rem;
	font-weight: 600;
	text-align: center;
	letter-spacing: 0.02em;
	box-sizing: border-box;
}
.sheltermgr-animal-card {
	position: relative;
}

/* ── Video embed (SM-DTL-012) ────────────────────────────────────────────── */

.sheltermgr-video-wrap {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%; /* 16:9 */
	height: 0;
	margin: 1rem 0;
	border-radius: var(--sheltermgr-radius, 6px);
	overflow: hidden;
}

.sheltermgr-video-embed {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* ── Merged bonded profile overlay (SM-DTL-011) ──────────────────────────── */

.sheltermgr-merged-scroll {
	overflow-y: auto;
	max-height: calc(100dvh - 4rem);
	padding: 0;
}

/* Each animal panel inside merged overlay —
   override detail-scroll so it doesn't cap height and cut off the second animal */
.sheltermgr-merged-scroll .sheltermgr-detail-scroll {
	max-height: none;
	overflow-y: visible;
}

/* Also allow the layout to flow vertically inside each panel */
.sheltermgr-merged-scroll .sheltermgr-detail-layout {
	flex-wrap: wrap;
}

/* ── Merged banner: label left, CTA right (SM-DTL-014) ─────────────────── */

.sheltermgr-merged-banner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0 0 1rem;
	padding: 0.5rem 0.75rem;
	border: 2px solid var(--sheltermgr-primary, #1a73e8);
	border-radius: var(--sheltermgr-radius, 6px);
}

.sheltermgr-merged-banner__label {
	font-weight: 700;
	font-size: 1rem;
	color: var(--sheltermgr-primary, #1a73e8);
	flex: 1 1 auto;
}

/* Banner CTA modifier — same appearance as base CTA by default;
   PLUS CSS config can target .sheltermgr-cta--banner independently. */
.sheltermgr-merged-banner .sheltermgr-cta--banner {
	flex-shrink: 0;
}

.sheltermgr-merged-columns {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.sheltermgr-merged-animal {
	border: 1px solid var(--sheltermgr-border, #e0e0e0);
	border-radius: var(--sheltermgr-radius, 6px);
	padding: 1rem;
	margin-bottom: 1rem;
}

.sheltermgr-merged-name {
	font-size: 1.1rem;
	font-weight: 700;
	margin: 0 0 0.75rem;
	color: var(--sheltermgr-heading, #111);
}

/* Panel-mode photo: full width above content */
.sheltermgr-panel-photo {
	display: block;
	width: 100%;
	max-height: 260px;
	object-fit: cover;
	border-radius: var(--sheltermgr-radius, 6px);
	margin-bottom: 0.75rem;
}

.sheltermgr-merged-photo {
	display: block;
	width: 100%;
	max-height: 240px;
	object-fit: cover;
	border-radius: var(--sheltermgr-radius, 6px);
	margin-bottom: 0.75rem;
}

.sheltermgr-merged-cta {
	text-align: center;
	padding: 1rem 0 0.5rem;
}

.sheltermgr-merged-unavailable {
	color: #8a2424;
	font-style: italic;
	margin-bottom: 1rem;
}

/* ── LFS date range filter (SM-LFS-003g/h) ─────────────────────────────── */
.sheltermgr-date-filter-bar {
	border-top: 1px solid var(--sheltermgr-border, #ddd);
	padding-top: 0.75rem;
	margin-top: 0.5rem;
}

.sheltermgr-date-filter-group {
	margin-bottom: 1rem;
}

.sheltermgr-date-range-inputs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.35rem;
}

.sheltermgr-date-label {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.875rem;
	color: var(--sheltermgr-text, #555);
}

.sheltermgr-date-label input[type="date"] {
	padding: 0.3rem 0.5rem;
	border: 1px solid var(--sheltermgr-border, #ddd);
	border-radius: var(--sheltermgr-radius, 4px);
	font-size: 0.875rem;
	color: var(--sheltermgr-text, #333);
	background: #fff;
}

.sheltermgr-date-clear {
	font-size: 0.8rem;
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--sheltermgr-border, #ccc);
	border-radius: var(--sheltermgr-radius, 4px);
	background: transparent;
	cursor: pointer;
	color: var(--sheltermgr-text, #555);
}

.sheltermgr-date-clear:hover {
	background: var(--sheltermgr-border, #eee);
}

.sheltermgr-meta-date-reported,
.sheltermgr-meta-date-lost,
.sheltermgr-meta-date-found,
.sheltermgr-meta-area-postcode {
	display: block;
	font-size: 0.875rem;
	color: var(--sheltermgr-text, #555);
}
