/* games-base.css — shared base styles for all 9 game pages.
 * Design tokens are defined in design-tokens.css (imported first).
 * Each game's <style> block only needs to define :root overrides and
 * game-specific rules.
 *
 * Load order in each game HTML:
 *   1. design-tokens.css  ← central variables
 *   2. shell.css          ← shell layout
 *   3. games-base.css     ← this file
 *   4. tutorial-modal.css ← tutorial overlay
 */

/* ─── Default Tokens (game-page scope) ────────────────────────────── */
:root {
  --brand-bg:         var(--dg-bg-game);              /* #0a0a0f */
  --brand-accent:     var(--brand-accent, #888888);   /* overridden per-game */
  --brand-accent-dim: var(--brand-accent-dim, #666666);
  --glass-bg:         var(--dg-bg-surface);           /* rgba(255,255,255,0.03) */
  --glass-border:     var(--dg-border);               /* rgba(255,255,255,0.08) */
}

/* ─── Base Reset ──────────────────────────────────────────────────── */
* {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--dg-font-ui);
  background: var(--brand-bg);
  color: var(--dg-text);
  overflow-x: hidden;
  overflow-y: auto;
}

/* Subtle dot-grid background texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: -1;
}

/* ─── Typography ──────────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--dg-font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mono {
  font-family: var(--dg-font-mono);
}

/* ─── Glass Surfaces ──────────────────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

.glass-strong {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 24px -4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
  padding: 0.625rem 1.25rem;
  min-height: 44px;                               /* iOS touch target minimum */
  border-radius: var(--dg-radius-md);             /* 12px */
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-accent-dim));
  color: var(--dg-bg-game);                       /* dark text on colored button */
  box-shadow: var(--dg-shadow-btn);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--dg-bg-surface);
  border: 1px solid var(--dg-border-1);
  color: var(--dg-text-2);
}

.btn-secondary:hover {
  background: var(--dg-bg-surface-1);
  border-color: var(--dg-border-2);
  color: var(--dg-text);
}

/* ─── Shared Components ───────────────────────────────────────────── */
.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.accent-text {
  color: var(--brand-accent);
}

.modal-backdrop {
  background: rgba(5, 5, 10, 0.9);
  backdrop-filter: blur(8px);
}

.leaderboard-row {
  transition: background 0.15s ease;
}

.leaderboard-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ─── Loading Pulse ───────────────────────────────────────────────── */
@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.loading-pulse {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* ─── Mobile App Bar (back button) ───────────────────────────────── */
.mobile-app-bar {
  display: none;
  position: fixed;
  /* env(safe-area-inset-top) keeps the button clear of the status bar.
   * The extra 0.25rem gives a small visual gap above the button. */
  top: calc(env(safe-area-inset-top, 0px) + 0.25rem);
  left: 0.25rem;
  z-index: 80;
}

/* Plain arrow — no circle or glass background */
.mobile-app-bar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 44×44 touch target, no visual chrome */
  width: 44px;
  height: 44px;
  color: rgba(255, 255, 255, 0.8);
  -webkit-tap-highlight-color: transparent;
}

.mobile-app-bar a:active {
  color: rgba(255, 255, 255, 1);
}

@media (max-width: 899px) {
  nav { display: none !important; }
  .mobile-app-bar { display: flex; }

  /* Apply safe-area offset to body so content never renders under the status
   * bar. The back button is position:fixed and floats over content, so main
   * only needs a small top gap — matching the look of the hub tab pages. */
  body {
    padding-top: env(safe-area-inset-top, 0px);
  }
  main {
    padding-top: 1rem !important;
    padding-bottom: var(--dg-bottom-clear, 88px) !important;
  }
}

/* ─── How to Play Accordion ───────────────────────────────────────── */
details summary {
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::marker {
  content: '';
}

summary.details-plus::after {
  content: '+';
  float: right;
  font-weight: 300;
  font-size: 1.25rem;
  color: #71717a;
  line-height: 1;
  transition: transform 0.2s ease;
}

details[open] summary.details-plus::after {
  transform: rotate(45deg);
}

/* ─── Scrollbar Utilities ─────────────────────────────────────────── */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ─── Focus States (Keyboard Accessibility) ──────────────────────── */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

input:focus {
  outline: none;
  border-color: var(--brand-accent) !important;
  box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.15);
}

/* ─── Reduced Motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .loading-pulse {
    animation: none;
    opacity: 0.6;
  }

  .btn-primary:hover,
  .btn-secondary:hover {
    transform: none !important;
  }

  summary.details-plus::after {
    transition: none;
  }

  .leaderboard-row {
    transition: none;
  }
}
