/* Payment Card Switcher — Performance-Optimized */

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root{
  --bg: #050510;
  --surface: rgba(255,255,255,.04);
  --surface-hover: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.15);
  --text: #f0f0f5;
  --text-secondary: rgba(255,255,255,.5);
  --text-tertiary: rgba(255,255,255,.3);
  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,.4);
  --green: #22c55e;
  --red: #ef4444;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease-out: cubic-bezier(.16,1,.3,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --max-w: 440px;
}

html,body{
  height:100%;
  overflow:hidden;
}

body{
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Aurora — no runtime blur, baked into large soft gradients ── */
.aurora{
  position:fixed;
  inset:0;
  overflow:hidden;
  pointer-events:none;
  z-index:0;
  contain: strict;
}
.aurora-blob{
  position:absolute;
  border-radius:50%;
  opacity:.3;
  will-change: transform;
}
.a1{
  width:800px;height:800px;
  background: radial-gradient(circle, rgba(99,102,241,.5) 0%, rgba(99,102,241,.15) 30%, transparent 60%);
  top:-30%;left:-20%;
  animation: auroraFloat1 18s ease-in-out infinite;
}
.a2{
  width:700px;height:700px;
  background: radial-gradient(circle, rgba(236,72,153,.45) 0%, rgba(236,72,153,.12) 30%, transparent 60%);
  bottom:-25%;right:-15%;
  animation: auroraFloat2 22s ease-in-out infinite;
}
.a3{
  width:600px;height:600px;
  background: radial-gradient(circle, rgba(6,182,212,.4) 0%, rgba(6,182,212,.1) 30%, transparent 60%);
  top:30%;left:50%;
  animation: auroraFloat3 20s ease-in-out infinite;
}
@keyframes auroraFloat1{
  0%,100%{transform:translate3d(0,0,0) scale(1)}
  33%{transform:translate3d(80px,60px,0) scale(1.15)}
  66%{transform:translate3d(-40px,30px,0) scale(.9)}
}
@keyframes auroraFloat2{
  0%,100%{transform:translate3d(0,0,0) scale(1)}
  33%{transform:translate3d(-60px,-40px,0) scale(1.1)}
  66%{transform:translate3d(50px,-20px,0) scale(.85)}
}
@keyframes auroraFloat3{
  0%,100%{transform:translate3d(0,0,0) scale(1)}
  33%{transform:translate3d(-30px,50px,0) scale(1.2)}
  66%{transform:translate3d(40px,-30px,0) scale(.95)}
}

/* ── Particle canvas ── */
#particles{
  position:fixed;
  inset:0;
  width:100%;height:100%;
  pointer-events:none;
  z-index:1;
}

/* ── App shell ── */
.app{
  position:relative;
  z-index:2;
  max-width: var(--max-w);
  margin:0 auto;
  height:100%;
  display:flex;
  flex-direction:column;
  padding: 16px 20px 24px;
  gap: 16px;
  overflow-y:auto;
  overflow-x:hidden;
  scrollbar-width:none;
}
.app::-webkit-scrollbar{display:none}

