/* The Mangekyo lens (lens.js): an x-ray of the page inside a circle that follows the pointer,
   plus margin notes that only exist inside it. Everything here is inert to clicks. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.lens, .lens-notes, .lens-marks, .lens-reticle { position: fixed; pointer-events: none; display: none; }
.lens-on .lens, .lens-on .lens-notes, .lens-on .lens-marks, .lens-on .lens-reticle { display: block; }
.lens-on .cursor-ring { opacity: 0; }

/* The x-ray: the page underneath, inverted to a bone-white negative and washed in crimson. */
.lens {
  left: 0;
  top: 0;
  z-index: 34;
  border-radius: 50%;
  overflow: hidden;
  -webkit-backdrop-filter: invert(1) grayscale(1) contrast(1.35) brightness(.92);
  backdrop-filter: invert(1) grayscale(1) contrast(1.35) brightness(.92);
  background: radial-gradient(circle closest-side, rgba(150, 18, 24, .34), rgba(110, 8, 14, .62) 92%, rgba(217, 54, 57, .9));
}
/* Construction lines: the layout grid the page is built on, visible only through the lens. */
.lens-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(10, 10, 11, .22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 10, 11, .22) 1px, transparent 1px),
    linear-gradient(rgba(10, 10, 11, .1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 10, 11, .1) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
  background-attachment: fixed;
}

/* Notes: above the x-ray; each one fades in whole when the lens finds its pin. */
.lens-notes { inset: 0; z-index: 38; }
.xn { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity .25s ease; }
.xn.is-found { opacity: 1; }
.xn .xn-card { transform: translateY(4px); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.xn.is-found .xn-card { transform: none; }
.xn-dot {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid #0a0a0b; background: var(--red, #d93639); box-shadow: 0 0 0 4px rgba(217, 54, 57, .25);
}
.xn-line { position: absolute; left: 5px; top: 0; width: 30px; height: 1px; background: #0a0a0b; }
.xn-card {
  position: absolute; left: 35px; top: -14px; width: min(250px, 62vw); margin: 0;
  padding: 10px 12px 11px; background: #0a0a0b; color: #eae7df; border-left: 2px solid var(--red, #d93639);
  font: 500 12px/1.5 var(--sans, "Manrope", sans-serif); letter-spacing: 0; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.xn-id { display: block; margin-bottom: 4px; font: 10px var(--mono, "IBM Plex Mono", monospace); letter-spacing: 1.4px; color: #ef5557; }
.xn.is-left .xn-line { left: auto; right: 5px; }
.xn.is-left .xn-card { left: auto; right: 35px; }
.xn.is-up .xn-card { top: auto; bottom: -14px; }

/* Where the notes are: faint crosshairs outside the lens, so there is a reason to look. */
.lens-marks { inset: 0; z-index: 35; }
.xn-mark { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.xn-mark::before, .xn-mark::after { content: ""; position: absolute; background: rgba(239, 85, 87, .75); transition: opacity .2s; }
.xn-mark.is-found::before, .xn-mark.is-found::after { opacity: 0; }
.xn-mark::before { left: -6px; top: -.5px; width: 12px; height: 1px; }
.xn-mark::after { left: -.5px; top: -6px; width: 1px; height: 12px; }

/* The reticle around the lens. */
.lens-reticle { left: 0; top: 0; z-index: 37; width: 0; height: 0; }
.lens-reticle svg { width: 100%; height: 100%; overflow: visible; display: block; }
.lens-reticle circle, .lens-reticle line { fill: none; vector-effect: non-scaling-stroke; }
.r-edge { stroke: rgba(239, 85, 87, .95); stroke-width: 1.5; }
.r-ticks line { stroke: rgba(239, 85, 87, .8); stroke-width: 1; }
/* The dashed orbit turns as an HTML layer: rotating the SVG circle itself forces a layout every frame. */
.r-spin { position: absolute; inset: 0; animation: lens-orbit 24s linear infinite; will-change: transform; }
.r-orbit { stroke: rgba(234, 231, 223, .35); stroke-width: 1; stroke-dasharray: 2 7; }
.r-label { position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(-50%); white-space: nowrap; font-size: 10px; letter-spacing: 1.6px; color: #ef5557; }
@keyframes lens-orbit { to { transform: rotate(360deg); } }

/* Keep the close control above the lens. */
body.genjutsu-active .perception-toggle { z-index: 41; }

@media (max-width: 760px) {
  .xn-card { width: min(210px, 58vw); font-size: 11.5px; }
  .r-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .r-spin { animation: none; }
  .xn, .xn .xn-card { transition: none; }
}
