/* 
  Kid-friendly mobile-first CSS.
  Every interactive element is at least 64px in both directions.
  Designed for small hands, using bright and friendly palette.
*/

:root {
  --primary-color: #FF6B6B;
  --secondary-color: #4ECDC4;
  --accent-color: #FFE66D;
  --bg-color: #F8F9FA;
  --text-color: #333;
  --border-radius: 16px;
  --button-size: 120px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Comic Sans MS', cursive, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  touch-action: manipulation; /* avoids unwanted zoom/scroll on tap */
  height: 100%;
  width: 100%;
  overflow: hidden;
}

#app {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ------------------------ */
/* Home Screen Styles       */
/* ------------------------ */
.home-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.world-button {
  width: var(--button-size);
  height: var(--button-size);
  border-radius: 50%;
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
  touch-action: manipulation;
}

.world-button:hover, .world-button:focus {
  transform: scale(1.05);
}

.world-button svg {
  width: 60%;
  height: 60%;
}

/* ------------------------ */
/* World Screens            */
/* ------------------------ */
.world-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.back-button {
  width: 64px;
  height: 64px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-color);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  margin-bottom: 10px;
}

.back-button svg {
  width: 32px;
  height: 32px;
}

.world-canvas {
  background-color: white;
  border-radius: var(--border-radius);
  padding: 20px;
  width: 100%;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* ------------------------ */
/* Responsive               */
/* ------------------------ */

@media (max-width: 500px) {
  .world-button {
    width: 100px;
    height: 100px;
  }
  /* back-button stays at the 64px floor — do not shrink below it here,
     this media query previously dropped it to 56px, violating the
     small-hands touch-target rule stated at the top of this file. */
  .world-canvas {
    min-height: 300px;
  }
}

/* ------------------------ */
/* Nest world (#3)          */
/* ------------------------ */
.nest-world {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.nest-sky {
  position: relative;
  flex: 1;
  min-height: 260px;
  overflow: hidden;
}

.falling-egg {
  /* 64px, not 56: every draggable piece in the game should meet the same
     small-hands touch-target floor, found missing here during the T10
     accessibility review. */
  position: absolute;
  width: 64px;
  height: 64px;
  touch-action: none; /* dragging owns the gesture, not the browser */
  cursor: grab;
}

.falling-egg.egg-caught {
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform: scale(1.3);
  opacity: 0;
}

.falling-egg.egg-rolled-away {
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform: translateY(20px) rotate(45deg);
  opacity: 0;
}

.nest-row {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}

.nest {
  /* Nests are the drop targets — generous size well above the 64px floor
     so a small hand has real margin for error while dragging. */
  width: 96px;
  height: 96px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  background: #EDE4D3;
  border: 4px dashed #B08968;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.nest svg {
  width: 40%;
  height: 40%;
  opacity: 0.55;
}

.nest.nest-happy {
  transform: scale(1.15);
}

/* ------------------------ */
/* Fossils world (#4)       */
/* ------------------------ */
.fossils-world {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.fossils-grid {
  /* grid-template-columns is set inline per-level by fossils.ts, not here:
     CSS custom properties cannot be used as the repeat() track count
     (a documented CSS limitation, not an oversight) — repeat(var(--x), …)
     silently falls back to a single column the width of the container,
     which is exactly the bug this comment replaces (cards rendered at
     480px, cascading far outside the viewport). Found via live screenshots
     after a user report, not caught by any test until then. */
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.fossil-card {
  /* minmax(64px, 1fr) above plus this aspect-ratio keeps every card a real
     square touch target no smaller than 64px, even on narrow phones. */
  aspect-ratio: 1 / 1;
  min-width: 64px;
  min-height: 64px;
  border: none;
  border-radius: 10px;
  background: #EDE4D3;
  padding: 8px;
  cursor: pointer;
  transition: transform 0.15s ease;
  touch-action: manipulation;
}

.fossil-card:active {
  transform: scale(0.95);
}

.fossil-card.face-up {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.fossil-card.matched {
  opacity: 0.35;
  cursor: default;
}

.fossil-card svg {
  width: 100%;
  height: 100%;
}

/* ------------------------ */
/* Sort world (#5)          */
/* ------------------------ */
.sort-world {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.sort-tray {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 10px;
  padding: 10px;
}

.sort-piece {
  width: 72px;
  height: 72px;
  min-width: 64px;
  min-height: 64px;
  touch-action: none; /* dragging owns the gesture, not the browser */
  cursor: grab;
  transition: opacity 0.25s ease;
}

.sort-piece.piece-sorted {
  opacity: 0;
}

.sort-bins {
  display: flex;
  justify-content: space-evenly;
  gap: 16px;
  padding: 16px 0;
}

.sort-bin {
  width: 110px;
  height: 110px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 20px;
  background: #EDE4D3;
  border: 4px dashed #B08968;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.sort-bin svg {
  width: 45%;
  height: 45%;
}

.sort-bin.bin-happy {
  transform: scale(1.12);
}

/*------------------------*/
/* Accessibility */
/*------------------------*/

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/*------------------------*/
