/* ============================================================
   HUB.CSS - Shared Styles for All Game Pages
   Consolidated from base.css and shared-systems.css
   Used by: puzzle, differences, shadow, shapes
   ============================================================ */

/* ============================================================
   CSS VARIABLES & RESET
   ============================================================ */
:root {
  --primary-font: 'Nunito', 'FbSpacer', sans-serif;
  --btn-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  --btn-hover-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  --star-gold: #FFD700;
  --star-empty: #E0E0E0;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --primary-kids: #FF6B6B;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background-color: #7fd4ff;
  font-family: var(--primary-font);
}

/* ============================================================
   HUB LAYOUT FOUNDATION
   ============================================================ */
.farm-hub {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-wrapper {
  position: relative;
  width: 100%;
  max-width: 150vh;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #7fd4ff;
}

.hub-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
}

.button-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

/* ============================================================
   HUB BUTTONS
   ============================================================ */
.hub-btn {
  position: absolute;
  display: block;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  border-radius: 50% / 30%;
  background: rgba(255, 0, 0, 0);
  pointer-events: auto;
  z-index: 20;
  touch-action: manipulation;
}

.hub-btn:active {
  transform: scale(0.95);
}

.btn-label {
  visibility: hidden;
}

/* Hub Button Positions */
.puzzles {
  width: 20%;
  height: 25%;
  top: 65%;
  right: 74%;
}

.differences {
  width: 20%;
  height: 25%;
  top: 65%;
  right: 52%;
}

.shadow {
  width: 20%;
  height: 25%;
  top: 65%;
  right: 31%;
}

.coloring {
  width: 18%;
  height: 25%;
  top: 45%;
  right: 65%;
}

.music {
  width: 18%;
  height: 25%;
  top: 45%;
  right: 22%;
}

.instruments {
  width: 20%;
  height: 30%;
  top: 40%;
  right: 42%;
}

.shapes {
  width: 20%;
  height: 25%;
  top: 65%;
  right: 9%;
}

/* ============================================================
   SYSTEM CONTROLS
   ============================================================ */
.system-controls {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 10px;
  z-index: 1000;
}

.speaker-btn, .music-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border: 4px solid var(--primary-kids);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .speaker-btn:hover, .music-toggle:hover {
    transform: scale(1.1);
  }
}

.speaker-btn:active, .music-toggle:active {
  transform: scale(0.9);
}

.music-toggle.muted {
  border-color: #999;
  filter: grayscale(1);
}

/* ============================================================
   NAVIGATION & BACK BUTTON
   ============================================================ */
.btn-back-hub {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: var(--primary-kids);
  color: white;
  text-decoration: none;
  padding: 10px 25px;
  border-radius: 50px;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  touch-action: manipulation;
  min-height: 44px;
}

@media (hover: hover) and (pointer: fine) {
  .btn-back-hub:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
  }
}

/* ============================================================
   MODAL SYSTEM
   ============================================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal.hidden {
  display: none !important;
}

.modal.active.hidden {
  display: flex !important;
}

.modal-content {
  background-color: white;
  padding: 2.5rem;
  border-radius: 40px;
  text-align: center;
  border: 8px solid var(--primary-kids);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  max-width: 90%;
  width: 450px;
  transform: scale(0.7);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-title {
  font-size: 3rem;
  color: var(--primary-kids);
  margin-bottom: 0.5rem;
  font-family: 'FbSpacer', 'Nunito', sans-serif;
  line-height: 1.2;
}

.modal-text {
  font-size: 1.6rem;
  font-weight: 800;
  color: #333;
  margin-bottom: 2rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-modal {
  padding: 15px 40px;
  font-size: 1.5rem;
  font-weight: 900;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 80%;
  max-width: 300px;
  text-decoration: none;
  display: inline-block;
  touch-action: manipulation;
}

.btn-modal-primary {
  background-color: #2ed573;
  color: white;
  box-shadow: 0 8px 0 #21a351, 0 15px 20px rgba(46, 213, 115, 0.2);
}

.btn-modal-secondary {
  background-color: #70a1ff;
  color: white;
  box-shadow: 0 8px 0 #4776d0, 0 15px 20px rgba(112, 161, 255, 0.2);
}

.btn-modal-danger {
  background-color: #ff4757;
  color: white;
  box-shadow: 0 8px 0 #d93846, 0 15px 20px rgba(255, 71, 87, 0.2);
}

@media (hover: hover) and (pointer: fine) {
  .btn-modal:hover {
    transform: translateY(-2px);
  }
}

.btn-modal:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 currentColor;
}

/* ============================================================
   REWARD STARS
   ============================================================ */
