/* =========================================================================
   MOTION.CSS v3 — LIQUID GLASS + 3D layer (loaded after enhance.css)
   -------------------------------------------------------------------------
   Purely additive skin. Theme-locked: green & white only (existing CSS vars
   or green/white rgba). No layout changes. Heavy effects auto-degrade on
   mobile, disappear under prefers-reduced-motion, and fall back to solid
   panels when backdrop-filter is unsupported.
   Layers (back → front):
     z:-2 .mo-bg    — liquid aurora blobs (animated green gradients)
     z:-1 .mo-glow  — soft light that follows the cursor
     z: 0 page      — glass surfaces blur everything behind them
   ========================================================================= */

/* ---------- root: page background moves to <html> so the fixed aurora
              (negative z-index) can live between it and the content ------- */
html { background: var(--bg); }
body { background: transparent; }
html .app, html .main { background: transparent; }

/* ---------- liquid aurora background (all pages) ---------- */
.mo-bg { position: fixed; inset: -10%; z-index: -2; pointer-events: none; overflow: hidden; }
.mo-bg i {
  position: absolute; border-radius: 50%; will-change: transform;
  background: radial-gradient(circle at 35% 35%, rgba(148,152,124,.32), rgba(148,152,124,.10) 45%, transparent 70%);
}
.mo-bg i:nth-child(1) { width: 54vmax; height: 54vmax; left: -12vmax; top: -14vmax;
  animation: moB1 26s ease-in-out infinite alternate; }
.mo-bg i:nth-child(2) { width: 46vmax; height: 46vmax; right: -10vmax; top: 22%;
  background: radial-gradient(circle at 60% 40%, rgba(184,190,160,.30), rgba(148,152,124,.10) 45%, transparent 70%);
  animation: moB2 32s ease-in-out infinite alternate; }
.mo-bg i:nth-child(3) { width: 50vmax; height: 50vmax; left: 18%; bottom: -18vmax;
  background: radial-gradient(circle at 40% 60%, rgba(43,58,38,.20), transparent 65%);
  animation: moB3 38s ease-in-out infinite alternate; }
@keyframes moB1 { to { transform: translate(8vmax, 6vmax)  scale(1.15) rotate(18deg); } }
@keyframes moB2 { to { transform: translate(-7vmax, 8vmax) scale(.9)  rotate(-14deg); } }
@keyframes moB3 { to { transform: translate(6vmax, -7vmax) scale(1.12); } }

html[data-theme="dark"] .mo-bg i { background: radial-gradient(circle at 35% 35%, rgba(170,177,188,.15), rgba(140,148,160,.05) 45%, transparent 70%); }
html[data-theme="dark"] .mo-bg i:nth-child(2) { background: radial-gradient(circle at 60% 40%, rgba(170,177,188,.12), transparent 65%); }
html[data-theme="dark"] .mo-bg i:nth-child(3) { background: radial-gradient(circle at 40% 60%, rgba(140,148,160,.10), transparent 65%); }

/* ---------- cursor-following ambient light (desktop only, injected by JS) */
.mo-glow {
  position: fixed; left: -270px; top: -270px; width: 540px; height: 540px;
  border-radius: 50%; pointer-events: none; z-index: -1; opacity: 0;
  transition: opacity .6s ease; will-change: transform;
  background: radial-gradient(circle, rgba(170,177,188,.20), rgba(148,152,124,.09) 45%, transparent 70%);
}
html[data-theme="dark"] .mo-glow { background: radial-gradient(circle, rgba(170,177,188,.13), transparent 65%); }

/* =========================================================================
   LIQUID GLASS SURFACES — frosted panels with specular top edge.
   `html` prefix outguns page-level single-class rules without !important.
   ========================================================================= */
html .card, html .stat-card, html .about-card, html .feature, html .plan,
html .modal-card, html .cong-card, html .auth-form-side {
  background: rgba(255,255,255,.62);
  -webkit-backdrop-filter: blur(16px) saturate(165%);
  backdrop-filter: blur(16px) saturate(165%);
  border-color: rgba(255,255,255,.65);
  box-shadow: 0 8px 32px rgba(24,30,22,.10),
              inset 0 1px 0 rgba(255,255,255,.75),
              inset 0 -1px 0 rgba(255,255,255,.22);
}
html .card-head { background: rgba(255,255,255,.42); border-bottom-color: rgba(43,58,38,.10); }

