﻿/* ==========================================================================
   glass.css — liquid glass: панели, рефракция, кнопки, ripple
   ========================================================================== */

/* ───────────────────────── Базовая стеклянная панель ─────────────────────────
   blur(24px) — это максимум. Всё, что больше, роняет FPS на встроенной графике.
   backdrop-filter живёт на самом элементе, а не на ::before: так браузер
   делает один проход блюра, а не два (экономия ~2×).
   ────────────────────────────────────────────────────────────────────────── */

.glass-liquid {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.045);
  /* brightness слегка поднимает преломлённый фон — так стекло читается
     как материал, а не как тёмный прямоугольник */
  backdrop-filter: blur(24px) saturate(180%) brightness(1.06);
  -webkit-backdrop-filter: blur(24px) saturate(180%) brightness(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    var(--shadow-deep);
}

/* Браузеры без backdrop-filter (старый Firefox/Safari): плотная матовая
   панель вместо прозрачной — интерфейс остаётся читаемым. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-liquid {
    background: rgba(16, 18, 26, 0.86);
  }
}

/* полированный блик сверху */
.glass-liquid::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 45%;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.16) 0%,
    rgba(255, 255, 255, 0.03) 40%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
}

.glass-liquid > * {
  position: relative;
  z-index: 1;
}

/* ───────────────────────── Рефракция ─────────────────────────
   SVG-фильтр из #liquid-glass. Включается только там, где это оправдано:
   крупные карточки и модалка. На мобильных и при reduced-transparency
   остаётся обычный блюр.
   ─────────────────────────────────────────────────────────────── */

@media (min-width: 900px) and (prefers-reduced-transparency: no-preference) {
  @supports (backdrop-filter: blur(1px)) {
    .glass-liquid--refract::after,
    .key-card::after,
    .modal__dialog--refract::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 0;
      pointer-events: none;
      border-radius: inherit;
      /* сначала обычный блюр — если браузер не умеет url()-фильтры в backdrop */
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      backdrop-filter: url(#liquid-glass) blur(12px);
      -webkit-backdrop-filter: url(#liquid-glass) blur(12px);
      opacity: 0.65;
      -webkit-mask-image: linear-gradient(155deg, #000 0%, transparent 62%);
      mask-image: linear-gradient(155deg, #000 0%, transparent 62%);
    }
  }
}

/* ───────────────────────── Кнопки ───────────────────────── */

.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.95em 1.7em;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 8px 24px rgba(0, 0, 0, 0.35);
  /* transform двигает magnetic.js, scale — ховер: свойства независимы */
  transition:
    scale var(--dur) var(--ease-back),
    box-shadow var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out);
}

.btn:hover {
  scale: 1.03;
  border-color: rgba(255, 255, 255, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 12px 34px rgba(0, 0, 0, 0.45);
}

.btn:active {
  scale: 0.985;
  transition-duration: 90ms;
}

.btn--acid {
  color: var(--bg-void);
  border-color: transparent;
  background-image: linear-gradient(100deg, var(--acid) 0%, #e8ff7a 30%, var(--acid) 55%, #9fd400 100%);
  background-size: 220% 100%;
  background-position: 0% 50%;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 10px 30px rgba(198, 255, 0, 0.28);
  transition:
    scale var(--dur) var(--ease-back),
    background-position var(--dur-slow) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

.btn--acid:hover {
  background-position: 100% 50%;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 14px 40px rgba(198, 255, 0, 0.42);
}

.btn--ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.07);
}

.btn--glass {
  background: rgba(255, 255, 255, 0.08);
}

.btn--buy {
  padding: 0.85em 1.45em;
  color: var(--bg-void);
  border-color: transparent;
  background-image: linear-gradient(100deg, var(--acid), #eaffa0 45%, var(--acid));
  background-size: 220% 100%;
  background-position: 0% 50%;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 8px 26px rgba(198, 255, 0, 0.22);
}

.btn--buy:hover {
  background-position: 100% 50%;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 12px 34px rgba(198, 255, 0, 0.36);
}

.btn--sm {
  padding: 0.6em 1.05em;
  font-size: var(--fs-micro);
  letter-spacing: 0.06em;
}

.btn--xs {
  padding: 0.45em 0.8em;
  font-size: var(--fs-micro);
  border-radius: var(--radius-sm);
}

.btn[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

/* ───────────────────────── Ripple ─────────────────────────
   Круг расходится из точки клика. Живёт 700 мс и удаляется.
   ─────────────────────────────────────────────────────────── */

.ripple-ink {
  position: absolute;
  z-index: 0;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: scale(0);
  animation: ripple 700ms var(--ease-out) forwards;
}

.btn--ghost .ripple-ink,
.btn--glass .ripple-ink {
  background: rgba(255, 255, 255, 0.35);
}

@keyframes ripple {
  to {
    transform: scale(34);
    opacity: 0;
  }
}

/* ───────────────────────── Спиннер ───────────────────────── */

.spinner {
  display: none;
  width: 1em;
  height: 1em;
  border: 2px solid rgba(5, 5, 7, 0.35);
  border-top-color: var(--bg-void);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading .spinner {
  display: inline-block;
}

.btn.is-loading .btn__label {
  opacity: 0.7;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
