/* ============================================================
   GAMES INDEX — Design System & Theme Styles
   Aesthetic: "Arcade Console" — geometric precision meets neon warmth
   ============================================================ */

/* ---------- Design Tokens: Dark Theme (default) ---------- */
:root {
  /* Background */
  --color-bg: #0b0b12;
  --color-bg-alt: #10101a;
  --color-surface: #161623;
  --color-surface-hover: #1c1c2e;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-hover: rgba(255, 255, 255, 0.12);

  /* Text */
  --color-text: #e4e2df;
  --color-text-secondary: #8b8a96;
  --color-text-dim: #5c5b6e;

  /* Accents */
  --color-accent: #00e5ff;
  --color-accent-dim: rgba(0, 229, 255, 0.1);
  --color-accent-glow: rgba(0, 229, 255, 0.3);
  --color-warm: #ff6d3a;
  --color-warm-glow: rgba(255, 109, 58, 0.25);
  --color-purple: #b388ff;
  --color-purple-glow: rgba(179, 136, 255, 0.2);

  /* Decorative */
  --color-grid-line: rgba(255, 255, 255, 0.02);
  --color-grid-dot: rgba(255, 255, 255, 0.05);
  --color-shimmer: rgba(255, 255, 255, 0.03);

  /* Theme toggle */
  --toggle-bg: #1a1a2e;
  --toggle-ring: rgba(0, 229, 255, 0.4);
  --toggle-dot: #ffe082;
  --toggle-icon-color: #1a1a2e;

  /* Spacing scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;

  /* Typography */
  --font-display: "Courier New", "Noto Sans SC", monospace;
  --font-body: system-ui, "Noto Sans SC", "Microsoft YaHei", sans-serif;

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

  --leading-tight: 1.15;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-black: 900;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-theme: 400ms;
}

/* ---------- Design Tokens: Light Theme ---------- */
[data-theme="light"] {
  --color-bg: #f5f2ed;
  --color-bg-alt: #eeebe5;
  --color-surface: #ffffff;
  --color-surface-hover: #faf8f5;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-hover: rgba(0, 0, 0, 0.15);

  --color-text: #1a1a28;
  --color-text-secondary: #6b6a78;
  --color-text-dim: #a8a7b4;

  --color-accent: #00796b;
  --color-accent-dim: rgba(0, 121, 107, 0.08);
  --color-accent-glow: rgba(0, 121, 107, 0.2);
  --color-warm: #d84315;
  --color-warm-glow: rgba(216, 67, 21, 0.15);
  --color-purple: #6d3fc9;
  --color-purple-glow: rgba(109, 63, 201, 0.12);

  --color-grid-line: rgba(0, 0, 0, 0.03);
  --color-grid-dot: rgba(0, 0, 0, 0.06);
  --color-shimmer: rgba(0, 0, 0, 0.015);

  --toggle-bg: #e8e5df;
  --toggle-ring: rgba(0, 121, 107, 0.35);
  --toggle-dot: #ffb300;
  --toggle-icon-color: #e8e5df;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  transition:
    background-color var(--duration-theme) var(--ease-out),
    color var(--duration-theme) var(--ease-out);
  overflow-x: hidden;
}

/* Prevent transition flash on load */
html.no-transition,
html.no-transition *,
html.no-transition *::before,
html.no-transition *::after {
  transition: none !important;
}

/* ---------- Background Pattern ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  /* Subtle dot grid */
  background-image:
    radial-gradient(circle, var(--color-grid-dot) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* Subtle diagonal shimmer strips */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.3;
  background:
    repeating-linear-gradient(
      -58deg,
      transparent,
      transparent 120px,
      var(--color-shimmer) 120px,
      var(--color-shimmer) 122px
    );
}

/* ---------- Links ---------- */
a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.site-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-12);
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0 var(--space-8);
  position: relative;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.site-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  line-height: var(--leading-tight);
}

.site-title .accent {
  color: var(--color-accent);
}

.site-subtitle {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

/* Header decorative bracket line */
.header-left::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 2px;
  background: var(--color-accent);
  opacity: 0.6;
}

.header-left::after {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 24px;
  height: 2px;
  background: var(--color-warm);
  opacity: 0.4;
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: var(--toggle-bg);
  cursor: pointer;
  transition:
    background var(--duration-theme) var(--ease-out),
    border-color var(--duration-theme) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
  display: flex;
  align-items: center;
  padding: 3px;
  flex-shrink: 0;
}

