/* ============================================================
   CYBER-FORGE Design System — Game Collage Platform
   Base CSS: Tokens, Typography, Utilities, Animations
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;600&display=swap');

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

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  color-scheme: dark;
  /* Forge Palette */
  --forge-orange:       #FF6B00;
  --forge-orange-dim:   rgba(255, 107, 0, 0.12);
  --forge-orange-glow:  rgba(255, 107, 0, 0.4);
  --circuit-teal:       #00D4AA;
  --circuit-teal-dim:   rgba(0, 212, 170, 0.10);
  --gold:               #FFD700;
  --gold-dim:           rgba(255, 215, 0, 0.15);

  /* Dark Surfaces */
  --abyss:   #0A0C10;
  --carbon:  #111318;
  --steel:   #191D26;
  --iron:    #21262F;
  --ash:     #2D3340;

  /* Text */
  --text-primary:   #E8EAF0;
  --text-secondary: #8892A4;
  --text-muted:     #4A5263;
  --text-inverse:   #0A0C10;

  /* Rarity (only place visual color variety is allowed) */
  --rarity-common:    #8892A4;
  --rarity-rare:      #4FC3F7;
  --rarity-epic:      #C084FC;
  --rarity-legendary: #FFD700;
  --rarity-mythic:    #FF6B00;
  --rarity-limited:   #F87171;

  /* Borders */
  --border:        1px solid var(--iron);
  --border-glow:   1px solid var(--forge-orange);
  --border-teal:   1px solid var(--circuit-teal);
  --border-gold:   1px solid var(--gold);

  /* Spacing (8-pt grid) */
  --s1:  0.5rem;    /* 8px */
  --s2:  1rem;      /* 16px */
  --s3:  1.5rem;    /* 24px */
  --s4:  2rem;      /* 32px */
  --s6:  3rem;      /* 48px */
  --s8:  4rem;      /* 64px */
  --s12: 6rem;      /* 96px */

  /* Typography Scale */
  --text-xs:   0.6875rem;
  --text-sm:   0.8125rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;
  --text-4xl:  3rem;
  --text-hero: clamp(2.8rem, 7vw, 5.5rem);

  /* Easing */
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:  cubic-bezier(0.65, 0, 0.35, 1);

  /* Transitions */
  --t-fast:   120ms;
  --t-normal: 280ms;
  --t-slow:   480ms;

  /* Radius — sharp by default */
  --r-none: 0;
  --r-sm:   2px;
  --r-md:   4px;
  --r-lg:   8px;

  /* Shadows */
  --shadow-card:  0 4px 24px rgba(0,0,0,0.5);
  --shadow-glow:  0 0 20px var(--forge-orange-glow);
  --shadow-teal:  0 0 20px rgba(0, 212, 170, 0.3);
}

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

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

body {
  background-color: var(--abyss);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-base);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

.heading-hero {
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.01em;
}

.label {
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Navigation ─────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(10, 12, 16, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s4);
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-logo .logo-accent { color: var(--forge-orange); }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--s3);
  list-style: none;
}

.nav-links a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--t-fast) ease;
  letter-spacing: 0.04em;
}
.nav-links a:hover { color: var(--text-primary); }
.nav-links a.active { color: var(--forge-orange); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  padding: 0.625rem 1.5rem;
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-normal) var(--ease-out), border-color var(--t-normal) var(--ease-out), box-shadow var(--t-normal) var(--ease-out), transform var(--t-normal) var(--ease-out);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.06);
  opacity: 0;
  transition: opacity var(--t-fast) ease;
}
.btn:hover::before { opacity: 1; }

.btn-primary {
  background: var(--forge-orange);
  color: #fff;
  border: 1px solid var(--forge-orange);
}
.btn-primary:hover {
  background: #FF8229;
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: var(--border);
}
.btn-secondary:hover {
  border-color: var(--forge-orange);
  color: var(--forge-orange);
  box-shadow: 0 0 12px var(--forge-orange-dim);
}

