/* =====================================================================
   Login / Register — animated auth screens
   Uses theme variables from app.css, so admin colour presets still apply.
   ===================================================================== */
@property --auth-ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.auth-page { position: relative; isolation: isolate; overflow: hidden; padding: 18px 0 48px; }
.auth-page .container { position: relative; z-index: 1; }

/* ---------- Animated background ---------- */
.auth-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.auth-bg .orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; will-change: transform; }
.auth-bg .o1 { width: 46vmax; height: 46vmax; left: -18vmax; top: -16vmax; background: radial-gradient(circle, rgba(var(--primary-rgb), .55), transparent 65%); animation: orbA 18s ease-in-out infinite alternate; }
.auth-bg .o2 { width: 40vmax; height: 40vmax; right: -16vmax; top: 22vh; background: radial-gradient(circle, rgba(var(--secondary-rgb), .5), transparent 65%); animation: orbB 22s ease-in-out infinite alternate; }
.auth-bg .o3 { width: 34vmax; height: 34vmax; left: 10vw; bottom: -18vmax; background: radial-gradient(circle, rgba(var(--accent-rgb), .3), transparent 65%); animation: orbC 26s ease-in-out infinite alternate; }
.auth-bg .grid {
  position: absolute; inset: -2px;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 20%, transparent 75%);
  animation: gridMove 14s linear infinite;
}
.auth-bg .spark {
  position: absolute; bottom: -12px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--hl-b); box-shadow: 0 0 10px 2px rgba(var(--primary-rgb), .7);
  opacity: 0; animation: sparkRise var(--t) linear infinite; animation-delay: var(--dl);
}
@keyframes orbA { to { transform: translate3d(14vw, 10vh, 0) scale(1.12); } }
@keyframes orbB { to { transform: translate3d(-12vw, 14vh, 0) scale(.9); } }
@keyframes orbC { to { transform: translate3d(18vw, -12vh, 0) scale(1.15); } }
@keyframes gridMove { to { background-position: 44px 44px; } }
@keyframes sparkRise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  10% { opacity: .9; }
  80% { opacity: .6; }
  100% { transform: translate3d(var(--drift), -105vh, 0); opacity: 0; }
}

/* ---------- Staggered entrance ---------- */
.a-in { animation: authIn .8s var(--ease) both; animation-delay: calc(.35s + var(--d, 0) * .09s); }
@keyframes authIn { from { opacity: 0; translate: 0 26px; scale: .97; filter: blur(6px); } to { opacity: 1; translate: 0 0; scale: 1; filter: none; } }

/* ---------- Header + emblem ---------- */
.auth-head { margin-bottom: 18px; }
.auth-head .brand { font-weight: 800; }
.auth-hero { display: grid; place-items: center; margin: 4px 0 18px; }
.auth-emblem {
  position: relative; width: 92px; height: 92px; display: grid; place-items: center;
  animation: emblemFloat 4.5s ease-in-out infinite;
}
.auth-emblem .core {
  position: relative; z-index: 2; width: 74px; height: 74px; border-radius: 24px; display: grid; place-items: center;
  font-size: 2.1rem; color: var(--on-primary);
  background: linear-gradient(180deg, rgba(255,255,255,.3), transparent 55%), var(--grad);
  box-shadow: 0 18px 40px -12px rgba(var(--primary-rgb), .95), inset 0 1px 0 rgba(255,255,255,.45);
  overflow: hidden;
}
.auth-emblem .core::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-120%) skewX(-20deg);
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.55), transparent 70%);
  animation: coreShine 3.6s ease-in-out infinite 1.4s;
}
.auth-emblem .core i { animation: corePop .9s var(--ease) both .55s; }
.auth-emblem .ring { position: absolute; inset: -12px; border-radius: 50%; border: 1.5px dashed rgba(var(--primary-rgb), .5); animation: spin 16s linear infinite; }
.auth-emblem .ring.r2 { inset: -26px; border: 1px solid rgba(var(--primary-rgb), .18); animation-duration: 24s; animation-direction: reverse; }
.auth-emblem .ring.r2::before {
  content: ''; position: absolute; top: -5px; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: var(--hl-b); box-shadow: 0 0 14px 3px rgba(var(--primary-rgb), .8);
}
.auth-emblem .halo { position: absolute; inset: -6px; border-radius: 30px; background: rgba(var(--primary-rgb), .35); filter: blur(22px); animation: haloPulse 3s ease-in-out infinite; }
@keyframes emblemFloat { 50% { transform: translateY(-8px); } }
@keyframes coreShine { 0% { transform: translateX(-120%) skewX(-20deg); } 35%, 100% { transform: translateX(140%) skewX(-20deg); } }
@keyframes corePop { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.18) rotate(6deg); } to { transform: none; } }
@keyframes haloPulse { 50% { opacity: .45; transform: scale(1.12); } }

