/* =====================================================================
   Content protection (see assets/js/protect.js). Loaded only on the
   screens that show questions and answers.
   ===================================================================== */

body[data-protect] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* iOS long-press "Copy / Save image" */
}
body[data-protect] input,
body[data-protect] textarea,
body[data-protect] [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
body[data-protect] img { -webkit-user-drag: none; user-drag: none; }

/* The watermark: faint enough to read through, present on every pixel. */
.wm {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  background-repeat: repeat;
  opacity: 0.09;
}
:root[data-theme="dark"] .wm { opacity: 0.13; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wm { opacity: 0.13; } }

/* Shield: blur everything when the window is not in focus. */
html.is-shielded body[data-protect] > *:not(.wm) {
  filter: blur(18px);
}
html.is-shielded body[data-protect]::after {
  content: "Content hidden while this window is not active. Click here to continue.";
  position: fixed;
  inset: 0;
  z-index: 2147482999;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font: 600 16px/1.5 var(--font-sans);
  color: var(--text);
  /* Near-opaque and blurring what is behind it, so nothing underneath is
     readable even where the element filter above does not apply. */
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

/* No printing, no "Save as PDF". */
@media print {
  body[data-protect] > * { display: none !important; }
  body[data-protect]::before {
    content: "Printing is disabled for this page.";
    display: block;
    padding: 40px;
    font: 600 18px Arial, sans-serif;
  }
}
