/* ============================================================
   WordShard — main.css
   Shared design tokens, resets, typography, and components
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Palette */
  --color-bg:         #080B14;
  --color-surface:    #0F1629;
  --color-card:       #1A2240;
  --color-card-hover: #1f2b52;
  --color-border:     rgba(123, 97, 255, 0.2);

  --color-primary:    #7B61FF;
  --color-primary-dim:#5A47CC;
  --color-accent:     #00E5FF;
  --color-gold:       #FFD700;
  --color-success:    #2ECC71;
  --color-error:      #FF4757;

  --color-text-1:     #FFFFFF;
  --color-text-2:     #A8B4CC;
  --color-text-3:     #5E6A80;

  /* Typography */
  --font-display: 'Orbitron', monospace;
  --font-body:    'Inter', sans-serif;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Border radii */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-full: 9999px;

  /* Shadows */
  --glow-primary: 0 0 20px rgba(123, 97, 255, 0.4);
  --glow-accent:  0 0 20px rgba(0, 229, 255, 0.35);
  --glow-gold:    0 0 16px rgba(255, 215, 0, 0.5);

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

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--color-bg);
  color: var(--color-text-1);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
ul { list-style: none; }

/* ── Utility ────────────────────────────────────────────────── */
.gold  { color: var(--color-gold); }
.green { color: var(--color-success); }
.red   { color: var(--color-error); }
.hidden { display: none !important; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--transition-fast);
}
.btn:hover::after  { background: rgba(255,255,255,0.07); }
.btn:active::after { background: rgba(255,255,255,0.12); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary), #9B7DFF);
  color: #fff;
  box-shadow: var(--glow-primary);
}
.btn--primary:hover { box-shadow: 0 0 30px rgba(123, 97, 255, 0.6); transform: translateY(-1px); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-2);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover { border-color: var(--color-primary); color: var(--color-text-1); }

.btn--lg  { padding: var(--space-4) var(--space-7); font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn--xl  { padding: var(--space-5) var(--space-8); font-size: 1.15rem; border-radius: var(--radius-lg); }
.btn--sm  { padding: var(--space-2) var(--space-3); font-size: 0.85rem; }
.btn-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
}
.card--outlined {
  background: transparent;
  border-color: rgba(123, 97, 255, 0.15);
}
.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-1);
  margin-bottom: var(--space-4);
  letter-spacing: 0.05em;
}
.card-body { color: var(--color-text-2); font-size: 0.9rem; margin-bottom: var(--space-4); }
.card-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--color-primary);
  margin-top: var(--space-3);
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 20, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-5);
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: var(--glow-primary);
}
.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  color: var(--color-text-3);
  font-size: 1.5rem;
  line-height: 1;
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--color-text-1); }
.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: var(--space-5);
  letter-spacing: 0.05em;
}
.modal-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ── Form elements ──────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-2);
  margin-bottom: var(--space-2);
}
.text-input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-1);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast);
  outline: none;
}
.text-input:focus { border-color: var(--color-primary); }
.text-input::placeholder { color: var(--color-text-3); }
.input-row { display: flex; gap: var(--space-2); align-items: center; }
.input-row .text-input { flex: 1; }
.input-error {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: var(--space-2);
}
.input-error[hidden] { display: none; }

