/*
 * Woweach Design System
 * =====================
 * Shared tokens and components for all Woweach services.
 * Source of truth: launcher visual language.
 *
 * Usage:
 *   <link rel="stylesheet" href="/path/to/design-system.css">
 *   or @import url('./design-system.css');
 *
 * All tokens prefixed --w- to avoid collision during migration.
 * All component classes prefixed .w- for the same reason.
 *
 * When building new UI: ALWAYS use --w-* tokens for colors.
 * NEVER hardcode hex values outside this file.
 */

/* ============================================================
   1. TOKENS — CSS Custom Properties
   ============================================================ */
:root {
  /* --- Backgrounds (darkest → lightest) --- */
  --w-bg-primary:    #0a0712;
  --w-bg-secondary:  #110e1a;
  --w-bg-tertiary:   #1a1526;
  --w-bg-card:       #13101d;
  --w-bg-card-hover: #1e192c;
  --w-bg-input:      #0d0a15;
  --w-bg-surface:    #161220;

  /* --- Borders --- */
  --w-border:        #2a2440;
  --w-border-subtle: #1e1a2e;
  --w-border-focus:  #8b6cc7;

  /* --- Text --- */
  --w-text-primary:   #f0ecf6;
  --w-text-secondary: #b5aacb;
  --w-text-muted:     #8578a0;

  /* --- Accent (warm gold) --- */
  --w-accent:       #e6c170;
  --w-accent-hover: #f2d48e;
  --w-accent-dim:   #b89545;
  --w-accent-glow:  rgba(230, 193, 112, 0.15);

  /* --- Semantic --- */
  --w-success:  #4ade80;
  --w-error:    #f87171;
  --w-warning:  #fbbf24;

  /* --- Purple (secondary accent) --- */
  --w-purple:     #8b6cc7;
  --w-purple-dim: rgba(139, 108, 199, 0.12);

  /* --- Radii --- */
  --w-radius-sm: 6px;
  --w-radius-md: 10px;
  --w-radius-lg: 14px;

  /* --- Shadows --- */
  --w-shadow-card:       0 2px 12px rgba(0, 0, 0, 0.3);
  --w-shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--w-border-focus);
  --w-shadow-glow:       0 0 20px var(--w-accent-glow);

  /* --- Transitions --- */
  --w-transition-fast: 0.15s ease;
  --w-transition-med:  0.25s ease;
  --w-transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Typography --- */
  --w-font-body: 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --w-font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}


/* ============================================================
   2. BASE RESET
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

.w-base {
  font-family: var(--w-font-body);
  background: var(--w-bg-primary);
  color: var(--w-text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
.w-base ::-webkit-scrollbar { width: 8px; }
.w-base ::-webkit-scrollbar-track { background: transparent; }
.w-base ::-webkit-scrollbar-thumb { background: var(--w-border); border-radius: 4px; }
.w-base ::-webkit-scrollbar-thumb:hover { background: var(--w-text-muted); }


/* ============================================================
   3. COMPONENT CLASSES
   ============================================================ */

/* --- Buttons --- */
.w-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--w-radius-sm);
  font-family: var(--w-font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--w-transition-fast);
  color: inherit;
}

.w-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.w-btn-primary {
  background: linear-gradient(135deg, var(--w-accent) 0%, var(--w-accent-dim) 100%);
  color: var(--w-bg-primary);
  font-weight: 700;
  padding: 10px 24px;
  border-radius: var(--w-radius-sm);
  border: none;
  cursor: pointer;
  font-family: var(--w-font-body);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(230, 193, 112, 0.2);
  transition: all var(--w-transition-fast);
}

.w-btn-primary:hover {
  background: linear-gradient(135deg, var(--w-accent-hover) 0%, var(--w-accent) 100%);
  box-shadow: 0 4px 16px rgba(230, 193, 112, 0.35);
  transform: translateY(-1px);
}

.w-btn-primary:active { transform: translateY(0); }
.w-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.w-btn-secondary {
  background: var(--w-bg-tertiary);
  color: var(--w-text-primary);
  padding: 10px 20px;
  border-radius: var(--w-radius-sm);
  border: 1px solid var(--w-border);
  cursor: pointer;
  font-family: var(--w-font-body);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--w-transition-fast);
}

.w-btn-secondary:hover {
  background: var(--w-bg-card-hover);
  border-color: var(--w-border-focus);
}

.w-btn-danger {
  background: transparent;
  color: var(--w-error);
  padding: 10px 20px;
  border-radius: var(--w-radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.3);
  cursor: pointer;
  font-family: var(--w-font-body);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--w-transition-fast);
}

.w-btn-danger:hover {
  background: rgba(248, 113, 113, 0.08);
  border-color: var(--w-error);
}

