/* =====================================================================
   LIQUID GLASS — layered translucent material system (macOS 27)
   Core recipe per surface:
     • backdrop blur + saturation (frost)
     • layered background gradients (specular sheen)
     • hairline rim (border) + multi inset shadows (edge lensing)
     • outer drop shadow (depth)
   Optional .glass--refract adds SVG displacement (liquid refraction).
   ===================================================================== */

.glass {
  position: relative;
  color: var(--glass-text);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.30), rgba(255,255,255,0) 42%),
    linear-gradient(to bottom, rgba(255,255,255,.16), rgba(255,255,255,0) 34%),
    radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.10), rgba(255,255,255,0) 60%),
    rgba(var(--glass-tint), var(--glass-tint-a));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)) brightness(1.06);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)) brightness(1.06);
  border: 0.5px solid var(--glass-stroke);
  box-shadow:
    0 10px 34px rgba(0,0,0,.20),
    0 2px 8px rgba(0,0,0,.12),
    inset 0 1px 0.5px rgba(255,255,255,.55),      /* top rim light */
    inset 0 0 0 0.5px rgba(255,255,255,.10),       /* inner ring */
    inset 0 -8px 20px rgba(255,255,255,.05),       /* lower bloom */
    inset 0 -1px 1px rgba(0,0,0,.10);              /* bottom shade */
}
:root[data-theme="dark"] .glass {
  background:
    linear-gradient(135deg, rgba(255,255,255,.14), rgba(255,255,255,0) 42%),
    linear-gradient(to bottom, rgba(255,255,255,.08), rgba(255,255,255,0) 34%),
    radial-gradient(120% 100% at 50% 0%, rgba(255,255,255,.06), rgba(255,255,255,0) 60%),
    rgba(var(--glass-tint), var(--glass-tint-a));
  box-shadow:
    0 12px 40px rgba(0,0,0,.5),
    0 2px 10px rgba(0,0,0,.4),
    inset 0 1px 0.5px rgba(255,255,255,.20),
    inset 0 0 0 0.5px rgba(255,255,255,.05),
    inset 0 -8px 24px rgba(255,255,255,.02),
    inset 0 -1px 1px rgba(0,0,0,.35);
}

/* Liquid refraction layer (opt-in; needs direct children) */
.glass--refract { isolation: isolate; }
.glass--refract::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: url(#glass-distortion) blur(1px);
  -webkit-backdrop-filter: blur(1px);
  z-index: 0;
  pointer-events: none;
  opacity: .55;
}
.glass--refract > * { position: relative; z-index: 1; }

/* Pill / capsule shape used a lot in Liquid Glass */
.glass--pill { border-radius: 999px; }
.glass--round { border-radius: 50%; }

/* Interactive glass (buttons/controls): brighten & lift on hover, press in */
.glass-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--glass-text);
  font-size: 13px;
  font-weight: 500;
  background:
    linear-gradient(135deg, rgba(255,255,255,.35), rgba(255,255,255,.05) 55%),
    rgba(var(--glass-tint), calc(var(--glass-tint-a) * .9));
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 0.5px solid var(--glass-stroke);
  box-shadow:
    0 2px 8px rgba(0,0,0,.14),
    inset 0 1px 0.5px rgba(255,255,255,.6),
    inset 0 -1px 1px rgba(0,0,0,.08);
  transition: transform .12s var(--ease-out), box-shadow .16s, filter .16s, background .16s;
}
.glass-btn:hover { filter: brightness(1.08); transform: translateY(-0.5px); }
.glass-btn:active { transform: translateY(0.5px) scale(.98); filter: brightness(.96); }
.glass-btn.primary {
  color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,0) 45%), var(--accent);
  border-color: rgba(255,255,255,.3);
}

/* Generic hover highlight used in lists/menus */
.hoverfill { transition: background .12s; border-radius: 8px; }
.hoverfill:hover { background: var(--control-bg); }

/* Accent-filled selection (menus, sidebar) */
.accentfill { background: var(--accent) !important; color: #fff !important; }
.accentfill * { color: #fff !important; }

/* Toggle switch */
.switch {
  --w: 40px; --h: 24px;
  width: var(--w); height: var(--h);
  border-radius: 999px;
  background: rgba(120,120,128,.32);
  position: relative;
  transition: background .22s var(--ease-out);
  flex: none;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: calc(var(--h) - 4px); height: calc(var(--h) - 4px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.28), 0 0 0 .5px rgba(0,0,0,.06);
  transition: transform .22s var(--ease-spring);
}
.switch.on { background: #34c759; }
.switch.on::after { transform: translateX(calc(var(--w) - var(--h))); }
.switch.accent.on { background: var(--accent); }

/* Slider */
.slider { position: relative; height: 26px; display: flex; align-items: center; cursor: pointer; flex: 1; }
.slider-track { height: 5px; border-radius: 3px; background: rgba(120,120,128,.3); width: 100%; overflow: hidden; }
.slider-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.slider-knob {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3), 0 0 0 .5px rgba(0,0,0,.08);
  transform: translateX(-50%);
}

/* Segmented control */
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--control-bg); gap: 2px; }
.segmented button { padding: 4px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--glass-text); }
.segmented button.sel { background: rgba(var(--glass-tint), .9); box-shadow: 0 1px 3px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.4); }
:root[data-theme="dark"] .segmented button.sel { background: rgba(120,120,128,.5); }

/* Focus ring */
.focusring:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2.5px solid rgba(var(--accent-rgb), .6); outline-offset: 1px; }
