/* ============================================
   FOUNDATION STYLES
   Clean & Modern Puzzle Website
   ============================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* --- CSS Variables (easy to customize later) --- */
:root {
  /* Colors */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1f2a40;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(99, 179, 237, 0.25);

  --text-primary: #e8ecf4;
  --text-secondary: #8a94a6;
  --text-muted: #556170;

  --accent: #63b3ed;
  --accent-glow: rgba(99, 179, 237, 0.15);
  --accent-bright: #90cdf4;
  --accent-secondary: #b794f4;
  --success: #68d391;
  --warning: #f6ad55;
  --danger: #fc8181;

  /* Typography */
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Layout */
  --max-width: 1140px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-bright);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Background Atmosphere --- */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(99, 179, 237, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(183, 148, 244, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* --- Layout Container --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  position: relative;
  z-index: 1;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.site-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* Desktop Nav */
.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  position: relative;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: var(--accent);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: var(--space-md);
  right: var(--space-md);
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
}

/* ============================================
   HERO SECTION (Home Page)
   ============================================ */
.hero {
  padding: var(--space-2xl) 0 var(--space-xl);
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  border-radius: 999px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--accent);
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.6s var(--ease-out) both;
}

.hero-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease infinite;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-md);
  animation: fadeInUp 0.6s var(--ease-out) 0.1s both;
}

.hero h1 .gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto var(--space-xl);
  line-height: 1.7;
  animation: fadeInUp 0.6s var(--ease-out) 0.2s both;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.7rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5a9fd4);
  color: var(--bg-primary);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(99, 179, 237, 0.25);
  color: var(--bg-primary);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.hero-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeInUp 0.6s var(--ease-out) 0.3s both;
}

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2xl);
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: var(--space-xs);
}

/* ============================================
   SECTION HEADINGS
   ============================================ */
.section-header {
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
}

.section-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ============================================
   CHALLENGE CARDS GRID
   ============================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: var(--space-md);
}

.card-icon.blue { background: rgba(99, 179, 237, 0.12); }
.card-icon.purple { background: rgba(183, 148, 244, 0.12); }
.card-icon.green { background: rgba(104, 211, 145, 0.12); }
.card-icon.orange { background: rgba(246, 173, 85, 0.12); }

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: var(--space-md);
}

/* Difficulty Tag */
.tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag-easy { background: rgba(104, 211, 145, 0.12); color: var(--success); }
.tag-medium { background: rgba(246, 173, 85, 0.12); color: var(--warning); }
.tag-hard { background: rgba(252, 129, 129, 0.12); color: var(--danger); }

/* Card status */
.card-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   LEADERBOARD TABLE
   ============================================ */
.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: var(--space-2xl);
}

.leaderboard-table th {
  text-align: left;
  padding: var(--space-md) var(--space-lg);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table td {
  padding: var(--space-md) var(--space-lg);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table tr:hover td {
  background: var(--bg-card);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.rank-1 { background: rgba(246, 173, 85, 0.15); color: var(--warning); }
.rank-2 { background: rgba(160, 174, 192, 0.15); color: #a0aec0; }
.rank-3 { background: rgba(198, 146, 107, 0.15); color: #c6926b; }
.rank-other { background: var(--bg-card); color: var(--text-muted); }

.player-name {
  font-weight: 600;
}

.score-value {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
}

/* ============================================
   BLOG CARDS
   ============================================ */
.blog-card {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  transition: all 0.3s var(--ease-out);
}

.blog-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

.blog-card-date {
  flex-shrink: 0;
  text-align: center;
  padding: var(--space-sm) var(--space-md);
  background: rgba(99, 179, 237, 0.06);
  border-radius: var(--radius-sm);
  align-self: flex-start;
}

.blog-card-date .month {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.blog-card-date .day {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.blog-card-body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.blog-card-body p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.blog-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
}

.footer-links a {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--text-secondary);
}

/* ============================================
   PAGE-SPECIFIC: Inner Pages
   ============================================ */
.page-header {
  padding: var(--space-2xl) 0 var(--space-xl);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-sm);
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Staggered card animation */
.card:nth-child(1) { animation: fadeInUp 0.5s var(--ease-out) 0.05s both; }
.card:nth-child(2) { animation: fadeInUp 0.5s var(--ease-out) 0.1s both; }
.card:nth-child(3) { animation: fadeInUp 0.5s var(--ease-out) 0.15s both; }
.card:nth-child(4) { animation: fadeInUp 0.5s var(--ease-out) 0.2s both; }
.card:nth-child(5) { animation: fadeInUp 0.5s var(--ease-out) 0.25s both; }
.card:nth-child(6) { animation: fadeInUp 0.5s var(--ease-out) 0.3s both; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: column;
    padding: var(--space-md);
  }

  .main-nav.open {
    display: flex;
  }

  .nav-link.active::after {
    display: none;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .blog-card {
    flex-direction: column;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}
