/* ============================================================
   global.css — Design tokens, reset, typography, shared components
   ============================================================ */

/* ── Custom properties ──────────────────────────────────────────────────── */
:root {
  /* Colours */
  --clr-bg:          #0b0d14;
  --clr-surface:     #13172a;
  --clr-surface-alt: #1c2240;
  --clr-border:      #2a3060;
  --clr-text:        #d8dff5;
  --clr-muted:       #7b88b8;
  --clr-accent:      #4f8cff;
  --clr-accent-glow: rgba(79, 140, 255, 0.25);
  --clr-p1:          #4f8cff;   /* Player 1 — blue */
  --clr-p2:          #ff5f7e;   /* Player 2 — coral */
  --clr-ghost:       rgba(255, 255, 255, 0.18);
  --clr-win:         #ffe066;   /* Win-line highlight */

  /* Typography */
  --font-sans:   system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono:   'Fira Code', 'Cascadia Code', Consolas, monospace;
  --fs-xs:       0.75rem;
  --fs-sm:       0.875rem;
  --fs-base:     1rem;
  --fs-lg:       1.125rem;
  --fs-xl:       1.375rem;
  --fs-2xl:      1.75rem;
  --fs-3xl:      2.25rem;
  --fs-hero:     clamp(2.5rem, 5vw, 4rem);

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-24: 6rem;

  /* Layout */
  --max-w: 1200px;
  --nav-h: 4rem;

  /* Radii */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast:   150ms;
  --t-base:   250ms;
  --t-slow:   400ms;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--clr-bg);
  color: var(--clr-text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

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

a {
  color: var(--clr-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #fff;
}

.section-title {
  font-size: var(--fs-2xl);
  text-align: center;
  margin-bottom: var(--sp-4);
}

.section-sub {
  color: var(--clr-muted);
  text-align: center;
  margin-bottom: var(--sp-8);
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  padding: 0 var(--sp-8);
  background: rgba(11, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--clr-border);
}

.nav-logo img {
  height: 32px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: var(--sp-6);
  margin-left: auto;
}

.nav-links a {
  color: var(--clr-text);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color var(--t-fast);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: #fff;
  text-decoration: none;
}

.nav-cta {
  margin-left: var(--sp-4);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2) var(--sp-6);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  border: 2px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
  text-decoration: none !important;
}

.btn-primary {
  background: var(--clr-accent);
  color: #fff;
}

.btn-primary:hover {
  background: #6ba3ff;
  box-shadow: 0 0 20px var(--clr-accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--clr-text);
  border-color: var(--clr-border);
}

.btn-ghost:hover {
  border-color: var(--clr-accent);
  color: #fff;
}

.btn-lg {
  padding: var(--sp-3) var(--sp-8);
  font-size: var(--fs-base);
  border-radius: var(--r-lg);
}

.btn-sm {
  padding: var(--sp-1) var(--sp-4);
  font-size: var(--fs-xs);
}

/* ── Pill toggle buttons (shared: /play difficulty, /community leaderboard filter) */
.pill {
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--clr-border);
  background: transparent;
  color: var(--clr-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.pill:hover {
  border-color: var(--clr-accent);
  color: var(--clr-text);
}

.pill[aria-pressed="true"] {
  background: var(--clr-accent-glow);
  border-color: var(--clr-accent);
  color: #fff;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--clr-border);
  padding: var(--sp-8);
  text-align: center;
  color: var(--clr-muted);
  font-size: var(--fs-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  align-items: center;
}

.site-footer nav {
  display: flex;
  gap: var(--sp-6);
}

.site-footer a {
  color: var(--clr-muted);
}

.site-footer a:hover {
  color: var(--clr-text);
}

/* ── Coordinate badge (shared across /play and /learn) ─────────────────── */
.coord-badge {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-sm);
  padding: var(--sp-1) var(--sp-3);
  color: var(--clr-accent);
  letter-spacing: 0.04em;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--sp-8);
}

/* ── Scrollbar (Webkit) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--clr-bg); }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-muted); }

/* ── Focus ring (accessibility) ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--clr-accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

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