/**
 * Wordnus Common Styles
 * CSS variables, base styles, utilities, and animations
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
  /* Confidence Colors */
  --wn-green: #22c55e;
  --wn-green-light: #86efac;
  --wn-green-dark: #16a34a;
  --wn-green-bg: rgba(34, 197, 94, 0.15);

  --wn-orange: #f97316;
  --wn-orange-light: #fdba74;
  --wn-orange-dark: #ea580c;
  --wn-orange-bg: rgba(249, 115, 22, 0.15);

  --wn-red: #ef4444;
  --wn-red-light: #fca5a5;
  --wn-red-dark: #dc2626;
  --wn-red-bg: rgba(239, 68, 68, 0.15);

  --wn-new: #94a3b8;
  --wn-new-light: #cbd5e1;
  --wn-new-dark: #64748b;
  --wn-new-bg: rgba(148, 163, 184, 0.15);

  /* UI Colors - Dark Theme */
  --wn-bg: #0f172a;
  --wn-bg-alt: #020617;
  --wn-surface: #1e293b;
  --wn-surface-hover: #334155;
  --wn-surface-active: #475569;
  --wn-border: #334155;
  --wn-border-light: #475569;

  /* Text Colors */
  --wn-text: #f1f5f9;
  --wn-text-secondary: #cbd5e1;
  --wn-text-muted: #94a3b8;
  --wn-text-disabled: #64748b;

  /* Accent Colors */
  --wn-primary: #6366f1;
  --wn-primary-light: #818cf8;
  --wn-primary-dark: #4f46e5;
  --wn-primary-bg: rgba(99, 102, 241, 0.15);

  --wn-accent: #8b5cf6;
  --wn-accent-light: #a78bfa;
  --wn-accent-dark: #7c3aed;

  /* Semantic Colors */
  --wn-success: var(--wn-green);
  --wn-warning: var(--wn-orange);
  --wn-error: var(--wn-red);
  --wn-info: #3b82f6;

  /* Shadows */
  --wn-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --wn-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --wn-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  --wn-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  --wn-shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

  /* Spacing */
  --wn-space-1: 0.25rem;
  --wn-space-2: 0.5rem;
  --wn-space-3: 0.75rem;
  --wn-space-4: 1rem;
  --wn-space-5: 1.25rem;
  --wn-space-6: 1.5rem;
  --wn-space-8: 2rem;
  --wn-space-10: 2.5rem;
  --wn-space-12: 3rem;
  --wn-space-16: 4rem;

  /* Border Radius */
  --wn-radius-sm: 0.25rem;
  --wn-radius: 0.5rem;
  --wn-radius-md: 0.75rem;
  --wn-radius-lg: 1rem;
  --wn-radius-xl: 1.5rem;
  --wn-radius-full: 9999px;

  /* Typography */
  --wn-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --wn-font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --wn-text-xs: 0.75rem;
  --wn-text-sm: 0.875rem;
  --wn-text-base: 1rem;
  --wn-text-lg: 1.125rem;
  --wn-text-xl: 1.25rem;
  --wn-text-2xl: 1.5rem;
  --wn-text-3xl: 1.875rem;
  --wn-text-4xl: 2.25rem;
  --wn-text-5xl: 3rem;

  /* Line Heights */
  --wn-leading-tight: 1.25;
  --wn-leading-normal: 1.5;
  --wn-leading-relaxed: 1.75;

  /* Transitions */
  --wn-transition-fast: 150ms ease;
  --wn-transition: 200ms ease;
  --wn-transition-slow: 300ms ease;
  --wn-transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-Index */
  --wn-z-dropdown: 100;
  --wn-z-sticky: 200;
  --wn-z-fixed: 300;
  --wn-z-modal-backdrop: 400;
  --wn-z-modal: 500;
  --wn-z-toast: 600;
}

/* ============================================
   BASE STYLES
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--wn-font-sans);
  font-size: var(--wn-text-base);
  line-height: var(--wn-leading-normal);
  color: var(--wn-text);
  background-color: var(--wn-bg);
  min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: var(--wn-leading-tight);
  color: var(--wn-text);
}

h1 { font-size: var(--wn-text-4xl); }
h2 { font-size: var(--wn-text-3xl); }
h3 { font-size: var(--wn-text-2xl); }
h4 { font-size: var(--wn-text-xl); }
h5 { font-size: var(--wn-text-lg); }
h6 { font-size: var(--wn-text-base); }

p {
  margin-bottom: var(--wn-space-4);
  color: var(--wn-text-secondary);
}

a {
  color: var(--wn-primary-light);
  text-decoration: none;
  transition: color var(--wn-transition-fast);
}

a:hover {
  color: var(--wn-primary);
}

/* ============================================
   BUTTONS
   ============================================ */

