@import url("https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.6.2/cropper.min.css");

.sparkle-wrapper {
  --transition: 0.25s;
  --spark: 1.8s;
  position: relative;
  display: inline-block;
}

.sparkle-wrapper button,
.sparkle-wrapper a {
  --cut: 0.1em;
  --active: 0;
  --bg:
    radial-gradient(40% 50% at center 100%,
      hsl(270 calc(var(--active) * 97%) 72% / var(--active)),
      transparent),
    radial-gradient(80% 100% at center 120%,
      hsl(260 calc(var(--active) * 97%) 70% / var(--active)),
      transparent),
    hsl(260 calc(var(--active) * 97%) calc((var(--active) * 44%) + 12%));
  background: var(--bg);
  font-size: 1rem;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  padding: 0.8em 1.2em;
  display: flex;
  align-items: center;
  gap: 0.25em;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 100px;
  position: relative;
  color: white;
  box-shadow:
    0 0 calc(var(--active) * 6em) calc(var(--active) * 3em) hsl(260 97% 61% / 0.75),
    0 0.05em 0 0 hsl(260 calc(var(--active) * 97%) calc((var(--active) * 50%) + 30%)) inset,
    0 -0.05em 0 0 hsl(260 calc(var(--active) * 97%) calc(var(--active) * 60%)) inset;
  transition: box-shadow var(--transition), scale var(--transition), background var(--transition);
  scale: calc(1 + (var(--active) * 0.1));
}

.sparkle-wrapper button:active,
.sparkle-wrapper a:active {
  scale: 1;
}

.sparkle-wrapper svg {
  overflow: visible !important;
}

.sparkle-wrapper .sparkle path {
  color: hsl(0 0% calc((var(--active, 0) * 70%) + var(--base)));
  transform-box: fill-box;
  transform-origin: center;
  fill: currentColor;
  stroke: currentColor;
  animation-delay: calc((var(--transition) * 1.5) + (var(--delay) * 1s));
  animation-duration: 0.6s;
  transition: color var(--transition);
}

.sparkle-wrapper button:is(:hover, :focus-visible),
.sparkle-wrapper a:is(:hover, :focus-visible) {
  --active: 1;
}

.sparkle-wrapper button:is(:hover, :focus-visible) .sparkle path,
.sparkle-wrapper a:is(:hover, :focus-visible) .sparkle path {
  animation-name: bounce;
}

@keyframes bounce {

  35%,
  65% {
    scale: var(--scale);
  }
}

.sparkle-wrapper .sparkle path:nth-of-type(1) {
  --scale: 0.5;
  --delay: 0.1;
  --base: 40%;
}

.sparkle-wrapper .sparkle path:nth-of-type(2) {
  --scale: 1.5;
  --delay: 0.2;
  --base: 20%;
}

.sparkle-wrapper .sparkle path:nth-of-type(3) {
  --scale: 2.5;
  --delay: 0.35;
  --base: 30%;
}

.sparkle-wrapper button:before,
.sparkle-wrapper a:before {
  content: "";
  position: absolute;
  inset: -0.25em;
  z-index: -1;
  border: 0.25em solid hsl(260 97% 50% / 0.5);
  border-radius: 100px;
  opacity: var(--active, 0);
  transition: opacity var(--transition);
}

.sparkle-wrapper .spark {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  rotate: 0deg;
  overflow: hidden;
  mask: linear-gradient(white, transparent 50%);
  -webkit-mask: linear-gradient(white, transparent 50%);
  animation: flip calc(var(--spark) * 2) infinite steps(2, end);
}

@keyframes flip {
  to {
    rotate: 360deg;
  }
}

.sparkle-wrapper .spark:before {
  content: "";
  position: absolute;
  width: 200%;
  aspect-ratio: 1;
  top: 0%;
  left: 50%;
  z-index: -1;
  translate: -50% -15%;
  rotate: 0;
  transform: rotate(-90deg);
  opacity: calc((var(--active)) + 0.4);
  background: conic-gradient(from 0deg,
      transparent 0 340deg,
      white 360deg);
  transition: opacity var(--transition);
  animation: rotate var(--spark) linear infinite both;
}

.sparkle-wrapper .spark:after {
  content: "";
  position: absolute;
  inset: var(--cut);
  border-radius: 100px;
}

.sparkle-wrapper .backdrop {
  position: absolute;
  inset: var(--cut);
  background: var(--bg);
  border-radius: 100px;
  transition: background var(--transition);
}

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

.sparkle-wrapper button:is(:hover, :focus-visible)~.particle-pen,
.sparkle-wrapper a:is(:hover, :focus-visible)~.particle-pen {
  --active: 1;
  --play-state: running;
}

.sparkle-wrapper .particle-pen {
  position: absolute;
  width: 200%;
  aspect-ratio: 1;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  -webkit-mask: radial-gradient(white, transparent 65%);
  z-index: -1;
  opacity: var(--active, 0);
  transition: opacity var(--transition);
  pointer-events: none;
}

