/* TEREZA'S WATCH — the memory CG test (js/dialogue-scenes/scene-tereza-watch-test.js).
   One square stage = the wrist photo (1254×1254); everything on it is
   placed in % of that square, so the stage can be any size. The dial
   (centre 612,607 · radius 170 px of the photo) is its own box. */
#twField {
  position: fixed; inset: 0; z-index: 2000050;
  background: #0b0908; overflow: hidden;
  opacity: 0; transition: opacity 1.2s ease;
  font-family: 'Courier Prime', 'Courier New', monospace;
  cursor: pointer;
}
#twField.tw-in { opacity: 1; }
/* the room behind the square, blurred, so a wide window is not two black bars */
#twField .tw-room {
  position: absolute; inset: -40px;
  background: url("../assets/images/scenes/tereza-watch/base.jpg") center / cover no-repeat;
  filter: blur(26px) brightness(0.45) saturate(0.8);
}
#twField .tw-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 38%, rgba(0,0,0,0.78) 100%);
}
#twField .tw-stage {
  position: absolute; left: 50%; top: 50%;
  width: min(var(--vh100, 100vh), var(--vw100, 100vw));
  height: min(var(--vh100, 100vh), var(--vw100, 100vw));
  transform: translate(-50%, -50%) scale(1);
  transform-origin: 48.8% 48.4%;
  transition: transform 3s cubic-bezier(0.45, 0, 0.2, 1);
}
/* the dial's centre lands a little above the middle, clear of the words */
#twField.tw-zoom .tw-stage { transform: translate(-50%, -50%) translate(1.2%, -5.2%) scale(2.55); }
#twField .tw-base { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* the dial: 340 px of 1254 = 27.11 %, top-left at (442, 437) */
#twField .tw-dial {
  position: absolute; left: 35.25%; top: 34.85%; width: 27.11%; height: 27.11%;
  border-radius: 50%; overflow: hidden;
}
/* the glass lights: the dial itself, inverted to cream with dark numerals */
#twField .tw-glass {
  position: absolute; inset: 0;
  background: url("../assets/images/scenes/tereza-watch/base.jpg") no-repeat;
  background-size: 368.82% 368.82%;
  background-position: 48.36% 47.81%;
  filter: invert(1) sepia(0.55) saturate(0.9) brightness(1.02) contrast(0.92);
  opacity: 0; transition: opacity 2.6s ease;
}
#twField.tw-lit .tw-glass { opacity: 1; }
/* the face is tilted on the wrist (−6.6°): what lives in the glass follows it */
#twField .tw-face { position: absolute; inset: 0; transform: rotate(-6.6deg); }

#twField .tw-frag {
  position: absolute; width: 64%; height: 64%;
  transform: translate(-50%, -50%) rotate(6.6deg);   /* upright: the face is tilted, the picture is not */
  background-size: cover; background-position: center;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 68%);
          mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 68%);
  filter: sepia(0.35) blur(1.4px);
  opacity: 0;
  transition: opacity 1.6s ease, filter 1.6s ease;
}
#twField .tw-frag.tw-seen  { opacity: 0.38; }                       /* a reflection */
#twField .tw-frag.tw-sharp { opacity: 1; filter: sepia(0.12) blur(0); }
/* plastic glass: one dull sheen across everything */
#twField .tw-sheen {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 2.6s ease;
  background: linear-gradient(128deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.04) 32%, transparent 48%, rgba(255,240,210,0.07) 78%, transparent 100%);
}
#twField.tw-lit .tw-sheen { opacity: 1; }

/* hands: pivot on the dial centre, origin = the ring of each hand */
#twField .tw-hand {
  position: absolute; display: block; opacity: 0;
  transition: transform 1.7s cubic-bezier(0.5, 0, 0.2, 1), opacity 1.6s ease;
  filter: drop-shadow(0 0.4px 0.6px rgba(0,0,0,0.45));
}
#twField.tw-lit .tw-hand { opacity: 1; }
#twField .tw-hand-hour   { left: 47.37%; top: 24%;  width: 5.26%; height: 28.63%; transform-origin: 50% 90.82%; }
#twField .tw-hand-minute { left: 47.66%; top: 7%;   width: 4.67%; height: 45.30%; transform-origin: 50% 94.85%; }
#twField .tw-hand-second { left: 48.13%; top: 5%;   width: 3.73%; height: 51.81%; transform-origin: 50% 86.85%;
  transition: opacity 1.6s ease; }
