/**
 * Single reference detail page (single-reference.php).
 *
 * Ported from the Claude Design prototype "Hausdetail Referenz"
 * (src-v2/detail-*.jsx, isReferenz branches), whose layout lives in inline style
 * objects — those are reconstructed here as classes.
 *
 * This file holds only what is unique to the reference variant. The hero, the
 * Merkmale strip, the lightbox and the sticky CTA are the same components in the
 * design as on the concept page, so they keep their fmt-house-* block names and
 * their rules stay in single-house.css, which this file is enqueued against. The
 * shared design layer (tokens, .wrap, .btn, .eyebrow, .h-display) comes from
 * global.css below that.
 *
 * Blocks follow the section order of the template:
 *   1 fmt-house-hero          (+ the fmt-reference-hero__meta line added here)
 *   2 fmt-house-merkmale      (single-house.css, unchanged)
 *   3 fmt-reference-galerie   (+ fmt-house-lightbox from single-house.css)
 *   4 fmt-reference-framing
 *   5 fmt-reference-besichtigung
 *   6 fmt-reference-crosssell (pending)
 *   7 fmt-reference-kontakt   (pending)
 *
 * Responsive rules are grouped at the end of the file.
 */

/* =========================================================
   1 · Hero — delta to the concept page
   ========================================================= */

/*
 * Location line under the headline. The only piece of the hero the reference
 * variant adds; everything around it is single-house.css's.
 */
.fmt-reference-hero__meta {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 16px 0 0;
	font-size: 13px;
	color: var(--ink-soft);
}
.fmt-reference-hero__meta .icon {
	flex-shrink: 0;
	color: var(--red);
}

/* =========================================================
   3 · Galerie
   ========================================================= */

.fmt-reference-galerie {
	background: var(--bg-2);
	padding: 104px 0 96px;
}
.fmt-reference-galerie__head {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	flex-wrap: wrap;
	gap: 36px;
	margin-bottom: 32px;
}
.fmt-reference-galerie__eyebrow {
	margin-bottom: 14px;
}
.fmt-reference-galerie__title {
	max-width: 760px;
}
.fmt-reference-galerie__lead {
	max-width: 360px;
	margin: 0;
	font-size: 15px;
	color: var(--ink-soft);
}

/*
 * The quilt. Six columns of 180px rows, matching the column count the mosaic
 * field offers in the editor, so what an author arranges is what gets rendered.
 *
 * grid-auto-flow: dense lets the singles backfill the gaps the large tiles leave
 * — without it a row that cannot fit a wide tile would stay half empty.
 */
.fmt-reference-galerie__grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	grid-auto-rows: 180px;
	grid-auto-flow: dense;
	gap: 12px;
}
/*
 * Each tile spans what the editor dragged, handed over as --tile-w / --tile-h
 * and clamped to the six columns on the way out. Spans plus order — never
 * absolute cells — so the narrow layouts below can re-flow instead of tearing
 * holes into the grid.
 */
.fmt-reference-galerie__grid > .fmt-reference-galerie__tile {
	grid-column: span var(--tile-w, 1);
	grid-row: span var(--tile-h, 1);
}

/*
 * Preview cap. Everything is in the markup; this decides how much of it shows
 * until the toggle sets .is-expanded.
 *
 * Here the budget is five grid rows, and PHP marks the tiles that start below
 * them — a count would say nothing about height once authors set their own
 * spans. The narrow steps further down go back to counting, because there
 * every tile is 1x1 again and the two amount to the same thing.
 */
.fmt-reference-galerie__grid:not(.is-expanded) .fmt-reference-galerie__tile--beyond-preview {
	display: none;
}

.fmt-reference-galerie__tile {
	position: relative;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow: hidden;
	background: var(--bg-3);
	cursor: pointer;
	transition: transform .25s ease, box-shadow .25s ease;
}
.fmt-reference-galerie__tile:hover {
	transform: scale(1.012);
	box-shadow: 0 18px 40px -20px rgba(20, 18, 12, .25);
}
.fmt-reference-galerie__tile-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Expand / collapse — centred below the grid, as the design places it. */
.fmt-reference-galerie__toggle-row {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 14px;
	margin-top: 32px;
}
.fmt-reference-galerie__toggle-icon {
	display: inline-flex;
}
.fmt-reference-galerie__toggle[aria-expanded="true"] .fmt-reference-galerie__toggle-icon--more,
.fmt-reference-galerie__toggle[aria-expanded="false"] .fmt-reference-galerie__toggle-icon--less {
	display: none;
}
/*
 * The button hides itself wherever the preview is already complete. PHP sets
 * one --hide-* class per such layout; each media query below undoes the one
 * above it, so a button carrying several of them surfaces exactly where it is
 * needed.
 */
.fmt-reference-galerie__toggle--hide-wide {
	display: none;
}

/* =========================================================
   4 · Framing-Band
   ========================================================= */

.fmt-reference-framing {
	background: var(--bg-2);
	padding: 32px 0;
}

