/* ===========================================================================
   protect.css - the watermark, and what little a stylesheet can do about
   copying.

   WHAT THIS IS HONESTLY FOR

   A screenshot cannot be blocked in a browser. The operating system never
   tells a page that the screen has been captured, and a phone pointed at a
   monitor is not on the computer at all. Anything that claims otherwise on
   the web is a disabled right-click button.

   So this does the thing that does work: it prints the student's own name
   and account number over the lecture and over every test page, faintly, and
   moves it so it cannot be reliably cropped out. A leaked image then names
   the account it came from, which is what actually deters passing a login
   around, because the person sharing it is the person identified.

   Everything here is deliberately subordinate to reading the paper. A
   watermark a student notices while answering question 23 has cost more than
   it protects, so it sits at a low opacity, never over an input, and never
   takes a click.
   =========================================================================== */

/* --------------------------------------------------------------- the mark */
.pwm {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* Every click, tap, drag and text selection passes straight through. The
     player's own controls sit under this, and so does every answer box. */
  pointer-events: none;
  z-index: 4;
}

/* Page-wide rather than boxed: fixed, so it stays in view down a long
   reading passage instead of sitting at the top where a screenshot of the
   questions would miss it. */
.pwm--page {
  position: fixed;
  z-index: 60;
}

/* Never in the top or bottom eighth of the viewport. Those bands are the
   test's own dark header and its page-turning bar, and a mark sitting on
   either is both invisible against navy and useless: a screenshot of the
   passage would not include it. The mark belongs over the content, which is
   the thing worth photographing. */
.pwm__t {
  position: absolute;
  top: 19%;
  left: 68%;
  font: 600 11px/1.3 "Public Sans", system-ui, sans-serif;
  letter-spacing: .04em;
  white-space: nowrap;
  /* Two tenths over the page. Legible in a screenshot that is looked at on
     purpose, close to invisible to somebody reading the question under it. */
  color: rgba(17, 24, 39, .17);
  transition: top 1.6s ease, left 1.6s ease;
}

/* Over video, which is dark and is also somebody else's picture, so the mark
   needs its own contrast rather than borrowing the page's. */
.pwm--vid .pwm__t {
  color: rgba(255, 255, 255, .34);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .pwm__t { transition: none; }
}

/* A phone screen has no room for a label wandering across it: every move
   would land on the answer somebody is typing. Pinned instead, a third of
   the way down the right edge, which on a phone is over the passage and
   clear of both the header and the page-turning bar. */
@media (max-width: 560px) {
  .pwm--page .pwm__t {
    top: 32%; left: auto; right: 6px;
    transition: none;
    font-size: 10px;
  }
}

/* ------------------------------------------------------------- the player */
/* The wrapper has to be a positioning context, or the overlay escapes to the
   nearest one and lands somewhere up the page. */
.pvid { position: relative; }

.pvid__fs {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  padding: 5px 11px;
  border: 0;
  border-radius: 6px;
  background: rgba(17, 24, 39, .62);
  color: #fff;
  font: 600 12px/1 "Public Sans", system-ui, sans-serif;
  cursor: pointer;
  opacity: 0;
  transition: opacity .18s ease;
}
.pvid:hover .pvid__fs,
.pvid__fs:focus-visible { opacity: 1; }

/* Full screen on the WRAPPER, not on the player, which is the whole point:
   the overlay is inside the wrapper, so it comes along. A fullscreen iframe
   would leave the mark behind on the page underneath. */
.pvid:fullscreen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: #000;
}
.pvid:fullscreen iframe { width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  .pvid__fs { transition: none; }
}

/* --------------------------------------------------------------- copying */
/* Selection off over the paper, and explicitly back on for anything a
   student types into. Without the second rule they cannot select a word of
   their own answer to correct it, which breaks the test to protect it. */
[data-protect] {
  -webkit-user-select: none;
  user-select: none;
}
[data-protect] input,
[data-protect] textarea,
[data-protect] select,
[data-protect] [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

/* An image dragged out of the page is a saved image. */
[data-protect] img { -webkit-user-drag: none; user-drag: none; }

/* ------------------------------------------------------------- printing */
/* Print to PDF is the easy way to take a whole paper away, and it is the one
   capture route the browser does hand us. The paper is replaced with a line
   explaining itself rather than silently vanishing, because a blank page
   reads as a bug and generates an email. */
/* The replacement line is real text in the page rather than CSS `content`,
   so it is one translatable string in one file and not a sentence hidden in
   a stylesheet where nobody looking for the wording would find it. */
.iprint { display: none; }

@media print {
  [data-protect] { display: none !important; }
  .pwm { display: none !important; }
  .iprint {
    display: block;
    padding: 2rem 0;
    font: 500 13pt/1.55 "Public Sans", system-ui, sans-serif;
    color: #111827;
  }
}

/* ------------------------------------------------- the capture notice */
/* Shown when the page is told a screenshot key was pressed. It is a panel
   and not a toast, because a message that fades out is a message a student
   can honestly say they did not read, and the whole value of this one is
   that it was read before anything was at stake.

   It is drawn by protect.js, which appends it to <body>, so these rules
   cannot rely on any page's own wrapper being there. */
.pcap {
  position: fixed;
  z-index: 200;
  inset: auto 1rem 1rem auto;
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.15rem 1.25rem 1.25rem;
  border: 1px solid #E5E7EB;
  border-left: 4px solid #C2762B;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(10, 34, 64, .18);
  font: 400 .95rem/1.55 "Public Sans", system-ui, sans-serif;
  color: #111827;
}

/* The suspension is not a corner notice. It takes the middle of the screen,
   because the student has just been signed out and every link behind it is
   about to fail; a message tucked in a corner would leave them clicking. */
.pcap--hard {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(30rem, calc(100vw - 2rem));
  border-left-color: #B42318;
}

.pcap__h {
  margin: 0 0 .5rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: #0A2240;
}

.pcap__p { margin: 0 0 .7rem; }
.pcap__p:last-of-type { margin-bottom: 1rem; }

.pcap__b {
  display: inline-block;
  padding: .5rem 1.1rem;
  border: 0;
  border-radius: 7px;
  background: #0A2240;
  color: #fff;
  font: 600 .92rem/1.2 inherit;
  cursor: pointer;
}
.pcap__b:hover { background: #123A69; }
.pcap__b:focus-visible { outline: 3px solid #C2762B; outline-offset: 2px; }

/* Never on paper, and never in a screenshot of the paper either: the notice
   is about the capture, not part of the material. */
@media print { .pcap { display: none !important; } }
