/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple: #6366f1;
  --purple-dark: #4f46e5;
  --purple-light: #a5b4fc;
  --card-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(99,102,241,0.12);
  --shadow-lg: 0 20px 60px rgba(99,102,241,0.2);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  background: var(--card-gradient);
  padding: 56px 24px 64px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(255,255,255,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 50%);
}
.hero-inner { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; }
.brand-icon { display: flex; justify-content: center; margin-bottom: 16px; }
.brand-icon svg { width: 56px; height: 56px; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.hero p { margin-top: 12px; color: rgba(255,255,255,0.82); font-size: 1.05rem; line-height: 1.6; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 600px;
  width: 100%;
  margin: -32px auto 48px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Form Section ─────────────────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.field:last-of-type { margin-bottom: 0; }
label { font-size: 0.85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
input {
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--text);
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}
input:focus { border-color: var(--purple); background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
input.invalid { border-color: #f43f5e; box-shadow: 0 0 0 3px rgba(244,63,94,0.12); }
.field-error { font-size: 0.8rem; color: #f43f5e; min-height: 1em; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  margin-top: 24px;
  background: var(--card-gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(99,102,241,0.45); transform: translateY(-1px); }

.btn-apple {
  flex: 1;
  background: #000;
  color: #fff;
  border-radius: 12px;
}
.btn-apple:hover { background: #1a1a1a; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.25); }

.btn-google {
  flex: 1;
  background: #fff;
  color: #3c4043;
  border: 1.5px solid var(--border);
}
.btn-google:hover { background: #f8f9fa; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.btn-loader .spinner {
  width: 20px; height: 20px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Wallet message ───────────────────────────────────────────────────────── */
.wallet-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.wallet-message.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.wallet-message.error { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.wallet-message.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ── Card Section ─────────────────────────────────────────────────────────── */
.card-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.card-section h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; }

/* ── 3D Card ──────────────────────────────────────────────────────────────── */
.card-3d-wrapper {
  perspective: 1200px;
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.card {
  position: relative;
  width: 340px;
  height: 215px;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: 18px;
}
.card.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(99,102,241,0.3), 0 10px 20px rgba(0,0,0,0.15);
}

/* ── Front face ── */
.card-front { background: var(--card-gradient); color: #fff; padding: 20px 24px 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-brand { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.15em; }
.card-type { font-size: 0.65rem; font-weight: 600; letter-spacing: 0.1em; opacity: 0.8; text-transform: uppercase; }
.card-chip svg { width: 46px; height: 34px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.card-details { margin-top: 14px; }
.card-holder-label { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.1em; opacity: 0.75; text-transform: uppercase; margin-bottom: 2px; }
.card-holder-name { font-size: 1rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.card-bottom-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 10px; }
.card-small-value { font-size: 0.85rem; font-weight: 600; letter-spacing: 0.06em; }
.card-number-display { font-size: 0.75rem; letter-spacing: 0.12em; font-family: 'Courier New', monospace; }
.card-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, transparent 50%, rgba(255,255,255,0.06) 100%);
  pointer-events: none;
}

/* ── Back face ── */
.card-back { background: #1e1b4b; transform: rotateY(180deg); }
.card-stripe { height: 42px; background: #111; margin-top: 24px; }
.card-back-content { padding: 12px 20px 16px; color: #fff; }
.barcode-wrapper {
  background: #fff;
  border-radius: 6px;
  padding: 8px 12px 4px;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
}
.barcode-wrapper svg { max-width: 100%; height: 48px; }
.card-back-info { text-align: center; margin-bottom: 8px; }
.card-back-info .card-holder-label { color: rgba(255,255,255,0.6); font-size: 0.6rem; }
.barcode-number { font-size: 0.75rem; font-family: 'Courier New', monospace; font-weight: 600; color: var(--purple-light); letter-spacing: 0.1em; }
.card-back-terms { font-size: 0.62rem; color: rgba(255,255,255,0.45); line-height: 1.4; text-align: center; }

/* ── Flip hint ── */
.flip-hint { font-size: 0.78rem; color: var(--muted); margin-bottom: 24px; }

/* ── Wallet buttons ── */
.wallet-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.wallet-buttons .btn { min-width: 140px; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer { text-align: center; padding: 24px 16px; color: var(--muted); font-size: 0.8rem; }

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-section:not([hidden]) { animation: slideUp 0.4s ease; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .form-section, .card-section { padding: 24px 18px; }
  .card { width: 290px; height: 183px; }
  .card-brand { font-size: 0.9rem; }
  .card-holder-name { font-size: 0.85rem; }
  .wallet-buttons { flex-direction: column; }
  .wallet-buttons .btn { width: 100%; }
}
