/* Liquid glass — Apple-style, built from stacked layers.
 *
 *   __effect  the backdrop: lightly blurred, then refracted by an SVG
 *             displacement map generated in js/liquid-glass.js. The map
 *             concentrates distortion at the bezel and leaves the centre
 *             clear, which is what separates glass from frosting.
 *   __tint    a translucent wash so the element reads as a solid object
 *   __shine   inset speculars along the bevel
 *   content   sits above all three
 *
 * No hover state: the material is static by design.
 */

.liquid-glass {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 6px 18px rgb(22 44 37 / 0.16),
    0 0 24px rgb(22 44 37 / 0.06);
}

/* Every layer must carry the wrapper's radius or the corners tear. */
.liquid-glass > .liquid-glass__effect,
.liquid-glass > .liquid-glass__tint,
.liquid-glass > .liquid-glass__shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.liquid-glass__effect {
  z-index: 0;
  overflow: hidden;
  /* The refractive backdrop-filter is assigned at runtime, once the map has
     been generated at the element's real size. */
}

/* Where the SVG displacement can't run, lean on blur alone so the material
   still separates from what's behind it. */
[data-glass-distortion='off'] .liquid-glass__effect {
  -webkit-backdrop-filter: blur(18px) saturate(180%) brightness(1.06);
  backdrop-filter: blur(18px) saturate(180%) brightness(1.06);
}

.liquid-glass__tint {
  z-index: 1;
  background: rgb(255 255 255 / 0.38);
}

.liquid-glass__shine {
  z-index: 2;
  box-shadow:
    inset 2px 2px 1px 0 rgb(255 255 255 / 0.6),
    inset -1px -1px 1px 1px rgb(255 255 255 / 0.5);
}

/* --- Dark tone, over imagery -------------------------------------------- */

.liquid-glass[data-tone='dark'] .liquid-glass__tint {
  background: rgb(18 24 22 / 0.4);
}

.liquid-glass[data-tone='dark'] .liquid-glass__shine {
  box-shadow:
    inset 2px 2px 1px 0 rgb(255 255 255 / 0.25),
    inset -1px -1px 1px 1px rgb(255 255 255 / 0.16);
}

/* --- Fallback ------------------------------------------------------------ */

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .liquid-glass__tint {
    background: rgb(var(--c-paper-rgb) / 0.95);
  }
  .liquid-glass[data-tone='dark'] .liquid-glass__tint {
    background: rgb(18 24 22 / 0.92);
  }
}
