/* ============================================================
   krimsky/prism.css
   The draggable prism instrument.

   The glass body, wedge gradient, chromatic fringe and printed power
   numeral are drawn as SVG by js/krimsky/ui/instrument-svg.js, so this
   file only owns layout, interaction state and the drop shadow.

   POSITIONING MODEL — small at rest, full size in use, matching the
   penlight and cover paddle already in this exam:
     js/krimsky/drag.js drives `transform: translate(x,y) scale(s)` from
     a fixed `left:0; top:0` origin. `translate()` anchors the element's
     UNSCALED top-left corner; `scale()` (default transform-origin:
     centre) then grows/shrinks the box symmetrically around one fixed
     logical centre point. That is what lets the resting dock icon and
     the full anatomical size share one motion — the centre never moves,
     so the transition between them is a plain, jump-free CSS animation
     on `transform`. Base-direction rotation stays on an inner `<g>`
     inside the SVG, so it never competes with this outer transform.
   ============================================================ */

/* Dock slot in the tool bar (moved here from the retired panel.css) */
#krimsky-dock-slot { display: none; transition: opacity var(--k-dur-mid) ease; }
#krimsky-dock-slot[data-relevant="true"] { display: flex; }

.krimsky-prism {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 50;
  /* Size is set in px by instrument-render.js from the instrument's real
     millimetre specification against the rendered cornea (Instr §8.1).
     These are only a pre-paint fallback. */
  width: var(--k-prism-w);
  height: var(--k-prism-h);

  cursor: grab;
  user-select: none;
  touch-action: none;     /* required for Pointer Events on touch screens */

  display: grid;
  place-items: center;

  filter: drop-shadow(4px 6px 10px rgba(0, 0, 0, 0.42));

  /* JS sets style.transition = "none" for instant repositioning (drag
     tracking, first paint) and style.transition = "" to fall back to
     this rule for the animated pick-up/dock-return spring. */
  transition:
    transform var(--k-dur-slow) var(--k-ease-spring),
    opacity   var(--k-dur-mid)  ease,
    filter    var(--k-dur-mid)  var(--k-ease-snap);
}

.krimsky-prism > svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;   /* the host div owns all pointer handling */
}

/* A Fresnel is a 1 mm membrane, not a wedge — it should not cast the
   chunky shadow a solid glass prism does (Instr §4.2). */
.krimsky-prism[data-instrument="fresnel"] {
  filter: drop-shadow(1px 2px 4px rgba(0, 0, 0, 0.28));
}

/* ----------------------------------------------------------------
   Hidden when the tool is not relevant to the current condition
   ---------------------------------------------------------------- */
.krimsky-prism[data-relevant="false"] { display: none; }

/* ----------------------------------------------------------------
   DRAGGING — position tracks the pointer every event, so its own
   transition is disabled inline by drag.js; only visual polish here.
   ---------------------------------------------------------------- */
.krimsky-prism.is-dragging {
  cursor: grabbing;
  opacity: 0.94;
  z-index: 200;
  filter:
    drop-shadow(8px 12px 20px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 10px var(--k-accent-glow));
}

/* ----------------------------------------------------------------
   Placed over an eye
   ---------------------------------------------------------------- */
.krimsky-prism[data-eye="OD"],
.krimsky-prism[data-eye="OS"] {
  filter:
    drop-shadow(3px 5px 9px rgba(0, 0, 0, 0.42))
    drop-shadow(0 0 14px rgba(79, 195, 247, 0.5));
}

/* The prism sits on the fixating eye in the classic technique and on the
   deviating eye in the modified one. Tinting the halo by role keeps that
   readable at a glance without a text lookup (Ref §1). */
.krimsky-prism[data-role="deviating"] {
  filter:
    drop-shadow(3px 5px 9px rgba(0, 0, 0, 0.42))
    drop-shadow(0 0 14px rgba(255, 183, 77, 0.5));
}

@media (prefers-reduced-motion: reduce) {
  .krimsky-prism { transition: opacity var(--k-dur-mid) ease !important; }
}

/* ----------------------------------------------------------------
   Live drag target — while the prism is actively being dragged
   (js/krimsky/drag.js), the eye zone currently under it lights up
   with a ring so the examiner can see where release will land it,
   using the exact same hit-test the drop itself uses.
   ---------------------------------------------------------------- */
.eye-zone.is-krimsky-target .eye-svg-wrap::after {
  content: "";
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  border: 2px solid var(--k-accent);
  box-shadow:
    0 0 0 6px var(--k-accent-subtle),
    0 0 22px var(--k-accent-glow);
  pointer-events: none;
  z-index: 6;
  animation: k-target-in var(--k-dur-fast) var(--k-ease-snap);
}

@keyframes k-target-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .eye-zone.is-krimsky-target .eye-svg-wrap::after { animation: none; }
}
