/**
 * TBS Check-In: Print Card Stylesheet (Avery U-1269-01)
 *
 * Uses absolute positioning from exact Avery template coordinates.
 * No CSS Grid — each card is placed at its precise (top, left) position.
 *
 * Template geometry (from PDF vector paths, 72pt = 1in):
 *   Page: 8.5in x 11in (Letter)
 *   Card: 3.5in x 2.0in
 *   Positions (top-left corner of each card):
 *     Row 1: top 0.75in   |  Row 2: top 3.25in
 *     Row 3: top 5.75in   |  Row 4: top 8.25in
 *     Col 1: left 0.5in   |  Col 2: left 4.5in
 *
 * @package TBS_Checkin
 */

/* ==========================================================================
   Page Sheet — contains 8 absolutely-positioned cards
   ========================================================================== */

.tbs-card-sheet {
	position: relative;
	width: 8.5in;
	height: 11in;
	margin: 0 auto;
	overflow: hidden;
}

/* ==========================================================================
   Card
   ========================================================================== */

.tbs-card {
	/* Position is set via inline style (top/left from PHP). */
	position: absolute;
	width: 3.5in;
	height: 2.0in;
	box-sizing: border-box;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 0.1in 0.15in;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	background: #fff;
}

/* Member name — small, above QR */
.tbs-card-name {
	font-size: 9pt;
	font-weight: 600;
	line-height: 1.2;
	color: #000;
	text-align: center;
	word-wrap: break-word;
	overflow-wrap: break-word;
	flex-shrink: 0;
}

/* QR code container — fixed size */
.tbs-card-qr {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.4in;
	height: 1.4in;
	overflow: hidden;
}

/* QR SVG — constrained to container size */
.tbs-card-qr svg {
	width: 1.4in !important;
	height: 1.4in !important;
	max-width: 1.4in !important;
	max-height: 1.4in !important;
	display: block !important;
}

/* QR image fallback — nuclear override to prevent WP theme img styles */
.tbs-card-qr img,
.tbs-card .tbs-card-qr img {
	width: 1.4in !important;
	height: 1.4in !important;
	max-width: 1.4in !important;
	max-height: 1.4in !important;
	min-width: 1.4in !important;
	min-height: 1.4in !important;
	display: block !important;
	object-fit: contain !important;
	image-rendering: crisp-edges;
}

/* ==========================================================================
   Form & UI Controls
   ========================================================================== */

.tbs-card-form-wrap {
	max-width: 500px;
	margin: 0 auto 30px;
	padding: 20px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 6px;
}

.tbs-card-form-wrap h2 {
	margin-top: 0;
	color: #000;
}

.tbs-card-form-row {
	margin-bottom: 15px;
}

.tbs-card-form-row label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}

.tbs-card-form-row select,
.tbs-card-form-row input[type="text"] {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #ccc;
	border-radius: 4px;
	font-size: 14px;
}

.tbs-card-print-btn {
	display: inline-block;
	padding: 10px 24px;
	margin-bottom: 20px;
	background: #333;
	color: #fff;
	border: none;
	border-radius: 4px;
	font-size: 15px;
	cursor: pointer;
}

.tbs-card-print-btn:hover {
	background: #111;
}

.tbs-card-count {
	color: #555;
	margin-bottom: 15px;
}

.tbs-card-error {
	color: #b00;
	padding: 10px;
}

/* ==========================================================================
   Screen Preview
   ========================================================================== */

