/*
 * ScanGrade Version 1.2: the approved Effect F "Glass bloom" profile for the
 * existing open-lid copier pass.
 *
 * The lamp itself does not suddenly change output. From a few feet away,
 * however, the moving tube and glass briefly align with the viewer and the
 * reflected line passes through a broad, soft exposure window. Keep the
 * approved lamp artwork, speed, travel, and character unchanged. The bright
 * tube and broad spill share Effect F's exact 25-68% timing envelope while
 * retaining the approved Version 1.1 carriage motion and bottom fade.
 */
.sg-photocopy-pass {
  --sg-photocopy-viewer-pass-duration: 3.6s;
  transition: opacity 360ms cubic-bezier(0.16, 0.7, 0.2, 1);
}

.sg-photocopy-pass--preparing {
  opacity: 0;
}

.sg-photocopy-pass--preparing .sg-photocopy-lamp,
.sg-photocopy-pass--preparing .sg-photocopy-glow-layer,
.sg-photocopy-pass--preparing .sg-photocopy-bloom,
.sg-photocopy-pass--preparing .sg-photocopy-core-layer,
.sg-photocopy-pass--preparing .sg-photocopy-core {
  animation-play-state: paused !important;
}

.sg-photocopy-pass--leaving .sg-photocopy-core-layer {
  filter: opacity(0);
  transition: filter 170ms ease-out;
}

.sg-photocopy-lamp {
  opacity: 1;
  background: none;
  animation-name:
    sg-photocopier-open-lid-pass-v11-motion,
    sg-photocopier-viewer-glint-lamp;
  animation-duration:
    var(--sg-photocopy-viewer-pass-duration),
    var(--sg-photocopy-viewer-pass-duration);
  animation-timing-function: linear, linear;
  animation-iteration-count: infinite, infinite;
  animation-delay: 0s, var(--sg-photocopy-viewer-glint-delay, 0s);
}

.sg-photocopy-lamp::before,
.sg-photocopy-lamp::after {
  content: none;
}

.sg-photocopy-glow-layer,
.sg-photocopy-core-layer {
  position: absolute;
  inset: 0;
  display: block;
  will-change: opacity;
}

.sg-photocopy-glow-layer {
  background: linear-gradient(
    to bottom,
    rgba(160, 225, 255, 0),
    rgba(160, 225, 255, 0.04) 10%,
    rgba(190, 232, 255, 0.14) 24%,
    rgba(222, 246, 255, 0.34) 39%,
    rgba(242, 252, 255, 0.72) 48%,
    rgba(255, 255, 255, 0.86) 51%,
    rgba(207, 244, 255, 0.48) 59%,
    rgba(166, 235, 211, 0.11) 78%,
    rgba(166, 235, 211, 0)
  );
  animation: sg-photocopier-open-lid-pass-v11-glow-fade var(--sg-photocopy-viewer-pass-duration) linear infinite;
}

.sg-photocopy-core-layer {
  animation: sg-photocopier-open-lid-pass-v11-core-fade var(--sg-photocopy-viewer-pass-duration) linear infinite;
}

/* Effect F opens a broad bloom as the glass/tube reflection aligns with the
   observer. Keeping the added energy in the lamp, rather than flashing the
   whole photographed sheet, makes the cue visible without feeling digital. */