.btn-teal {
  background: var(--circuit-teal);
  color: var(--abyss);
  border: 1px solid var(--circuit-teal);
  font-weight: 700;
}
.btn-teal:hover {
  box-shadow: var(--shadow-teal);
  transform: translateY(-1px);
}

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

.btn-sm { padding: 0.375rem 1rem; font-size: var(--text-sm); }
.btn-lg { padding: 0.875rem 2rem; font-size: var(--text-xl); }
.btn-icon { padding: 0.5rem; width: 2.25rem; height: 2.25rem; }

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

/* ── Form Elements ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }

.form-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.form-input {
  background: var(--carbon);
  border: var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  padding: 0.75rem var(--s2);
  font-size: var(--text-base);
  outline: none;
  touch-action: manipulation;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
  width: 100%;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus {
  border-color: var(--forge-orange);
  box-shadow: 0 0 0 3px var(--forge-orange-dim);
}
.form-input.error { border-color: #F87171; }

.form-error {
  font-size: var(--text-xs);
  color: #F87171;
  margin-top: 0.25rem;
}

/* Search input */
.search-input {
  background: var(--steel);
  border: var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  padding: 0.625rem var(--s2) 0.625rem 2.75rem;
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--t-fast) ease;
  width: 100%;
}
.search-input:focus { border-color: var(--forge-orange); }
.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute; left: var(--s2); top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px; height: 16px;
  pointer-events: none;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--carbon);
  border: var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  touch-action: manipulation;
  transition: border-color var(--t-normal) ease, transform var(--t-normal) var(--ease-spring), box-shadow var(--t-normal) ease;
}
.card:hover {
  border-color: var(--forge-orange);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

/* ── Rarity Badges ───────────────────────────────────────── */
.rarity-badge {
  display: inline-block;
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.125rem 0.5rem;
  border-radius: var(--r-sm);
}

.rarity-common   { color: var(--rarity-common);    background: rgba(136,146,164,0.12); border: 1px solid rgba(136,146,164,0.3); }
.rarity-rare     { color: var(--rarity-rare);      background: rgba(79,195,247,0.10);  border: 1px solid rgba(79,195,247,0.3); }
.rarity-epic     { color: var(--rarity-epic);      background: rgba(192,132,252,0.10); border: 1px solid rgba(192,132,252,0.3); }
.rarity-legendary{ color: var(--rarity-legendary); background: rgba(255,215,0,0.10);   border: 1px solid rgba(255,215,0,0.3); }
.rarity-mythic   { color: var(--rarity-mythic);    background: rgba(255,107,0,0.10);   border: 1px solid rgba(255,107,0,0.3); }
.rarity-limited  { color: var(--rarity-limited);   background: rgba(248,113,113,0.10); border: 1px solid rgba(248,113,113,0.3); }

/* ── Dividers & Chips ────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--iron);
  border: none;
  margin: var(--s3) 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--steel);
  border: var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast) ease;
  white-space: nowrap;
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chip:hover { color: var(--text-primary); border-color: var(--ash); }
.chip.active {
  background: var(--forge-orange-dim);
  border-color: var(--forge-orange);
  color: var(--forge-orange);
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--s4);
  right: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  z-index: 9999;
}

.toast {
  background: var(--steel);
  border: var(--border);
  border-radius: var(--r-sm);
  padding: 0.875rem var(--s2);
  font-size: var(--text-sm);
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: var(--s2);
  animation: toastIn var(--t-normal) var(--ease-spring);
  box-shadow: var(--shadow-card);
}
.toast.success { border-left: 3px solid var(--circuit-teal); }
.toast.error   { border-left: 3px solid #F87171; }
.toast.info    { border-left: 3px solid var(--forge-orange); }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--abyss); }
::-webkit-scrollbar-thumb { background: var(--ash); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--forge-orange); }

/* ── Grain Texture Overlay ───────────────────────────────── */
.grain::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: inherit;
}

