/* ========================================
   Family Crest Generator - Design System
   ======================================== */

/* CSS Variables - Heraldic Theme */
:root {
  /* Colors */
  --color-bg-primary: #0d0d12;
  --color-bg-secondary: #16161d;
  --color-bg-card: rgba(26, 26, 35, 0.8);
  --color-bg-card-hover: rgba(35, 35, 48, 0.9);

  --color-gold: #d4af37;
  --color-gold-light: #f0d060;
  --color-gold-dark: #a38829;

  --color-accent: #8b0000;
  --color-accent-light: #b22222;

  --color-text-primary: #f5f5f5;
  --color-text-secondary: #a0a0a8;
  --color-text-muted: #6a6a72;

  --color-border: rgba(212, 175, 55, 0.2);
  --color-border-focus: rgba(212, 175, 55, 0.6);

  /* Typography */
  --font-heading: 'Cinzel', 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 5rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 20px rgba(212, 175, 55, 0.2);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background Pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 0, 0, 0.03) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4af37' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: -1;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text-primary);
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  letter-spacing: 0.02em;
}

h2 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  letter-spacing: 0.01em;
}

h3 {
  font-size: clamp(1.25rem, 2vw, 1.5rem);
}

p {
  color: var(--color-text-secondary);
  max-width: 65ch;
}

a {
  color: var(--color-gold);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-gold-light);
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* Header */
.header {
  padding: var(--space-md) 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(13, 13, 18, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.logo-icon {
  width: 40px;
  height: 40px;
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) 0;
  text-align: center;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 50px;
  font-size: 0.875rem;
  color: var(--color-gold);
  margin-bottom: var(--space-lg);
  letter-spacing: 0.05em;
}

.hero h1 {
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--color-gold-light), var(--color-gold), var(--color-gold-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.25rem;
  margin-bottom: var(--space-xl);
  color: var(--color-text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
  color: var(--color-bg-primary);
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-gold-light), var(--color-gold));
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--color-gold);
  border: 2px solid var(--color-gold);
}

