/* ============================================
   Let's Speak English — Design System
   Cream Glass: Warm cream × Apple minimal × Glassmorphism
   ============================================ */

:root {
  /* 🌈 Colors */
  --bg-page: #FBFBF9;
  --bg-card: #F6F6F3;
  --bg-elevated: #FFFFFF;
  --bg-chat-user: #007AFF;
  --bg-chat-ai: #F0F0ED;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-heavy: rgba(255, 255, 255, 0.88);
  --bg-overlay: rgba(0, 0, 0, 0.32);
  --bg-input: #FFFFFF;

  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #A1A1A6;
  --text-inverse: #FFFFFF;
  --text-link: #007AFF;

  --accent: #007AFF;
  --accent-pressed: #0063CC;
  --success: #34C759;
  --warning: #FF9500;
  --error: #FF3B30;

  /* 🔤 Typography */
  --font-stack: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;

  --fs-hero: 2rem;
  --fs-display: 1.625rem;
  --fs-title: 1.3125rem;
  --fs-heading: 1rem;
  --fs-body: 1rem;
  --fs-body-small: 0.875rem;
  --fs-caption: 0.75rem;
  --fs-caption-strong: 0.75rem;
  --fs-micro: 0.6875rem;
  --fs-button: 1rem;
  --fs-button-small: 0.875rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.1;
  --lh-normal: 1.25;
  --lh-relaxed: 1.4;
  --lh-loose: 1.5;

  /* 📐 Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ⭕ Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* ⬛ Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.10);

  /* 🪟 Glass */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-heavy-bg: rgba(255, 255, 255, 0.88);
  --glass-border: 0.5px solid rgba(255, 255, 255, 0.3);

  /* 🎬 Easing */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-enter: cubic-bezier(0.0, 0, 0.2, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-stack);
  font-size: 17px;
  line-height: var(--lh-loose);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

/* iOS Safe Area */
.safe-area {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ============================================
   Typography Helpers
   ============================================ */
.text-hero { font-size: var(--fs-hero); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: -0.5px; }
.text-display { font-size: var(--fs-display); font-weight: var(--fw-semibold); line-height: var(--lh-normal); letter-spacing: -0.3px; }
.text-title { font-size: var(--fs-title); font-weight: var(--fw-semibold); line-height: var(--lh-normal); letter-spacing: -0.2px; }
.text-heading { font-size: var(--fs-heading); font-weight: var(--fw-semibold); line-height: var(--lh-normal); letter-spacing: -0.2px; }
.text-body { font-size: var(--fs-body); font-weight: var(--fw-regular); line-height: var(--lh-loose); }
.text-body-small { font-size: var(--fs-body-small); font-weight: var(--fw-regular); line-height: var(--lh-relaxed); }
.text-caption { font-size: var(--fs-caption); font-weight: var(--fw-regular); line-height: var(--lh-relaxed); }
.text-caption-strong { font-size: var(--fs-caption-strong); font-weight: var(--fw-semibold); line-height: var(--lh-relaxed); }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-inverse { color: var(--text-inverse); }
.text-accent { color: var(--accent); }

/* ============================================
   Glass Utility
   ============================================ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--glass-border);
}

.glass-heavy {
  background: var(--glass-heavy-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: var(--glass-border);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  font-family: var(--font-stack);
  font-size: var(--fs-button);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: transform 150ms var(--ease-standard), opacity 150ms var(--ease-standard);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

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

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  padding: 14px 28px;
  width: 100%;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(0, 122, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: var(--fs-button-small);
  width: 100%;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 8px 16px;
  font-size: var(--fs-button-small);
}

/* ============================================
   Page Container
   ============================================ */
.page {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: var(--bg-page);
  animation: pageEnter 300ms var(--ease-enter) both;
}

.page.active {
  display: flex;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-5);
  -webkit-overflow-scrolling: touch;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Card
   ============================================ */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

/* ============================================
   Chip / Tag
   ============================================ */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: var(--fw-medium);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms var(--ease-standard);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
  border: none;
  font-family: var(--font-stack);
}

.chip:active {
  transform: scale(0.96);
}

.chip.active {
  background: var(--text-primary);
  color: var(--text-inverse);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  max-width: 340px;
  width: 90%;
  text-align: center;
  animation: modalEnter 250ms var(--ease-enter) both;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 29, 31, 0.88);
  color: var(--text-inverse);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--fs-caption);
  z-index: 200;
  opacity: 0;
  transition: opacity 250ms var(--ease-standard);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-track {
  width: 100%;
  height: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 300ms var(--ease-standard);
  width: 0%;
}

/* ============================================
   Animations
   ============================================ */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.3); }
  70% { box-shadow: 0 0 0 16px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.fade-in-up {
  animation: fadeInUp 200ms var(--ease-enter) both;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
