/* ==========================================================================
   Games & Tools Hub — /games/
   base.css handles tokens, reset, body, Inter font, .chip, focus-visible,
   touch-action, .home-btn, .visually-hidden, reduced-motion
   ========================================================================== */

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

main {
  width: 100%;
  max-width: 960px;
  padding: 0 24px 40px;
}

/* =============================================
   Header
   ============================================= */
.hub-header {
  text-align: center;
  padding: 52px 0 24px;
}

.hub-header h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.hub-sub {
  color: var(--muted);
  font-size: 15px;
}

/* =============================================
   Recently Played
   ============================================= */
.recent-section {
  margin-bottom: 20px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.recent-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.recent-row::-webkit-scrollbar { display: none; }

.recent-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.recent-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  opacity: 1;
}

.recent-card .card-icon {
  width: 16px;
  height: 16px;
}

/* =============================================
   Controls — search + filter chips
   ============================================= */
.hub-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 340px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  pointer-events: none;
  color: var(--muted);
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Cancel button in search (webkit) */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23a7a7c2' stroke-width='2.5' stroke-linecap='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E") no-repeat center;
  cursor: pointer;
}


/* =============================================
   Category sections
   ============================================= */
.cat-section {
  margin-bottom: 24px;
}

.cat-section[hidden] {
  display: none;
}

.cat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.no-results {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  padding: 40px 0;
}

/* =============================================
   Card grid
   ============================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.project-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: background 0.2s ease, transform 0.3s ease, border-color 0.2s ease, box-shadow 0.3s ease;
  min-width: 0;
}

.project-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  box-shadow: 0 8px 30px rgba(138, 124, 255, 0.15);
  transform: translateY(-2px);
  opacity: 1;
}

.project-card:active {
  transform: scale(0.97) !important;
  transition-duration: 0.1s;
}

.project-card[hidden] {
  display: none;
}

/* Preview illustration */
.card-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg);
  overflow: hidden;
}

.card-art {
  width: 100%;
  height: 100%;
  display: block;
}

/* Bottom bar with icon + label */
.card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.card-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: var(--muted);
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s ease, stroke 0.2s ease;
}

.project-card:hover .card-icon {
  stroke: var(--accent);
  transform: scale(1.15);
}

.card-label {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Coming soon */
.project-card.coming-soon {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.card-tag-alpha {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #e08a3a;
  color: #fff;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.2;
}

.project-card.coming-soon .card-tag-alpha {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  top: 8px;
  right: 8px;
  transform: none;
}


/* =============================================
   Footer
   ============================================= */
footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  width: 100%;
  max-width: 960px;
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(138, 124, 255, 0.4) 30%,
    rgba(138, 124, 255, 0.4) 70%,
    transparent
  );
}

/* =============================================
   Card hover micro-interactions
   ============================================= */
.project-card .card-icon {
  transition: transform 0.3s ease, stroke 0.2s ease;
}

/* Existing games */
.project-card[href*="yahtzee"]:hover .card-icon { animation: dice-shake 0.4s ease; }
.project-card[href*="battleship"]:hover .card-icon { animation: ship-bob 0.6s ease; }
.project-card[href*="hearts"]:hover .card-icon { animation: heart-beat 0.5s ease; }
.project-card[href*="pong"]:hover .card-icon { animation: pong-bounce 0.5s ease; }
.project-card[href*="minesweeper"]:hover .card-icon { animation: flag-wave 0.5s ease; }
.project-card[href*="racing"]:hover .card-icon { animation: car-zoom 0.4s ease; }
.project-card[href*="10sec"]:hover .card-icon { animation: clock-tick 0.3s ease 2; }
.project-card[href*="sudoku"]:hover .card-icon { animation: grid-pulse 0.4s ease; }
.project-card[href*="connect4"]:hover .card-icon { animation: chip-drop 0.4s ease; }
.project-card[href*="buzzer"]:hover .card-icon { animation: buzzer-press 0.3s ease; }
.project-card[href*="tally"]:hover .card-icon { animation: tally-scratch 0.4s ease; }
.project-card[href*="notepad"]:hover .card-icon { animation: pencil-write 0.4s ease; }
.project-card[href*="study"]:hover .card-icon { animation: page-flip 0.4s ease; }
.project-card[href*="time"]:hover .card-icon { animation: clock-tick 0.3s ease 2; }
.project-card[href*="metadata"]:hover .card-icon { animation: tag-swing 0.45s ease; }
.project-card[href*="tonedeaf"]:hover .card-icon { animation: note-bob 0.55s ease; }
.project-card[href*="flappy"]:hover .card-icon { animation: bird-flap 0.5s ease; }
.project-card[href*="battle"]:not([href*="battleship"]):hover .card-icon { animation: sword-swing 0.4s ease; }

