/* Games Browser — CSS Custom Properties (from UI-SPEC) */
:root {
  --color-bg: #1a1a2e;
  --color-card: #16213e;
  --color-accent: #f7d774;
  --color-accent-hover: #ffe066;
  --color-text: #f7f7ff;
  --color-text-muted: rgba(247, 247, 255, 0.7);
  --color-badge-bg: #2d3a5c;
  --color-border: rgba(255, 255, 255, 0.12);
  --color-border-hover: #f7d774;
  --color-danger: #e57373;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 22px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-size-sm: 14px;
  --font-size-md: 16px;
  --font-size-lg: 20px;
  --font-size-xl: 28px;

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-play: 0 4px 12px rgba(247, 215, 116, 0.3);
  --shadow-play-hover: 0 6px 20px rgba(247, 215, 116, 0.4);
}

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

/* Body */
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: var(--font-size-md);
  min-height: 100vh;
}

/* Page Header */
header h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  color: var(--color-text);
}

@media (min-width: 640px) {
  header h1 {
    text-align: left;
    padding: var(--space-lg) var(--space-lg);
    max-width: 960px;
    margin: 0 auto;
  }
}

/* Card Grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-md);
}

@media (min-width: 640px) {
  .games-grid {
    padding: var(--space-2xl) var(--space-lg);
  }
}

@media (min-width: 960px) {
  .games-grid {
    padding: var(--space-2xl) var(--space-xl);
  }
}

/* Game Card */
.game-card {
  background: var(--color-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* Thumbnail */
.game-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Thumbnail Fallback */
.thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  background: var(--color-card);
  font-size: 32px;
}

/* Card Content */
.game-card__content {
  padding: var(--space-md);
}

/* Title Row */
.game-card__title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

/* Title */
.game-card__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Age Badge */
.game-card__badge {
  background: var(--color-badge-bg);
  color: var(--color-accent);
  font-size: var(--font-size-sm);
  font-weight: 700;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Play Button */
.game-card__play {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
  background: var(--color-accent);
  color: var(--color-bg);
  font-family: var(--font);
  font-size: var(--font-size-md);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 24px;
  min-height: 48px;
  line-height: 1;
  border-radius: var(--radius-md);
  border: none;
  box-shadow: var(--shadow-play);
  text-decoration: none;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

/* Focus-visible for keyboard users (always active, not motion-dependent) */
.game-card__play:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Hover & focus states — respect reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .game-card:hover,
  .game-card:focus-within {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-4px);
  }

  .game-card__play:hover {
    background: var(--color-accent-hover);
    box-shadow: var(--shadow-play-hover);
    transform: scale(1.02);
  }

  .game-card__play:active {
    transform: scale(0.98);
    transition-duration: 50ms;
  }
}

/* Non-motion hover states (color changes only, no transforms) */
@media (prefers-reduced-motion: reduce) {
  .game-card:hover,
  .game-card:focus-within {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-card-hover);
  }

  .game-card__play:hover {
    background: var(--color-accent-hover);
    box-shadow: var(--shadow-play-hover);
  }
}

/* State Messages (empty / error) */
.state-message {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  grid-column: 1 / -1;
}

.state-message__emoji {
  font-size: 48px;
  display: block;
  margin-bottom: var(--space-md);
}

.state-message__text {
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Play count — shown below the Play button once plays data loads */
.game-card__play-count {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: center;
  min-height: 20px;
  padding-top: var(--space-xs);
  line-height: 1.4;
}

/* ================================================================
   Reaction Strip — Phase 3 (Emoji Reactions)
   All specs from 03-UI-SPEC.md. No new custom properties needed.
   ================================================================ */

/* Container: horizontal scrollable row below Play button (D-04, D-05, D-06) */
.reaction-strip {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  margin-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.reaction-strip::-webkit-scrollbar {
  display: none;
}

/* Individual emoji button (D-12: emoji on top, count below) */
.reaction-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  min-width: 36px;
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.2s ease;
}

/* Emoji glyph */
.reaction-btn__emoji {
  font-size: 24px;
  line-height: 1;
  display: block;
}

/* Count text below emoji (D-12) */
.reaction-btn__count {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-height: 11px;
}

/* Focus-visible for keyboard (matches Play button pattern) */
.reaction-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.reaction-btn:focus:not(:focus-visible) {
  outline: none;
}

/* Bounce animation — only when motion is OK (D-07) */
@media (prefers-reduced-motion: no-preference) {
  @keyframes reaction-bounce {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.4); }
    100% { transform: scale(1); }
  }

  .reaction-btn--bouncing {
    animation: reaction-bounce 200ms ease-out;
  }
}

/* Reduced motion: no bounce, just opacity change (established project pattern) */
@media (prefers-reduced-motion: reduce) {
  .reaction-btn--bouncing {
    /* No animation — opacity transition on .reaction-btn handles the visual feedback */
  }
}