.reward-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
}

.reward-star {
  font-size: 50px;
  color: var(--star-empty);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s;
  transform: scale(0);
}

.reward-star.active {
  color: var(--star-gold);
  transform: scale(1);
  animation: star-pop 0.5s forwards;
}

.reward-star:nth-child(2) {
  animation-delay: 0.2s;
}

.reward-star:nth-child(3) {
  animation-delay: 0.4s;
}

/* ============================================================
   CONFETTI
   ============================================================ */
.confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
}

.confetti.hidden {
  display: none;
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width: 768px) {
  .speaker-btn, .music-toggle {
    width: 50px;
    height: 50px;
    font-size: 24px;
    top: 10px;
    left: 10px;
    min-width: 44px;
    min-height: 44px;
  }

  .reward-star {
    font-size: 40px;
  }

  .btn-back-hub {
    top: 10px;
    right: 10px;
    padding: 8px 15px;
    font-size: 0.9rem;
    min-width: 44px;
    min-height: 44px;
  }

  .modal {
    padding: 10px;
    overflow-y: auto;
  }

  .modal-content {
    padding: 1.5rem;
    border-radius: 30px;
    border: 6px solid var(--primary-kids);
    width: 95%;
    max-width: calc(100vw - 20px);
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-title {
    font-size: 2rem;
  }

  .modal-text {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
  }

  .btn-modal {
    padding: 12px 30px;
    font-size: 1.2rem;
    width: 90%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .speaker-btn, .music-toggle {
    width: 44px;
    height: 44px;
    font-size: 20px;
    top: 8px;
    left: 8px;
    min-width: 44px;
    min-height: 44px;
  }

  .reward-star {
    font-size: 35px;
  }

  .btn-back-hub {
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: 44px;
    min-height: 44px;
  }

  .hub-btn {
    transition: transform 0.1s;
  }

  .system-controls {
    gap: 8px;
    max-width: calc(100vw - 10px);
  }
}

/* ============================================================
   PORTRAIT ORIENTATION (Tablet/Phone)
   ============================================================ */
@media (orientation: portrait) {
  .hub-wrapper {
    padding-bottom: 0;
    height: 100%;
    max-width: 100%;
    aspect-ratio: auto;
  }

  .hub-bg {
    object-fit: contain;
  }

  .button-overlay {
    top: calc((100% - 66.67vw) / 2);
    height: 66.67vw;
  }
}

/* ============================================================
   DESKTOP SAFEGUARDS (1200px+)
   ============================================================ */
@media (min-width: 1200px) {
  .farm-hub {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .hub-wrapper {
    max-width: 150vh;
    margin: 0 auto;
  }

  .system-controls {
    gap: 10px;
  }

  .btn-back-hub {
    min-width: 44px;
    min-height: 44px;
  }

  .modal {
    padding: 20px;
  }

  .modal-content {
    width: 450px;
    max-width: 90%;
  }

  .button-overlay {
    width: 100%;
    height: 100%;
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes hub-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes star-pop {
  0% {
    transform: scale(0) rotate(-30deg);
  }
  70% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.bounce {
  animation: bounce 0.6s ease-in-out infinite;
}

/* ============================================================
   GLOBAL UX POLISH
   ============================================================ */
button, .choice-card, .card, .shape, .object-emoji, .shadow-card, .emoji-cell, .thumbnail-wrapper, .puzzle-piece {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

@media (hover: hover) and (pointer: fine) {
  .hub-btn:hover {
    animation: hub-bounce 1s infinite;
  }
}
