/**
 * MF Post-Header variant: series-flip (ported from demo MFQ10 "3D-Kartenflip").
 * Loaded only when a post's header variant is `series-flip`.
 *
 * Two columns on a capped, centred layout: a square card on the left (a native
 * <details class="mfr-reveal"> that IS the 3D perspective box) and a text column on
 * the right. The box holds two independently-rotated faces: the FRONT is the
 * <summary> (the trigger) showing the SQUARE featured image, deliberately cropped 1:1
 * via the higher-specificity override (a conscious exception to the crop-free rule
 * for this square-format round); the BACK is a <details> child AFTER </summary> — a
 * dark panel with the full parts list, so the parts-list links stay OUT of the
 * role="button" summary (no links-inside-a-button anti-pattern). Closed, the front
 * faces the viewer; on hover/click (series.js opens the <details>; native toggle also
 * works) the front rotates 180° away and the back rotates in. pointer-events flip
 * with the rotation so the front is the toggle when closed and the back's links are
 * clickable once flipped. System fonts + base.css colour vars only; no Google Fonts,
 * no remote assets.
 *
 * The flipped end-state lives under `details[open]`, so it stays reachable even under
 * prefers-reduced-motion (the base guard only removes the transition, not the
 * open-state transform). backface-visibility:hidden keeps only the facing side
 * visible after the (possibly instant) rotation.
 */

/* Same floating-card WIDTH as series-square-split (capped 1080, two columns), but
   the flip stage stays a COMPACT, centred square card (its own radius + shadow) — a
   full-column square would look wrong mid-flip. Text column on the right; the ad
   slot lives inside that text column (under the lead), not full width. */
.mfph-series-flip {
	max-width: 1080px;
	margin: 20px auto;
	padding: clamp(28px, 4vw, 48px);
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: clamp(20px, 4vw, 48px);
	align-items: center;
	background: var(--mf-paper);
	border: 1px solid var(--mf-line);
	border-radius: 16px;
	box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.35);
}

/* Reveal container = the 3D perspective box (native <details>; series.js adds
   hover-open). A compact 1:1 card capped well below the column width and centred,
   so the flip reads as a card turning over rather than a whole panel. */
.mfph-series-flip__reveal {
	position: relative;
	width: 100%;
	max-width: 400px;
	aspect-ratio: 1;
	margin: 0 auto;
	perspective: 1200px;
	border: none;
	padding: 0;
}

/* Both faces stack in the perspective box and rotate independently in 3D.
   backface-visibility:hidden keeps only the side facing the viewer visible. Each
   carries its own radius + shadow so the compact card floats on the white panel. */
.mfph-series-flip__face {
	position: absolute;
	inset: 0;
	margin: 0;
	backface-visibility: hidden;
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 20px 44px -22px rgba(0, 0, 0, 0.4);
	transition: transform 0.5s ease;

	/* Keep a compositor layer promoted so repeat flips stay as smooth as the first
	   (without this the layer is discarded after the first close and re-created on
	   the next open, which reads as a one-time-only smooth flip). */
	will-change: transform;
}

/* Front = the <summary> trigger. Kill the default disclosure marker so it reads as a
   plain card. Closed: facing the viewer and catching pointer/click. */
.mfph-series-flip__front {
	display: block;
	cursor: pointer;
	list-style: none;
	transform: rotateY(0);
	pointer-events: auto;
}

.mfph-series-flip__front::-webkit-details-marker {
	display: none;
}

.mfph-series-flip__front:focus-visible {
	outline: 2px solid var(--mf-violet);
	outline-offset: 6px;
}

/* Visually-hidden label inside the front summary (self-contained; the frontend theme
   may not ship a .screen-reader-text rule). */
.mfph-series-flip__front .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Deliberate square crop: three classes (0,3,0) override base.css
   `.mfph-header .mf-uncropped { height:auto }` (0,2,0) for THIS variant only, so the
   front's featured image fills the 1:1 card via object-fit:cover. */
.mfph-header .mfph-series-flip__front .mf-uncropped {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Back = dark panel, rotated away when closed and pointer-inert so it never
   intercepts clicks meant for the front trigger. */
.mfph-series-flip__back {
	background: var(--mf-ink);
	color: #fff;
	transform: rotateY(180deg);
	padding: clamp(24px, 4vw, 40px);
	display: flex;
	flex-direction: column;
	justify-content: center;
	pointer-events: none;

	/* The "+N more" pill + fade are shared (see base.css); this panel is dark, so
	   theme them for the ink background (lime accent, fade into the ink). */
	--mfph-more-fade: var(--mf-ink);
	--mfph-more-bg: #1b212a;
	--mfph-more-border: rgba(255, 255, 255, 0.14);
	--mfph-more-fg: var(--mf-lime);
}

/* Open: the front rotates away (and stops catching pointers) while the back rotates
   in and becomes clickable, so its links are reachable once flipped. */
.mfph-series-flip__reveal[open] .mfph-series-flip__front {
	transform: rotateY(180deg);
	pointer-events: none;
}

.mfph-series-flip__reveal[open] .mfph-series-flip__back {
	transform: rotateY(0);
	pointer-events: auto;
}

/* Flat fallback (no featured image): the back panel rendered statically in normal
   flow — no 3D, no rotation, always clickable — since there is no front to flip to. */
.mfph-series-flip__back--flat {
	position: static;
	width: 100%;
	max-width: 400px;
	aspect-ratio: 1;
	margin: 0 auto;
	transform: none;
	backface-visibility: visible;
	overflow: auto;
	pointer-events: auto;
}

.mfph-series-flip__backhead {
	font: 700 10px/1 var(--mf-mono);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--mf-lime);
	margin: 0 0 10px;
}

/* Parts list on the (dark) back: light text, lime numbers, the current part lime. */
.mfph-series-flip__back .mfph-series-parts {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 200px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.mfph-series-flip__back .mfph-series-parts__item {
	display: flex;
	gap: 8px;
	font-size: 12px;
	padding: 4px 0;
	color: #c7cdd8;
}

.mfph-series-flip__back .mfph-series-parts__num {
	font: 700 11px/1.4 var(--mf-mono);
	color: var(--mf-lime);
	flex: 0 0 auto;
}

.mfph-series-flip__back .mfph-series-part {
	color: inherit;
	text-decoration: none;
}

.mfph-series-flip__back .mfph-series-part:hover,
.mfph-series-flip__back .mfph-series-part:focus-visible {
	text-decoration: underline;
}

.mfph-series-flip__back .mfph-series-part--current {
	color: var(--mf-lime);
	font-weight: 700;
	scroll-margin: 10px;
}

.mfph-series-flip__series {
	font: 700 12px/1 var(--mf-font);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--mf-muted);
	margin: 0 0 14px;
}

.mfph-series-flip__title {
	font-family: var(--mf-serif);
	font-weight: 900;
	font-size: clamp(24px, 3.2vw, 36px);
	line-height: 1.1;
	margin: 0 0 16px;
}

.mfph-series-flip__hint {
	font-size: 12.5px;
	color: var(--mf-muted);
	margin: 0 0 10px;
}

.mfph-series-flip__lead {
	font-size: 15.5px;
	line-height: 1.6;
	margin: 0 0 18px;
}

.mfph-series-flip__slot {
	color: var(--mf-violet);
}

@media (max-width: 760px) {

	/* Single column: the card/panel sits on top (first in source) above the text;
	   the flip still works. */
	.mfph-series-flip {
		grid-template-columns: 1fr;
	}
}