.sg-photocopy-bloom {
  position: absolute;
  top: 50%;
  left: -2%;
  right: -2%;
  display: block;
  height: 34px;
  background:
    radial-gradient(ellipse 19% 48% at 7% 48%, rgba(246, 254, 255, 0.38), rgba(181, 230, 250, 0.13) 52%, transparent 100%),
    radial-gradient(ellipse 23% 42% at 28% 54%, rgba(255, 255, 239, 0.42), rgba(199, 241, 247, 0.11) 57%, transparent 100%),
    radial-gradient(ellipse 17% 52% at 47% 46%, rgba(222, 248, 255, 0.31), rgba(183, 231, 245, 0.08) 61%, transparent 100%),
    radial-gradient(ellipse 24% 46% at 66% 53%, rgba(247, 255, 244, 0.40), rgba(184, 238, 220, 0.10) 56%, transparent 100%),
    radial-gradient(ellipse 20% 50% at 86% 47%, rgba(255, 252, 231, 0.37), rgba(195, 239, 238, 0.09) 58%, transparent 100%),
    linear-gradient(to bottom, transparent, rgba(189, 235, 251, 0.08) 27%, rgba(240, 253, 255, 0.18) 50%, rgba(181, 239, 215, 0.07) 72%, transparent);
  background-size: 112% 100%;
  transform: translateY(-50%);
  animation-name:
    sg-photocopier-bloom-variation,
    sg-photocopier-viewer-glint-bloom;
  animation-duration:
    1.32s,
    var(--sg-photocopy-viewer-pass-duration);
  animation-timing-function: steps(6, end), linear;
  animation-iteration-count: infinite, infinite;
  animation-delay: 0s, var(--sg-photocopy-viewer-glint-delay, 0s);
}

.sg-photocopy-core {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  display: block;
  height: 15px;
  background: linear-gradient(
    to right,
    rgba(197, 238, 253, 0.66),
    rgba(255, 255, 244, 0.98) 8%,
    rgba(211, 244, 255, 0.61) 17%,
    rgba(255, 255, 255, 0.96) 28%,
    rgba(187, 233, 248, 0.58) 41%,
    rgba(255, 255, 239, 0.99) 54%,
    rgba(204, 244, 239, 0.60) 66%,
    rgba(255, 252, 229, 0.96) 80%,
    rgba(188, 235, 211, 0.60)
  );
  background-size: 146% 100%;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent,
    rgba(0, 0, 0, 0.16) 14%,
    rgba(0, 0, 0, 0.76) 38%,
    #000 49%,
    rgba(0, 0, 0, 0.88) 58%,
    rgba(0, 0, 0, 0.24) 80%,
    transparent
  );
  mask-image: linear-gradient(
    to bottom,
    transparent,
    rgba(0, 0, 0, 0.16) 14%,
    rgba(0, 0, 0, 0.76) 38%,
    #000 49%,
    rgba(0, 0, 0, 0.88) 58%,
    rgba(0, 0, 0, 0.24) 80%,
    transparent
  );
  transform: translateY(-50%);
  animation-name:
    sg-photocopier-tube-variation,
    sg-photocopier-viewer-glint-core;
  animation-duration:
    840ms,
    var(--sg-photocopy-viewer-pass-duration);
  animation-timing-function: steps(5, end), linear;
  animation-iteration-count: infinite, infinite;
  animation-delay: 0s, var(--sg-photocopy-viewer-glint-delay, 0s);
}

@keyframes sg-photocopier-open-lid-pass-v11-motion {
  0% {
    transform: translateZ(0);
  }
  78% {
    transform: translate3d(0, 335%, 0);
  }
  80% {
    transform: translate3d(0, 346%, 0);
  }
  82% {
    transform: translate3d(0, 356%, 0);
  }
  84% {
    transform: translate3d(0, 366%, 0);
  }
  86% {
    transform: translate3d(0, 377%, 0);
  }
  88% {
    transform: translate3d(0, 388%, 0);
  }
  90% {
    transform: translate3d(0, 398%, 0);
  }
  92% {
    transform: translate3d(0, 406.8%, 0);
  }
  94% {
    transform: translate3d(0, 413.8%, 0);
  }
  100% {
    transform: translate3d(0, 416.5%, 0);
  }
}

@keyframes sg-photocopier-open-lid-pass-v11-glow-fade {
  0% { opacity: 0; }
  0.35% { opacity: 0.16; }
  1.2% { opacity: 0.52; }
  2.4%, 78% { opacity: 1; }
  80% { opacity: 0.96; }
  82% { opacity: 0.88; }
  84% { opacity: 0.76; }
  86% { opacity: 0.61; }
  88% { opacity: 0.46; }
  90% { opacity: 0.32; }
  92% { opacity: 0.19; }
  94% { opacity: 0.08; }
  96%, 100% { opacity: 0; }
}