/* ── Page Wrapper ────────────────────────────────────────── */
.page { min-height: 100vh; padding-top: 60px; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--s4); }
.container-lg { max-width: 1440px; margin: 0 auto; padding: 0 var(--s4); }

/* ── Section Headers ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.section-title-wrap { display: flex; flex-direction: column; gap: 0.25rem; }
.section-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.section-subtitle { color: var(--text-secondary); font-size: var(--text-sm); }

/* ── Loading Spinner ─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--iron);
  border-top-color: var(--forge-orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-screen {
  position: fixed; inset: 0;
  background: var(--abyss);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--s2); z-index: 9999;
}
.loading-screen.hidden { display: none; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s8) var(--s4);
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg { color: var(--text-muted); opacity: 0.5; }
.empty-state h3 { font-size: var(--text-xl); color: var(--text-primary); }

/* ── Keyframe Animations ─────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px var(--forge-orange-glow); }
  50%       { box-shadow: 0 0 24px var(--forge-orange-glow), 0 0 48px var(--forge-orange-dim); }
}

@keyframes scanline {
  0%   { background-position: 0 0; }
  100% { background-position: 0 100%; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

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

/* ── Utility Classes ─────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--s1); }
.gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); }
.w-full { width: 100%; }
.text-orange { color: var(--forge-orange); }
.text-teal   { color: var(--circuit-teal); }
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--text-secondary); }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }

/* Stagger animation for lists */
.stagger > * { animation: fadeInUp 0.5s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }
.stagger > *:nth-child(n+7) { animation-delay: 0.35s; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .container { padding: 0 var(--s2); }
}

/* Mobile / small-screen nav toggle */
.nav-toggle {
  display: none;
  order: -1;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  font-size: 1.125rem;
  border-radius: 6px;
}

@media (max-width: 768px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; margin-right: var(--s3); }
  .nav { padding: 0 12px; }
  .nav.open { align-items: flex-start; }
  .nav.open .nav-links {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    position: absolute;
    top: 60px; left: 0; right: 0;
    background: rgba(10,12,16,0.98);
    padding: var(--s3);
    border-bottom: var(--border);
    z-index: 200;
  }
}

/* Additional responsive breakpoints */
@media (max-width: 1200px) {
  .container { max-width: 1000px; }
}

@media (max-width: 900px) {
  .hero { min-height: 70vh; padding: calc(60px + var(--s6)) 0 var(--s6); }
  .hero-title { font-size: clamp(1.6rem, 6vw, 2.8rem); }
  .hero-desc { font-size: var(--text-base); max-width: 100%; }
  .hero-actions { flex-direction: column; width: 100%; }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .template-preview-wrap { max-height: 320px; }
  .card:hover { transform: none; box-shadow: none; }
  .float-game-card { display: none; }
}

@media (max-width: 600px) {
  .section-header { flex-direction: column; align-items: flex-start; gap: var(--s2); }
  .showcase-grid { grid-template-columns: 1fr; }
  .steps-grid { flex-direction: column; }
  .nav { height: 56px; }
  .nav-logo { font-size: 1rem; }
}

/* Performance: reduce heavy visual effects on mobile */
@media (prefers-reduced-motion: reduce), (max-width: 900px) {
  .hero-orb, .hero-grid, .game-float-grid { animation: none !important; }
  .card, .btn-primary:hover { box-shadow: none !important; }
}

/* ── Premium Glassmorphism UI ─────────────────────────────────── */
.glass-panel {
  background: rgba(17, 19, 24, 0.65) !important;
  backdrop-filter: blur(16px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37) !important;
}

.glass-card {
  background: rgba(25, 29, 38, 0.5) !important;
  backdrop-filter: blur(12px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(12px) saturate(160%) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.25) !important;
  transition: all var(--t-normal) var(--ease-spring);
}

.glass-card:hover {
  background: rgba(25, 29, 38, 0.7) !important;
  border-color: rgba(255, 107, 0, 0.35) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 107, 0, 0.15) !important;
}