/* Headline left, the argument and its CTA right — on the page's only dark card. */
.fmt-reference-framing__card {
	display: grid;
	grid-template-columns: 1fr 1.3fr;
	gap: 48px;
	align-items: center;
	padding: 34px 40px;
	border-radius: 16px;
	background: var(--ink);
	color: #fff;
}
/* Dimmer than the shared .eyebrow--light, per the design. */
.fmt-reference-framing__eyebrow {
	margin-bottom: 12px;
	color: rgba(255, 255, 255, .6);
}
/*
 * The colour is spelled out rather than inherited from the card: style.css sets
 * a colour on the bare h1–h6 selectors, which beats inheritance no matter how
 * dark the background behind them is.
 */
.fmt-reference-framing__title {
	margin: 0;
	font-size: 30px;
	line-height: 1.12;
	letter-spacing: -0.02em;
	font-weight: 500;
	color: #fff;
}
.fmt-reference-framing__text {
	max-width: 560px;
	margin: 0 0 20px;
	font-size: 16px;
	line-height: 1.6;
	color: rgba(255, 255, 255, .78);
}
/* The promise the band is built around, lifted out of the dimmed body copy. */
.fmt-reference-framing__text strong {
	color: #fff;
	font-weight: 500;
}
.fmt-reference-framing__actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
}
.fmt-reference-framing__signet {
	flex-shrink: 0;
	width: 46px;
	height: 46px;
}

/* =========================================================
   5 · Besichtigung
   ========================================================= */

.fmt-reference-besichtigung {
	background: var(--bg-2);
	padding: 80px 0;
}
.fmt-reference-besichtigung__card {
	display: grid;
	grid-template-columns: 1.1fr 1fr;
	border: 1px solid var(--line);
	border-radius: 16px;
	overflow: hidden;
	background: var(--paper);
	box-shadow: var(--shadow-card);
}

/* Photo half — overlay chrome sits above a bottom-weighted gradient */
.fmt-reference-besichtigung__media {
	position: relative;
	min-height: 380px;
	background: var(--bg-3);
}
.fmt-reference-besichtigung__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
/* Darkens towards the bottom so the caption keeps its contrast. */
.fmt-reference-besichtigung__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, .55) 100%);
}
.fmt-reference-besichtigung__chip {
	position: absolute;
	top: 22px;
	left: 22px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .94);
	backdrop-filter: blur(6px);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--ink);
}
.fmt-reference-besichtigung__chip .icon {
	color: var(--red);
}
.fmt-reference-besichtigung__caption {
	position: absolute;
	left: 24px;
	right: 24px;
	bottom: 24px;
	z-index: 2;
	color: #fff;
}
.fmt-reference-besichtigung__caption-meta {
	margin-bottom: 6px;
	font-size: 11px;
	letter-spacing: .12em;
	text-transform: uppercase;
	opacity: .85;
}
.fmt-reference-besichtigung__caption-title {
	font-size: 32px;
	font-weight: 500;
	letter-spacing: -0.015em;
}

/* Text half */
.fmt-reference-besichtigung__body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 18px;
	padding: 36px 40px;
}
.fmt-reference-besichtigung__title {
	margin: 0;
	font-size: 30px;
	line-height: 1.1;
	letter-spacing: -0.015em;
	font-weight: 500;
}
.fmt-reference-besichtigung__title em {
	font-style: italic;
	font-weight: 400;
	color: var(--em);
}

/* "Termin nach Absprache" */
.fmt-reference-besichtigung__note {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--bg-2);
}
.fmt-reference-besichtigung__note-icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border: 1px solid var(--line);
	border-radius: 50%;
	background: var(--paper);
	color: var(--red);
}
.fmt-reference-besichtigung__note-text {
	margin: 0;
	font-size: 13px;
	line-height: 1.5;
	color: var(--ink-soft);
}
.fmt-reference-besichtigung__note-text strong {
	color: var(--ink);
	font-weight: 500;
}

.fmt-reference-besichtigung__actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}
/* Pushed to the far edge of the row, away from the two actions. */
.fmt-reference-besichtigung__reply {
	margin-left: auto;
	font-size: 11px;
	color: var(--ink-mute);
}

/* The design does not gate its motion; production should. */
@media (prefers-reduced-motion: reduce) {
	.fmt-reference-galerie__tile {
		transition: none;
	}
}

/* =========================================================
   Responsive

   Same split as single-house.css: up to 680px the values come from the mobile
   design (src-v2/mobile-detail.jsx), the 1100/900 steps are ours — the design
   authors desktop at a fixed 1440px and the phone as a separate tree, and
   covers nothing in between.
   ========================================================= */

/* --- Tablet range · not covered by the design ------------- */

@media (max-width: 1100px) {
	.fmt-reference-framing__card {
		gap: 32px;
		padding: 30px 32px;
	}
	.fmt-reference-besichtigung__body {
		padding: 30px 32px;
	}
}