@keyframes sg-photocopier-open-lid-pass-v11-core-fade {
  0% { opacity: 0; }
  0.35% { opacity: 0.14; }
  1.2% { opacity: 0.44; }
  2.4%, 88% { opacity: 0.88; }
  89.5% { opacity: 0.72; }
  91% { opacity: 0.42; }
  92.5% { opacity: 0.18; }
  93.5%, 100% { opacity: 0; }
}

@keyframes sg-photocopier-viewer-glint-lamp {
  0%, 25%, 68%, 100% {
    filter: brightness(1) drop-shadow(0 0 0 rgba(226, 248, 255, 0));
  }
  34%, 60% {
    filter: brightness(1.03) drop-shadow(0 0 2px rgba(226, 248, 255, 0.16));
  }
  40%, 55% {
    filter: brightness(1.08) drop-shadow(0 0 4px rgba(226, 248, 255, 0.34));
  }
  45%, 50% {
    filter: brightness(1.18) drop-shadow(0 0 7px rgba(226, 248, 255, 0.58));
  }
}

@keyframes sg-photocopier-viewer-glint-bloom {
  0%, 25%, 68%, 100% {
    filter: brightness(1) drop-shadow(0 0 0 rgba(226, 248, 255, 0));
    transform: translateY(-50%) scaleY(1);
  }
  34%, 60% {
    filter: brightness(1.10) drop-shadow(0 0 3px rgba(226, 248, 255, 0.22));
    transform: translateY(-50%) scaleY(1);
  }
  40%, 55% {
    filter: brightness(1.28) drop-shadow(0 0 7px rgba(226, 248, 255, 0.48));
    transform: translateY(-50%) scaleY(1);
  }
  45%, 50% {
    filter: brightness(1.64) drop-shadow(0 0 13px rgba(226, 248, 255, 0.78));
    transform: translateY(-50%) scaleY(1);
  }
}

@keyframes sg-photocopier-viewer-glint-core {
  0%, 25%, 68%, 100% {
    filter: brightness(1) drop-shadow(0 0 0 rgba(245, 254, 255, 0));
  }
  34%, 60% {
    filter: brightness(1.06) drop-shadow(0 0 2px rgba(245, 254, 255, 0.22));
  }
  40%, 55% {
    filter: brightness(1.15) drop-shadow(0 0 4px rgba(245, 254, 255, 0.42));
  }
  45%, 50% {
    filter: brightness(1.31) drop-shadow(0 0 7px rgba(245, 254, 255, 0.68));
  }
}

/* Make the current teacher-review target easier to track on photographed
   paper without changing the correction hotspot, queue, or keypad behavior.
   The entered/committing states deliberately keep the frozen app's immediate
   handoff to the next unresolved digit. */
.on-sheet-correction-focus:not(.on-sheet-correction-focus--entered):not(.on-sheet-correction-focus--committing) {
  border-width: 2px;
  border-color: rgba(68, 132, 205, 0.68);
  box-shadow:
    0 0 0 3px rgba(190, 230, 255, 0.28),
    0 0 10px rgba(92, 170, 230, 0.2);
  animation-name: sg-correction-focus-breathe-prominent;
}

@keyframes sg-correction-focus-breathe-prominent {
  0%,
  100% {
    border-color: rgba(68, 132, 205, 0.55);
    box-shadow:
      0 0 0 3px rgba(190, 230, 255, 0.24),
      0 0 9px rgba(92, 170, 230, 0.18);
  }
  50% {
    border-color: rgba(68, 132, 205, 0.78);
    box-shadow:
      0 0 0 5px rgba(196, 234, 255, 0.42),
      0 0 15px rgba(92, 170, 230, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sg-photocopy-pass {
    --sg-photocopy-viewer-pass-duration: 5.4s;
  }

  .sg-photocopy-lamp {
    animation-delay: 0s, var(--sg-photocopy-viewer-glint-delay-reduced, 0s);
  }

  .sg-photocopy-bloom,
  .sg-photocopy-core {
    animation-delay: 0s, var(--sg-photocopy-viewer-glint-delay-reduced, 0s);
  }
}