/* green feature surfaces stay green — glassy version of their gradient */
html .stat-card.green {
  background: linear-gradient(135deg, rgba(43,58,38,.92), rgba(18,26,20,.95));
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border-color: rgba(255,255,255,.18);
}
html .plan.featured {
  background: linear-gradient(180deg, rgba(43,58,38,.92), rgba(18,26,20,.95));
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}

/* sidebar: deep-green glass — aurora shimmers through it */
html .sidebar {
  background: linear-gradient(180deg, rgba(18,26,20,.86) 0%, rgba(43,58,38,.84) 100%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border-right: 1px solid rgba(255,255,255,.12);
}

/* Main Wallet chip + toast + tables + forms */
html .balance-chip {
  background: linear-gradient(135deg, rgba(217,221,228,.60), rgba(238,240,244,.50));
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  border-color: rgba(255,255,255,.70);
}
html .toast {
  background: rgba(18,26,20,.84);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.16);
}
html table th { background: rgba(148,152,124,.13); }
html .deposit-info {
  background: rgba(223,227,233,.45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-color: rgba(255,255,255,.60);
}
html input, html select, html textarea { background: rgba(255,255,255,.55); }

/* ---------- dark theme glass variants ---------- */
html[data-theme="dark"] .card, html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .about-card, html[data-theme="dark"] .feature,
html[data-theme="dark"] .plan, html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .cong-card, html[data-theme="dark"] .auth-form-side {
  background: rgba(18,26,20,.58);
  border-color: rgba(150,156,128,.16);
  box-shadow: 0 8px 32px rgba(0,0,0,.38), inset 0 1px 0 rgba(150,156,128,.10);
}
html[data-theme="dark"] .card-head { background: rgba(18,26,20,.40); border-bottom-color: rgba(150,156,128,.12); }
html[data-theme="dark"] .stat-card.green {
  background: linear-gradient(135deg, rgba(42,49,59,.88), rgba(21,26,33,.92));
  border-color: rgba(150,156,128,.20);
}
html[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, rgba(11,14,18,.84) 0%, rgba(27,33,42,.80) 100%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
}
html[data-theme="dark"] .balance-chip {
  background: linear-gradient(135deg, rgba(35,41,49,.60), rgba(25,30,37,.50));
  border-color: rgba(150,156,128,.25);
}
html[data-theme="dark"] table th { background: rgba(170,177,188,.10); }
html[data-theme="dark"] .deposit-info { background: rgba(27,32,39,.48); border-color: rgba(150,156,128,.16); }

/* ---------- no backdrop-filter support → solid readable panels ---------- */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  html .card, html .stat-card, html .about-card, html .feature, html .plan,
  html .modal-card, html .cong-card, html .auth-form-side { background: rgba(255,255,255,.94); }
  html .sidebar { background: linear-gradient(180deg, var(--green-deep) 0%, var(--green) 100%); }
  html[data-theme="dark"] .card, html[data-theme="dark"] .stat-card,
  html[data-theme="dark"] .about-card, html[data-theme="dark"] .feature,
  html[data-theme="dark"] .plan, html[data-theme="dark"] .modal-card,
  html[data-theme="dark"] .cong-card, html[data-theme="dark"] .auth-form-side { background: rgba(18,26,20,.97); }
}

/* ---------- scroll progress bar (top of viewport) ---------- */
#moProgress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--green), var(--green-2), var(--green-mint));
  box-shadow: 0 1px 10px rgba(43,58,38,.55);
  z-index: 200; pointer-events: none; opacity: 0;
  transition: transform .08s linear, opacity .3s;
}
#moProgress.on { opacity: 1; }

/* ---------- liquid glass: frosted sticky topbar + scrolled nav ---------- */
.topbar {
  background: linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,.52));
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
}
html[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, rgba(18,26,20,.72), rgba(18,26,20,.55));
}
.nav.scrolled {
  background: rgba(247,248,250,.62);
  -webkit-backdrop-filter: saturate(175%) blur(18px);
  backdrop-filter: saturate(175%) blur(18px);
}

