/* =========================================================
   MERGICALLY — GLOBAL DESIGN SYSTEM
   One source of truth for colors, typography, spacing,
   components, and motion. Import this on every page.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,700;12..96,800&family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- DESIGN TOKENS ---------- */
:root {
  /* — Brand palette — */
  --mg-spotify:        #1DB954;
  --mg-spotify-dark:   #159c44;
  --mg-spotify-glow:   rgba(29, 185, 84, 0.45);
  --mg-spotify-soft:   rgba(29, 185, 84, 0.12);

  --mg-apple:          #FC3C44;
  --mg-apple-dark:     #d42b32;
  --mg-apple-glow:     rgba(252, 60, 68, 0.45);
  --mg-apple-soft:     rgba(252, 60, 68, 0.12);

  /* Other platform brand colors (for future YouTube Music, Amazon, etc) */
  --mg-youtube:        #FF0033;
  --mg-amazon:         #00A8E1;
  --mg-tidal:          #000000;
  --mg-deezer:         #A238FF;

  /* — Surfaces — */
  --mg-bg:             #000000;
  --mg-bg-1:           #0a0a0a;
  --mg-bg-2:           #141414;
  --mg-bg-3:           #1c1c1c;
  --mg-surface:        #161616;
  --mg-surface-hover:  #1e1e1e;
  --mg-border:         rgba(255, 255, 255, 0.08);
  --mg-border-strong:  rgba(255, 255, 255, 0.16);

  /* — Text — */
  --mg-text:           #ffffff;
  --mg-text-dim:       #b3b3b3;
  --mg-text-dimmer:    #7a7a7a;
  --mg-text-faint:     #4a4a4a;

  /* — Status — */
  --mg-success:        #1DB954;
  --mg-warn:           #F5A623;
  --mg-error:          #FC3C44;
  --mg-info:           #4A9EFF;

  /* — Typography — */
  --mg-font-display:   'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --mg-font-body:      'Inter', system-ui, -apple-system, sans-serif;

  /* — Radii — */
  --mg-r-sm:           6px;
  --mg-r-md:           10px;
  --mg-r-lg:           14px;
  --mg-r-xl:           20px;
  --mg-r-pill:         999px;

  /* — Shadows & glows — */
  --mg-shadow-sm:      0 1px 2px rgba(0,0,0,0.4);
  --mg-shadow-md:      0 4px 16px rgba(0,0,0,0.5);
  --mg-shadow-lg:      0 12px 40px rgba(0,0,0,0.6);
  --mg-glow-spotify:   0 0 60px var(--mg-spotify-glow);
  --mg-glow-apple:     0 0 60px var(--mg-apple-glow);

  /* — Spacing scale — */
  --mg-s-1: 4px;  --mg-s-2: 8px;  --mg-s-3: 12px;
  --mg-s-4: 16px; --mg-s-5: 24px; --mg-s-6: 32px;
  --mg-s-7: 48px; --mg-s-8: 64px;

  /* — Motion — */
  --mg-ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --mg-ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
  --mg-dur-fast:       120ms;
  --mg-dur:            220ms;
  --mg-dur-slow:       400ms;

  /* — Gradients (the Mergically signature) — */
  --mg-grad-spotify:   radial-gradient(ellipse at center, rgba(29,185,84,0.55) 0%, rgba(29,185,84,0.15) 35%, #000 75%);
  --mg-grad-apple:     radial-gradient(ellipse at center, rgba(252,60,68,0.55) 0%, rgba(252,60,68,0.15) 35%, #000 75%);
  --mg-grad-hero:      linear-gradient(90deg, var(--mg-apple) 0%, var(--mg-spotify) 100%);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--mg-font-body);
  background: var(--mg-bg);
  color: var(--mg-text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* =========================================================
   TYPOGRAPHY
   ========================================================= */
.mg-display {
  font-family: var(--mg-font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.mg-h1 { font-family: var(--mg-font-display); font-weight: 800; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -0.03em; line-height: 1.05; }
.mg-h2 { font-family: var(--mg-font-display); font-weight: 700; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -0.02em; line-height: 1.15; }
.mg-h3 { font-family: var(--mg-font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; }
.mg-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--mg-text-dimmer);
}
.mg-muted { color: var(--mg-text-dim); }
.mg-faint { color: var(--mg-text-faint); }

/* Hero gradient text — the "Transfer Your Music" treatment */
.mg-grad-text {
  background: var(--mg-grad-hero);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.mg-text-spotify { color: var(--mg-spotify); }
.mg-text-apple   { color: var(--mg-apple); }

/* =========================================================
   LAYOUT
   ========================================================= */
.mg-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.mg-container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--mg-s-5);
}
.mg-container-sm { max-width: 720px; }
.mg-container-md { max-width: 960px; }

/* =========================================================
   TOP BAR (Logo + nav action — appears on every page)
   ========================================================= */
.mg-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--mg-s-4) var(--mg-s-5);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--mg-border);
}
.mg-logo {
  font-family: var(--mg-font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--mg-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mg-logo::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--mg-grad-hero);
  box-shadow: 0 0 12px var(--mg-spotify-glow);
}
.mg-logo span { color: var(--mg-spotify); }