.theme-toggle:hover {
  box-shadow: 0 0 0 3px var(--toggle-ring);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-toggle .toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--toggle-dot);
  position: relative;
  transition: transform var(--duration-normal) var(--ease-in-out);
  transform: translateX(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .theme-toggle .toggle-thumb {
  transform: translateX(24px);
}

/* Sun rays (visible in dark mode = toggle shows sun → switch to light) */
.toggle-thumb::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-color: transparent;
  transition: border-color var(--duration-normal) var(--ease-out);
}

/* Moon crescent overlay (visible in light mode) */
.toggle-thumb::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--toggle-bg);
  transition:
    transform var(--duration-normal) var(--ease-in-out),
    opacity var(--duration-normal) var(--ease-out);
  opacity: 0;
  transform: scale(0);
}

[data-theme="light"] .toggle-thumb::after {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Main Content ---------- */
.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

/* Section label */
.section-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
  opacity: 0.3;
}

/* ---------- Games Grid ---------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

/* ---------- Game Card ---------- */
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6) var(--space-6);
  transition:
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

/* Accent glow on hover — each card gets its own glow color via inline style or nth */
.game-card .card-glow {
  position: absolute;
  inset: -1px;
  z-index: -2;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
  pointer-events: none;
}

.game-card:nth-child(1) .card-glow {
  background: var(--color-accent-glow);
  filter: blur(24px);
}

.game-card:nth-child(2) .card-glow {
  background: var(--color-warm-glow);
  filter: blur(24px);
}

.game-card:nth-child(3) .card-glow {
  background: var(--color-purple-glow);
  filter: blur(24px);
}

.game-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.game-card:hover .card-glow {
  opacity: 1;
}

/* Card number badge */
.card-number {
  position: absolute;
  top: var(--space-4);
  right: var(--space-5);
  font-family: var(--font-display);
  font-size: 4.5rem;
  font-weight: var(--weight-black);
  color: var(--color-border);
  line-height: 1;
  pointer-events: none;
  transition: color var(--duration-normal) var(--ease-out);
}

.game-card:hover .card-number {
  color: var(--color-border-hover);
}

/* Card icon */
.card-icon {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 1;
  transition: transform var(--duration-normal) var(--ease-out);
}

.game-card:hover .card-icon {
  transform: scale(1.1) rotate(-3deg);
}

/* Card title */
.card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  position: relative;
  z-index: 1;
}

/* Card description */
.card-desc {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-5);
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Card link/button */
.card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  padding: var(--space-2) 0;
  position: relative;
  z-index: 1;
  transition:
    color var(--duration-fast) var(--ease-out),
    gap var(--duration-normal) var(--ease-out);
}

.card-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--color-accent);
  opacity: 0.3;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    height var(--duration-fast) var(--ease-out);
}

.game-card:hover .card-link {
  gap: var(--space-3);
}

.game-card:hover .card-link::after {
  opacity: 0.7;
  height: 2px;
}

/* Card accent colors */
.game-card:nth-child(1) .card-link { color: var(--color-accent); }
.game-card:nth-child(1) .card-link::after { background: var(--color-accent); }
.game-card:nth-child(2) .card-link { color: var(--color-warm); }
.game-card:nth-child(2) .card-link::after { background: var(--color-warm); }
.game-card:nth-child(3) .card-link { color: var(--color-purple); }
.game-card:nth-child(3) .card-link::after { background: var(--color-purple); }

/* ============================================================
   CARD ENTRY ANIMATIONS (staggered on load)
   ============================================================ */

.game-card {
  opacity: 0;
  transform: translateY(24px);
  animation: cardEnter 0.6s var(--ease-out) forwards;
}

.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.15s; }
.game-card:nth-child(3) { animation-delay: 0.25s; }

@keyframes cardEnter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  margin-top: auto;
  padding-top: var(--space-12);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.footer-text {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.footer-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-text-dim);
  opacity: 0.4;
}

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

@media (max-width: 860px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-title {
    font-size: var(--text-2xl);
  }
}

@media (max-width: 580px) {
  .games-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .site-wrapper {
    padding: var(--space-4) var(--space-4) var(--space-8);
  }

  .site-title {
    font-size: var(--text-xl);
  }

  .card-number {
    font-size: 3rem;
  }
}
