/* ================================================================
   MEMORY MATCH — SimplyJavaScript Game
   styles.css
   ================================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0d0d0d;
  color: #f0f0f0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
#game-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
}

/* ── Top bar ── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: #111;
  border-bottom: 2px solid #FFC107;
  flex-shrink: 0;
  z-index: 20;
  gap: 4px 8px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFC107;
  letter-spacing: 0.3px;
  white-space: nowrap;
  text-decoration: none;
}
.brand:hover { color: #ffca28; }

/* ── Game controls ── */
.game-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #333;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #aaa;
  cursor: pointer;
  transition: all 0.15s;
}
.ctrl-btn:hover {
  border-color: #FFC107;
  color: #FFC107;
  background: rgba(255,193,7,0.08);
}
.ctrl-btn svg { width: 14px; height: 14px; fill: currentColor; pointer-events: none; }

/* ── Stats row ── */
.stats {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.stat-item {
  font-size: 0.78rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.stat-value {
  color: #FFC107;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 18px;
  text-align: center;
}

/* ── Main game content area ── */
#game-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #131320 0%, #0a0a0a 80%);
}

/* ── Card grid ── */
#card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 560px;
  perspective: 1000px;
}

/* ── Card ── */
.card {
  position: relative;
  aspect-ratio: 1 / 1.15;
  cursor: pointer;
  perspective: 800px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.35;
  word-break: break-word;
}

/* Face-down (back of card — visible first) */
.card-back {
  background: #161622;
  border: 2px solid rgba(255,193,7,0.25);
  color: #FFC107;
  font-size: 1.6rem;
  font-weight: 700;
  z-index: 2;
}

.card-back .card-logo {
  opacity: 0.5;
  font-family: 'Fira Code', monospace;
  font-size: 1.5rem;
}

/* Face-up (front of card — shows concept/result) */
.card-front {
  background: #1a1a2e;
  border: 2px solid #2a2a3a;
  color: #e0e0e0;
  transform: rotateY(180deg);
}

.card-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.55rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.5;
}

.card.type-concept .card-front {
  border-color: rgba(255,193,7,0.35);
}

.card.type-result .card-front {
  border-color: rgba(100,181,246,0.35);
}

.card.type-concept .card-label { color: #FFC107; }
.card.type-result .card-label { color: #64b5f6; }

/* Matched state */
.card.matched .card-front {
  border-color: #4caf50;
  box-shadow: 0 0 12px rgba(76,175,80,0.3), 0 0 24px rgba(76,175,80,0.1);
}

/* Shake animation for wrong match */
.card.shake {
  animation: cardShake 0.4s ease-in-out;
}

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
}

/* Sparkle for matched cards */
.card.matched .card-front::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  background: transparent;
  animation: sparkleGlow 0.6s ease-out;
  pointer-events: none;
}

@keyframes sparkleGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(76,175,80,0.6);
  }
  50% {
    box-shadow: 0 0 20px 4px rgba(76,175,80,0.4);
  }
  100% {
    box-shadow: 0 0 12px 2px rgba(76,175,80,0.15);
  }
}

/* Disabled state (during comparison) */
.card.disabled {
  pointer-events: none;
}

/* ── Screen overlays ── */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.screen-overlay.hidden { display: none; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-overlay:not(.hidden) > * {
  animation: fadeSlideIn 0.4s ease-out both;
}
.screen-overlay:not(.hidden) > *:nth-child(2) { animation-delay: 0.06s; }
.screen-overlay:not(.hidden) > *:nth-child(3) { animation-delay: 0.12s; }
.screen-overlay:not(.hidden) > *:nth-child(4) { animation-delay: 0.18s; }
.screen-overlay:not(.hidden) > *:nth-child(5) { animation-delay: 0.24s; }
.screen-overlay:not(.hidden) > *:nth-child(6) { animation-delay: 0.30s; }

.screen-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #FFC107;
  margin-bottom: 8px;
}

.screen-subtitle {
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 28px;
  max-width: 460px;
  line-height: 1.6;
}

.screen-score {
  font-size: 2.8rem;
  font-weight: 800;
  color: #FFC107;
  margin-bottom: 4px;
}

.screen-score-label {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 22px;
}

.screen-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  justify-content: center;
}

.screen-stat { text-align: center; }

.screen-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.screen-stat-label {
  font-size: 0.72rem;
  color: #777;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 12px 32px;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #FFC107;
  color: #111;
}
.btn-primary:hover {
  background: #ffca28;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255,193,7,0.3);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: #ccc;
  border: 1.5px solid #444;
}
.btn-secondary:hover {
  border-color: #FFC107;
  color: #FFC107;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  #top-bar { padding: 6px 10px; gap: 3px 6px; }
  .top-left { gap: 8px; }
  .brand { font-size: 0.78rem; }
  .ctrl-btn { width: 26px; height: 26px; }
  .ctrl-btn svg { width: 11px; height: 11px; }
  .game-controls { gap: 4px; }
  .stats { gap: 10px; }
  .stat-item { font-size: 0.68rem; }
  .stat-value { font-size: 0.75rem; min-width: 14px; }
  .screen-title { font-size: 1.35rem; }
  .screen-score { font-size: 2rem; }
  .screen-stats { gap: 16px; }
  .btn { padding: 10px 24px; font-size: 0.82rem; }

  #game-content { padding: 12px 10px; }
  #card-grid { gap: 8px; max-width: 400px; }
  .card-face { font-size: 0.72rem; padding: 6px; }
  .card-back .card-logo { font-size: 1.2rem; }
  .card-label { font-size: 0.5rem; top: 4px; left: 6px; }
}

@media (max-width: 480px) {
  #card-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-width: 340px;
  }
  .card-face { font-size: 0.65rem; padding: 5px 4px; }
}

@media (max-width: 380px) {
  .brand { font-size: 0.7rem; }
  .ctrl-btn { width: 24px; height: 24px; }
  .ctrl-btn svg { width: 10px; height: 10px; }
  .game-controls { gap: 3px; }
  .stats { gap: 8px; }
  .stat-item { font-size: 0.64rem; }
  .stat-value { font-size: 0.7rem; }

  #card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 280px;
  }
  .card-face { font-size: 0.75rem; padding: 8px; }
  .card-back .card-logo { font-size: 1.3rem; }
}
