/*
 * SuperDimension · 液态玻璃的光效与动效
 * 叠加在组件之上：指针高光、按压涟漪、运行流光、叠层入场、主题揭示与品牌标。
 * 不设置组件的尺寸、间距和圆角。坐标变量由 shared/liquid-light.js 写入。
 */
@property --lx {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 50%;
}

@property --ly {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: -40%;
}

@property --px {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 50%;
}

@property --py {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 50%;
}

@property --spot {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

@property --ripple {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

@property --ripple-alpha {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

@property --orbit {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

[data-light] {
  position: relative;
  isolation: isolate;
}

:is(.panel, .glass-card, .stat, .sidebar, .topbar, .login-card, .deck-pane, dialog:not(.image-viewer), .drawer, .toast, .glass-overlay, [data-light="edge"])::before {
  --lx: inherit;
  --ly: inherit;
  --px: inherit;
  --py: inherit;
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  background: radial-gradient(260px circle at var(--lx) var(--ly), var(--light-edge), transparent 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .35s;
}

@media (hover: hover) {
  :is(.panel, .glass-card, .stat, .sidebar, .topbar, .login-card, .deck-pane, dialog:not(.image-viewer), .drawer, .toast, .glass-overlay, [data-light="edge"]):hover::before {
    opacity: 1;
  }
}

:is(.btn, .icon-btn, .option, .option-card, .segmented > button, .nav-link, .account-trigger, .deck-pane, [data-light="spot"])::after {
  --lx: inherit;
  --ly: inherit;
  --px: inherit;
  --py: inherit;
  --spot: inherit;
  --ripple: inherit;
  --ripple-alpha: inherit;
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  opacity: 1;
  background:
    radial-gradient(circle at var(--px) var(--py), transparent calc(var(--ripple) - 24%), color-mix(in srgb, var(--light-ripple) calc(var(--ripple-alpha) * 100%), transparent) var(--ripple), transparent calc(var(--ripple) + 3%)),
    radial-gradient(var(--spot-size, 140px) circle at var(--lx) var(--ly), color-mix(in srgb, var(--light-spot) calc(var(--spot) * 100%), transparent), color-mix(in srgb, var(--light-spot-soft) calc(var(--spot) * 100%), transparent) 45%, transparent 72%);
  transition: --spot .25s;
}

:is(.btn, .icon-btn, .option, .option-card, .segmented > button, .nav-link, .account-trigger, .deck-pane, [data-light="spot"]):hover::after {
  --spot: 1;
}

:is(.btn, .icon-btn, .option, .option-card, .segmented > button, .nav-link, .account-trigger, .deck-pane, [data-light="spot"]):active::after {
  --spot: .55;
}

.deck-pane {
  --spot-size: 260px;
}

:is(.panel, .glass-card, [data-light="edge"]).is-running::before {
  opacity: 1;
  background: conic-gradient(from var(--orbit), transparent 0 62%, var(--light-edge) 82%, transparent 100%);
  animation: orbit-light 2.4s linear infinite;
}

@keyframes orbit-light {
  to {
    --orbit: 360deg;
  }
}

@keyframes liquid-flow {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -120% 0;
  }
}

.progress.is-active > i, .skeleton {
  position: relative;
  overflow: hidden;
}

.skeleton {
  background: var(--track-fill);
  border-radius: var(--radius-control);
}

.progress.is-active > i::after, .skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 30%, var(--light-ripple) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: liquid-flow 1.6s linear infinite;
}

@keyframes status-pulse {
  from {
    box-shadow: 0 0 0 0 currentColor;
  }

  to {
    box-shadow: 0 0 0 6px transparent;
  }
}

.status.running::before {
  animation: status-pulse 1.6s ease-out infinite;
}

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

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

dialog[open], .toast {
  animation: rise-in var(--t-enter) var(--ease-liquid) both;
}

.drawer-backdrop > .drawer {
  animation: drawer-in var(--t-enter) var(--ease-liquid) both;
}

.drawer-backdrop, dialog::backdrop {
  animation: fade-in var(--t-enter) var(--ease-liquid) both;
}

html.theme-switching .bg-scene::before, html.theme-switching .bg-scene::after {
  animation-play-state: paused;
}

.brand-mark {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(140deg, #1b1712 0%, #2e2513 48%, #4a3a17 80%, #211b0f 100%);
  border: 1px solid rgba(212, 175, 55, 0.6);
  box-shadow: 0 6px 18px -6px rgba(124, 108, 240, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: brand-glow 4.2s ease-in-out infinite;
  cursor: pointer;
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(212, 175, 55, 0.32) 46%, rgba(255, 232, 160, 0.5) 50%, rgba(212, 175, 55, 0.32) 54%, transparent 70%);
  background-size: 240% 100%;
  background-position: 130% 0;
  animation: brand-gold-sheen 3.8s ease-in-out infinite;
}

.brand-mark-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(100deg, #f7df9a 0%, #d4af37 22%, #fff6cf 42%, #c98f1b 60%, #f2d88b 80%, #d4af37 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brand-text-flow 5s linear infinite;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.brand-spark {
  position: absolute;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.95), 0 0 12px rgba(139, 124, 240, 0.85);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  font-style: normal;
}

.brand-spark::before {
  content: '✦';
}

.brand-spark.s1 {
  top: 5px;
  right: 6px;
  font-size: 9px;
}

.brand-spark.s2 {
  top: 4px;
  left: 9px;
  font-size: 6px;
}

.brand-spark.s3 {
  bottom: 6px;
  right: 9px;
  font-size: 7px;
}

[data-theme="dark"] .brand-spark {
  animation: spark-twinkle 6.5s ease-in-out infinite;
}

[data-theme="dark"] .brand-spark.s2 {
  animation-duration: 8.2s;
  animation-delay: 2.7s;
}

[data-theme="dark"] .brand-spark.s3 {
  animation-duration: 9.8s;
  animation-delay: 5.1s;
}

button.brand-mark {
  padding: 0;
  flex: none;
  appearance: none;
  line-height: 1;
}

.brand-mark:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.brand-mark:active {
  transform: scale(.94);
}

[data-theme="dark"] .brand-mark {
  background: linear-gradient(140deg, #f2f3f7 0%, #d9dce6 45%, #f9f5ec 75%, #e2e5ee 100%);
  border-color: rgba(255, 255, 255, 0.72);
  animation: brand-glow-dark 4.2s ease-in-out infinite;
}

[data-theme="dark"] .brand-mark-text {
  background: linear-gradient(100deg, #8b7cf0 0%, #e86ac4 22%, #f2b04a 40%, #4cc89d 58%, #5b8dee 78%, #8b7cf0 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: brand-text-flow 5s linear infinite;
}

[data-theme="dark"] .brand-mark::after {
  display: none;
}

html.theme-switching :is(.brand-mark, .brand-mark-text, .brand-spark),
html.theme-switching .brand-mark::after {
  animation-play-state: paused !important;
  transition: none !important;
}

@keyframes brand-glow {
  0%, 100% {
    box-shadow:
      0 8px 22px -8px rgba(0, 0, 0, 0.6),
      0 0 14px -3px rgba(212, 175, 55, 0.45),
      inset 0 1px 0 rgba(255, 228, 150, 0.4),
      inset 0 -2px 4px rgba(0, 0, 0, 0.55);
  }

  50% {
    box-shadow:
      0 10px 26px -8px rgba(0, 0, 0, 0.65),
      0 0 22px -2px rgba(212, 175, 55, 0.7),
      inset 0 1px 0 rgba(255, 240, 180, 0.55),
      inset 0 -2px 4px rgba(0, 0, 0, 0.55);
  }
}

@keyframes brand-glow-dark {
  0%, 100% {
    box-shadow:
      0 8px 22px -8px rgba(0, 0, 0, 0.6),
      0 0 14px -3px rgba(255, 255, 255, 0.42),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      inset 0 -2px 4px rgba(90, 96, 120, 0.35);
  }

  50% {
    box-shadow:
      0 10px 26px -8px rgba(0, 0, 0, 0.65),
      0 0 24px -2px rgba(255, 255, 255, 0.62),
      inset 0 1px 0 rgba(255, 255, 255, 1),
      inset 0 -2px 4px rgba(90, 96, 120, 0.35);
  }
}

@keyframes brand-gold-sheen {
  0% {
    background-position: 130% 0;
  }

  55%, 100% {
    background-position: -30% 0;
  }
}

@keyframes brand-text-flow {
  0% {
    background-position: 300% 0;
    filter: hue-rotate(0deg);
  }

  50% {
    filter: hue-rotate(22deg);
  }

  100% {
    background-position: 0% 0;
    filter: hue-rotate(0deg);
  }
}

@keyframes spark-twinkle {
  0%, 100% {
    opacity: 0;
    transform: translate(0, 0) scale(0.15) rotate(-10deg);
  }

  6%, 10% {
    opacity: 1;
    transform: translate(1px, -1px) scale(1.6) rotate(30deg);
  }

  14%, 20% {
    opacity: 0.3;
    transform: translate(-0.5px, 0.5px) scale(0.7) rotate(80deg);
  }

  24%, 58% {
    opacity: 0;
    transform: translate(0, 1px) scale(0.15) rotate(140deg);
  }

  64%, 68% {
    opacity: 0.85;
    transform: translate(-1px, 0) scale(1.05) rotate(200deg);
  }

  72%, 92% {
    opacity: 0;
    transform: translate(0.5px, 0.5px) scale(0.15) rotate(260deg);
  }
}

::view-transition-group(root) {
  animation-duration: 620ms;
  animation-timing-function: cubic-bezier(0.22, 0.8, 0.26, 1);
}

::view-transition-old(root), ::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  z-index: 2;
  clip-path: circle(0 at var(--theme-origin-x) var(--theme-origin-y));
  animation: theme-ripple-in 620ms cubic-bezier(0.22, 0.8, 0.26, 1) both;
}

::view-transition-old(root) {
  z-index: 1;
}

@keyframes theme-ripple-in {
  to {
    clip-path: circle(var(--theme-radius) at var(--theme-origin-x) var(--theme-origin-y));
  }
}

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

:root[data-motion="reduced"]::view-transition-group(root),
:root[data-motion="reduced"]::view-transition-old(root),
:root[data-motion="reduced"]::view-transition-new(root) {
  animation: none !important;
  clip-path: none !important;
}
