/* ==========================================================================
   Bubbli Invitation Studio 2.0 - Complete Design System & Stylesheet
   Mobile-First UX • Intelligent Color Systems • 8px Spacing System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Alex+Brush&family=Cinzel:wght@500;700;800&family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,400&family=Great+Vibes&family=Outfit:wght@400;500;600;700;800;900&family=Playfair+Display:ital,wght@0,500;0,600;0,700;0,900;1,400;1,600&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Rozha+One&display=swap');

:root {
  /* ----------------------------------------------------
     Layer A: Bubbli Website UI Design Tokens
     Modern, calm, trustworthy, strictly isolated from invitation templates
     ---------------------------------------------------- */
  --bubbli-brand: #2563eb;
  --bubbli-brand-hover: #1d4ed8;
  --bubbli-action: #0284c7;
  --bubbli-action-hover: #0369a1;
  
  --bubbli-bg: #070c18;
  --bubbli-bg-gradient: radial-gradient(circle at 50% 0%, #172554 0%, #070c18 65%, #030712 100%);
  --bubbli-surface: #0f172a;
  --bubbli-surface-card: rgba(17, 24, 39, 0.72);
  --bubbli-surface-card-hover: rgba(30, 41, 59, 0.85);
  
  --bubbli-text: #f8fafc;
  --bubbli-text-secondary: #94a3b8;
  --bubbli-text-muted: #64748b;
  
  --bubbli-border: rgba(148, 163, 184, 0.16);
  --bubbli-border-focus: #38bdf8;
  
  --bubbli-success: #10b981;
  --bubbli-warning: #f59e0b;
  --bubbli-error: #ef4444;
  --bubbli-focus: #38bdf8;

  /* ----------------------------------------------------
     8px Spacing System Tokens
     ---------------------------------------------------- */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */

  /* Touch accessibility standards */
  --min-touch-target: 44px;
  --btn-height-primary: 50px;
}

/* Base resets & viewport safety */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  max-width: 100vw;
  overflow-x: clip;
  scroll-behavior: smooth;
}

@supports not (overflow: clip) {
  html {
    overflow-x: hidden;
  }
}

body.studio-body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem; /* 16px readable base */
  line-height: 1.5;
  background-color: var(--bubbli-bg);
  background: var(--bubbli-bg-gradient);
  color: var(--bubbli-text);
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: clip;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

@supports not (overflow: clip) {
  body.studio-body {
    overflow-x: hidden;
  }
}

/* Headings typography */
h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Safe text wrapping helper */
.text-wrap-safe {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

/* Touch-optimized button classes */
.btn-touch-primary {
  min-height: var(--btn-height-primary);
  min-width: var(--min-touch-target);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.btn-touch-secondary {
  min-height: var(--btn-height-primary);
  min-width: var(--min-touch-target);
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  border-radius: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--bubbli-border);
  background: rgba(15, 23, 42, 0.65);
  color: #e2e8f0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.btn-touch-secondary:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(148, 163, 184, 0.35);
  color: #ffffff;
}

/* Minimum 44x44px touch targets */
.touch-target {
  min-width: var(--min-touch-target);
  min-height: var(--min-touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Focus indicator accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--bubbli-focus);
  outline-offset: 3px;
  border-radius: 0.5rem;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

/* Glassmorphism Surfaces */
.studio-glass {
  background: rgba(11, 19, 38, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--bubbli-border);
}

.studio-card {
  background: var(--bubbli-surface-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--bubbli-border);
  border-radius: 1rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.studio-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

/* Guided Step Progress Indicator Bar */
.step-nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  padding: 0.5rem 0.25rem;
}

.step-nav-bar::-webkit-scrollbar {
  display: none;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  color: var(--bubbli-text-secondary);
  background: rgba(15, 23, 42, 0.6);
  cursor: pointer;
}

.step-pill.active {
  background: rgba(37, 99, 235, 0.18);
  border-color: #3b82f6;
  color: #60a5fa;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.step-pill.completed {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.step-badge {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.2);
  color: currentColor;
}

.step-pill.active .step-badge {
  background: #2563eb;
  color: #ffffff;
}

.step-pill.completed .step-badge {
  background: #10b981;
  color: #ffffff;
}

/* Category Filter Cards */
.category-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  min-height: 44px;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid var(--bubbli-border);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.category-chip-btn:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(56, 189, 248, 0.4);
  color: #ffffff;
}

.category-chip-btn.active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

/* Sub-event pill */
.subevent-pill-btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 23, 42, 0.55);
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
}

.subevent-pill-btn:hover {
  color: #f1f5f9;
  border-color: rgba(56, 189, 248, 0.3);
}

.subevent-pill-btn.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: #06b6d4;
  color: #22d3ee;
}

/* Form Inputs & Safe 16px Sizing */
.studio-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 0.875rem;
  padding: 0.8rem 1rem;
  font-size: 1rem; /* 16px prevents iOS zoom bug */
  line-height: 1.4;
  color: #f8fafc;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.studio-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.studio-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bubbli-text-secondary);
  margin-bottom: 0.45rem;
}

/* Template Browser Card */
.template-browser-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  border: 1px solid var(--bubbli-border);
  background: var(--bubbli-surface-card);
  border-radius: 1.25rem;
}

.template-browser-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  border-color: rgba(56, 189, 248, 0.45);
}

/* Thumbnail preview container */
.template-thumb-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4/5;
  overflow: hidden;
  border-radius: 0.875rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: #090e1c;
  pointer-events: none;
}

/* Live Preview Canvas Container */
.preview-canvas-container {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 1.25rem;
  overflow: hidden;
  background: transparent;
}

/* Mobile Sticky Bottom Action Bar */
.studio-bottom-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(11, 19, 38, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--bubbli-border);
  padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

/* Swatch buttons */
.palette-swatch-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.875rem;
  border: 1px solid var(--bubbli-border);
  background: rgba(15, 23, 42, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.palette-swatch-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(30, 41, 59, 0.85);
}

.palette-swatch-card.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.color-dot-stack {
  display: flex;
  align-items: center;
  position: relative;
  width: 2.25rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.color-dot-stack .dot-bg {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-dot-stack .dot-primary {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  margin-left: -0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Toast alert notification */
.studio-toast {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid #38bdf8;
  color: #f8fafc;
  padding: 0.75rem 1.25rem;
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.studio-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
