/* ============================================================
   games-core.css
   Shared styles for the Brain Games hub: nav, player profile
   panel, game card grid, game container shell, leaderboard,
   percentile celebration toast, footer, and responsive rules.

   Game-specific visuals (e.g. the reaction box, memory tiles,
   stroop word, schulte grid) live inside each game's own JS
   module and are injected as a scoped <style> tag at runtime.
   Keep this file limited to things every game shares.
   ============================================================ */

:root {
  --bg:#faf8f4;
  --panel:#ffffff;
  --border:#e4e0d6;
  --accent:#b5502a;
  --accent2:#2c3532;
  --text:#1e1c18;
  --muted:#6b6558;
  --success:#3f7d5c;
  --shadow: rgba(30,28,24,0.08);
}

* {
  box-sizing:border-box;
  font-family:'Inter', system-ui, sans-serif;
  scroll-behavior: smooth;
}

body {
  margin:0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  width: 100%;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

nav .nav-content {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

nav .logo {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

nav .nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

nav .nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition: color 0.15s ease;
}

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

main {
  max-width:1000px;
  margin:0 auto;
  padding:3rem 1.5rem;
  margin-top: 80px;
  position: relative;
  z-index: 1;
}

h1 {
  font-family:'Fraunces', Georgia, serif;
  font-size:2.6rem;
  margin-bottom:1rem;
  color: var(--accent);
}

.hero-subtitle {
  max-width: 760px;
  font-size: 1.05rem;
  line-height: 1.6;
}

.player-hub {
  margin: 1.3rem 0 2.2rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 4px 16px var(--shadow);
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  align-items: end;
}

.player-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-field label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.player-input,
.player-select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  font-size: 0.95rem;
}

.focus-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(140deg, rgba(181, 80, 42,0.14), rgba(44, 53, 50,0.18));
  color: var(--accent2);
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid rgba(44, 53, 50,0.3);
}

.coach-line {
  margin-top: 0.85rem;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
}

.percentile-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--accent2);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: linear-gradient(150deg, rgba(44, 53, 50,0.25), rgba(181, 80, 42,0.22));
  border: 1px solid rgba(44, 53, 50,0.38);
}

.stat-value.percentile-animated {
  animation: percentilePop 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.percentile-celebration {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(320px, calc(100vw - 2rem));
  border-radius: 18px;
  padding: 1rem;
  background: var(--accent2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 40px rgba(30, 28, 24, 0.35);
  color: #faf8f4;
  z-index: 11000;
  display: none;
  transform: translateY(14px) scale(0.98);
}

.percentile-celebration.show {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  animation: percentileToastIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.percentile-ring {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent2) 0deg, rgba(255,255,255,0.16) 0deg);
  position: relative;
}

.percentile-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--accent2);
}

.percentile-ring-value {
  position: relative;
  font-weight: 700;
  font-size: 1.05rem;
}

.percentile-meta h4 { margin: 0 0 0.22rem; font-size: 1rem; }
.percentile-meta p { margin: 0; color: rgba(245, 251, 255, 0.9); font-size: 0.88rem; line-height: 1.35; }

.leaderboard-value {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 6px 20px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: fadeLift 0.55s ease both;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,0.7) 45%, transparent 70%);
  transform: translateX(-130%);
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 32px var(--shadow);
  border-color: var(--accent2);
}

.game-card:hover::before { animation: cardSheen 0.95s ease; }

.game-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.game-icon svg { width: 100%; height: 100%; stroke-width: 1.4; }

.game-card h3 { margin: 0 0 0.5rem 0; color: var(--accent2); font-size: 1.5rem; }
.game-card p { color: var(--muted); margin: 0; font-size: 0.95rem; }

.game-container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 6px 20px var(--shadow);
  display: none;
}

.game-container.active { display: block; animation: panelReveal 0.35s ease; }

@keyframes panelReveal {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.game-stats { display: flex; gap: 2rem; flex-wrap: wrap; }
.stat { text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--muted); }

.game-hint { color: var(--muted); text-align: center; margin-top: 0.6rem; }

.btn {
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s ease;
  font-size: 1rem;
  margin: 0.5rem;
}

.btn-primary { background: var(--accent2); color: white; }
.btn-primary:hover { background: var(--accent); transform: scale(1.05); }

.btn-secondary { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent2); color: var(--accent2); }

.leaderboard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 6px 20px var(--shadow);
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.leaderboard-item:last-child { border-bottom: none; }

.rank { font-size: 1.5rem; font-weight: 700; color: var(--accent); min-width: 50px; }

footer {
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4rem;
}
footer a { color: var(--accent2); text-decoration: none; font-weight: 600; text-align: center; }
footer a:hover { text-decoration: underline; }

@keyframes percentilePop {
  0% { transform: scale(0.9); opacity: 0.7; }
  45% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes percentileToastIn {
  from { transform: translateY(14px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes fadeLift {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardSheen {
  from { transform: translateX(-130%); }
  to { transform: translateX(130%); }
}
@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ===== Hamburger ===== */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.menu-toggle span { width: 24px; height: 3px; background: var(--text); display: block; border-radius: 2px; transition: all 0.3s ease; }
.menu-toggle.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.nav-stats { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: var(--muted); }
.nav-stats .stat-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.65rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.nav-stats .stat-pill strong { color: var(--text); font-weight: 700; }

@media (max-width:600px){
  h1{font-size:2rem;}
  .games-grid{grid-template-columns:1fr;}
}

@media (max-width: 860px) {
  .menu-toggle { display: flex; z-index: 1100; }
  .logo { font-size: 1.15rem; }

  nav .nav-links {
    position: fixed;
    top: 72px;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--panel);
    border-radius: 14px;
    padding: 1.1rem;
    gap: 0.9rem;
    box-shadow: 0 18px 40px var(--shadow);
    border: 1px solid var(--border);
    transform: translateY(-10px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 999;
  }
  nav .nav-links.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }
  .nav-stats { order: 3; }
}