/* =========================================================
   BUTTONS
   ========================================================= */
.mg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-family: var(--mg-font-body);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border: none;
  border-radius: var(--mg-r-pill);
  cursor: pointer;
  transition: transform var(--mg-dur-fast) var(--mg-ease),
              background var(--mg-dur) var(--mg-ease),
              box-shadow var(--mg-dur) var(--mg-ease),
              opacity var(--mg-dur) var(--mg-ease);
  text-decoration: none;
  white-space: nowrap;
}
.mg-btn:active { transform: scale(0.97); }
.mg-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.mg-btn:focus-visible {
  outline: 2px solid var(--mg-text);
  outline-offset: 2px;
}

.mg-btn-primary {
  background: var(--mg-apple);
  color: #fff;
  box-shadow: 0 4px 20px rgba(252,60,68,0.35);
}
.mg-btn-primary:hover:not(:disabled) {
  background: var(--mg-apple-dark);
  box-shadow: 0 6px 28px rgba(252,60,68,0.5);
}

.mg-btn-spotify {
  background: var(--mg-spotify);
  color: #000;
  box-shadow: 0 4px 20px rgba(29,185,84,0.35);
}
.mg-btn-spotify:hover:not(:disabled) {
  background: var(--mg-spotify-dark);
  box-shadow: 0 6px 28px rgba(29,185,84,0.5);
}

.mg-btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--mg-text);
  border: 1px solid var(--mg-border);
}
.mg-btn-ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
  border-color: var(--mg-border-strong);
}

.mg-btn-outline {
  background: transparent;
  color: var(--mg-text);
  border: 1px solid var(--mg-border-strong);
}
.mg-btn-outline:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
}

.mg-btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.mg-btn-lg { padding: 14px 28px; font-size: 0.95rem; }

.mg-btn-block { width: 100%; }

/* =========================================================
   CARDS & PANELS
   ========================================================= */
.mg-card {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-r-lg);
  overflow: hidden;
}
.mg-card-pad { padding: var(--mg-s-5); }

.mg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--mg-s-4) var(--mg-s-5);
  border-bottom: 1px solid var(--mg-border);
}
.mg-card-title {
  font-family: var(--mg-font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.mg-card-meta { font-size: 11px; color: var(--mg-text-dimmer); font-weight: 600; }

/* Signature gradient cards (the green/red glow blocks) */
.mg-card-glow-spotify {
  background: var(--mg-grad-spotify), var(--mg-bg);
  border: 1px solid rgba(29,185,84,0.25);
  border-radius: var(--mg-r-xl);
}
.mg-card-glow-apple {
  background: var(--mg-grad-apple), var(--mg-bg);
  border: 1px solid rgba(252,60,68,0.25);
  border-radius: var(--mg-r-xl);
}

/* =========================================================
   PILLS / CHIPS / BADGES
   ========================================================= */
.mg-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: var(--mg-r-pill);
  background: rgba(255,255,255,0.08);
  color: var(--mg-text-dim);
}
.mg-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.mg-pill-success { background: var(--mg-spotify-soft); color: var(--mg-spotify); }
.mg-pill-error   { background: var(--mg-apple-soft); color: var(--mg-apple); }
.mg-pill-warn    { background: rgba(245,166,35,0.15); color: var(--mg-warn); }

/* =========================================================
   FORM CONTROLS
   ========================================================= */
.mg-field { margin-bottom: var(--mg-s-4); }
.mg-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--mg-text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.mg-input {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--mg-font-body);
  font-size: 0.9rem;
  color: var(--mg-text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-r-md);
  transition: border-color var(--mg-dur) var(--mg-ease),
              background var(--mg-dur) var(--mg-ease);
}
.mg-input::placeholder { color: var(--mg-text-faint); }
.mg-input:focus {
  outline: none;
  border-color: var(--mg-spotify);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 3px var(--mg-spotify-soft);
}

