/* X-ray torch: an image with a circular lens that reveals a second image beneath it.
   Works with torch.js. Without JS the plain top image shows and nothing else.
   Turn it off for a page or one image with data-torch="off" on the component (or any parent). */

.torch{
  --torch-ar:3/2;
  --tx:50%; --ty:50%; --tr:0px; --full:0; --uo:0; --ro:0;
  position:relative;display:block;width:100%;aspect-ratio:var(--torch-ar);
  border-radius:var(--radius,10px);overflow:hidden;background:var(--soft,#f8faff);
  isolation:isolate;touch-action:pan-y;-webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;user-select:none;
}
.torch:focus{outline:0}
.torch:focus-visible{outline:3px solid var(--teal,#26aac3);outline-offset:3px}

/* both layers fill the box exactly, so there is no layout shift and the two stay aligned */
.torch>img.torch-top,.torch>img.torch-under{position:absolute;inset:0;width:100%;height:100%;max-width:none;max-height:none;border-radius:0;object-fit:cover;object-position:50% 50%;pointer-events:none;-webkit-user-drag:none}
.torch>img.torch-under{
  opacity:var(--uo);
  -webkit-mask-image:radial-gradient(circle at var(--tx) var(--ty),#000 0,#000 calc(var(--tr) * .66),transparent calc(var(--tr) * .94)),linear-gradient(rgba(0,0,0,var(--full)),rgba(0,0,0,var(--full)));
  mask-image:radial-gradient(circle at var(--tx) var(--ty),#000 0,#000 calc(var(--tr) * .66),transparent calc(var(--tr) * .94)),linear-gradient(rgba(0,0,0,var(--full)),rgba(0,0,0,var(--full)));
}

/* the ring: thin brand teal, a hairline of white outside it so it reads on dark and light pictures */
.torch-ring{
  position:absolute;left:0;top:0;z-index:2;pointer-events:none;
  width:calc(var(--tr) * 1.92);height:calc(var(--tr) * 1.92);
  margin:calc(var(--tr) * -.96) 0 0 calc(var(--tr) * -.96);
  transform:translate3d(var(--tpx,0px),var(--tpy,0px),0);
  border-radius:50%;border:1.5px solid var(--teal,#26aac3);
  box-shadow:0 0 0 1px rgba(255,255,255,.35),0 0 0 1px rgba(255,255,255,.35) inset,0 6px 26px rgba(11,29,54,.28);
  background:radial-gradient(circle,transparent 62%,rgba(38,170,195,.16) 100%);
  opacity:var(--ro);
}
.torch-label{
  position:absolute;left:50%;bottom:0;transform:translate(-50%,50%);white-space:nowrap;
  display:inline-flex;align-items:center;gap:.5em;padding:.34em .8em .34em .7em;border-radius:99px;
  font-size:.7rem;font-weight:600;letter-spacing:.12em;text-transform:uppercase;line-height:1.2;
  color:#fff;background:rgba(11,29,54,.86);box-shadow:0 2px 10px rgba(11,29,54,.3);
}
.torch-label::before{content:"";width:.5em;height:.5em;border-radius:50%;background:var(--teal,#26aac3)}
.torch.torch--label-top .torch-label{bottom:auto;top:0;transform:translate(-50%,-50%)}

/* small prompt, top left, goes once the visitor has found the lens */
.torch-hint{
  position:absolute;left:.75rem;top:.75rem;z-index:3;max-width:calc(100% - 1.5rem);pointer-events:none;
  padding:.4em .85em;border-radius:99px;font-size:.78rem;line-height:1.3;color:var(--ink,#14212e);
  background:rgba(255,255,255,.88);box-shadow:0 2px 10px rgba(11,29,54,.14);transition:opacity .4s;
}
.torch-hint .t{display:none}
.torch-hint .m{display:inline}
@media (hover:none){.torch-hint .t{display:inline}.torch-hint .m{display:none}}
.torch.torch--touched .torch-hint,.torch.torch--full .torch-hint{opacity:0}

/* the keyboard and touch alternative: a real button that fades the whole picture to the scan and back */
.torch-toggle{
  position:absolute;right:.75rem;bottom:.75rem;z-index:3;cursor:pointer;border:0;font:inherit;
  display:inline-flex;align-items:center;gap:.55em;padding:.7em 1.1em .7em 1.2em;
  font-size:.78rem;font-weight:600;letter-spacing:.06em;text-transform:uppercase;line-height:1.1;color:#fff;
  background:rgba(11,29,54,.86);
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  clip-path:polygon(0 0,calc(100% - 10px) 0,100% 10px,100% 100%,0 100%);
  transition:background .25s;
}
.torch-toggle::before{content:"";width:.62em;height:.62em;border-radius:50%;border:1.5px solid var(--teal,#26aac3);background:transparent;transition:background .25s}
.torch-toggle:hover{background:var(--navy-2,#2b5598)}
.torch-toggle[aria-pressed="true"]::before{background:var(--teal,#26aac3)}
.torch-toggle:focus-visible{outline:3px solid var(--teal,#26aac3);outline-offset:-3px}

/* progressive enhancement: the extra pieces only exist once torch.js has set the component up */
.torch:not(.torch--ready) .torch-ring,.torch:not(.torch--ready) .torch-hint,.torch:not(.torch--ready) .torch-toggle,.torch:not(.torch--ready)>img.torch-under{display:none}

/* off switch: data-torch="off" on the component, or on any parent, shows the plain top image only */
.torch[data-torch="off"] .torch-ring,.torch[data-torch="off"] .torch-hint,.torch[data-torch="off"] .torch-toggle,.torch[data-torch="off"]>img.torch-under,
[data-torch="off"] .torch .torch-ring,[data-torch="off"] .torch .torch-hint,[data-torch="off"] .torch .torch-toggle,[data-torch="off"] .torch>img.torch-under{display:none}
.torch[data-torch="off"],[data-torch="off"] .torch{touch-action:auto;cursor:auto}

/* lens cursor while the mouse is over the picture */
.torch.torch--ready:not(.torch--full){cursor:crosshair}
.torch.torch--ready.torch--full{cursor:default}

@media (max-width:560px){
  .torch-label{font-size:.62rem}
  .torch-toggle{font-size:.72rem;padding:.65em 1em .65em 1.1em}
  .torch-hint{font-size:.72rem}
}
/* reduced motion: the lens still works, it just doesn't ease, grow or fade (torch.js skips the easing too) */
@media (prefers-reduced-motion:reduce){
  .torch-hint,.torch-toggle,.torch-toggle::before{transition:none}
}
