/*
 * Spec sheet — bordered dark "comparison card" pinned to the top of
 * /lineup/ and /build/. Outer card has a thin green outline with a
 * floating "SPEC SHEET" pill above; inner nested card holds the model
 * summary + quick stats + 4×4 spec grid + a floorplan thumbnail in the
 * upper-right; tab row below wraps to fit every rig; a native <dialog>
 * modal handles the floorplan large view.
 *
 * Brand-aligned: reuses the existing token palette, .liv-chip styles
 * for the tabs, and .liv-serif for the large quick-stat numerals.
 */

.liv-spec-sheet {
	padding-block: clamp(1rem, 2.5vw, 1.75rem);
	background: var(--liv-ink-900);
}

/* ─── Outer card ────────────────────────────────────────────────── */

.liv-spec-sheet__card {
	position: relative;
	max-width: 1080px;
	margin-inline: auto;
	background: var(--liv-ink-900);
	color: var(--liv-paper);
	border: 1px solid color-mix(in srgb, var(--liv-leaf-500) 35%, transparent);
	border-radius: var(--r-lg);
	padding: clamp(0.65rem, 1.25vw, 0.95rem);
	padding-top: clamp(0.9rem, 1.5vw, 1.1rem);
	display: grid;
	gap: clamp(0.4rem, 0.7vw, 0.6rem);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4) inset, 0 0 28px rgba(151, 196, 89, 0.05);
}

/* ─── Header strip (brand + pill + sub) ─────────────────────────── */

.liv-spec-sheet__header {
	position: relative;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 1rem;
	padding-bottom: clamp(0.3rem, 0.6vw, 0.45rem);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.liv-spec-sheet__brand {
	color: var(--liv-paper);
	display: inline-flex;
	align-items: center;
}

.liv-spec-sheet__sub {
	justify-self: end;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.625rem;
	font-weight: 600;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-ink-300);
	text-align: right;
}

/* "SPEC SHEET" pill — protrudes above the top edge of the outer card. */
.liv-spec-sheet__pill {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translate(-50%, -50%);
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	background: var(--liv-leaf-500);
	color: var(--liv-ink-900);
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	padding: 0.45rem 1rem;
	border-radius: var(--r-pill);
	box-shadow: 0 0 0 4px var(--liv-ink-900);
}
.liv-spec-sheet__pill-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--liv-ink-900);
}

/* ─── Inner card ────────────────────────────────────────────────── */

.liv-spec-sheet__inner {
	position: relative;
	background: rgba(151, 196, 89, 0.06);
	border: 1px solid color-mix(in srgb, var(--liv-leaf-700) 40%, transparent);
	border-radius: var(--r-md);
	padding: clamp(0.65rem, 1.25vw, 0.95rem);
	display: grid;
	gap: clamp(0.5rem, 0.9vw, 0.75rem);
}

/* ─── Summary row: model name (left). Quick stats sit on their own
 *      centered row below this. Right padding keeps the model name from
 *      colliding with the absolute-positioned floorplan thumbnail. */

.liv-spec-sheet__summary {
	padding-right: clamp(6.5rem, 13vw, 8.5rem);
}

/* "Build Yours Now" CTA — sits inside the model block, directly under the
 * green rule beneath "<title> / <descriptor>". Same pill geometry as the
 * active tab chip below, but with a slightly transparent green fill +
 * white text so it reads as a primary CTA rather than a tab. */
