/* ProTech Content Guard — loaded only when protection is active (body.ptcg-on). */

body.ptcg-on {
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

/* Allowed: form fields and inline code. */
body.ptcg-on input,
body.ptcg-on textarea,
body.ptcg-on select,
body.ptcg-on [contenteditable=""],
body.ptcg-on [contenteditable="true"],
body.ptcg-on code {
	-webkit-user-select: text;
	user-select: text;
	-webkit-touch-callout: default;
}

/* Command blocks are copied through the button only. */
body.ptcg-on pre,
body.ptcg-on pre code {
	-webkit-user-select: none;
	user-select: none;
}

body.ptcg-on img {
	-webkit-user-drag: none;
}

/* ---------- Command block + copy button ---------- */

.ptcg-cmd {
	--ptcg-btn-bg: #ffffff;
	--ptcg-btn-fg: #1f2937;
	--ptcg-btn-border: #d1d5db;
	--ptcg-btn-hover: #f3f4f6;
	--ptcg-ok: #15803d;
	--ptcg-err: #b91c1c;
	position: relative;
}

/* The <pre> keeps the theme's own look — nothing is added to its padding or margins. */

/* Blocks made with the editor button: box hugs the text and follows the writer's alignment. */
.ptcg-fit {
	width: -moz-fit-content;
	width: fit-content;
	min-width: 12em;
	max-width: 100%;
}

.ptcg-fit > pre {
	white-space: pre-wrap;
	word-break: break-word;
}

.ptcg-align-center {
	margin-left: auto;
	margin-right: auto;
}

.ptcg-align-left {
	margin-left: 0;
	margin-right: auto;
}

.ptcg-align-right {
	margin-left: auto;
	margin-right: 0;
}

.ptcg-copy {
	position: absolute;
	top: 0;
	right: 0.5em; /* commands are LTR: button sits at their top-right */
	z-index: 2;
	transform: translateY(-50%); /* rides the top edge, so it never covers the command text */
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	padding: 0.3em 0.7em;
	font: inherit;
	font-size: 13px;
	line-height: 1.4;
	color: var(--ptcg-btn-fg);
	background: var(--ptcg-btn-bg);
	border: 1px solid var(--ptcg-btn-border);
	border-radius: 6px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease, visibility 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

/* Shown on hover / keyboard focus / right after copying. */
.ptcg-cmd:hover .ptcg-copy,
.ptcg-cmd:focus-within .ptcg-copy,
.ptcg-copy[data-state] {
	opacity: 1;
	visibility: visible;
}

/* Touch screens have no hover: keep the button always visible there. */
@media (hover: none) {
	.ptcg-copy {
		opacity: 1;
		visibility: visible;
	}
}

.ptcg-copy:hover {
	background: var(--ptcg-btn-hover);
}

.ptcg-copy:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.ptcg-copy[data-state="ok"] {
	color: var(--ptcg-ok);
	border-color: currentColor;
}

.ptcg-copy[data-state="error"] {
	color: var(--ptcg-err);
	border-color: currentColor;
}

[data-theme="dark"] .ptcg-cmd {
	--ptcg-btn-bg: #1f2937;
	--ptcg-btn-fg: #e5e7eb;
	--ptcg-btn-border: #374151;
	--ptcg-btn-hover: #374151;
	--ptcg-ok: #4ade80;
	--ptcg-err: #f87171;
}

/* ---------- Printing ---------- */

@media print {
	body.ptcg-on > * {
		display: none !important;
	}

	body.ptcg-on::before {
		content: var(--ptcg-print-msg, "Printing is disabled.");
		display: block;
		padding: 2em;
		font-size: 16pt;
		text-align: center;
	}
}
