/* ==========================================================================
   Listing single page — improvements over global style.css base
   Loaded only on single km_listing pages.
   ========================================================================== */

/* ── Page layout ──────────────────────────────────────────────────────────── */

.km-listing-single {
	padding-bottom: 5rem; /* space for mobile sticky bar */
}

.km-listing-single__layout {
	gap: 1.5rem;
	padding-block: 1.5rem 3rem;
}

.km-listing-main,
.km-listing-sidebar {
	gap: 1.25rem;
}

/* ── Gallery ──────────────────────────────────────────────────────────────── */

.km-listing-gallery {
	border-radius: var(--km-radius-xl);
	overflow: hidden;
	background: var(--km-neutral-900);
}

/* Main image area */
.km-listing-gallery__main {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--km-neutral-900);
}

.km-listing-gallery__cover {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	cursor: zoom-in;
	transition: opacity 260ms ease;
}

.km-listing-gallery__cover.is-transitioning {
	opacity: 0;
}

.km-listing-gallery__placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	background: linear-gradient(135deg, rgba(241, 87, 34, 0.16), rgba(25, 28, 29, 0.08));
	color: var(--km-primary);
	font-size: 2.5rem;
}

/* Prev / Next navigation arrows */
.km-gallery-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 4;
	display: grid;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	border: 0;
	border-radius: 50%;
	background: rgba(25, 28, 29, 0.55);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color: var(--km-neutral-0);
	font-size: 1.5rem;
	cursor: pointer;
	opacity: 0;
	transition: opacity 200ms ease, background 160ms ease, transform 160ms ease;
}

.km-gallery-nav--prev { left: 0.75rem; }
.km-gallery-nav--next { right: 0.75rem; }

.km-listing-gallery__main:hover .km-gallery-nav {
	opacity: 1;
}

.km-gallery-nav:hover {
	background: rgba(25, 28, 29, 0.82);
	transform: translateY(-50%) scale(1.08);
}

.km-gallery-nav:focus-visible {
	opacity: 1;
	outline: 3px solid rgba(241, 87, 34, 0.5);
	outline-offset: 2px;
}

/* Counter badge — bottom-left */
.km-gallery-counter {
	position: absolute;
	bottom: 0.75rem;
	left: 0.75rem;
	z-index: 4;
	padding: 0.25rem 0.65rem;
	border-radius: var(--km-radius-pill);
	background: rgba(25, 28, 29, 0.6);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color: var(--km-neutral-0);
	font-size: 0.8rem;
	font-weight: 700;
	pointer-events: none;
}

/* Fullscreen expand — bottom-right */
.km-gallery-expand {
	position: absolute;
	bottom: 0.75rem;
	right: 0.75rem;
	z-index: 4;
	display: grid;
	place-items: center;
	width: 2.1rem;
	height: 2.1rem;
	border: 0;
	border-radius: var(--km-radius);
	background: rgba(25, 28, 29, 0.6);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color: var(--km-neutral-0);
	font-size: 1.05rem;
	cursor: pointer;
	opacity: 0;
	transition: opacity 200ms ease, background 160ms ease;
}

.km-listing-gallery__main:hover .km-gallery-expand {
	opacity: 1;
}

.km-gallery-expand:hover {
	background: rgba(25, 28, 29, 0.9);
}

.km-gallery-expand:focus-visible {
	opacity: 1;
	outline: 3px solid rgba(241, 87, 34, 0.5);
}

/* Thumbnail strip */
.km-listing-gallery__thumbs {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.4rem;
	padding: 0.55rem;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	background: rgba(25, 28, 29, 0.08);
}

.km-listing-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