@media screen {
	.tbs-card-sheet {
		border: 1px solid #ddd;
		margin-bottom: 30px;
		background: #fafafa;
	}

	.tbs-card {
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {

	/* Hide ALL non-card page chrome */
	header,
	footer,
	nav,
	aside,
	.site-header,
	.site-footer,
	.site-navigation,
	.nav-menu,
	.masthead,
	.widget-area,
	.sidebar,
	.comments-area,
	.post-navigation,
	.breadcrumbs,
	.page-title,
	.entry-header,
	.entry-footer,
	.elementor-location-header,
	.elementor-location-footer,
	.e-scroll-to-top,
	.scroll-to-top,
	.back-to-top,
	#back-to-top,
	.to-top,
	#to-top,
	.scrollToTop,
	.rocket-to-top,
	[class*="scroll-to-top"],
	[class*="back-to-top"],
	[class*="to-top"],
	a[href="#top"],
	.no-print,
	.tbs-card-print-btn,
	.tbs-card-form-wrap,
	.tbs-card-count,
	.tbs-card-error,
	#wpadminbar,
	/* Rife Free header & title bar */
	#header,
	.title-bar,
	.a13-title-bar,
	[class*="title-bar"],
	/* Rife Free header tools & social icons */
	#header-tools,
	.search-container,
	.socials,
	#search-button,
	#side-menu-switch,
	#basket-menu-switch,
	#mobile-menu-opener,
	.tools_button {
		display: none !important;
		height: 0 !important;
		max-height: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		overflow: hidden !important;
		border: none !important;
	}

	body {
		margin: 0 !important;
		padding: 0 !important;
		background: #fff !important;
	}

	/*
	 * Hide all sibling page content (meeting info, footer text, photos, etc.)
	 * that lives alongside the shortcode output in the WordPress editor.
	 * Only the .tbs-card-output wrapper and its children should be visible.
	 */
	.real-content > *:not(.tbs-card-output),
	.formatter > *:not(.real-content) {
		display: none !important;
	}

	/*
	 * Nuke ALL ancestor wrappers — generic WP, Elementor, AND Rife Free.
	 *
	 * Rife Free DOM: body > .whole-layout > #mid.to-move > article#content
	 *   > .content-limiter > #col-mask > .content-box > .formatter
	 *   > .real-content > [shortcode output]
	 *
	 * #mid has position:relative + overflow:hidden + z-index.
	 * .whole-layout has transform:translate3d (also creates containing block).
	 * Both MUST be reset or position:absolute on the sheet is trapped.
	 */
	.whole-layout,
	#mid,
	.to-move,
	.entry-content,
	.site-content,
	.site-main,
	.page-content,
	.post-content,
	.elementor-widget-container,
	.elementor-element,
	.elementor-section,
	.elementor-container,
	.elementor-column,
	.elementor-column-wrap,
	.elementor-widget-wrap,
	.elementor,
	.e-con,
	.e-con-inner,
	article,
	main,
	#content,
	#main,
	#primary,
	.site,
	.hfeed,
	.content-limiter,
	#col-mask,
	.content-box,
	.formatter,
	.real-content,
	.tbs-card-output,
	.clear,
	.clearfix {
		padding: 0 !important;
		margin: 0 !important;
		border: none !important;
		max-width: none !important;
		width: auto !important;
		display: block !important;
		position: static !important;
		float: none !important;
		transform: none !important;
		z-index: auto !important;
		overflow: visible !important;
	}

	@page {
		size: letter portrait;
		margin: 0;
	}

	/*
	 * Page sheet — absolute positioning origin.
	 * Height is NOT set — the container has zero flow height because
	 * all children are absolutely positioned. This prevents the browser
	 * from rendering a blank page for the empty flow content.
	 * page-break-after forces each sheet onto its own page.
	 */
	/*
	 * First sheet: position absolute to break free from any
	 * wrapper spacing that pushes it down on page 1.
	 */
	/*
	 * First sheet: position absolute to escape wrapper spacing.
	 * Height MUST be 11in — with absolutely-positioned children the
	 * sheet has zero intrinsic height, and Chrome skips page breaks
	 * between zero-height elements, collapsing all sheets to one page.
	 */
	.tbs-card-sheet {
		position: absolute !important;
		top: 0 !important;
		left: 0 !important;
		width: 8.5in !important;
		height: 11in !important;
		margin: 0 !important;
		padding: 0 !important;
		overflow: visible !important;
		border: none !important;
	}

	/*
	 * Sheets 2+: back to relative positioning in normal flow.
	 * page-break-before forces each onto a new page.
	 * Height 11in fills exactly one page (with @page margin: 0).
	 */
	.tbs-card-page-break {
		position: relative !important;
		top: auto !important;
		left: auto !important;
		height: 11in !important;
		page-break-before: always;
		break-before: page;
	}

	/* Card — absolutely positioned at inline top/left coordinates */
	.tbs-card {
		position: absolute !important;
		width: 3.5in !important;
		height: 2.0in !important;
		max-height: 2.0in !important;
		overflow: hidden !important;
		box-shadow: none !important;
		border: none !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
		background: transparent !important;
	}

	.tbs-card-qr {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.tbs-card-qr svg {
		width: 1.4in !important;
		height: 1.4in !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.tbs-card-qr img {
		image-rendering: crisp-edges;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.tbs-card-name {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
		color: #000 !important;
	}
}