#twField .tw-cap {
  position: absolute; left: 50%; top: 50%; width: 4%; height: 4%; border-radius: 50%;
  transform: translate(-50%, -50%); background: #1a1714; opacity: 0; transition: opacity 1.6s ease;
}
#twField.tw-lit .tw-cap { opacity: 1; }

/* the words, under the picture */
#twField .tw-line {
  position: absolute; left: 50%; bottom: calc(var(--vh100, 100vh) * 0.07);
  transform: translateX(-50%); width: min(72ch, 86%);
  text-align: center; color: #ece4d2; font-size: 1.05rem; line-height: 1.6;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  opacity: 0; transition: opacity 0.9s ease;
}
#twField .tw-line.on { opacity: 1; }
#twField .tw-line .tw-hour {
  display: block; color: #c4a87a; font-size: 0.72rem; letter-spacing: 4px; margin-bottom: 0.35rem;
}
#twField .tw-hint {
  position: absolute; left: 50%; bottom: calc(var(--vh100, 100vh) * 0.025); transform: translateX(-50%);
  color: rgba(236,228,210,0.45); font-size: 0.62rem; letter-spacing: 4px;
}
#twField .tw-stamp {
  position: absolute; left: 18px; top: 16px; color: #8B0000; border: 2px solid #8B0000;
  padding: 2px 10px; font-size: 0.68rem; letter-spacing: 3px; opacity: 0.85; background: rgba(235,230,216,0.85);
}
#twField .tw-close {
  position: absolute; right: 18px; top: 14px; background: rgba(235,230,216,0.9); border: 1px solid #8E7F7F;
  color: #3A3238; font-family: inherit; letter-spacing: 2px; font-size: 0.7rem; padding: 5px 12px; cursor: pointer;
}

/* ── a memory opens to the whole screen (play({ enter })) ──
   ZOOM: the camera keeps going into the glass and goes soft; the memory
   comes up full size out of that blur behind a feathered vignette that
   widens to the edges — no hard circle, nothing flies (the author: "надто
   кострубато … картинка вилетіла"). FADE: it rises over the watch. Back
   out: the memory blurs and thins while the camera pulls back. */
#twField .tw-stage.tw-diving {
  transition: transform 2s cubic-bezier(0.6, 0, 0.35, 1), filter 1.1s ease;
}
#twField .tw-stage.tw-deep { filter: blur(0.22px); }
/* the hands step out of the way while the camera is in the glass */
#twField .tw-stage.tw-diving .tw-hand,
#twField .tw-stage.tw-diving .tw-cap { opacity: 0 !important; transition: opacity 0.7s ease; }
#twField .tw-mem {
  position: absolute; inset: 0; pointer-events: none;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  opacity: 0;
  transform: scale(1);
  filter: sepia(0.12) blur(14px);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 32%, transparent 70%);
          mask-image: radial-gradient(circle at 50% 50%, #000 32%, transparent 70%);
  -webkit-mask-size: 70% 70%;  mask-size: 70% 70%;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  transition: opacity 1.4s ease, transform 1.6s ease,
              filter 1.6s ease, -webkit-mask-size 2.2s ease, mask-size 2.2s ease;
}
#twField .tw-mem::after {               /* the memory keeps the room's dark edges */
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0,0,0,0.55) 100%);
}
#twField .tw-mem.tw-mem-zoom {
  opacity: 1; transform: scale(1);
  filter: sepia(0.12) blur(0);
  -webkit-mask-size: 420% 420%; mask-size: 420% 420%;
}
#twField .tw-mem.tw-mem-fadeprep {
  transform: scale(1.06);
  -webkit-mask-size: 420% 420%; mask-size: 420% 420%;
  filter: sepia(0.12) blur(10px);
}
#twField .tw-mem.tw-mem-fade { opacity: 1; transform: scale(1); filter: sepia(0.12) blur(0); }
/* a stand-in cut small from the composite: soft at this size anyway */
#twField .tw-mem.tw-mem-low.tw-mem-zoom,
#twField .tw-mem.tw-mem-low.tw-mem-fade { filter: sepia(0.12) blur(1.6px); }