/* ---------- glass overlays (dim + frost behind modals/popups) ---------- */
.overlay, .cong-overlay {
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  backdrop-filter: blur(7px) saturate(120%);
}

/* ---------- the 'expensive' sheen: light sweep across primary buttons ---------- */
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::before {
  content: ""; position: absolute; top: 0; left: -80%; width: 55%; height: 100%; z-index: 0;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.30), transparent);
  transform: skewX(-18deg); pointer-events: none;
}
.btn-primary:hover::before { animation: moSheen .9s ease; }
@keyframes moSheen { from { left: -80%; } to { left: 140%; } }

/* glass top-light on primary buttons + tactile press on all buttons */
.btn-primary { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 22px rgba(43,58,38,.28); }
.btn:active { transform: translateY(1px) scale(.965); }

/* ---------- ambient glow pulse on the hero orb (landing) ---------- */
.hero-orb { animation: moOrbGlow 7s ease-in-out infinite; }
@keyframes moOrbGlow {
  0%, 100% { filter: drop-shadow(0 30px 60px rgba(43,58,38,.22)); }
  50%      { filter: drop-shadow(0 42px 84px rgba(43,58,38,.40)); }
}

/* hero headline accent: liquid shimmer sweep */
.hero h1 .accent {
  background: linear-gradient(110deg, var(--green) 25%, var(--green-2) 42%, #aab1bd 50%, var(--green-2) 58%, var(--green) 75%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: moShimmer 5.5s linear infinite;
}
@keyframes moShimmer { to { background-position: -220% 0; } }

/* ---------- scroll reveal with a motion-blur feel (landing sections) ---------- */
.mo-reveal {
  opacity: 0; transform: translateY(28px) scale(.99); filter: blur(7px);
  transition: opacity .75s cubic-bezier(.2,.8,.2,1),
              transform .75s cubic-bezier(.2,.8,.2,1),
              filter .6s ease;
  will-change: opacity, transform, filter;
}
.mo-reveal.mo-in { opacity: 1; transform: none; filter: blur(0); }

/* =========================================================================
   CARD LIFE — hover lift + glow accent (desktop)
   ========================================================================= */
html .card, html .stat-card {
  transition: transform .32s cubic-bezier(.2,.8,.2,1), box-shadow .32s ease,
              background-color .25s ease, color .25s ease, border-color .25s ease;
}
html .card:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(24,30,22,.13), inset 0 1px 0 rgba(255,255,255,.75); }
html .stat-card:hover { box-shadow: 0 16px 34px rgba(24,30,22,.16), inset 0 1px 0 rgba(255,255,255,.75); }

/* growing accent underline along the bottom of a stat card */
.stat-card::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--green), var(--green-mint));
  transform: scaleX(0); transform-origin: left;
  transition: transform .45s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
}
.stat-card:hover::after { transform: scaleX(1); }

/* =========================================================================
   3D TILT — cards tilt toward the cursor with a moving glass glare.
   .mo-tilt + .mo-glare are added by motion.js (desktop fine-pointer only).
   ========================================================================= */
.mo-tilt { will-change: transform; }
.mo-glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  opacity: 0; transition: opacity .35s ease; z-index: 2;
  background: radial-gradient(320px circle at var(--gx,50%) var(--gy,50%),
              rgba(255,255,255,.50), rgba(255,255,255,.12) 40%, transparent 65%);
}
.mo-tilt:hover .mo-glare { opacity: 1; }
.stat-card.green .mo-glare, .plan.featured .mo-glare {
  background: radial-gradient(320px circle at var(--gx,50%) var(--gy,50%),
              rgba(255,255,255,.32), transparent 60%);
}
html[data-theme="dark"] .mo-glare {
  background: radial-gradient(320px circle at var(--gx,50%) var(--gy,50%),
              rgba(200,206,215,.22), transparent 60%);
}

/* =========================================================================
   DASHBOARD / ADMIN — 3D pane switch, sidebar micro-interactions, topbar
   ========================================================================= */
