/* style.css - Cozy Garden Mobile UI Styles */

:root {
  --primary-green: #4ca644;
  --dark-green: #295e24;
  --cozy-cream: #fcf9f2;
  --warm-brown: #6b4329;
  --gold-yellow: #f5b027;
  --coral-red: #e64545;
  --shadow-color: rgba(26, 43, 18, 0.25);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background-color: #3b732d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: none; /* Prevents pull-to-refresh & browser scrolling on mobile */
}

#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* =========================================
   TOP HUD & CHARACTER SWITCHER
   ========================================= */

#topHud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

/* Character Selector Bar */
.char-selector {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 8px;
  border-radius: 40px;
  box-shadow: 0 4px 14px var(--shadow-color);
  pointer-events: auto;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.char-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 30px;
  padding: 3px 8px 3px 3px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.char-btn img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.char-btn span {
  font-size: 13px;
  font-weight: 700;
  color: #333333;
}

.char-btn.active {
  background: #fffaea;
  border-color: var(--gold-yellow);
  box-shadow: 0 2px 8px rgba(245, 176, 39, 0.35);
  transform: scale(1.04);
}

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

/* Top Right Utility Buttons */
.top-tools {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid #ffffff;
  box-shadow: 0 4px 12px var(--shadow-color);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
  touch-action: manipulation;
}

.hud-btn:active {
  transform: scale(0.9);
}

.hud-counter-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 24px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
  color: #4a2c16;
  box-shadow: 0 4px 12px var(--shadow-color);
  border: 1.5px solid #ffffff;
}

/* =========================================
   BOTTOM MOBILE CONTROLS & ACTION BUTTON
   ========================================= */

/* Floating Context Action Button */
#actionButton {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px 26px;
  background: linear-gradient(135deg, #ff8c42, #ff5722);
  color: #ffffff;
  border: 3px solid #ffffff;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 24px rgba(230, 69, 69, 0.45);
  cursor: pointer;
  z-index: 25;
  touch-action: manipulation;
  pointer-events: auto;
  transition: transform 0.1s ease;
}

#actionButton:active {
  transform: scale(0.92);
}

@keyframes pulseEffect {
  0% { transform: scale(1); box-shadow: 0 8px 24px rgba(230, 69, 69, 0.45); }
  50% { transform: scale(1.06); box-shadow: 0 10px 30px rgba(230, 69, 69, 0.65); }
  100% { transform: scale(1); box-shadow: 0 8px 24px rgba(230, 69, 69, 0.45); }
}

#actionButton.pulse {
  animation: pulseEffect 1.5s infinite ease-in-out;
}

/* Dynamic Virtual Joystick */
#virtualJoystick {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 2.5px solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
  display: none;
  transform: translate(-50%, -50%);
  z-index: 15;
}

#joystickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

/* In-game Toast Notification */
#gameToast {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 48, 22, 0.92);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 30;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 85%;
}

#gameToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================
   MODALS & OVERLAYS
   ========================================= */

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 35, 15, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-card {
  background: var(--cozy-cream);
  border-radius: 24px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  border: 3px solid #ffffff;
  position: relative;
  text-align: center;
}

.modal-card h2 {
  color: var(--warm-brown);
  font-size: 22px;
  margin-bottom: 12px;
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eee5db;
  border: none;
  font-size: 18px;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Journal Task List */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
  text-align: left;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1.5px solid #ece4da;
  font-size: 14px;
  font-weight: 600;
  color: #444;
}

.task-item .status-icon {
  font-size: 18px;
}

.task-item.done {
  border-color: #79c26d;
  background: #f2faf0;
  color: #2e6624;
}

.task-item.done .status-icon::before {
  content: '✅ ';
}

.task-item:not(.done) .status-icon::before {
  content: '⚪ ';
}

/* Family Album Modal */
.album-photo-container {
  margin: 12px 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  border: 3px solid #ffffff;
}

.album-photo-container img {
  width: 100%;
  display: block;
}

.character-bios {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-top: 14px;
}

.bio-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 12px;
}

.bio-card img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.bio-text h4 {
  font-size: 14px;
  color: var(--warm-brown);
}

.bio-text p {
  font-size: 12px;
  color: #666;
}

/* Postcard Celebration Modal */
.postcard-img-container {
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  margin-bottom: 14px;
  border: 4px solid #ffffff;
}

.postcard-img-container img {
  width: 100%;
  display: block;
}

.btn-primary {
  background: linear-gradient(135deg, #4ca644, #32832a);
  color: #ffffff;
  border: none;
  border-radius: 30px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(50, 131, 42, 0.4);
  touch-action: manipulation;
  margin-top: 10px;
}

.btn-primary:active {
  transform: scale(0.96);
}

/* =========================================
   START / TITLE SCREEN OVERLAY
   ========================================= */

#titleOverlay {
  position: absolute;
  inset: 0;
  background: #25441b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#titleOverlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.title-card {
  background: var(--cozy-cream);
  border-radius: 28px;
  padding: 20px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  border: 4px solid #ffffff;
  text-align: center;
}

.title-banner {
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.title-banner img {
  width: 100%;
  display: block;
}

.title-text h1 {
  font-size: 26px;
  color: var(--warm-brown);
  margin-bottom: 4px;
}

.title-text p {
  font-size: 14px;
  color: #555;
  margin-bottom: 18px;
}

.char-trio-preview {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.trio-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.trio-item img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--gold-yellow);
  object-fit: cover;
}

.trio-item span {
  font-size: 12px;
  font-weight: 700;
  color: var(--warm-brown);
}

/* Responsive tweaks for compact mobile screens */
@media (max-width: 480px) {
  .char-btn span {
    display: none; /* Icon-only on very narrow screens for maximum room */
  }
  .char-btn {
    padding: 2px;
  }
  .char-btn img {
    width: 32px;
    height: 32px;
  }
  #actionButton {
    bottom: 20px;
    right: 18px;
    padding: 14px 20px;
    font-size: 16px;
  }
}