.liv-spec-sheet__build-btn {
	justify-self: start;
	margin-top: clamp(1.25rem, 3vw, 2rem);
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	height: 40px;
	padding: 0 1.5rem;
	background: color-mix(in srgb, var(--liv-leaf-500) 75%, transparent);
	color: var(--liv-ink-900);
	border: 1px solid var(--liv-leaf-500);
	border-radius: var(--r-pill);
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--liv-transition), transform var(--liv-transition), box-shadow var(--liv-transition);
}
.liv-spec-sheet__build-btn:hover,
.liv-spec-sheet__build-btn:focus-visible {
	background: var(--liv-leaf-500);
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* Ballpark price phrase, directly under the Build button. Deal-forward sales
 * cue — not a hard MSRP. Hidden via [hidden] for models with no mapped price. */
.liv-spec-sheet__price {
	margin: 0.85rem 0 0;
	max-width: 32ch;
	color: var(--liv-leaf-300);
	font-family: var(--wp--preset--font-family--serif);
	font-size: 0.9375rem;
	font-style: italic;
	line-height: 1.35;
}
.liv-spec-sheet__price[hidden] { display: none; }

.liv-spec-sheet__model {
	display: grid;
	gap: 0.25rem;
}
.liv-spec-sheet__model-label {
	margin: 0;
	font-size: 0.625rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-leaf-500);
	font-weight: 700;
}
.liv-spec-sheet__model-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--display, var(--wp--preset--font-family--accent));
	font-size: clamp(1.75rem, 4vw, 3rem);
	line-height: 1;
	color: var(--liv-paper);
	letter-spacing: -0.01em;
}
.liv-spec-sheet__model-descriptor {
	margin: 0;
	font-size: 0.75rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--liv-ink-300);
	font-weight: 500;
}
.liv-spec-sheet__model-descriptor:empty { display: none; }
.liv-spec-sheet__model-rule {
	display: block;
	width: 56px;
	height: 2px;
	background: var(--liv-leaf-500);
	margin-top: 0.35rem;
}

/* Quick stats — own centered row with thin vertical separators between cells
 * and a green leaf-500 underline spanning the row's content width. */
.liv-spec-sheet__quick {
	display: flex;
	align-items: flex-end;
	gap: 0;
	margin: 0 auto;
	padding: 0 0.4rem 0.4rem;
	width: fit-content;
	max-width: 100%;
	border-bottom: 2px solid var(--liv-leaf-500);
}
.liv-spec-sheet__quick > div {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	padding: 0 clamp(0.75rem, 1.8vw, 1.25rem);
	border-left: 1px solid rgba(255, 255, 255, 0.12);
	text-align: center;
	align-items: center;
}
.liv-spec-sheet__quick > div:first-child {
	border-left: 0;
}
.liv-spec-sheet__quick-value {
	font-size: clamp(1.25rem, 2.5vw, 1.75rem);
	color: var(--liv-paper);
	margin: 0;
	line-height: 1.05;
	font-weight: 600;
}
.liv-spec-sheet__quick-label {
	font-size: 0.625rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-ink-300);
	font-weight: 600;
}

/* ─── Floorplan thumbnail (upper-right of inner card) ───────────── */

.liv-spec-sheet__floorplan {
	position: absolute;
	top: clamp(0.75rem, 1.5vw, 1.15rem);
	right: clamp(0.75rem, 1.5vw, 1.15rem);
	width: clamp(100px, 12vw, 140px);
	margin: 0;
	display: grid;
	gap: 0.35rem;
	z-index: 1;
}
.liv-spec-sheet__floorplan[hidden] { display: none; }

.liv-spec-sheet__floorplan-caption {
	font-size: 0.625rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-ink-300);
	font-weight: 600;
	text-align: right;
}

.liv-spec-sheet__floorplan-link {
	position: relative;
	display: block;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid color-mix(in srgb, var(--liv-leaf-500) 30%, transparent);
	border-radius: var(--r-md);
	aspect-ratio: 4 / 3;
	transition: transform var(--liv-transition), border-color var(--liv-transition), box-shadow var(--liv-transition);
}
.liv-spec-sheet__floorplan-link:hover,
.liv-spec-sheet__floorplan-link:focus-visible {
	transform: translateY(-1px);
	border-color: var(--liv-leaf-500);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.liv-spec-sheet__floorplan-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: rgba(255, 255, 255, 0.92);
	display: block;
}

.liv-spec-sheet__floorplan-zoom {
	position: absolute;
	bottom: 6px;
	right: 6px;
	width: 24px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--liv-ink-900);
	color: var(--liv-leaf-300);
	border-radius: 50%;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
	opacity: 0.95;
}
.liv-spec-sheet__floorplan-zoom svg { width: 12px; height: 12px; }

