/**
 * Rules PDF landing / viewer shell (404-handled routes).
 * Relies on theme styles from wp_head(); only adds layout + light button styling.
 */

/*
 * Approximate space from top of viewport to top of iframe on small screens
 * (shell padding, title, actions, intro). Top safe-area is already in shell padding.
 */
body.nrl22-rules-page--pdf {
	--nrl22-rules-pdf-mobile-chrome: 15rem;
}

.nrl22-rules-shell {
	box-sizing: border-box;
	/*
	 * Extra top offset: WP admin bar is fixed; some themes zero out html margin-top.
	 * Optional: body.nrl22-rules-page { --nrl22-rules-extra-top: 80px; } if a sticky header still overlaps.
	 */
	--nrl22-rules-top-add: var(--nrl22-rules-extra-top, 0px);
	padding: calc(1.5rem + env(safe-area-inset-top, 0px) + var(--nrl22-rules-top-add)) 1rem 3rem;
}

body.admin-bar .nrl22-rules-shell {
	--nrl22-rules-top-add: calc(var(--nrl22-rules-extra-top, 0px) + 32px);
}

@media screen and (max-width: 782px) {
	body.admin-bar .nrl22-rules-shell {
		--nrl22-rules-top-add: calc(var(--nrl22-rules-extra-top, 0px) + 46px);
	}
}

.nrl22-rules-shell__inner {
	max-width: 960px;
	margin-left: auto;
	margin-right: auto;
}

.nrl22-rules-shell__inner h1 {
	margin: 0 0 0.75rem;
	padding-top: 0.125rem;
	font-size: clamp(1.5rem, 2.5vw, 2rem);
	line-height: 1.2;
}

.nrl22-rules-shell__inner > p {
	margin: 0 0 1rem;
	line-height: 1.55;
}

.nrl22-rules-past {
	margin-top: 2rem;
	padding-top: 1.5rem;
	border-top: 1px solid rgba(127, 127, 127, 0.35);
}

.nrl22-rules-past h2 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.1rem, 2vw, 1.35rem);
	line-height: 1.3;
	font-weight: 600;
}

/* Tighter block above the PDF viewer on /rules/nrl22 and /rules/nrl22x */
.nrl22-rules-past--pdf-subpage {
	margin-top: 1rem;
	padding-top: 1rem;
}

.nrl22-rules-past--pdf-subpage .nrl22-rules-actions--past {
	margin-top: 0.35rem;
	margin-bottom: 0.5rem;
}

.nrl22-rules-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.65rem;
	margin: 1rem 0 1.25rem;
}

.nrl22-rules-actions--past {
	margin-top: 0.75rem;
}

.nrl22-rules-actions a {
	display: inline-block;
	box-sizing: border-box;
	font-family: inherit;
	font-size: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	padding: 0.65rem 1rem;
	border-radius: 4px;
	border: 1px solid transparent;
	transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

/* Primary: prefer theme accent when available */
.nrl22-rules-actions a.nrl22-rules-btn--primary {
	background-color: var(--nrl22-rules-accent, #b40000);
	color: var(--nrl22-rules-on-accent, #fff);
	border-color: var(--nrl22-rules-accent, #b40000);
}

.nrl22-rules-actions a.nrl22-rules-btn--primary:hover,
.nrl22-rules-actions a.nrl22-rules-btn--primary:focus {
	opacity: 0.92;
	color: var(--nrl22-rules-on-accent, #fff);
}

/*
 * Secondary: light text + light border for contrast on dark theme chrome (matches headings).
 * On a light background, set e.g. body.nrl22-rules-page { --nrl22-rules-secondary-fg: #8a0000; --nrl22-rules-secondary-border: rgba(180,0,0,0.55); }
 */
.nrl22-rules-actions a.nrl22-rules-btn--secondary {
	background-color: transparent;
	color: var(--nrl22-rules-secondary-fg, rgba(255, 255, 255, 0.95));
	border-color: var(--nrl22-rules-secondary-border, rgba(255, 255, 255, 0.65));
}

.nrl22-rules-actions a.nrl22-rules-btn--secondary:hover,
.nrl22-rules-actions a.nrl22-rules-btn--secondary:focus {
	background-color: var(--nrl22-rules-secondary-hover-bg, rgba(255, 255, 255, 0.12));
	color: var(--nrl22-rules-secondary-fg-hover, #fff);
	border-color: var(--nrl22-rules-secondary-border-hover, rgba(255, 255, 255, 0.9));
}

.nrl22-rules-pdfjs-intro {
	margin: 0 0 1rem;
	line-height: 1.55;
	opacity: 0.92;
	font-size: 0.9375rem;
}

/* Bundled PDF.js web viewer (iframe) — only on rules PDF subpages. */
body.nrl22-rules-page--pdf .nrl22-rules-pdfjs-viewer-frame {
	width: 100%;
	max-width: 100%;
	margin-top: 0.5rem;
	border: 1px solid rgba(127, 127, 127, 0.35);
	border-radius: 6px;
	overflow: hidden;
	background: #3f3f3f;
}

body.nrl22-rules-page--pdf .nrl22-rules-pdfjs-iframe {
	display: block;
	width: 100%;
	height: min(88vh, 960px);
	border: 0;
}

/*
 * Mobile: use dynamic viewport height so the frame isn’t capped by min(vh, px).
 * Edge-to-edge width reclaims horizontal space lost to padding.
 */
@media (max-width: 768px) {
	body.nrl22-rules-page--pdf .nrl22-rules-shell__inner {
		max-width: none;
	}

	body.nrl22-rules-page--pdf .nrl22-rules-pdfjs-viewer-frame {
		margin-left: calc(-1 * (0.75rem + env(safe-area-inset-left, 0px)));
		margin-right: calc(-1 * (0.75rem + env(safe-area-inset-right, 0px)));
		width: auto;
		max-width: none;
		border-radius: 0;
		border-left: 0;
		border-right: 0;
	}

	body.nrl22-rules-page--pdf .nrl22-rules-pdfjs-iframe {
		height: calc(100vh - var(--nrl22-rules-pdf-mobile-chrome) - env(safe-area-inset-bottom, 0px));
		min-height: 20rem;
	}
}

@supports (height: 100dvh) {
	@media (max-width: 768px) {
		body.nrl22-rules-page--pdf .nrl22-rules-pdfjs-iframe {
			height: calc(100dvh - var(--nrl22-rules-pdf-mobile-chrome) - env(safe-area-inset-bottom, 0px));
		}
	}
}

@media (max-width: 768px) {
	.nrl22-rules-shell {
		padding: calc(1rem + env(safe-area-inset-top, 0px) + var(--nrl22-rules-top-add)) 0.75rem 2rem;
	}
}