.content.active {
  animation: moPaneIn .45s cubic-bezier(.22,.85,.25,1) both;
  transform-origin: 50% 0;
}
@keyframes moPaneIn {
  from { opacity: 0; transform: perspective(1100px) translateY(16px) rotateX(2.5deg); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

.topbar { animation: moTopIn .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes moTopIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.sidebar .menu a { animation: moMenuIn .4s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes moMenuIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.sidebar .menu a:nth-of-type(1)  { animation-delay: .04s; }
.sidebar .menu a:nth-of-type(2)  { animation-delay: .08s; }
.sidebar .menu a:nth-of-type(3)  { animation-delay: .12s; }
.sidebar .menu a:nth-of-type(4)  { animation-delay: .16s; }
.sidebar .menu a:nth-of-type(5)  { animation-delay: .20s; }
.sidebar .menu a:nth-of-type(6)  { animation-delay: .24s; }
.sidebar .menu a:nth-of-type(7)  { animation-delay: .28s; }
.sidebar .menu a:nth-of-type(8)  { animation-delay: .32s; }
.sidebar .menu a:nth-of-type(9)  { animation-delay: .36s; }
.sidebar .menu a:nth-of-type(10) { animation-delay: .40s; }
.sidebar .menu a:nth-of-type(11) { animation-delay: .44s; }
.sidebar .menu a:nth-of-type(12) { animation-delay: .48s; }

.sidebar .menu a { transition: background .25s, color .25s, padding-left .25s, transform .25s; }
.sidebar .menu a:hover { transform: translateX(3px); }
.sidebar .menu a .ico { transition: transform .3s cubic-bezier(.34,1.56,.64,1); }
.sidebar .menu a:hover .ico { transform: scale(1.22) rotate(-8deg); }
.sidebar .menu a.active .ico { animation: moIcoPop .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes moIcoPop { from { transform: scale(.55); } to { transform: scale(1); } }

.brand-mark { transition: transform .45s cubic-bezier(.34,1.56,.64,1); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.08); }

/* Main Wallet chip: periodic light sweep + hover lift */
.balance-chip { position: relative; overflow: hidden; transition: transform .3s, box-shadow .3s; }
.balance-chip:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(24,30,22,.14); }
.balance-chip::after {
  content: ""; position: absolute; top: 0; left: -70%; width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.38), transparent);
  transform: skewX(-18deg); pointer-events: none;
  animation: moChipSheen 7s ease-in-out infinite;
}
@keyframes moChipSheen { 0%, 80% { left: -70%; } 94%, 100% { left: 150%; } }

/* =========================================================================
   TABLES — rows cascade in on render + gentle hover highlight
   ========================================================================= */
.card tbody tr { animation: moRowIn .32s ease both; }
@keyframes moRowIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card tbody tr:nth-child(1) { animation-delay: .02s; }
.card tbody tr:nth-child(2) { animation-delay: .06s; }
.card tbody tr:nth-child(3) { animation-delay: .10s; }
.card tbody tr:nth-child(4) { animation-delay: .14s; }
.card tbody tr:nth-child(5) { animation-delay: .18s; }
.card tbody tr:nth-child(6) { animation-delay: .22s; }
.card tbody tr:nth-child(7) { animation-delay: .26s; }
.card tbody tr:nth-child(8) { animation-delay: .30s; }
.card tbody tr td { transition: background-color .2s; }
.card tbody tr:hover td { background: rgba(43,58,38,.05); }
html[data-theme="dark"] .card tbody tr:hover td { background: rgba(150,156,128,.07); }

/* =========================================================================
   MODALS / POPUPS — spring pop-in
   ========================================================================= */
.modal.open .modal-card,
.cong-overlay.open .cong-card {
  animation: moPop .42s cubic-bezier(.18,.95,.3,1.18);
}
@keyframes moPop {
  from { opacity: 0; transform: translateY(22px) scale(.93); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================================
   FORMS — animated focus ring
   ========================================================================= */
input, select, textarea { transition: box-shadow .25s, border-color .25s, background-color .25s; }
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 4px rgba(43,58,38,.13);
  border-color: var(--green);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus { box-shadow: 0 0 0 4px rgba(170,177,188,.16); }

/* =========================================================================
   AUTH PAGES (login / register / forgot) — staggered entrance
   ========================================================================= */
.auth-form-side > * { animation: moUp .55s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes moUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.auth-form-side > *:nth-child(1) { animation-delay: .05s; }
.auth-form-side > *:nth-child(2) { animation-delay: .12s; }
.auth-form-side > *:nth-child(3) { animation-delay: .19s; }
.auth-form-side > *:nth-child(4) { animation-delay: .26s; }
.auth-form-side > *:nth-child(5) { animation-delay: .33s; }
.auth-form-side > *:nth-child(6) { animation-delay: .40s; }
.auth-form-side > *:nth-child(7) { animation-delay: .47s; }

.auth-art-content > * { animation: moUp .6s cubic-bezier(.2,.8,.2,1) backwards; }
.auth-art-content > *:nth-child(1) { animation-delay: .10s; }
.auth-art-content > *:nth-child(2) { animation-delay: .20s; }
.auth-art-content > *:nth-child(3) { animation-delay: .30s; }
.auth-art .feats li { animation: moLeft .5s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes moLeft { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.auth-art .feats li:nth-child(1) { animation-delay: .35s; }
.auth-art .feats li:nth-child(2) { animation-delay: .45s; }
.auth-art .feats li:nth-child(3) { animation-delay: .55s; }
.auth-art .feats li:nth-child(4) { animation-delay: .65s; }

/* =========================================================================
   JS-DRIVEN ENTRANCE (cards cascade) + NUMBER COUNT-UP POP
   .mo-pop is only ever added by motion.js, so no-JS users see everything.
   ========================================================================= */
.mo-pop { opacity: 0; }
.mo-pop.mo-in {
  opacity: 1;
  animation: moCardIn .6s cubic-bezier(.2,.8,.2,1) backwards;
  animation-delay: var(--mo-d, 0s);
}
@keyframes moCardIn {
  from { opacity: 0; transform: perspective(900px) translateY(18px) rotateX(3deg) scale(.985); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* tick pop when a live number changes (added briefly by motion.js) */
.mo-numpop { display: inline-block; animation: moNumPop .45s cubic-bezier(.34,1.56,.64,1); }
@keyframes moNumPop {
  0%   { transform: scale(1.22); color: var(--green); }
  100% { transform: scale(1); }
}

/* =========================================================================
   MOBILE — keep the glass, lighten the cost
   ========================================================================= */
@media (max-width: 640px) {
  html .card, html .stat-card, html .about-card, html .feature, html .plan,
  html .modal-card, html .cong-card, html .auth-form-side {
    -webkit-backdrop-filter: blur(9px) saturate(150%);
    backdrop-filter: blur(9px) saturate(150%);
  }
  html .sidebar { -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .topbar { -webkit-backdrop-filter: blur(10px) saturate(150%); backdrop-filter: blur(10px) saturate(150%); }
  .mo-bg i:nth-child(3) { display: none; }            /* two blobs are plenty */
  .mo-reveal { transform: translateY(20px); filter: blur(5px); }
  .content.active { animation-duration: .32s; }
  @keyframes moPaneIn {
    from { opacity: 0; transform: translateY(10px); filter: none; }
    to   { opacity: 1; transform: none; filter: none; }
  }
  html .card:hover, html .stat-card:hover { transform: none; }
}

/* ---------- respect reduced-motion: everything calm + fully visible ---------- */
@media (prefers-reduced-motion: reduce) {
  #moProgress { display: none; }
  .mo-bg i { animation: none; }
  .mo-glow { display: none; }
  .btn-primary::before, .balance-chip::after { display: none; animation: none; }
  .hero-orb { animation: none; }
  .hero h1 .accent { animation: none; }
  .mo-reveal { opacity: 1 !important; transform: none !important; filter: none !important; transition: none; }
  .mo-pop { opacity: 1; }
  .mo-pop.mo-in, .content.active, .topbar, .sidebar .menu a,
  .sidebar .menu a.active .ico, .card tbody tr,
  .modal.open .modal-card, .cong-overlay.open .cong-card,
  .auth-form-side > *, .auth-art-content > *, .auth-art .feats li,
  .mo-numpop { animation: none !important; }
  html .card, html .stat-card, .sidebar .menu a, .brand-mark,
  .balance-chip, .stat-card::after { transition: none; }
  html .card:hover, html .stat-card:hover, .sidebar .menu a:hover,
  .balance-chip:hover { transform: none; }
}