/* Thumbnail buttons */
.km-gallery-thumb {
	flex: 0 0 auto;
	width: 5.25rem;
	height: 3.75rem;
	padding: 0;
	border: 2px solid transparent;
	border-radius: var(--km-radius);
	overflow: hidden;
	background: var(--km-neutral-200);
	cursor: pointer;
	opacity: 0.72;
	transition: opacity 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.km-gallery-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

.km-gallery-thumb:hover {
	opacity: 1;
	transform: scale(1.04);
}

.km-gallery-thumb:focus-visible {
	opacity: 1;
	outline: 3px solid rgba(241, 87, 34, 0.5);
	outline-offset: 2px;
}

.km-gallery-thumb.is-active {
	opacity: 1;
	border-color: var(--km-primary);
	transform: none;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.km-lightbox {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.km-lightbox[hidden] {
	display: none;
}

.km-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 20, 25, 0.94);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	cursor: zoom-out;
}

.km-lightbox__content {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	height: 100%;
	max-width: min(92vw, 1400px);
	max-height: 100vh;
	padding: 3.5rem 0 3rem;
}

.km-lightbox__viewport {
	position: relative;
	flex: 1;
	min-height: 0;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.km-lightbox__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: var(--km-radius);
	user-select: none;
	transition: opacity 220ms ease;
}

.km-lightbox__img.is-loading {
	opacity: 0.3;
}

/* Close button — top-right */
.km-lightbox__close {
	position: fixed;
	top: 1rem;
	right: 1rem;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	background: rgba(25, 28, 29, 0.7);
	color: var(--km-neutral-0);
	font-size: 1.4rem;
	cursor: pointer;
	transition: background 160ms ease, border-color 160ms ease;
}

.km-lightbox__close:hover {
	background: rgba(220, 38, 38, 0.75);
	border-color: rgba(220, 38, 38, 0.4);
}

/* Prev / Next in lightbox */
.km-lightbox__nav {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	display: grid;
	place-items: center;
	width: 3rem;
	height: 3rem;
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	background: rgba(25, 28, 29, 0.55);
	color: var(--km-neutral-0);
	font-size: 1.7rem;
	cursor: pointer;
	transition: background 160ms ease, transform 160ms ease;
}

.km-lightbox__nav--prev { left: 1rem; }
.km-lightbox__nav--next { right: 1rem; }

.km-lightbox__nav:hover {
	background: rgba(25, 28, 29, 0.88);
	transform: translateY(-50%) scale(1.06);
}

.km-lightbox__nav:focus-visible {
	outline: 3px solid rgba(241, 87, 34, 0.5);
	outline-offset: 2px;
}

/* Footer counter */
.km-lightbox__footer {
	position: fixed;
	bottom: 1.25rem;
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
}

.km-lightbox__counter {
	padding: 0.3rem 0.85rem;
	border-radius: var(--km-radius-pill);
	background: rgba(25, 28, 29, 0.6);
	color: var(--km-neutral-0);
	font-size: 0.82rem;
	font-weight: 700;
	white-space: nowrap;
}

/* ── Header section ───────────────────────────────────────────────────────── */

.km-listing-single__header {
	padding: 1.25rem;
	display: grid;
	gap: 0.75rem;
}

.km-listing-single__header .km-card-badges {
	margin-bottom: 0.1rem;
}

.km-listing-single__header h1 {
	margin: 0;
	font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem);
	line-height: 1.2;
}

.km-listing-single__price {
	margin: 0;
	font-size: clamp(1.45rem, 1.2rem + 0.8vw, 1.85rem);
	font-weight: 600;
}

.km-listing-single__header .km-card-meta {
	gap: 0.35rem 0.9rem;
	font-size: 0.85rem;
}

.km-listing-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.25rem;
	padding-top: 0.85rem;
	border-top: 1px solid var(--km-neutral-100);
}

.km-listing-actions .km-button {
	border-radius: var(--km-radius-pill);
	min-height: 2.5rem;
	padding-inline: 1rem;
	font-size: 0.88rem;
}

/* ── Content sections ─────────────────────────────────────────────────────── */

.km-listing-section {
	padding: 1.25rem;
}

.km-listing-section > h2 {
	margin: 0 0 1rem;
	padding-bottom: 0.65rem;
	border-bottom: 1px solid var(--km-neutral-100);
	font-size: 1rem;
	color: var(--km-neutral-700);
	font-weight: 700;
	letter-spacing: -0.01em;
}

.km-listing-details {
	gap: 0;
}

.km-listing-details div {
	padding-block: 0.65rem;
	border-bottom: 1px solid var(--km-neutral-100);
}

.km-listing-details div:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.km-listing-details dt {
	font-size: 0.88rem;
	color: var(--km-neutral-500);
}

.km-listing-details dd {
	font-size: 0.88rem;
}

/* ── Map section ──────────────────────────────────────────────────────────── */

.km-listing-map {
	padding: 1.25rem;
}

