/* ============================================================
   NIGHT ONE — THE FACE (scene-night1-face.js)
   After the freezer he lies back down. No clock runs: a face
   comes up out of the dark, takes the cold, cracks and comes
   apart, and between the pictures a voice says its four lines.
   Sized in percentages of the overlay — the page is zoomed, so
   vh/vw would run past the glass.
   ============================================================ */
#n1Face {
  position: fixed;
  inset: 0;
  z-index: 1000020;
  background: #000;
  opacity: 0;
  transition: opacity 0.9s ease;
  overflow: hidden;
  cursor: default;
  user-select: none;
}
#n1Face.n1f-up  { opacity: 1; }
#n1Face.n1f-out { opacity: 0; transition: opacity 1.3s ease; pointer-events: none; }

/* the face: five pictures on one spot, slowly coming nearer */
#n1Face .n1f-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(1);
  transition: opacity 0.18s ease;       /* back from a line: at once, the crack is waiting */
}
#n1Face.n1f-run .n1f-stage { animation: n1fNear 23s linear forwards; }
#n1Face .n1f-frames {
  position: relative;
  height: 96%;
  aspect-ratio: 1 / 1;
  max-width: 96%;
}
#n1Face .n1f-frames img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1.5s ease;
  pointer-events: none;
  -webkit-user-drag: none;
}
#n1Face .n1f-frames img.n1f-on   { opacity: 1; }
#n1Face .n1f-frames img.n1f-slow { transition-duration: 2.6s; }
#n1Face .n1f-frames img.n1f-snap { transition-duration: 0.22s; }
/* the last picture goes outward and out */
#n1Face .n1f-frames img.n1f-gone {
  opacity: 0;
  transform: scale(1.4);
  filter: blur(3px);
  transition: opacity 2.5s ease-in, transform 2.6s ease-out, filter 2.6s ease-in;
}

/* a line is said: the face steps back into the dark */
#n1Face.n1f-said .n1f-stage { opacity: 0.1; transition: opacity 0.7s ease; }

/* the crack: one hard frame, a small jump */
#n1Face .n1f-frames.n1f-jolt   { animation: n1fJolt 0.34s steps(1, end) 1; }
#n1Face .n1f-frames.n1f-jolt-2 { animation: n1fJoltHard 0.46s steps(1, end) 1; }

/* the cold comes into the grey */
#n1Face .n1f-tint {
  position: absolute;
  inset: 0;
  background: #7fa8d4;
  mix-blend-mode: color;
  opacity: 0;
  transition: opacity 3s ease;
  pointer-events: none;
}
#n1Face[data-cold="1"] .n1f-tint { opacity: 0.22; }
#n1Face[data-cold="2"] .n1f-tint { opacity: 0.38; }
#n1Face[data-cold="3"] .n1f-tint { opacity: 0.52; }
#n1Face[data-cold="4"] .n1f-tint { opacity: 0.64; }

/* frost grows in from the edges of the glass */
#n1Face .n1f-frost {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 3.4s ease;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 46%, rgba(150,190,225,0.10) 72%, rgba(205,228,246,0.30) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.82  0 0 0 0 0.91  0 0 0 0 1  0 0 0 0.9 -0.42'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0) 38%, rgba(0,0,0,0.55) 74%, #000 100%);
          mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0) 38%, rgba(0,0,0,0.55) 74%, #000 100%);
}
#n1Face[data-cold="1"] .n1f-frost { opacity: 0.25; }
#n1Face[data-cold="2"] .n1f-frost { opacity: 0.5; }
#n1Face[data-cold="3"] .n1f-frost { opacity: 0.75; }
#n1Face[data-cold="4"] .n1f-frost { opacity: 1; }

/* the voice */
#n1Face .n1f-word {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-family: 'Special Elite', 'Courier Prime', 'Courier New', Courier, monospace;
  font-size: 1.85rem;
  line-height: 1.5;
  letter-spacing: 0.14em;
  color: #dce8f4;
  text-shadow: 0 0 18px rgba(150, 195, 235, 0.55), 0 0 2px rgba(255, 255, 255, 0.5);
  opacity: 0;
  filter: blur(7px);
  transition: opacity 0.8s ease, filter 0.9s ease;
  pointer-events: none;
}
#n1Face .n1f-word.n1f-on  { opacity: 1; filter: blur(0); }
/* the last line stays up while the face goes: the face only half steps back */
#n1Face.n1f-half .n1f-stage { opacity: 0.4; transition: opacity 0.7s ease; }
#n1Face .n1f-word.n1f-low { text-shadow: 0 0 10px #000, 0 0 26px #000, 0 0 18px rgba(150, 195, 235, 0.55); }

/* the white of the wake */
#n1Face .n1f-flash {
  position: absolute;
  inset: 0;
  background: #e9f2fa;
  opacity: 0;
  pointer-events: none;
}
#n1Face .n1f-flash.n1f-on { animation: n1fFlash 1.1s ease-out 1; }

@keyframes n1fNear { from { transform: scale(1); } to { transform: scale(1.1); } }
@keyframes n1fJolt {
  0%   { filter: brightness(2.1) contrast(1.3); transform: translate(3px, -2px); }
  30%  { filter: brightness(0.55); transform: translate(-3px, 2px); }
  60%  { filter: brightness(1.35); transform: translate(1px, 1px); }
  100% { filter: none; transform: none; }
}
@keyframes n1fJoltHard {
  0%   { filter: brightness(2.6) contrast(1.4); transform: translate(6px, -4px) scale(1.015); }
  20%  { filter: brightness(0.4); transform: translate(-7px, 3px); }
  40%  { filter: brightness(1.8); transform: translate(4px, 4px) scale(1.01); }
  70%  { filter: brightness(0.8); transform: translate(-2px, -2px); }
  100% { filter: none; transform: none; }
}
@keyframes n1fFlash { 0% { opacity: 0; } 12% { opacity: 0.85; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  #n1Face.n1f-run .n1f-stage { animation: none; }
  #n1Face .n1f-frames.n1f-jolt, #n1Face .n1f-frames.n1f-jolt-2 { animation: none; }
  #n1Face .n1f-flash.n1f-on { animation: none; }
}