/* ── Topbar ── */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  animation: fadeSlideDown .6s var(--ease-out) both;
}
.back-btn{
  display:grid;
  place-items:center;
  width:44px;height:44px;
  border-radius:50%;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration:none;
  transition: transform .25s var(--ease-out), background-color .25s ease, border-color .25s ease;
}
.back-btn:hover{
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: scale(1.05);
}
.topbar-center{text-align:center}
.topbar-label{
  font-size:12px;
  font-weight:500;
  color: var(--text-secondary);
  letter-spacing:.08em;
  text-transform:uppercase;
}
.topbar-balance{
  font-size:24px;
  font-weight:800;
  letter-spacing:-.03em;
  background: linear-gradient(135deg, #fff 30%, rgba(255,255,255,.6));
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
  background-clip:text;
}
.icon-circle{
  display:grid;
  place-items:center;
  width:44px;height:44px;
  border-radius:50%;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor:pointer;
  transition: transform .3s var(--ease-spring), background-color .25s ease, border-color .25s ease, box-shadow .3s ease;
}
.icon-circle:hover{
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
  transform: scale(1.05) rotate(90deg);
}

/* ── Card Stage ── */
.card-stage{
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:16px;
  padding: 8px 0;
  animation: fadeSlideUp .7s .1s var(--ease-out) both;
}
.card-track{
  position:relative;
  width:100%;
  height: 210px;
  perspective: 1200px;
  cursor: grab;
  touch-action: pan-y;
}
.card-track:active{cursor:grabbing}

/* ── Individual Card ── */
.card-wrapper{
  position:absolute;
  top:0;left:50%;
  width: 320px;
  height: 200px;
  margin-left:-160px;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  cursor:pointer;
  -webkit-user-select:none;
  user-select:none;
  contain: layout style;
  /* transition set via JS — .no-transition disables during drag */
  transition: transform .55s var(--ease-out), opacity .4s ease;
}
.card-wrapper.no-transition{
  transition: none !important;
}

.card{
  width:100%;height:100%;
  border-radius: 20px;
  position:relative;
  overflow:hidden;
  transform: translateZ(0);
  /* Static shadow — no animated shadow transitions */
  box-shadow:
    0 25px 50px rgba(0,0,0,.5),
    0 0 0 1px rgba(255,255,255,.1) inset;
}
/* Active card glow via pseudo — avoids box-shadow repaint transition */
.card::before{
  content:'';
  position:absolute;
  inset:-1px;
  border-radius: 21px;
  opacity:0;
  transition: opacity .4s ease;
  box-shadow: 0 0 40px var(--card-glow, rgba(99,102,241,.3));
  pointer-events:none;
  z-index:-1;
}
.card-wrapper.active .card::before{
  opacity:1;
}

.card-bg{
  position:absolute;
  inset:0;
  z-index:0;
}

/* Card themes */
.card-theme-indigo .card-bg{
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
}
.card-theme-rose .card-bg{
  background: linear-gradient(135deg, #4c0519 0%, #881337 40%, #e11d48 100%);
}
.card-theme-emerald .card-bg{
  background: linear-gradient(135deg, #022c22 0%, #064e3b 40%, #059669 100%);
}
.card-theme-amber .card-bg{
  background: linear-gradient(135deg, #451a03 0%, #78350f 40%, #d97706 100%);
}

/* Card shimmer — uses transform (GPU) instead of background-position */
.card-shimmer{
  position:absolute;
  inset:0;
  z-index:1;
  opacity:0;
  transition: opacity .4s ease;
  pointer-events:none;
  overflow:hidden;
}
.card-shimmer::after{
  content:'';
  position:absolute;
  top:0;bottom:0;
  width:60%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255,255,255,.06) 20%,
    rgba(255,255,255,.18) 50%,
    rgba(255,255,255,.06) 80%,
    transparent 100%
  );
  transform: translateX(-150%);
  will-change: transform;
}
.card-wrapper.active .card-shimmer{
  opacity:1;
}
.card-wrapper.active .card-shimmer::after{
  animation: shimmerSlide 3.5s ease-in-out infinite;
}
@keyframes shimmerSlide{
  0%{transform:translateX(-150%)}
  100%{transform:translateX(300%)}
}

/* Card grain overlay */
.card-grain{
  position:absolute;
  inset:0;
  z-index:2;
  opacity:.08;
  mix-blend-mode:overlay;
  pointer-events:none;
  background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Card content */
.card-content{
  position:relative;
  z-index:3;
  width:100%;height:100%;
  padding: 22px 24px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}
.card-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
}
.card-brand{
  font-size:18px;
  font-weight:900;
  letter-spacing:-.02em;
  opacity:.9;
}
.card-chip{
  width:40px;height:28px;
  border-radius:6px;
  background: linear-gradient(135deg, #f5d98e 0%, #c9a84c 50%, #f5d98e 100%);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.4),
    inset 0 -1px 2px rgba(0,0,0,.3);
  position:relative;
  overflow:hidden;
}
.card-chip::before{
  content:'';position:absolute;
  top:50%;left:0;right:0;height:1px;
  background: rgba(0,0,0,.2);
}
.card-chip::after{
  content:'';position:absolute;
  left:35%;top:0;bottom:0;width:1px;
  background: rgba(0,0,0,.15);
  box-shadow: 8px 0 rgba(0,0,0,.15);
}
.card-contactless{
  opacity:.5;
  transition: opacity .3s ease;
}
.card-wrapper.active .card-contactless{opacity:.8}

.card-number-display{
  font-family: var(--mono);
  font-size:18px;
  font-weight:500;
  letter-spacing:.1em;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.card-bottom{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
}
.card-holder{
  font-size:11px;
  letter-spacing:.15em;
  text-transform:uppercase;
  opacity:.7;
}
.card-expiry{
  font-family: var(--mono);
  font-size:12px;
  font-weight:500;
  opacity:.7;
}
.card-network{
  position:absolute;
  bottom:22px;right:24px;
  z-index:3;
  display:flex;
  align-items:center;
  gap:6px;
}
.card-network-text{
  font-size:16px;
  font-weight:900;
  font-style:italic;
  letter-spacing:-.02em;
  opacity:.8;
}
.mc-circles{display:flex;align-items:center}
.mc-circles span{
  display:block;width:22px;height:22px;border-radius:50%;
}
.mc-circles .mc-r{background:#eb001b}
.mc-circles .mc-y{background:#f79e1b;margin-left:-8px;mix-blend-mode:screen;opacity:.85}

/* ── Card Indicators — no layout-triggering width animation ── */
.card-indicators{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}
.indicator{
  height:8px;
  border-radius:99px;
  background: rgba(255,255,255,.15);
  border:none;
  cursor:pointer;
  position:relative;
  /* fixed width, scale trick for active expansion */
  width:8px;
  transition: transform .4s var(--ease-spring), background-color .3s ease, box-shadow .3s ease;
  transform-origin: center center;
}
.indicator::after{
  content:'';
  position:absolute;
  inset:-4px;
  border-radius:99px;
}
.indicator.active{
  transform: scaleX(4);
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ── Card Details ── */
.card-details{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  backdrop-filter: blur(20px);
  animation: fadeSlideUp .7s .2s var(--ease-out) both;
}
.detail-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding-bottom:14px;
  border-bottom:1px solid var(--border);
  margin-bottom:14px;
}
.detail-item{
  display:flex;flex-direction:column;gap:4px;
}
.detail-label{
  font-size:11px;
  font-weight:500;
  color: var(--text-tertiary);
  letter-spacing:.08em;
  text-transform:uppercase;
}
.detail-value{
  font-size:15px;
  font-weight:700;
  color: var(--text);
}
.detail-value.mono{
  font-family: var(--mono);
  letter-spacing:.05em;
}
.status-active{
  color: var(--green);
  position:relative;
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.status-active::before{
  content:'';
  width:6px;height:6px;
  border-radius:50%;
  background: var(--green);
  animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse{
  0%,100%{box-shadow: 0 0 0 0 rgba(34,197,94,.5)}
  50%{box-shadow: 0 0 0 6px rgba(34,197,94,0)}
}
.copy-btn{
  display:flex;
  align-items:center;
  gap:6px;
  padding:8px 14px;
  border-radius: var(--radius-xs);
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor:pointer;
  font-size:12px;
  font-weight:600;
  transition: transform .2s var(--ease-out), background-color .2s ease, color .2s ease, border-color .2s ease;
}
.copy-btn:hover{
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.copy-btn.copied{
  color: var(--green);
  border-color: rgba(34,197,94,.3);
  background: rgba(34,197,94,.1);
}
.detail-grid{
  display:grid;
  grid-template-columns: repeat(3,1fr);
  gap:12px;
}

/* ── Actions Bar ── */
.actions-bar{
  display:grid;
  grid-template-columns: repeat(4,1fr);
  gap:10px;
  animation: fadeSlideUp .7s .3s var(--ease-out) both;
}
.action-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  padding:16px 8px;
  border-radius: var(--radius);
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor:pointer;
  font-size:11px;
  font-weight:600;
  letter-spacing:.04em;
  transition: transform .3s var(--ease-out), background-color .25s ease, border-color .25s ease, color .25s ease;
  position:relative;
  overflow:hidden;
}
/* Glow pseudo — opacity-only transition (cheap) */
.action-btn::before{
  content:'';
  position:absolute;
  inset:0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow) 0%, transparent 70%);
  opacity:0;
  transition: opacity .3s ease;
  pointer-events:none;
}
.action-btn:hover{
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-3px);
}
.action-btn:hover::before{opacity:1}
.action-btn:active{
  transform: translateY(-1px) scale(.97);
  transition-duration:.1s;
}
.action-icon{
  width:44px;height:44px;
  border-radius:14px;
  background: rgba(255,255,255,.06);
  display:grid;
  place-items:center;
  transition: transform .3s var(--ease-out), background-color .3s ease, box-shadow .3s ease;
  position:relative;
  z-index:1;
}
.action-btn:hover .action-icon{
  background: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(1.05);
}

/* ── Transactions ── */
.transactions{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:12px;
  animation: fadeSlideUp .7s .4s var(--ease-out) both;
}
.tx-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.tx-title{
  font-size:18px;
  font-weight:800;
  letter-spacing:-.02em;
}
.tx-filter{
  display:flex;
  align-items:center;
  gap:6px;
  padding:7px 14px;
  border-radius:99px;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size:12px;
  font-weight:600;
  cursor:pointer;
  transition: background-color .25s ease, color .25s ease;
}
.tx-filter:hover{
  background: var(--surface-hover);
  color: var(--text);
}
.tx-list{
  display:flex;
  flex-direction:column;
  gap:4px;
  overflow-y:auto;
  scrollbar-width:none;
  padding-bottom:8px;
  contain: content;
}
.tx-list::-webkit-scrollbar{display:none}

.tx-item{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 16px;
  border-radius: var(--radius-sm);
  border:1px solid transparent;
  background: var(--surface);
  transition: transform .25s var(--ease-out), background-color .25s ease, border-color .25s ease;
  cursor:default;
  animation: txSlideIn .5s var(--ease-out) both;
}
.tx-item:hover{
  border-color: var(--border-hover);
  background: var(--surface-hover);
  transform: translateX(4px);
}
.tx-icon{
  width:42px;height:42px;
  border-radius:14px;
  display:grid;
  place-items:center;
  font-size:18px;
  flex-shrink:0;
  position:relative;
  overflow:hidden;
}
.tx-icon::after{
  content:'';position:absolute;inset:0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,.1));
  pointer-events:none;
}
.tx-icon.coffee{background: rgba(245,158,11,.12);color:#f59e0b}
.tx-icon.ride{background: rgba(59,130,246,.12);color:#3b82f6}
.tx-icon.shop{background: rgba(236,72,153,.12);color:#ec4899}
.tx-icon.food{background: rgba(34,197,94,.12);color:#22c55e}
.tx-icon.sub{background: rgba(168,85,247,.12);color:#a855f7}

.tx-info{flex:1;min-width:0}
.tx-name{font-size:14px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tx-date{font-size:12px;color:var(--text-tertiary);margin-top:2px}
.tx-amount{
  font-family: var(--mono);
  font-size:14px;
  font-weight:700;
  white-space:nowrap;
}
.tx-amount.negative{color: var(--text)}
.tx-amount.positive{color: var(--green)}

@keyframes txSlideIn{
  from{opacity:0;transform:translateX(-20px)}
  to{opacity:1;transform:translateX(0)}
}

/* ── Toast ── */
.toast{
  position:fixed;
  bottom:32px;
  left:50%;
  transform: translateX(-50%) translateY(100px);
  padding:12px 24px;
  border-radius:99px;
  background: rgba(255,255,255,.95);
  color: #111;
  font-weight:700;
  font-size:14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  z-index:999;
  pointer-events:none;
  transition: transform .5s var(--ease-spring), opacity .5s ease;
  opacity:0;
  will-change: transform, opacity;
}
.toast.show{
  transform: translateX(-50%) translateY(0);
  opacity:1;
}

/* ── Shared keyframes ── */
@keyframes fadeSlideDown{
  from{opacity:0;transform:translateY(-20px)}
  to{opacity:1;transform:translateY(0)}
}
@keyframes fadeSlideUp{
  from{opacity:0;transform:translateY(24px)}
  to{opacity:1;transform:translateY(0)}
}

/* ── Card enter animation ── */
.card-wrapper.entering{
  animation: cardEnter .8s var(--ease-spring) both;
}
@keyframes cardEnter{
  from{opacity:0;transform:translate3d(0,60px,0) rotateY(30deg) scale(.8)}
}

/* ── Frozen state ── */
.card-wrapper.frozen .card{
  filter: grayscale(.6) brightness(.7);
}
.card-wrapper.frozen .card::after{
  content:'FROZEN';
  position:absolute;
  top:50%;left:50%;
  transform:translate(-50%,-50%) rotate(-15deg);
  font-size:28px;
  font-weight:900;
  letter-spacing:.2em;
  color: rgba(255,255,255,.3);
  z-index:10;
  text-shadow: 0 0 20px rgba(255,255,255,.15);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .aurora-blob{animation:none}
  .card-shimmer::after{animation:none}
}

/* ── Responsive ── */
@media (max-width:380px){
  .card-wrapper{width:280px;height:175px;margin-left:-140px}
  .card-track{height:185px}
  .card-number-display{font-size:15px}
  .detail-grid{grid-template-columns:1fr 1fr;gap:10px}
  .actions-bar{grid-template-columns:repeat(4,1fr);gap:6px}
  .action-btn{padding:12px 4px}
}

/* ── Page Loader ──────────────────────────────────────── */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 400ms ease;
}

.page-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.page-loader__spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loaderSpin 0.75s linear infinite;
}

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