.w-btn-play {
  background: linear-gradient(135deg, var(--w-accent) 0%, #d4a94e 100%);
  color: var(--w-bg-primary);
  font-weight: 800;
  padding: 14px 48px;
  border-radius: var(--w-radius-md);
  font-size: 16px;
  font-family: var(--w-font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: all var(--w-transition-med);
  box-shadow: 0 4px 20px rgba(230, 193, 112, 0.3), 0 0 40px rgba(230, 193, 112, 0.1);
}

.w-btn-play:hover {
  box-shadow: 0 6px 30px rgba(230, 193, 112, 0.45), 0 0 60px rgba(230, 193, 112, 0.15);
  transform: translateY(-2px);
}

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

/* Small button modifier */
.w-btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* --- Badges --- */
.w-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.w-badge-success { background: rgba(74, 222, 128, 0.12); color: var(--w-success); }
.w-badge-warning { background: rgba(251, 191, 36, 0.12); color: var(--w-warning); }
.w-badge-accent  { background: var(--w-accent-glow); color: var(--w-accent); }
.w-badge-error   { background: rgba(248, 113, 113, 0.12); color: var(--w-error); }

/* --- Card --- */
.w-card {
  background: var(--w-bg-card);
  border: 1px solid var(--w-border-subtle);
  border-radius: var(--w-radius-md);
  padding: 16px 20px;
  transition: border-color var(--w-transition-fast);
}

.w-card:hover,
.w-card-hover:hover {
  border-color: var(--w-border);
}

.w-card-interactive {
  cursor: pointer;
  transition: all var(--w-transition-med);
}

.w-card-interactive:hover {
  border-color: var(--w-border-focus);
  background: var(--w-bg-card-hover);
  box-shadow: var(--w-shadow-card);
}

/* --- Input --- */
.w-input {
  font-family: var(--w-font-body);
  font-size: 14px;
  background: var(--w-bg-input);
  border: 1px solid var(--w-border);
  color: var(--w-text-primary);
  padding: 10px 14px;
  border-radius: var(--w-radius-sm);
  outline: none;
  transition: border-color var(--w-transition-fast), box-shadow var(--w-transition-fast);
  width: 100%;
}

.w-input:focus {
  border-color: var(--w-border-focus);
  box-shadow: 0 0 0 3px var(--w-purple-dim);
}

.w-input::placeholder { color: var(--w-text-muted); }

/* --- Section Label --- */
.w-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--w-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

/* --- Toggle Switch --- */
.w-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  display: inline-block;
}

.w-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.w-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--w-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--w-transition-fast);
}

.w-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: var(--w-text-secondary);
  border-radius: 50%;
  transition: all var(--w-transition-fast);
}

.w-toggle input:checked + .w-toggle-track {
  background: var(--w-accent);
}

.w-toggle input:checked + .w-toggle-track::after {
  left: 23px;
  background: var(--w-bg-primary);
}

/* --- Progress Bar --- */
.w-progress-track {
  height: 6px;
  background: var(--w-bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.w-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--w-accent-dim), var(--w-accent));
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}

.w-progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: w-shimmer 2s infinite;
}

@keyframes w-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* --- Spinner --- */
.w-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--w-border);
  border-top-color: var(--w-accent);
  border-radius: 50%;
  animation: w-spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes w-spin {
  to { transform: rotate(360deg); }
}

/* --- Skeleton Loading --- */
.w-skeleton {
  background: linear-gradient(90deg, var(--w-bg-tertiary) 0%, var(--w-bg-card-hover) 50%, var(--w-bg-tertiary) 100%);
  background-size: 200% 100%;
  animation: w-skeleton-pulse 1.5s ease infinite;
  border-radius: var(--w-radius-sm);
}

@keyframes w-skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Message / Alert --- */
.w-msg-error {
  background: rgba(248, 113, 113, 0.08);
  color: var(--w-error);
  border: 1px solid rgba(248, 113, 113, 0.15);
  padding: 10px 14px;
  border-radius: var(--w-radius-sm);
  font-size: 13px;
}

.w-msg-success {
  background: rgba(74, 222, 128, 0.08);
  color: var(--w-success);
  border: 1px solid rgba(74, 222, 128, 0.15);
  padding: 10px 14px;
  border-radius: var(--w-radius-sm);
  font-size: 13px;
}

.w-msg-warning {
  background: rgba(251, 191, 36, 0.08);
  color: var(--w-warning);
  border: 1px solid rgba(251, 191, 36, 0.15);
  padding: 10px 14px;
  border-radius: var(--w-radius-sm);
  font-size: 13px;
}


/* ============================================================
   4. AUTH FORM — shared between launcher + game client
   ============================================================ */

/* Overlay */
.w-auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  z-index: 9999;
  overflow: hidden;
}

/* Animated background orbs */
.w-auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
}
.w-auth-orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(139,108,199,0.3), transparent);
  top: -10%; right: -5%;
  animation: w-auth-float1 12s ease-in-out infinite;
}
.w-auth-orb-2 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(230,193,112,0.15), transparent);
  bottom: -5%; left: -5%;
  animation: w-auth-float2 15s ease-in-out infinite;
}
.w-auth-orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(139,108,199,0.15), transparent);
  top: 40%; left: 30%;
  animation: w-auth-float3 10s ease-in-out infinite;
}
@keyframes w-auth-float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-30px,20px)} }
@keyframes w-auth-float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(20px,-30px)} }
@keyframes w-auth-float3 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-15px,-15px)} }