@media (max-width: 900px) {
	/*
	 * The quilt needs six columns to read as one; below that it would just be
	 * lopsided. Tiles go uniform instead, and their height comes from an aspect
	 * ratio rather than a fixed row.
	 */
	.fmt-reference-galerie {
		padding: 72px 0 64px;
	}
	.fmt-reference-galerie__grid {
		grid-template-columns: repeat(3, 1fr);
		grid-auto-rows: auto;
	}
	/* Three columns leave no room for the editor's spans; every tile is equal. */
	.fmt-reference-galerie__grid > .fmt-reference-galerie__tile {
		grid-column: span 1;
		grid-row: span 1;
	}
	/*
	 * With the spans gone the editor's rows no longer describe what renders, so
	 * the wide cap is lifted and counting takes over: fifteen tiles fill five
	 * rows of three exactly.
	 */
	.fmt-reference-galerie__grid:not(.is-expanded) .fmt-reference-galerie__tile--beyond-preview {
		display: revert;
	}
	.fmt-reference-galerie__grid:not(.is-expanded) .fmt-reference-galerie__tile:nth-child(n + 16) {
		display: none;
	}
	.fmt-reference-galerie__toggle--hide-wide {
		display: inline-flex;
	}
	.fmt-reference-galerie__toggle--hide-narrow {
		display: none;
	}
	.fmt-reference-galerie__tile {
		aspect-ratio: 4 / 3;
	}

	/* Both cards go single column; the photo leads. */
	.fmt-reference-framing__card {
		grid-template-columns: 1fr;
		gap: 24px;
	}
	.fmt-reference-besichtigung {
		padding: 64px 0;
	}
	.fmt-reference-besichtigung__card {
		grid-template-columns: 1fr;
	}
	.fmt-reference-besichtigung__media {
		min-height: 0;
		aspect-ratio: 16 / 10;
	}
}

/* --- Phone · values from the mobile design ---------------- */

@media (max-width: 680px) {
	/* Galerie */
	.fmt-reference-galerie {
		padding: 56px 0;
	}
	.fmt-reference-galerie__head {
		display: block;
		margin-bottom: 20px;
	}
	.fmt-reference-galerie__eyebrow {
		margin-bottom: 12px;
	}
	/* The mobile design's .mh2, smaller than global.css's .h-display here. */
	.fmt-reference-galerie__title {
		font-size: 28px;
		line-height: 1.04;
		letter-spacing: -0.02em;
	}
	.fmt-reference-galerie__lead {
		max-width: none;
		margin-top: 12px;
	}
	.fmt-reference-galerie__grid {
		grid-template-columns: 1fr 1fr;
	}
	/* Six tiles in the preview here, not fourteen. */
	.fmt-reference-galerie__grid:not(.is-expanded) .fmt-reference-galerie__tile:nth-child(n + 7) {
		display: none;
	}
	/* Where the wider previews were already complete, the phone still needs it. */
	.fmt-reference-galerie__toggle--hide-narrow {
		display: inline-flex;
	}
	.fmt-reference-galerie__toggle--hide-phone {
		display: none;
	}
	.fmt-reference-galerie__toggle-row {
		margin-top: 16px;
	}
	.fmt-reference-galerie__toggle {
		width: 100%;
		justify-content: center;
	}

	/* Framing-Band */
	.fmt-reference-framing {
		padding: 40px 0;
	}
	.fmt-reference-framing__card {
		display: block;
		padding: 28px 24px;
	}
	.fmt-reference-framing__title {
		margin-bottom: 16px;
		font-size: 26px;
	}
	.fmt-reference-framing__text {
		max-width: none;
		font-size: 15px;
	}
	/* Signet and button share the row, the button taking what is left. */
	.fmt-reference-framing__actions .btn {
		flex: 1;
		justify-content: center;
	}

	/* Besichtigung */
	.fmt-reference-besichtigung {
		padding: 48px 0;
	}
	.fmt-reference-besichtigung__media {
		aspect-ratio: 4 / 3;
	}
	.fmt-reference-besichtigung__chip {
		top: 16px;
		left: 16px;
		padding: 7px 13px;
		letter-spacing: .1em;
	}
	.fmt-reference-besichtigung__caption {
		left: 18px;
		right: 18px;
		bottom: 16px;
	}
	.fmt-reference-besichtigung__caption-meta {
		margin-bottom: 4px;
		font-size: 10.5px;
	}
	.fmt-reference-besichtigung__caption-title {
		font-size: 26px;
	}
	.fmt-reference-besichtigung__body {
		gap: 16px;
		padding: 24px 22px;
	}
	.fmt-reference-besichtigung__title {
		font-size: 24px;
		line-height: 1.12;
	}
	/* Two lines of note copy instead of three, top-aligned with its icon. */
	.fmt-reference-besichtigung__note {
		align-items: flex-start;
	}
	.fmt-reference-besichtigung__note-extra {
		display: none;
	}
	/*
	 * One full-width action. The mobile design drops the secondary link and the
	 * response-time note — the references archive is in the menu either way.
	 */
	.fmt-reference-besichtigung__more,
	.fmt-reference-besichtigung__reply {
		display: none;
	}
	.fmt-reference-besichtigung__actions .btn {
		width: 100%;
		justify-content: center;
		padding: 14px 22px;
		font-size: 15px;
	}
}