/* OAuth provider buttons — "Continue with Google/Apple/Microsoft" */
.mg-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-r-md);
  color: var(--mg-text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--mg-dur) var(--mg-ease), border-color var(--mg-dur) var(--mg-ease);
}
.mg-oauth-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--mg-border-strong); }
.mg-oauth-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Divider with "or" */
.mg-or {
  display: flex;
  align-items: center;
  gap: var(--mg-s-3);
  margin: var(--mg-s-4) 0;
  color: var(--mg-text-faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.mg-or::before, .mg-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--mg-border);
}

/* =========================================================
   STATE INDICATORS
   ========================================================= */
.mg-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--mg-text);
  border-radius: 50%;
  animation: mg-spin 0.7s linear infinite;
}
@keyframes mg-spin { to { transform: rotate(360deg); } }

.mg-empty {
  padding: var(--mg-s-6) var(--mg-s-4);
  text-align: center;
  color: var(--mg-text-faint);
  font-size: 0.85rem;
}

.mg-divider {
  border: none;
  border-top: 1px solid var(--mg-border);
  margin: 0;
}

/* =========================================================
   PROGRESS BAR
   ========================================================= */
.mg-progress {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--mg-r-pill);
  overflow: hidden;
}
.mg-progress-fill {
  height: 100%;
  background: var(--mg-grad-hero);
  border-radius: var(--mg-r-pill);
  transition: width var(--mg-dur-slow) var(--mg-ease-out);
  width: 0%;
}

/* =========================================================
   PLATFORM TILES (the dashboard 2x3 grid of brand squares)
   ========================================================= */
.mg-platform-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--mg-s-3);
}
.mg-platform-tile {
  aspect-ratio: 1;
  border-radius: var(--mg-r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform var(--mg-dur) var(--mg-ease),
              box-shadow var(--mg-dur) var(--mg-ease);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.mg-platform-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--mg-shadow-lg);
}
.mg-platform-tile.is-selected {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.mg-tile-spotify { background: var(--mg-spotify); color: #000; }
.mg-tile-apple   { background: var(--mg-apple); }
.mg-tile-youtube { background: var(--mg-youtube); }
.mg-tile-amazon  { background: var(--mg-amazon); }
.mg-tile-tidal   { background: #0F0F0F; border-color: rgba(255,255,255,0.15); }
.mg-tile-deezer  { background: var(--mg-deezer); }

.mg-platform-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   ANIMATIONS — used for hero reveal & subtle motion
   ========================================================= */
@keyframes mg-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes mg-fade-in {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes mg-pulse-glow {
  0%, 100% { box-shadow: 0 0 40px var(--mg-spotify-glow); }
  50%      { box-shadow: 0 0 80px var(--mg-spotify-glow); }
}

.mg-anim-up    { animation: mg-fade-up 0.7s var(--mg-ease-out) both; }
.mg-anim-fade  { animation: mg-fade-in 0.5s var(--mg-ease-out) both; }
.mg-anim-d1    { animation-delay: 0.1s; }
.mg-anim-d2    { animation-delay: 0.2s; }
.mg-anim-d3    { animation-delay: 0.3s; }
.mg-anim-d4    { animation-delay: 0.4s; }

/* =========================================================
   UTILITIES
   ========================================================= */
.mg-flex        { display: flex; }
.mg-flex-center { display: flex; align-items: center; justify-content: center; }
.mg-flex-between{ display: flex; align-items: center; justify-content: space-between; }
.mg-grid        { display: grid; }
.mg-gap-1 { gap: var(--mg-s-1); } .mg-gap-2 { gap: var(--mg-s-2); }
.mg-gap-3 { gap: var(--mg-s-3); } .mg-gap-4 { gap: var(--mg-s-4); }
.mg-gap-5 { gap: var(--mg-s-5); } .mg-gap-6 { gap: var(--mg-s-6); }
.mg-mt-1 { margin-top: var(--mg-s-1); } .mg-mt-2 { margin-top: var(--mg-s-2); }
.mg-mt-3 { margin-top: var(--mg-s-3); } .mg-mt-4 { margin-top: var(--mg-s-4); }
.mg-mt-5 { margin-top: var(--mg-s-5); } .mg-mt-6 { margin-top: var(--mg-s-6); }
.mg-mb-1 { margin-bottom: var(--mg-s-1); } .mg-mb-2 { margin-bottom: var(--mg-s-2); }
.mg-mb-3 { margin-bottom: var(--mg-s-3); } .mg-mb-4 { margin-bottom: var(--mg-s-4); }
.mg-mb-5 { margin-bottom: var(--mg-s-5); } .mg-mb-6 { margin-bottom: var(--mg-s-6); }
.mg-text-center { text-align: center; }
.mg-hidden { display: none !important; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  .mg-container { padding: 0 var(--mg-s-4); }
  .mg-topbar { padding: var(--mg-s-3) var(--mg-s-4); }
}