/* Card */
.w-auth-card {
  width: 420px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(17,14,26,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius-lg);
  padding: 36px 32px;
  position: relative;
  z-index: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Brand header */
.w-auth-brand {
  text-align: center;
  margin-bottom: 28px;
}
.w-auth-brand-logo {
  width: 60px; height: 60px;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--w-accent) 0%, #d4a94e 100%);
  color: var(--w-bg-primary);
  font-size: 1.75rem; font-weight: 900;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(230,193,112,0.25);
}
.w-auth-brand h1,
.w-auth-brand h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--w-text-primary);
  letter-spacing: -0.01em;
  margin: 0;
}
.w-auth-brand-sub {
  color: var(--w-text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* Close button */
.w-auth-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  color: var(--w-text-muted);
  font-size: 1.4em; cursor: pointer; padding: 4px;
  transition: color var(--w-transition-fast);
  z-index: 2;
}
.w-auth-close:hover { color: var(--w-error); }

/* Form layout */
.w-auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Password field with toggle */
.w-auth-pw-field {
  position: relative;
}
.w-auth-pw-field .w-input {
  padding-right: 60px;
}
.w-auth-pw-toggle {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--w-text-muted);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px; cursor: pointer;
  font-family: var(--w-font-body);
}
.w-auth-pw-toggle:hover { color: var(--w-accent); }

/* Password requirements */
.w-auth-pw-reqs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--w-text-muted);
}
.w-auth-pw-reqs span { opacity: 0.5; }
.w-auth-pw-reqs span::before { content: "\2715 "; color: var(--w-error); }
.w-auth-pw-reqs span.met { opacity: 1; color: var(--w-success); }
.w-auth-pw-reqs span.met::before { content: "\2713 "; color: var(--w-success); }

/* Checkbox rows */
.w-auth-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--w-text-secondary);
  cursor: pointer;
  line-height: 1.4;
}
.w-auth-checkbox input[type="checkbox"] {
  margin-top: 2px; width: 16px; height: 16px;
  flex-shrink: 0; accent-color: var(--w-accent); cursor: pointer;
}

/* Inline link */
.w-auth-inline-link {
  background: none; border: none;
  color: var(--w-accent);
  font-size: inherit; padding: 0;
  text-decoration: underline;
  cursor: pointer; display: inline;
  font-family: var(--w-font-body);
}
.w-auth-inline-link:hover { color: var(--w-accent-hover); }

/* Divider */
.w-auth-divider {
  color: var(--w-text-muted);
  font-size: 0.75em;
  text-align: center;
  margin: 4px 0;
  text-transform: uppercase;
  letter-spacing: 3px;
}

/* Auth links (below form) */
.w-auth-links {
  text-align: center;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.w-auth-link-btn {
  background: none; border: none;
  color: var(--w-text-muted);
  font-size: 13px; padding: 4px;
  cursor: pointer;
  font-family: var(--w-font-body);
  transition: color var(--w-transition-fast);
}
.w-auth-link-btn strong { color: var(--w-accent); }
.w-auth-link-btn:hover { color: var(--w-text-secondary); }
.w-auth-link-btn:hover strong { color: var(--w-accent-hover); }
.w-auth-link-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Hint / verify text */
.w-auth-hint {
  color: var(--w-text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
  line-height: 1.5;
}
.w-auth-hint strong { color: var(--w-text-primary); }

/* Error / success message */
.w-auth-msg {
  padding: 10px 14px;
  border-radius: var(--w-radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.w-auth-msg-error {
  background: rgba(248,113,113,0.08);
  color: var(--w-error);
  border: 1px solid rgba(248,113,113,0.15);
}
.w-auth-msg-success {
  background: rgba(74,222,128,0.08);
  color: var(--w-success);
  border: 1px solid rgba(74,222,128,0.15);
}

/* Inline spinner */
.w-auth-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--w-border);
  border-top-color: var(--w-accent);
  border-radius: 50%;
  animation: w-spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

/* Full-width modifier for buttons inside auth forms */
.w-auth-form .w-btn-primary,
.w-auth-form .w-btn-secondary {
  width: 100%;
}


/* ============================================================
   5. UTILITY CLASSES
   ============================================================ */
.w-text-primary   { color: var(--w-text-primary); }
.w-text-secondary { color: var(--w-text-secondary); }
.w-text-muted     { color: var(--w-text-muted); }
.w-text-accent    { color: var(--w-accent); }
.w-text-success   { color: var(--w-success); }
.w-text-error     { color: var(--w-error); }
.w-text-mono      { font-family: var(--w-font-mono); }


/* ============================================================
   5. PAGE TRANSITION (optional)
   ============================================================ */
.w-page-enter {
  animation: w-pageIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes w-pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