.btn-secondary:hover {
  background: rgba(212, 175, 55, 0.1);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: 1.125rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Generator Section */
.generator {
  padding: var(--space-2xl) 0;
  background: var(--color-bg-secondary);
}

.generator-title {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.generator-title h2 {
  margin-bottom: var(--space-sm);
}

.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: start;
}

@media (max-width: 900px) {
  .generator-grid {
    grid-template-columns: 1fr;
  }
}

/* Form Card */
.form-card {
  background: var(--color-bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}

.form-card h3 {
  margin-bottom: var(--space-lg);
  color: var(--color-gold);
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  color: var(--color-text-primary);
}

.form-group small {
  display: block;
  margin-top: var(--space-xs);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

input,
textarea {
  width: 100%;
  padding: var(--space-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

textarea {
  min-height: 150px;
  resize: vertical;
}

/* Preview Card */
.preview-card {
  background: var(--color-bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.preview-placeholder {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  gap: var(--space-sm);
}

.preview-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: 0.5;
}

.preview-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-lg);
  display: none;
}

.preview-image.visible {
  display: block;
}

/* Watermark overlay */
.preview-image-wrapper::after {
  content: 'PREVIEW';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 10;
  letter-spacing: 0.2em;
  white-space: nowrap;
  display: none;
}

.preview-image-wrapper.has-image::after {
  display: block;
}

.preview-actions {
  margin-top: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.preview-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-gold);
  margin-bottom: var(--space-xs);
}

.preview-price-note {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Loading State */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 13, 18, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-crest {
  width: 120px;
  height: 120px;
  animation: pulse 2s ease-in-out infinite;
}

.loading-text {
  margin-top: var(--space-lg);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--color-gold);
}

.loading-subtext {
  margin-top: var(--space-xs);
  color: var(--color-text-muted);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.95);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* Features Section */
.features {
  padding: var(--space-2xl) 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

@media (max-width: 768px) {
  .features-grid {
    grid-template-columns: 1fr;
  }
}

.feature-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--transition-base);
}

.feature-card:hover {
  background: var(--color-bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.feature-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-md);
  color: var(--color-gold);
}

.feature-card h3 {
  margin-bottom: var(--space-sm);
}

/* How It Works */
.how-it-works {
  padding: var(--space-2xl) 0;
  background: var(--color-bg-secondary);
}

.section-title {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.section-title h2 {
  margin-bottom: var(--space-sm);
}

.steps {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.step {
  flex: 1;
  min-width: 200px;
  max-width: 280px;
  text-align: center;
  position: relative;
}

.step-number {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
  color: var(--color-bg-primary);
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 50%;
}

.step h3 {
  margin-bottom: var(--space-xs);
}

/* Footer */
.footer {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer p {
  color: var(--color-text-muted);
  margin: 0 auto;
}

/* Success Page Styles */
.success-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.success-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  text-align: center;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  color: #22c55e;
}

.success-card h1 {
  font-size: 2rem;
  margin-bottom: var(--space-md);
  color: var(--color-text-primary);
  -webkit-text-fill-color: var(--color-text-primary);
}

.success-card p {
  margin: 0 auto var(--space-lg);
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-gold {
  color: var(--color-gold);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.delay-1 {
  animation-delay: 0.1s;
}

.delay-2 {
  animation-delay: 0.2s;
}

.delay-3 {
  animation-delay: 0.3s;
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */

/* Tablet and smaller */
@media (max-width: 900px) {
  :root {
    --space-2xl: 3rem;
  }

  .hero {
    padding-top: 100px;
    min-height: auto;
    padding-bottom: var(--space-xl);
  }

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .form-card,
  .preview-card {
    padding: var(--space-lg);
  }
}

/* Mobile devices */
@media (max-width: 768px) {
  :root {
    --space-xl: 2rem;
    --space-2xl: 2.5rem;
  }

  .container {
    padding: 0 var(--space-sm);
  }

  /* Header mobile */
  .header {
    padding: var(--space-sm) 0;
  }

  .logo {
    font-size: 1.1rem;
    gap: 0.5rem;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
  }

  .logo span {
    display: inline;
  }

  .header nav .btn {
    padding: 8px 12px;
    font-size: 0.7rem;
    white-space: nowrap;
  }

  /* Hide header CTA on very small screens, hero CTA is visible anyway */
  @media (max-width: 400px) {
    .header nav {
      display: none;
    }
  }

  /* Hero mobile */
  .hero {
    padding: 80px var(--space-sm) var(--space-xl);
    min-height: auto;
  }

  .hero-content {
    padding: 0 var(--space-xs);
  }

  .hero-badge {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .hero h1 {
    font-size: 2rem;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 1rem;
    padding: 0 var(--space-xs);
  }

  .btn-lg {
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.95rem;
    width: auto;
    max-width: 100%;
  }

  /* Steps mobile */
  .steps {
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
  }

  .step {
    max-width: 100%;
    padding: 0 var(--space-sm);
  }

  .step-number {
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }

  /* Generator section mobile */
  .generator {
    padding: var(--space-xl) 0;
  }

  .generator-title {
    margin-bottom: var(--space-lg);
  }

  .generator-title h2 {
    font-size: 1.5rem;
  }

  .generator-grid {
    gap: var(--space-lg);
  }

  .form-card,
  .preview-card {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
  }

  .form-card h3,
  .preview-card h3 {
    font-size: 1.1rem;
    margin-bottom: var(--space-md);
  }

  input,
  textarea {
    padding: 14px var(--space-sm);
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  textarea {
    min-height: 120px;
  }

  .form-group label {
    font-size: 0.95rem;
  }

  .form-group small {
    font-size: 0.8rem;
  }

  /* Preview mobile */
  .preview-placeholder {
    min-height: 250px;
  }

  .preview-placeholder svg {
    width: 48px;
    height: 48px;
  }

  .preview-placeholder span {
    font-size: 0.9rem;
  }

  .preview-price {
    font-size: 1.75rem;
  }

  .preview-actions .btn {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
  }

  /* Features mobile */
  .features {
    padding: var(--space-xl) 0;
  }

  .feature-card {
    padding: var(--space-md);
  }

  .feature-icon {
    width: 48px;
    height: 48px;
  }

  /* How it works mobile */
  .how-it-works {
    padding: var(--space-xl) 0;
  }

  .section-title h2 {
    font-size: 1.5rem;
  }

  /* Footer mobile */
  .footer {
    padding: var(--space-lg) 0;
  }

  .footer p {
    font-size: 0.85rem;
  }

  /* Success page mobile */
  .success-card {
    padding: var(--space-lg);
    margin: var(--space-sm);
  }

  .success-card h1 {
    font-size: 1.5rem;
  }

  .success-icon {
    width: 60px;
    height: 60px;
  }

  /* Loading overlay mobile */
  .loading-crest {
    width: 80px;
    height: 80px;
  }

  .loading-text {
    font-size: 1.1rem;
  }

  .loading-subtext {
    font-size: 0.85rem;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .btn {
    font-size: 0.85rem;
    letter-spacing: 0.03em;
  }

  .form-card,
  .preview-card {
    border-radius: var(--radius-md);
  }

  .step h3 {
    font-size: 1rem;
  }

  .step p {
    font-size: 0.9rem;
  }

  .feature-card h3 {
    font-size: 1rem;
  }

  .feature-card p {
    font-size: 0.9rem;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 48px;
    /* Touch target size */
  }

  .btn-primary:hover {
    transform: none;
    /* Disable hover effects on touch */
  }

  .feature-card:hover {
    transform: none;
  }

  input,
  textarea {
    min-height: 48px;
  }
}

/* Landscape phone */
@media (max-width: 900px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: 80px var(--space-md) var(--space-lg);
  }

  .hero::before {
    width: 300px;
    height: 300px;
  }
}

/* Safe area insets for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: max(var(--space-md), env(safe-area-inset-top));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .footer {
    padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
  }
}