.wn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wn-space-2);
  padding: var(--wn-space-3) var(--wn-space-5);
  font-family: inherit;
  font-size: var(--wn-text-sm);
  font-weight: 500;
  line-height: 1;
  color: var(--wn-text);
  background: var(--wn-surface);
  border: 1px solid var(--wn-border);
  border-radius: var(--wn-radius);
  cursor: pointer;
  transition: all var(--wn-transition-fast);
  min-height: 44px;
  min-width: 44px;
}

.wn-btn:hover:not(:disabled) {
  background: var(--wn-surface-hover);
  border-color: var(--wn-border-light);
  transform: translateY(-1px);
}

.wn-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.wn-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wn-btn--primary {
  background: var(--wn-primary);
  border-color: var(--wn-primary);
  color: white;
}

.wn-btn--primary:hover:not(:disabled) {
  background: var(--wn-primary-dark);
  border-color: var(--wn-primary-dark);
}

.wn-btn--green {
  background: var(--wn-green);
  border-color: var(--wn-green);
  color: white;
}

.wn-btn--green:hover:not(:disabled) {
  background: var(--wn-green-dark);
}

.wn-btn--orange {
  background: var(--wn-orange);
  border-color: var(--wn-orange);
  color: white;
}

.wn-btn--orange:hover:not(:disabled) {
  background: var(--wn-orange-dark);
}

.wn-btn--red {
  background: var(--wn-red);
  border-color: var(--wn-red);
  color: white;
}

.wn-btn--red:hover:not(:disabled) {
  background: var(--wn-red-dark);
}

.wn-btn--ghost {
  background: transparent;
  border-color: transparent;
}

.wn-btn--ghost:hover:not(:disabled) {
  background: var(--wn-surface);
}

.wn-btn--lg {
  padding: var(--wn-space-4) var(--wn-space-6);
  font-size: var(--wn-text-base);
  min-height: 52px;
}

.wn-btn--sm {
  padding: var(--wn-space-2) var(--wn-space-3);
  font-size: var(--wn-text-xs);
  min-height: 36px;
}

.wn-btn--icon {
  padding: var(--wn-space-2);
  width: 44px;
}

/* ============================================
   CARDS
   ============================================ */

.wn-card {
  background: var(--wn-surface);
  border: 1px solid var(--wn-border);
  border-radius: var(--wn-radius-lg);
  padding: var(--wn-space-5);
  transition: all var(--wn-transition);
}

.wn-card--interactive {
  cursor: pointer;
}

.wn-card--interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--wn-shadow-md);
  border-color: var(--wn-border-light);
}

.wn-card--locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.wn-card--locked:hover {
  transform: none;
  box-shadow: none;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.wn-progress-bar {
  display: flex;
  align-items: stretch;
  height: 32px;
  background: var(--wn-bg-alt);
  border-radius: var(--wn-radius);
  overflow: hidden;
  gap: 2px;
}

.wn-progress-bar__segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 0 var(--wn-space-2);
  font-size: var(--wn-text-xs);
  font-weight: 600;
  color: white;
  transition: flex var(--wn-transition-slow);
}

.wn-progress-bar__segment--green {
  background: var(--wn-green);
}

.wn-progress-bar__segment--orange {
  background: var(--wn-orange);
}

.wn-progress-bar__segment--red {
  background: var(--wn-red);
}

.wn-progress-bar__segment--new {
  background: var(--wn-new);
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.wn-skeleton {
  background: linear-gradient(
    90deg,
    var(--wn-surface) 25%,
    var(--wn-surface-hover) 50%,
    var(--wn-surface) 75%
  );
  background-size: 200% 100%;
  animation: wn-skeleton-shimmer 1.5s infinite;
  border-radius: var(--wn-radius);
}

@keyframes wn-skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.wn-skeleton--text {
  height: 1em;
  width: 100%;
  margin-bottom: var(--wn-space-2);
}

.wn-skeleton--title {
  height: 2rem;
  width: 60%;
  margin-bottom: var(--wn-space-3);
}

.wn-skeleton--card {
  height: 200px;
  width: 100%;
}

/* ============================================
   TOAST / NOTIFICATIONS
   ============================================ */

.wn-toast-container {
  position: fixed;
  bottom: var(--wn-space-6);
  right: var(--wn-space-6);
  z-index: var(--wn-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--wn-space-3);
}

.wn-toast {
  display: flex;
  align-items: center;
  gap: var(--wn-space-3);
  padding: var(--wn-space-4) var(--wn-space-5);
  background: var(--wn-surface);
  border: 1px solid var(--wn-border);
  border-radius: var(--wn-radius);
  box-shadow: var(--wn-shadow-lg);
  animation: wn-toast-in 0.3s ease;
}

.wn-toast--success {
  border-left: 4px solid var(--wn-green);
}

.wn-toast--error {
  border-left: 4px solid var(--wn-red);
}

.wn-toast--warning {
  border-left: 4px solid var(--wn-orange);
}

.wn-toast--info {
  border-left: 4px solid var(--wn-info);
}

@keyframes wn-toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   MODAL
   ============================================ */

.wn-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: var(--wn-z-modal-backdrop);
  animation: wn-fade-in 0.2s ease;
}