/* ---------- Title ---------- */
.auth-title { margin-bottom: 22px; }
.auth-title h1 { margin-bottom: 4px; }
.auth-title h1 .text-grad { background-size: 220% 100%; animation: titleFlow 6s linear infinite; }
.auth-title .wave { display: inline-block; transform-origin: 70% 70%; animation: authWave 2.6s ease-in-out infinite 1.2s; }
.auth-title p { margin: 0; }
@keyframes titleFlow { to { background-position: -220% 0; } }

/* ---------- Card with rotating gradient border ---------- */
.auth-card { padding: 22px 22px 24px; transform-style: preserve-3d; transition: transform .35s var(--ease); }
.auth-card::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--auth-ang), transparent 0 55%, rgba(var(--primary-rgb), .95) 70%, rgba(var(--accent-rgb), .9) 76%, rgba(var(--secondary-rgb), .8) 82%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: borderSpin 5s linear infinite;
}
.auth-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, -20%), rgba(var(--primary-rgb), .13), transparent 45%);
  transition: opacity .3s;
}
@keyframes borderSpin { to { --auth-ang: 360deg; } }
.auth-card.shake { animation: authIn .8s var(--ease) both .35s, shake .55s cubic-bezier(.36,.07,.19,.97) 1.15s; }
@keyframes shake { 10%, 90% { translate: -2px 0; } 20%, 80% { translate: 4px 0; } 30%, 50%, 70% { translate: -7px 0; } 40%, 60% { translate: 7px 0; } }

/* ---------- Login / Register switch ---------- */
.auth-switch {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 5px; margin-bottom: 22px;
  border-radius: 999px; background: rgba(0,0,0,.25); border: 1px solid var(--border);
}
.auth-switch a { position: relative; z-index: 1; text-align: center; padding: 9px 0; font-weight: 700; color: var(--muted); border-radius: 999px; transition: color .3s; }
.auth-switch a.on { color: var(--on-primary); }
.auth-switch .ind {
  position: absolute; top: 5px; bottom: 5px; left: 5px; width: calc(50% - 5px); border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.25), transparent 60%), var(--grad);
  box-shadow: 0 8px 22px -8px rgba(var(--primary-rgb), .9);
  transition: transform .45s cubic-bezier(.65,0,.35,1);
}
.auth-switch[data-on="register"] .ind { transform: translateX(100%); }
.auth-switch.go-login .ind { transform: translateX(0); }
.auth-switch.go-register .ind { transform: translateX(100%); }
.auth-switch.go-login a, .auth-switch.go-register a { color: var(--muted); }
.auth-switch.go-login a:first-of-type, .auth-switch.go-register a:nth-of-type(2) { color: var(--on-primary); }

/* ---------- Inputs ---------- */
.auth-card .input-wrap > i:first-child { transition: color .3s, transform .35s var(--ease); }
.auth-card .input-wrap:focus-within > i:first-child { color: var(--link); transform: translateY(-50%) scale(1.18); }
.auth-card .input-wrap::after {
  content: ''; position: absolute; left: 18px; right: 18px; bottom: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--hl-b), var(--primary), transparent);
  transform: scaleX(0); transition: transform .45s var(--ease); pointer-events: none;
}
.auth-card .input-wrap:focus-within::after { transform: scaleX(1); }
.auth-card .input { transition: border-color .25s, box-shadow .25s, background .25s, transform .25s var(--ease); }
.auth-card .input:focus { transform: translateY(-1px); }
.auth-card .label { display: flex; align-items: center; gap: 6px; }
.auth-card .field.is-ok .input-wrap > i:first-child { color: var(--ok); }
.auth-card .error-text { animation: slideDown .35s var(--ease) both; }
.auth-card .error-text::before { content: '\F33A'; font-family: 'bootstrap-icons'; margin-right: 6px; vertical-align: -1px; }

