/*
  ELVN Specular — a glass button whose rim catches a moving point of light.

  Original ELVN work (2026-11-12). Written from a description of the
  behaviour Matthew selected (React Bits "Specular" button, option 04): a
  bright highlight on the rim that slides round toward the pointer, a
  fainter answering highlight on the opposite side, a quiet hairline rim at
  rest, a soft halo, and a flash when pressed. No React Bits code, shader or
  markup is used: this version is plain CSS (a conic-gradient ring) driven by
  a few lines of JavaScript (elvn-specular.js) that only set two numbers.

  Use: add class "specular" to a button or link that already has the V3
  .control look (or any rounded element). Without JavaScript it shows the
  resting highlight at the top-left, the same light direction as the rest of
  the V3 material.

  Custom properties (set by elvn-specular.js, safe defaults here):
    --sp-angle  where the highlight sits, degrees clockwise from the top
    --sp-level  how bright it is, 0..1.6 (resting ~.38, pointer near 1, press flash above 1)
*/

.specular {
  --sp-angle: 315deg;
  --sp-level: 0.38;
  --sp-color: 255, 255, 255;
  --sp-rim: 2px;
  position: relative;
  isolation: isolate;
}

/* The ring: a hairline that is brightest at --sp-angle and again, more
   faintly, directly opposite. */
.specular > .sp-rim,
.specular > .sp-halo {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    conic-gradient(from var(--sp-angle),
      rgba(var(--sp-color), var(--sp-level)) 0deg,
      rgba(var(--sp-color), calc(var(--sp-level) * 0.35)) 22deg,
      rgba(var(--sp-color), 0) 48deg,
      rgba(var(--sp-color), 0) 140deg,
      rgba(var(--sp-color), calc(var(--sp-level) * 0.42)) 180deg,
      rgba(var(--sp-color), 0) 220deg,
      rgba(var(--sp-color), 0) 312deg,
      rgba(var(--sp-color), calc(var(--sp-level) * 0.35)) 338deg,
      rgba(var(--sp-color), var(--sp-level)) 360deg),
    linear-gradient(rgba(var(--sp-color), 0.16), rgba(var(--sp-color), 0.16));
}
.specular > .sp-rim {
  z-index: 2;
  padding: var(--sp-rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
/* The halo: the same light, softened, spilling just past the rim. */
.specular > .sp-halo {
  z-index: 0;
  inset: -3px;
  padding: 4px;
  filter: blur(5px);
  opacity: 0.8;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.specular:active { transform: scale(0.98); }

@media (prefers-reduced-motion: reduce) {
  .specular:active { transform: none; }
}
@media (forced-colors: active) {
  .specular > .sp-rim, .specular > .sp-halo { display: none; }
}
