/*
 * Liquid glass material.
 *
 * Every browser gets frosted glass with a specular rim. In Chromium,
 * js/glass.js adds real refraction by swapping in an SVG displacement filter.
 * The rim and the inner sheen follow --light-angle, which js/glass.js points
 * at the cursor (or the phone's tilt).
 */

.glass {
  position: relative;
  isolation: isolate;
  color: var(--text);
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow: var(--glass-shadow);
  transition: --light-angle 700ms var(--ease-out);
}

/* Specular rim: a thin ring, brightest where the light hits and faintly lit opposite. */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1.5px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--light-angle),
    var(--rim-bright),
    var(--rim-soft) 10%,
    var(--rim-faint) 28%,
    var(--rim-soft) 50%,
    var(--rim-faint) 72%,
    var(--rim-soft) 90%,
    var(--rim-bright)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Sheen: soft light pooling inside the glass on the side the light comes from. */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(
    75% 75% at calc(50% + sin(var(--light-angle)) * 50%) calc(50% - cos(var(--light-angle)) * 50%),
    var(--sheen),
    transparent
  );
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .glass {
    transition: none;
  }
}
