/* Design tokens, reset, loading states and shared blocks */

/* Outfit (SIL Open Font License, assets/fonts/OFL.txt), one variable file per alphabet: the browser only downloads
   the one whose characters a page uses */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../assets/fonts/outfit-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../assets/fonts/outfit-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Colors */
  --bg-base: #0a0a14;
  --bg-surface: #0f0f1e;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(99, 210, 190, 0.35);

  --accent-teal: #3dd9b3;
  --accent-gold: #f5c542;
  --check-pending: #c9c9e0; /* the complete mark of a game that is not completed yet */
  --accent-purple: #a78bfa;
  --accent-pink: #f472b6;
  /* the colour of each level of a special achievement (js/lib/special.js): vivid, to shine against the dark cards */
  --aura-1: 214, 226, 245;
  --aura-2: 255, 200, 40;
  --aura-3: 180, 100, 255;
  --live-green: #4ade80;

  --gradient-brand: linear-gradient(135deg, #3dd9b3 0%, #f5c542 100%);
  --gradient-hero: linear-gradient(135deg, #1e3a5f 0%, #0f0f1e 60%);
  --gradient-card: linear-gradient(145deg, rgba(61,217,179,0.08) 0%, rgba(245,197,66,0.04) 100%);

  --text-primary: #f1f1f5;
  --text-secondary: #9a9ab0;
  --text-muted: #5c5c78;

  /* Typography */
  --font: 'Outfit', system-ui, sans-serif;

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-glow: 0 0 40px rgba(61, 217, 179, 0.15);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.45);
  --shadow-btn: 0 4px 20px rgba(61, 217, 179, 0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }

::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* A page that could not load (no connection, the server failing): the session is kept and it can be retried */
.load-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 420px;
  margin: 15vh auto 0;
  padding: 0 24px;
  text-align: center;
  color: var(--text-secondary);
}

.load-error-icon { font-size: 2.5rem; }

.load-error-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.load-error button {
  font: inherit;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.load-error button.primary { background: var(--gradient-brand); color: var(--bg-base); border-color: transparent; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
  grid-column: 1 / -1;
}

.empty-state span {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.loading-spinner {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes pulse { 50% { opacity: 0.3; } }

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* the hidden attribute must win over any display rule */
[hidden] { display: none !important; }

/* A rating (1-100) next to a game's name: a ring whose hue goes from red to green with the score */
.score-badge {
  --h: 60;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 1.9em; height: 1.9em; padding: 0 0.4em; box-sizing: border-box; vertical-align: middle;
  border-radius: var(--radius-pill); border: 1.5px solid hsl(var(--h) 50% 55% / 0.75);
  background: hsl(var(--h) 50% 55% / 0.12); color: hsl(var(--h) 55% 72%);
  font-size: 0.72rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}

/* A game's name that leads to its page: it keeps the look of the text around it */
.game-link { color: inherit; text-decoration: none; }
.game-link:hover { color: var(--accent-teal); text-decoration: underline; }

/* A special achievement: the level sets the colour (rgb triplet) that everything painted for it reads */
.special-1 { --aura-rgb: var(--aura-1); }
.special-2 { --aura-rgb: var(--aura-2); }
.special-3 { --aura-rgb: var(--aura-3); }