.km-listing-map > h2 {
	margin: 0 0 0.35rem;
	font-size: 1rem;
	color: var(--km-neutral-700);
	font-weight: 700;
	letter-spacing: -0.01em;
}

/* ── Seller card ──────────────────────────────────────────────────────────── */

.km-listing-seller {
	padding: 1.25rem;
	gap: 1rem;
}

.km-seller-heading {
	margin: 0 0 0.25rem;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--km-neutral-500);
}

.km-seller-profile {
	display: flex;
	align-items: center;
	gap: 0.85rem;
}

.km-seller-avatar {
	flex-shrink: 0;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	overflow: hidden;
	background: linear-gradient(135deg, rgba(241, 87, 34, 0.16), rgba(25, 28, 29, 0.06));
	border: 2px solid var(--km-neutral-100);
	color: var(--km-primary);
}

.km-seller-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.km-seller-avatar__initials {
	display: flex;
	width: 100%;
	height: 100%;
	align-items: center;
	justify-content: center;
	font-size: 1.4rem;
	font-weight: 700;
}

.km-seller-info {
	display: grid;
	gap: 0.3rem;
	min-width: 0;
}

.km-seller-name {
	display: block;
	font-size: 1rem;
	font-weight: 600;
	color: var(--km-neutral-900);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.km-seller-listed {
	display: block;
	font-size: 0.78rem;
	color: var(--km-neutral-500);
	font-weight: 600;
}

.km-seller-actions {
	display: grid;
	gap: 0.55rem;
}

.km-seller-actions .km-button {
	width: 100%;
	border-radius: var(--km-radius-pill);
	min-height: 2.75rem;
}

/* ── Sticky CTA bar — mobile only ─────────────────────────────────────────── */

.km-listing-sticky-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 15;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.75rem 1.25rem;
	padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
	background: var(--km-neutral-0);
	border-top: 1px solid var(--km-neutral-100);
	box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
}

.km-listing-sticky-bar__price {
	font-size: 1.1rem;
	font-weight: 600;
	color: var(--km-primary);
	white-space: nowrap;
}

.km-listing-sticky-bar__cta {
	flex-shrink: 0;
	border-radius: var(--km-radius-pill);
	padding-inline: 1.25rem;
}

/* ── Review section ───────────────────────────────────────────────────────── */

.km-listing-section.km-review-section > h2 {
	margin-bottom: 0.85rem;
}

/* ── Desktop layout ───────────────────────────────────────────────────────── */

@media (min-width: 60rem) {
	.km-listing-single {
		padding-bottom: 0;
	}

	.km-listing-sticky-bar {
		display: none;
	}

	.km-listing-single__layout {
		grid-template-columns: minmax(0, 1fr) 22rem;
		gap: 2rem;
	}

	.km-listing-sidebar {
		position: sticky;
		top: calc(var(--km-nav-height) + 1.25rem);
		align-self: start;
	}

	.km-listing-single__header h1 {
		font-size: 1.75rem;
	}

	.km-gallery-thumb {
		width: 6.5rem;
		height: 4.75rem;
	}
}

/* ── Listing detail map ───────────────────────────────────────────────────── */

.km-listing-map-helper {
	color: var(--km-neutral-500);
	font-size: 0.92rem;
	margin-bottom: 1rem;
}

.km-map-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.85rem;
	padding: 2.5rem 1.5rem;
	border: 1.5px dashed rgba(241, 87, 34, 0.22);
	border-radius: var(--km-radius-xl);
	background: rgba(241, 87, 34, 0.04);
	text-align: center;
	margin-bottom: 1rem;
}

.km-map-placeholder > i {
	color: var(--km-primary);
	font-size: 2.5rem;
	opacity: 0.65;
}

.km-listing-detail-map {
	width: 100%;
	height: 320px;
	border-radius: var(--km-radius-xl);
	overflow: hidden;
	margin-bottom: 1rem;
}

.km-listing-map-gmaps {
	margin-top: 0.5rem;
}

.km-map-pin {
	width: 14px !important;
	height: 14px !important;
	background: var(--km-primary);
	border: 2.5px solid #fff;
	border-radius: 50%;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (min-width: 40rem) {
	.km-listing-detail-map {
		height: 420px;
	}
}