.sparkle-wrapper .particle {
  fill: white;
  width: calc(var(--size, 0.25) * 1rem);
  aspect-ratio: 1;
  position: absolute;
  top: calc(var(--y) * 1%);
  left: calc(var(--x) * 1%);
  opacity: var(--alpha, 1);
  animation: float-out calc(var(--duration, 1) * 1s) calc(var(--delay) * -1s) infinite linear;
  transform-origin: var(--origin-x, 1000%) var(--origin-y, 1000%);
  z-index: -1;
  animation-play-state: var(--play-state, paused);
}

.sparkle-wrapper .particle path {
  fill: hsl(0 0% 90%);
  stroke: none;
}

.sparkle-wrapper .particle:nth-of-type(even) {
  animation-direction: reverse;
}

@keyframes float-out {
  to {
    rotate: 360deg;
  }
}

.sparkle-wrapper .text {
  translate: 2% -6%;
  letter-spacing: 0.01ch;
  background: linear-gradient(90deg, hsl(0 0% calc((var(--active) * 100%) + 65%)), hsl(0 0% calc((var(--active) * 100%) + 26%)));
  -webkit-background-clip: text;
  color: transparent;
  transition: background var(--transition);
}

.sparkle-wrapper button>svg,
.sparkle-wrapper a>svg {
  inline-size: 1.25em;
  translate: -25% -5%;
}

/* Navigation Bar Global Mapping */
body {
  padding-bottom: 90px;
}

.mobile-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: space-around;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: rgba(11, 17, 24, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 9999;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.65rem;
  font-weight: 600;
  transition: color 0.2s;
  font-family: 'Montserrat', sans-serif;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item.active {
  color: #0ed3ff;
}

/* Global WebSocket Toasts */
#global-notifications {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 15px;
  pointer-events: none;
}

.toast-notification {
  pointer-events: auto;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 16px;
  padding: 18px;
  width: 320px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.02);
  animation: slideInRight 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 768px) {
  #global-notifications {
    top: auto;
    bottom: 100px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 90%;
    align-items: center;
  }

  .toast-notification {
    width: 100%;
    max-width: 350px;
  }
}

.challenge-toast {
  border-left: 4px solid #0ed3ff;
}

.decline-toast {
  border-left: 4px solid #ef4444;
}

.toast-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast-avatar,
.toast-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.toast-avatar-placeholder {
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
}

.toast-text {
  display: flex;
  flex-direction: column;
}

.toast-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: #0ed3ff;
}

.toast-desc {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.3;
}

.toast-actions {
  display: flex;
  gap: 10px;
}

.btn-toast-accept {
  flex: 1;
  text-align: center;
  background: #0ed3ff;
  color: #000;
  padding: 8px 0;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-toast-accept:hover {
  background: #fff;
}

.btn-toast-decline {
  flex: 1;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 0;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toast-decline:hover {
  background: rgba(239, 68, 68, 0.2);
}

.toast-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
}

.toast-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

@keyframes slideInRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Global Kinetic Interfaces */
.hover-animate-card {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  position: relative;
  overflow: hidden;
}

@media (hover: hover) {
  .hover-animate-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    z-index: 10;
  }
}

.hover-animate-card:active {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.5) !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
}

.hover-animate-btn,
.auth-btn,
.auth-btn-google {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

@media (hover: hover) {

  .hover-animate-btn:hover,
  .auth-btn:hover,
  .auth-btn-google:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4) !important;
    z-index: 10;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .5;
  }
}

.hover-animate-btn:active,
.auth-btn:active,
.auth-btn-google:active {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.5) !important;
}

.hover-animate-card::after,
.hover-animate-btn::after,
.auth-btn::after,
.auth-btn-google::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  transform: translate(-10%, -10%);
}

@media (hover: hover) {

  .hover-animate-card:hover::after,
  .hover-animate-btn:hover::after,
  .auth-btn:hover::after,
  .auth-btn-google:hover::after {
    opacity: 1;
    transform: translate(0, 0);
  }
}

.hover-animate-card:active::after,
.hover-animate-btn:active::after,
.auth-btn:active::after,
.auth-btn-google:active::after {
  opacity: 1;
  transform: translate(0, 0);
}

#global-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* -----------------[ Native Structural Hover CSS Definitions ]----------------- */
.btn-challenge:hover {
  transform: translateY(-2px);
}

.logout-btn:hover {
  color: #ef4444 !important;
}

.modal-close-btn:hover,
.hover-color-white:hover {
  color: #ffffff !important;
}

.category-pill:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 182, 255, 0.4) !important;
}

.hover-bg-blue-transparent:hover {
  background: rgba(56, 182, 255, 0.05) !important;
}

.btn-clone-persona:hover {
  background: rgba(56, 182, 255, 0.1) !important;
}