/* Small "View Gallery" CTA that tucks under the floorplan image — links
 * to the rig's gallery anchor on /lineup/<slug>/#liv-rig-gallery. Sized
 * and weighted to read as a secondary action: matches floorplan width,
 * shares the floorplan-link's dark fill + green border, and stays compact
 * so it doesn't push down into the spec grid. */
.liv-spec-sheet__gallery-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	width: 100%;
	margin-top: 0.35rem;
	padding: 0.4rem 0.5rem;
	background: rgba(255, 255, 255, 0.04);
	color: var(--liv-leaf-300);
	border: 1px solid color-mix(in srgb, var(--liv-leaf-500) 30%, transparent);
	border-radius: var(--r-md);
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.625rem;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--liv-transition), color var(--liv-transition), border-color var(--liv-transition);
}
.liv-spec-sheet__gallery-btn:hover,
.liv-spec-sheet__gallery-btn:focus-visible {
	background: rgba(151, 196, 89, 0.12);
	color: var(--liv-paper);
	border-color: var(--liv-leaf-500);
}

/* ─── Spec detail grid: 4 columns × 4 rows ──────────────────────── */

.liv-spec-sheet__specs {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0;
	margin: 0;
}
.liv-spec-sheet__specs > div {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	padding: clamp(0.55rem, 1vw, 0.7rem) clamp(0.6rem, 1.3vw, 0.9rem);
	border-right: 1px dashed rgba(255, 255, 255, 0.1);
	border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}
/* Drop right border on every 4th cell (column 4). */
.liv-spec-sheet__specs > div:nth-child(4n) {
	border-right: 0;
	padding-right: 0;
}
/* Drop bottom border on the last row. */
.liv-spec-sheet__specs > div:nth-last-child(-n+4) {
	border-bottom: 0;
	padding-bottom: 0;
}
/* Drop left padding on the first cell of each row (column 1). */
.liv-spec-sheet__specs > div:nth-child(4n+1) {
	padding-left: 0;
}
.liv-spec-sheet__specs dt {
	font-size: 0.625rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-ink-300);
	font-weight: 600;
}
.liv-spec-sheet__specs dd {
	margin: 0;
	font-size: clamp(1rem, 1.5vw, 1.125rem);
	color: var(--liv-paper);
	font-weight: 500;
	font-variant-numeric: tabular-nums;
	line-height: 1.1;
}

/* ─── Tab row — wrap-to-fit, no horizontal scroll ───────────────── */

.liv-spec-sheet__tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.625rem;
	margin: 0;
	padding: 0;
}

.liv-spec-sheet__tabs .liv-chip {
	color: var(--liv-ink-200);
	border-color: rgba(255, 255, 255, 0.18);
	flex: 0 0 auto;
	height: 40px;
	padding: 0 1.25rem;
	font-size: 0.75rem;
}
.liv-spec-sheet__tabs .liv-chip:hover,
.liv-spec-sheet__tabs .liv-chip:focus-visible {
	background: rgba(255, 255, 255, 0.06);
	color: var(--liv-paper);
	border-color: var(--liv-leaf-500);
}
.liv-spec-sheet__tabs .liv-chip--active {
	background: var(--liv-leaf-500);
	color: var(--liv-ink-900);
	border-color: var(--liv-leaf-500);
	font-weight: 700;
}
.liv-spec-sheet__tab-dot {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--liv-ink-900);
	margin-right: 0.45rem;
}

/* ─── Download PDF link ─────────────────────────────────────────── */

.liv-spec-sheet__pdf {
	justify-self: end;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-leaf-300);
	text-decoration: none;
	padding: 0.25rem 0;
	transition: color var(--liv-transition);
}
.liv-spec-sheet__pdf:hover,
.liv-spec-sheet__pdf:focus-visible {
	color: var(--liv-paper);
}
.liv-spec-sheet__pdf[hidden] { display: none; }

/* ─── Floorplan modal (<dialog>) ────────────────────────────────── */

/* Dialog fills the viewport (with transparent fill) so clicks on the empty
 * region around the centered image land on the <dialog> element itself —
 * the JS uses `ev.target === dialog` to detect backdrop-region clicks. */
