/* Liquid glass, from the build in isotau (method: Armagan Amcalar's
   liquid-glass-js, MIT). Class renamed lglass: the app already has a .glass. */
/* Liquid glass. Pair with files/glass.js, which builds the lens per element.
   The element keeps its own content and layout; everything here sits behind or
   over it, so an existing panel can be made of glass without being rebuilt. */

.lglass {
  position: relative;
  isolation: isolate;
  background: rgba(255, 255, 255, calc(var(--glass-tint, 0.07) * 0.55));
  border-radius: inherit;
  /* the lens itself: blur what is behind, then bend it through the map */
  -webkit-backdrop-filter: blur(var(--glass-blur, 7px)) saturate(1.22) var(--glass-filter, none);
  backdrop-filter: blur(var(--glass-blur, 7px)) saturate(1.22) var(--glass-filter, none);
  box-shadow:
    0 1px 1px rgba(255, 255, 255, 0.22) inset,
    0 -1px 1px rgba(0, 0, 0, 0.12) inset,
    0 10px 30px -14px rgba(0, 0, 0, 0.45);
}

/* The bright edge. A real one is brightest where the surface turns away from
   you, so it runs strongest along the top-left and fades round the sides. */
.lglass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.62) 0%,
    rgba(255, 255, 255, 0.14) 28%,
    rgba(255, 255, 255, 0.04) 55%,
    rgba(255, 255, 255, 0.34) 100%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}

/* A wash across the top, the way light sits on a curved surface. */
.lglass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, calc(var(--glass-tint, 0.07) * 1.6)) 0%,
    rgba(255, 255, 255, 0) 42%
  );
  pointer-events: none;
  z-index: 1;
}

.lglass > * { position: relative; z-index: 2; }

/* Nothing to bend: no backdrop-filter, or the viewer has asked for less
   transparency. A readable panel rather than a broken lens. */
.lglass-flat {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: rgba(255, 255, 255, 0.1);
}
.lglass-flat::after { display: none; }

@media (prefers-reduced-transparency: reduce) {
  .lglass {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.1);
  }
  .lglass::after { display: none; }
}

/* On a dark page the wash reads as haze rather than light, so it is pulled back
   and the rim does the work. */
@media (prefers-color-scheme: dark) {
  .lglass {
    background: rgba(255, 255, 255, calc(var(--glass-tint, 0.07) * 0.3));
    box-shadow:
      0 1px 1px rgba(255, 255, 255, 0.14) inset,
      0 -1px 1px rgba(0, 0, 0, 0.3) inset,
      0 12px 34px -16px rgba(0, 0, 0, 0.7);
  }
}