.btn-update-engine:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(56, 182, 255, 0.3) !important;
}

.hoverable-row {
  transition: background-color 0.2s ease;
}

@media (hover: hover) {
  .hoverable-row:hover {
    background-color: rgba(56, 182, 255, 0.05) !important;
  }
}

/* CSP-compliant hover states to replace inline JS event handlers */
.hover-icon-emerald:hover {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #10b981 !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
}

.hover-icon-blue:hover {
  background: rgba(56, 182, 255, 0.2) !important;
  color: #38b6ff !important;
  border-color: rgba(56, 182, 255, 0.5) !important;
}

.hover-card-blue:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 30px rgba(56, 182, 255, 0.1) !important;
  border-color: rgba(56, 182, 255, 0.2) !important;
}

.hover-card-purple:hover {
  background: rgba(168, 85, 247, 0.05) !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
  transform: translateX(5px) !important;
}

.hover-btn-blue:hover {
  background: rgba(56, 182, 255, 0.1) !important;
}

.hover-btn-emerald:hover {
  background: rgba(16, 185, 129, 0.1) !important;
}

.hover-btn-purple:hover {
  background: rgba(168, 85, 247, 0.3) !important;
}

.hover-bg-white-subtle:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
}

.hover-bg-white-10:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}

.hover-bg-white-20:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

.hover-bg-white-08:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

/* ==========================================================================
   GLOBAL NATIVE APP MOBILE OVERRIDES (Max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {

  /* 1. Global Inline Style Resizing for Density */

  /* Aggressively crush large inline paddings */
  [style*="padding: 2.5rem"],
  [style*="padding: 3rem"],
  [style*="padding: 2rem"] {
    padding: 1.25rem !important;
  }

  /* Crush inline 4rem/5rem margins (often used at bottom of lists) */
  [style*="margin-bottom: 5rem"],
  [style*="margin-bottom: 4rem"] {
    margin-bottom: 2rem !important;
  }

  /* Crush large inline text sizes */
  [style*="font-size: 2rem"],
  [style*="font-size: 2.5rem"],
  [style*="font-size: 3rem"] {
    font-size: 1.5rem !important;
  }

  [style*="font-size: 1.5rem"],
  [style*="font-size: 1.25rem"] {
    font-size: 1.1rem !important;
  }

  /* Scale down inline icon wrappers */
  [style*="width: 140px; height: 140px"],
  [style*="width: 120px; height: 120px"] {
    width: 80px !important;
    height: 80px !important;
    font-size: 2rem !important;
  }

  [style*="width: 70px; height: 70px"],
  [style*="width: 60px; height: 60px"] {
    width: 50px !important;
    height: 50px !important;
  }

  /* 2. Global Component Scaling */

  /* Admin Cards */
  .admin-card {
    padding: 1rem !important;
  }

  /* Debate Cards */
  .debate-card {
    padding: 1.25rem !important;
  }

  /* Primary Headings */
  h1 {
    font-size: 1.5rem !important;
  }

  h2 {
    font-size: 1.3rem !important;
  }

  h3 {
    font-size: 1.1rem !important;
  }

  /* Section Headers */
  .section-header {
    font-size: 1.15rem !important;
    margin-bottom: 1rem !important;
  }

  /* Buttons */
  .admin-btn,
  .hero-cta,
  .btn-challenge {
    padding: 0.6rem 1.2rem !important;
    font-size: 0.9rem !important;
  }

  /* Split Panel Form Elements */
  .form-input {
    padding: 0.6rem 1rem !important;
    font-size: 0.95rem !important;
  }

  /* 3. Global Grid and Layout Collapsing */

  /* Admin Settings split panel wrapper */
  [data-controller="split-panel"] {
    flex-direction: column !important;
  }

  [data-split-panel-target="leftPane"],
  [data-split-panel-target="rightPane"] {
    flex-basis: auto !important;
    min-width: 100% !important;
    padding: 1.25rem !important;
  }

  /* Hide resizer on mobile */
  [data-split-panel-target="resizer"] {
    display: none !important;
  }

  /* Convert all explicitly inline grid layouts to single columns */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 400px"],
  [style*="grid-template-columns: 350px 1fr"],
  [style*="grid-template-columns: repeat"] {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* Prevent span-2 elements from overflowing */
  [style*="grid-column: span 2"],
  [style*="grid-column: span 3"] {
    grid-column: span 1 !important;
  }

  /* 4. Sidebars */
  .floating-sidebar {
    width: 100% !important;
    right: -100% !important;
    padding: 4rem 1.25rem 1.25rem 1.25rem !important;
  }

  .floating-sidebar.active {
    right: 0 !important;
  }

  .toggle-sidebar-btn {
    top: 15vh !important;
    padding: 0.6rem !important;
  }

  /* 5. Mobile Navbar clearance */
  body {
    padding-bottom: 100px !important;
  }
}