/* ── Overlays ───────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 20, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: var(--space-5);
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-8);
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: var(--glow-primary);
  animation: slideUp var(--transition-slow) both;
}
.overlay-card--sm { max-width: 360px; padding: var(--space-6); }
.overlay-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: var(--space-6);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.overlay-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.overlay-stat {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-3);
}
.overlay-stat__label { display: block; font-size: 0.75rem; color: var(--color-text-3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.overlay-stat__value { display: block; font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; }
.overlay-rank { margin-bottom: var(--space-5); }
.overlay-rank__label { font-size: 0.85rem; color: var(--color-text-2); display: block; margin-bottom: 4px; }
.overlay-rank__value { font-family: var(--font-display); font-size: 2rem; color: var(--color-gold); font-weight: 900; }
.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  color: var(--color-text-3);
  font-size: 0.9rem;
  padding: var(--space-5) 0;
  text-align: center;
}

/* ── Leaderboard ────────────────────────────────────────────── */
.leaderboard-wrap { width: 100%; }
.leaderboard-loading { color: var(--color-text-3); font-size: 0.9rem; padding: var(--space-5) 0; text-align: center; }
.lb-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.lb-row:hover { background: var(--color-surface); }
.lb-row--self { background: rgba(123, 97, 255, 0.1); border: 1px solid rgba(123, 97, 255, 0.3); }
.lb-rank {
  width: 28px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text-3);
  flex-shrink: 0;
}
.lb-rank--1 { color: var(--color-gold); }
.lb-rank--2 { color: #C0C0C0; }
.lb-rank--3 { color: #CD7F32; }
.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.lb-name { flex: 1; font-size: 0.95rem; font-weight: 500; }
.lb-score { font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--color-gold); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--glow-primary); }
  50%       { box-shadow: 0 0 40px rgba(123, 97, 255, 0.7); }
}
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(var(--rot, 0deg)); }
  50%       { transform: translateY(-12px) rotate(var(--rot, 0deg)); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ── Landing page ───────────────────────────────────────────── */
.landing-page {
  overflow-x: hidden;
  position: relative;
}
#bg-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.shard-deco {
  position: fixed;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  color: rgba(123, 97, 255, 0.12);
  pointer-events: none;
  z-index: 0;
  animation: float 6s ease-in-out infinite;
}
.shard-deco--1 { top: 12%; left: 6%;  --rot: -12deg; animation-delay: 0s; }
.shard-deco--2 { top: 18%; left: 14%; --rot:  8deg;  animation-delay: 0.5s; }
.shard-deco--3 { top: 60%; left: 5%;  --rot: -6deg;  animation-delay: 1.2s; }
.shard-deco--4 { top: 65%; left: 14%; --rot: 14deg;  animation-delay: 0.8s; }
.shard-deco--5 { top: 30%; right: 6%; --rot: 10deg;  animation-delay: 0.3s; }
.shard-deco--6 { top: 36%; right: 14%; --rot:-8deg;  animation-delay: 1.5s; }

.landing-main {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-5);
  gap: var(--space-7);
}

.landing-header { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }
.logo-wrap { position: relative; }
.landing-logo {
  filter: drop-shadow(0 0 24px rgba(123, 97, 255, 0.8));
  animation: pulse-glow 3s ease-in-out infinite;
}
.landing-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}
.title-word--1 { color: var(--color-text-1); }
.title-word--2 {
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
}
.landing-tagline {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--color-text-2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.landing-cta {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

.feature-pills {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
}
.pill {
  background: rgba(123, 97, 255, 0.1);
  border: 1px solid rgba(123, 97, 255, 0.25);
  color: var(--color-text-2);
  font-size: 0.8rem;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}

.how-to-play {
  position: relative;
  z-index: 1;
  padding: var(--space-8) var(--space-5);
  text-align: center;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.how-to-play .section-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-7);
  color: var(--color-text-1);
}
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
  max-width: 900px;
  margin: 0 auto;
}
.step-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.step-card:hover { transform: translateY(-4px); box-shadow: var(--glow-primary); }
.step-number {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  color: rgba(123, 97, 255, 0.2);
  margin-bottom: var(--space-3);
}
.step-icon { width: 64px; height: 64px; margin: 0 auto var(--space-4); }
.step-card h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  text-transform: uppercase;
}
.step-card p { font-size: 0.9rem; color: var(--color-text-2); }

.landing-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-5);
  color: var(--color-text-3);
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .overlay-stats { grid-template-columns: 1fr; }
  .landing-cta { flex-direction: column; align-items: center; }
  .btn--lg { width: 100%; max-width: 320px; }
}