.liv-spec-sheet__modal {
	background: transparent;
	border: 0;
	padding: 0;
	margin: 0;
	color: var(--liv-paper);
	width: 100vw;
	height: 100vh;
	max-width: 100vw;
	max-height: 100vh;
}
.liv-spec-sheet__modal::backdrop {
	background: rgba(0, 0, 0, 0.82);
	backdrop-filter: blur(6px);
}
.liv-spec-sheet__modal[open] {
	display: grid;
	place-items: center;
}

.liv-spec-sheet__modal-stage {
	position: relative;
	margin: 0;
	display: grid;
	gap: 0.5rem;
	place-items: center;
	max-width: min(1200px, 96vw);
	max-height: 96vh;
}
.liv-spec-sheet__modal-img {
	width: 100%;
	max-height: 86vh;
	height: auto;
	object-fit: contain;
	background: var(--liv-paper);
	border-radius: var(--r-md);
}
.liv-spec-sheet__modal-caption {
	font-size: 0.6875rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--liv-ink-300);
	font-weight: 600;
	text-align: center;
}
.liv-spec-sheet__modal-caption:empty { display: none; }

.liv-spec-sheet__modal-close {
	position: absolute;
	top: -16px;
	right: -16px;
	width: 40px;
	height: 40px;
	background: var(--liv-ink-900);
	color: var(--liv-paper);
	border: 1px solid var(--liv-leaf-500);
	border-radius: 50%;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background-color var(--liv-transition), color var(--liv-transition);
}
.liv-spec-sheet__modal-close:hover,
.liv-spec-sheet__modal-close:focus-visible {
	background: var(--liv-leaf-500);
	color: var(--liv-ink-900);
}
.liv-spec-sheet__modal-close svg { width: 16px; height: 16px; }

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

@media (max-width: 1024px) {
	.liv-spec-sheet__floorplan {
		width: clamp(96px, 18vw, 140px);
	}
}

@media (max-width: 900px) {
	.liv-spec-sheet__specs { grid-template-columns: repeat(2, 1fr); }
	.liv-spec-sheet__specs > div:nth-child(4n) {
		border-right: 1px dashed rgba(255, 255, 255, 0.1);
		padding-right: clamp(0.6rem, 1.3vw, 0.9rem);
	}
	.liv-spec-sheet__specs > div:nth-child(2n) {
		border-right: 0;
		padding-right: 0;
	}
	.liv-spec-sheet__specs > div:nth-child(4n+1) { padding-left: 0; }
	.liv-spec-sheet__specs > div:nth-child(2n+1) { padding-left: 0; }
	.liv-spec-sheet__specs > div:nth-last-child(-n+4) { border-bottom: 1px dashed rgba(255, 255, 255, 0.1); padding-bottom: clamp(0.55rem, 1vw, 0.7rem); }
	.liv-spec-sheet__specs > div:nth-last-child(-n+2) { border-bottom: 0; padding-bottom: 0; }
}

@media (max-width: 640px) {
	.liv-spec-sheet__header { grid-template-columns: auto 1fr; }
	.liv-spec-sheet__pill { left: auto; right: 1rem; transform: translateY(-50%); }
	.liv-spec-sheet__summary { padding-right: 0; }
	.liv-spec-sheet__quick { flex-wrap: wrap; gap: 0.5rem 0; justify-content: stretch; width: auto; padding-bottom: 0.75rem; }
	.liv-spec-sheet__quick > div {
		flex: 1 1 50%;
		border-left: 0;
		padding: 0.5rem 0;
		border-top: 1px solid rgba(255, 255, 255, 0.06);
	}
	.liv-spec-sheet__floorplan {
		position: static;
		width: 100%;
		max-width: 220px;
		justify-self: start;
	}
	.liv-spec-sheet__floorplan-caption { text-align: left; }
	.liv-spec-sheet__specs { grid-template-columns: 1fr; }
	.liv-spec-sheet__specs > div {
		border-right: 0;
		border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
		padding: 0.75rem 0;
	}
	.liv-spec-sheet__specs > div:last-child { border-bottom: 0; }
	.liv-spec-sheet__modal-close { top: 8px; right: 8px; }
}