/* New games */
.project-card[href*="tictactoe"]:hover .card-icon { animation: xo-spin 0.5s ease; }
.project-card[href*="2048"]:hover .card-icon { animation: tile-slide 0.4s ease; }
.project-card[href*="hangman"]:hover .card-icon { animation: rope-swing 0.6s ease; }
.project-card[href*="slide"]:hover .card-icon { animation: tile-shift 0.4s ease; }
.project-card[href*="snake"]:hover .card-icon { animation: slither 0.5s ease; }
.project-card[href*="darts"]:hover .card-icon { animation: dart-throw 0.4s ease; }
.project-card[href*="pixelflow"]:hover .card-icon { animation: grid-pulse 0.4s ease; }
.project-card[href*="archery"]:hover .card-icon { animation: bow-pull 0.5s ease; }
.project-card[href*="nutsbolts"]:hover .card-icon { animation: bolt-turn 0.5s ease; }
.project-card[href*="mazepaint"]:hover .card-icon { animation: maze-trace 0.5s ease; }
.project-card[href*="svgeditor"]:hover .card-icon { animation: pencil-write 0.4s ease; }

/* Keyframe animations — each handles its own scale + motion */
@keyframes dice-shake {
  0%, 100% { transform: scale(1.15); }
  25% { transform: rotate(-15deg) scale(1.25); }
  75% { transform: rotate(15deg) scale(1.25); }
}
@keyframes ship-bob {
  0%, 100% { transform: translateY(0) scale(1.15); }
  50% { transform: translateY(-3px) rotate(4deg) scale(1.2); }
}
@keyframes heart-beat {
  0%, 100% { transform: scale(1.15); }
  25% { transform: scale(1.45); }
  50% { transform: scale(1.1); }
  75% { transform: scale(1.35); }
}
@keyframes pong-bounce {
  0%, 100% { transform: translateX(0) scale(1.15); }
  50% { transform: translateX(4px) scale(1.2); }
}
@keyframes flag-wave {
  0%, 100% { transform: scale(1.15); }
  50% { transform: rotate(8deg) scale(1.2); }
}
@keyframes car-zoom {
  0% { transform: translateX(-4px) scale(1.15); }
  100% { transform: translateX(4px) scale(1.2); }
}
@keyframes clock-tick {
  0%, 100% { transform: scale(1.15); }
  50% { transform: rotate(8deg) scale(1.2); }
}
@keyframes grid-pulse {
  0%, 100% { transform: scale(1.15); }
  50% { transform: scale(1.35); }
}
@keyframes chip-drop {
  0% { transform: translateY(-6px) scale(1.15); }
  60% { transform: translateY(2px) scale(1.2); }
  100% { transform: translateY(0) scale(1.15); }
}
@keyframes buzzer-press {
  0%, 100% { transform: scale(1.15); }
  50% { transform: scale(0.9); }
}
@keyframes tally-scratch {
  0%, 100% { transform: scale(1.15); }
  50% { transform: rotate(-10deg) scale(1.25); }
}
@keyframes pencil-write {
  0%, 100% { transform: scale(1.15); }
  25% { transform: translateX(2px) rotate(2deg) scale(1.2); }
  75% { transform: translateX(-2px) rotate(-2deg) scale(1.2); }
}
@keyframes page-flip {
  0%, 100% { transform: rotateY(0deg) scale(1.15); }
  50% { transform: rotateY(20deg) scale(1.2); }
}
@keyframes sword-swing {
  0%, 100% { transform: scale(1.15); }
  50% { transform: rotate(20deg) scale(1.25); }
}
@keyframes tag-swing {
  0%, 100% { transform: scale(1.15); }
  30% { transform: rotate(-16deg) scale(1.2); }
  60% { transform: rotate(8deg) scale(1.2); }
  85% { transform: scale(1.15); }
}
@keyframes globe-spin {
  0%   { transform: scale(1.15) rotateY(0deg); }
  100% { transform: scale(1.15) rotateY(360deg); }
}
@keyframes note-bob {
  0%, 100% { transform: translateY(0) scale(1.15); }
  25%  { transform: translateY(-4px) rotate(-4deg) scale(1.2); }
  55%  { transform: translateY(2px) rotate(3deg) scale(1.2); }
  80%  { transform: translateY(-2px) scale(1.18); }
}
@keyframes bird-flap {
  0%, 100% { transform: translateY(0) scale(1.15); }
  20%  { transform: translateY(-5px) rotate(-8deg) scale(1.22); }
  45%  { transform: translateY(3px) rotate(4deg) scale(1.15); }
  70%  { transform: translateY(-3px) rotate(-4deg) scale(1.2); }
}
@keyframes xo-spin {
  0%   { transform: scale(1.15); }
  50%  { transform: rotate(180deg) scale(1.25); }
  100% { transform: rotate(360deg) scale(1.15); }
}
@keyframes tile-slide {
  0%, 100% { transform: scale(1.15); }
  50% { transform: translateX(4px) scale(1.22); }
}
@keyframes rope-swing {
  0%, 100% { transform: scale(1.15); }
  25% { transform: rotate(-12deg) scale(1.2); }
  75% { transform: rotate(8deg) scale(1.2); }
}
@keyframes tile-shift {
  0%, 100% { transform: scale(1.15); }
  33% { transform: translate(3px, 0) scale(1.2); }
  66% { transform: translate(0, -3px) scale(1.2); }
}
@keyframes slither {
  0%, 100% { transform: scale(1.15); }
  25% { transform: translateX(3px) rotate(3deg) scale(1.2); }
  50% { transform: translateX(-2px) rotate(-2deg) scale(1.2); }
  75% { transform: translateX(2px) scale(1.2); }
}
@keyframes dart-throw {
  0% { transform: translateX(-4px) translateY(2px) scale(1.1); }
  60% { transform: translateX(3px) translateY(-1px) scale(1.25); }
  100% { transform: scale(1.15); }
}

@keyframes bow-pull {
  0%, 100% { transform: scale(1.15); }
  50% { transform: translateX(-3px) scale(1.25); }
}

@keyframes bolt-turn {
  0%, 100% { transform: scale(1.15); }
  50% { transform: rotate(60deg) scale(1.25); }
}

@keyframes maze-trace {
  0%, 100% { transform: scale(1.15); }
  50% { transform: translateX(3px) scale(1.2); }
}

/* =============================================
   Mobile
   ============================================= */
@media (max-width: 600px) {
  main {
    padding: 0 16px 32px;
  }

  .hub-header {
    padding: 44px 0 16px;
  }

  .hub-header h1 {
    font-size: 28px;
  }

  .hub-sub {
    font-size: 13px;
  }

  .hub-controls {
    flex-wrap: wrap;
  }

  .search-wrap {
    max-width: 100%;
    flex-basis: 100%;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .card-info {
    padding: 8px 10px;
  }

  .card-label {
    font-size: 12px;
  }

  footer {
    font-size: 12px;
    padding: 16px;
  }

  footer::before {
    left: 16px;
    right: 16px;
  }
}