/* Password strength meter */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.pw-meter span { height: 5px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; position: relative; }
.pw-meter span::after { content: ''; position: absolute; inset: 0; background: var(--pw-c, var(--bad)); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease), background .3s; }
.pw-meter[data-lv="1"] span:nth-child(-n+1)::after,
.pw-meter[data-lv="2"] span:nth-child(-n+2)::after,
.pw-meter[data-lv="3"] span:nth-child(-n+3)::after,
.pw-meter[data-lv="4"] span:nth-child(-n+4)::after { transform: scaleX(1); }
.pw-meter[data-lv="1"] { --pw-c: var(--bad); }
.pw-meter[data-lv="2"] { --pw-c: var(--warn); }
.pw-meter[data-lv="3"] { --pw-c: #a3e635; }
.pw-meter[data-lv="4"] { --pw-c: var(--ok); }
.pw-label { font-size: .82rem; margin-top: 4px; color: var(--pw-c, var(--muted)); min-height: 1.3em; transition: color .3s; }

/* ---------- Buttons ---------- */
.auth-card .btn-lg { margin-top: 6px; }
.auth-card .btn-lg i { transition: transform .4s var(--ease); }
.auth-card .btn-lg:hover i { transform: translateX(3px) rotate(-8deg) scale(1.15); }
.auth-card .btn-rainbow { background-size: 200% 100%; animation: rainbowFlow 5s ease-in-out infinite; }
.auth-card .btn-rainbow::after {
  content: ''; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.4), transparent);
  transform: skewX(-20deg); animation: btnSweep 3.4s ease-in-out infinite 1.8s;
}
.auth-card .btn-primary::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 rgba(var(--primary-rgb), .55); animation: authPulse 2.6s infinite 1.6s;
}
@keyframes rainbowFlow { 50% { background-position: 100% 0; } }
@keyframes btnSweep { 0% { left: -120%; } 40%, 100% { left: 140%; } }
.ripple { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255,255,255,.45); animation: ripple .65s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

.auth-forgot { display: flex; justify-content: flex-end; margin: -6px 0 14px; }
.auth-forgot a { font-size: .9rem; color: var(--muted); transition: color .2s; }
.auth-forgot a:hover { color: var(--link); }
.auth-alt { text-align: center; margin: 18px 0 0; color: var(--muted); }
.auth-alt a { color: var(--link); font-weight: 700; position: relative; }
.auth-alt a::after { content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .35s var(--ease); }
.auth-alt a:hover::after { transform: scaleX(1); transform-origin: left; }

.auth-card .bonus-note { animation: bonusGlow 2.8s ease-in-out infinite; }
.auth-card .bonus-note i { display: inline-block; animation: authTick 1.8s ease-in-out infinite; }
@keyframes bonusGlow { 50% { box-shadow: 0 0 22px -4px rgba(var(--primary-rgb), .6); } }

/* ---------- Trust row ---------- */
.auth-trust { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.auth-trust div {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; text-align: center;
  font-size: .8rem; color: var(--tint-2); border-radius: 16px; border: 1px solid var(--border); background: rgba(255,255,255,.03);
  transition: transform .3s var(--ease), border-color .3s, background .3s;
}
.auth-trust div:hover { transform: translateY(-3px); border-color: rgba(var(--primary-rgb), .4); background: rgba(var(--primary-rgb), .06); }
.auth-trust i { font-size: 1.25rem; color: var(--link); }

@media (max-width: 380px) {
  .auth-card { padding: 18px 16px 20px; }
  .auth-trust { gap: 6px; }
  .auth-trust div { font-size: .72rem; padding: 10px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-bg .orb, .auth-bg .grid, .auth-bg .spark, .auth-emblem, .auth-emblem *, .auth-emblem .core::after,
  .auth-card::before, .auth-title *, .auth-card .btn-rainbow, .auth-card .btn-rainbow::after, .auth-card .btn-primary::before,
  .auth-card .bonus-note, .auth-card .bonus-note i { animation: none !important; }
  .auth-bg .spark { display: none; }
  .a-in, .auth-card.shake { animation: none; }
  .auth-card { transition: none; }
}

@keyframes authWave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }
@keyframes authTick { 50% { transform: scale(1.3) rotate(-10deg); } }
@keyframes authPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), .55); } 60% { box-shadow: 0 0 0 12px rgba(var(--primary-rgb), 0); } }