.wn-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  background: var(--wn-surface);
  border: 1px solid var(--wn-border);
  border-radius: var(--wn-radius-xl);
  padding: var(--wn-space-6);
  z-index: var(--wn-z-modal);
  animation: wn-modal-in 0.3s ease;
  overflow-y: auto;
}

@keyframes wn-modal-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.wn-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--wn-space-4);
}

.wn-modal__title {
  font-size: var(--wn-text-xl);
  font-weight: 600;
}

.wn-modal__close {
  background: transparent;
  border: none;
  color: var(--wn-text-muted);
  cursor: pointer;
  padding: var(--wn-space-2);
  transition: color var(--wn-transition-fast);
}

.wn-modal__close:hover {
  color: var(--wn-text);
}

.wn-modal__body {
  margin-bottom: var(--wn-space-5);
}

.wn-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--wn-space-3);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes wn-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes wn-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes wn-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wn-slide-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wn-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes wn-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

@keyframes wn-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Animation utility classes */
.wn-animate-fade-in { animation: wn-fade-in 0.3s ease; }
.wn-animate-slide-up { animation: wn-slide-up 0.3s ease; }
.wn-animate-pulse { animation: wn-pulse 2s infinite; }
.wn-animate-bounce { animation: wn-bounce 1s infinite; }
.wn-animate-spin { animation: wn-spin 1s linear infinite; }
.wn-animate-shake { animation: wn-shake 0.3s ease; }

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Display */
.wn-hidden { display: none !important; }
.wn-block { display: block; }
.wn-flex { display: flex; }
.wn-inline-flex { display: inline-flex; }
.wn-grid { display: grid; }

/* Flex */
.wn-flex-col { flex-direction: column; }
.wn-items-center { align-items: center; }
.wn-items-start { align-items: flex-start; }
.wn-items-end { align-items: flex-end; }
.wn-justify-center { justify-content: center; }
.wn-justify-between { justify-content: space-between; }
.wn-justify-end { justify-content: flex-end; }
.wn-flex-wrap { flex-wrap: wrap; }
.wn-gap-2 { gap: var(--wn-space-2); }
.wn-gap-3 { gap: var(--wn-space-3); }
.wn-gap-4 { gap: var(--wn-space-4); }
.wn-gap-5 { gap: var(--wn-space-5); }

/* Text */
.wn-text-center { text-align: center; }
.wn-text-left { text-align: left; }
.wn-text-right { text-align: right; }
.wn-text-xs { font-size: var(--wn-text-xs); }
.wn-text-sm { font-size: var(--wn-text-sm); }
.wn-text-lg { font-size: var(--wn-text-lg); }
.wn-text-xl { font-size: var(--wn-text-xl); }
.wn-text-2xl { font-size: var(--wn-text-2xl); }
.wn-font-medium { font-weight: 500; }
.wn-font-semibold { font-weight: 600; }
.wn-font-bold { font-weight: 700; }
.wn-text-muted { color: var(--wn-text-muted); }
.wn-text-green { color: var(--wn-green); }
.wn-text-orange { color: var(--wn-orange); }
.wn-text-red { color: var(--wn-red); }

/* Spacing */
.wn-m-0 { margin: 0; }
.wn-mt-2 { margin-top: var(--wn-space-2); }
.wn-mt-4 { margin-top: var(--wn-space-4); }
.wn-mb-2 { margin-bottom: var(--wn-space-2); }
.wn-mb-4 { margin-bottom: var(--wn-space-4); }
.wn-p-0 { padding: 0; }
.wn-p-4 { padding: var(--wn-space-4); }
.wn-p-6 { padding: var(--wn-space-6); }

/* Width */
.wn-w-full { width: 100%; }
.wn-max-w-md { max-width: 28rem; }
.wn-max-w-lg { max-width: 32rem; }
.wn-max-w-xl { max-width: 36rem; }

/* ============================================
   RESPONSIVE CONTAINER
   ============================================ */

.wn-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--wn-space-4);
}

/* Mobile first responsive */
@media (min-width: 640px) {
  .wn-container {
    padding: 0 var(--wn-space-6);
  }
}

@media (min-width: 1024px) {
  .wn-container {
    padding: 0 var(--wn-space-8);
  }
}

/* Safe area insets for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .wn-safe-bottom {
    padding-bottom: max(var(--wn-space-4), env(safe-area-inset-bottom));
  }
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.wn-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--wn-border);
  border-top-color: var(--wn-primary);
  border-radius: 50%;
  animation: wn-spin 0.8s linear infinite;
}

.wn-spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.wn-spinner--lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* Full page loading */
.wn-loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--wn-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--wn-space-4);
  z-index: var(--wn-z-fixed);
}

/* ============================================
   FOCUS & ACCESSIBILITY
   ============================================ */

:focus-visible {
  outline: 2px solid var(--wn-primary);
  outline-offset: 2px;
}

.wn-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
