/* ============================================
   MARTA — Mi Perrita Virtual
   Main Stylesheet — Variables, Reset, Layout
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;800&display=swap');

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #FFF8F0;
  --accent-primary: #FF6B9D;
  --accent-secondary: #FFB347;
  --text-primary: #3D2B1F;
  --card-bg: #FFFFFF;
  --card-shadow: rgba(0, 0, 0, 0.08);

  --marta-base: #F5E6C8;
  --marta-spots: #C8964A;
  --marta-nose: #4A4040;
  --marta-collar: #CC3333;

  --health-color: #FF4B6E;
  --hunger-color: #FF8C42;
  --energy-color: #FFD93D;
  --happiness-color: #FF6B9D;
  --cleanliness-color: #6BC5D2;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-lifted: 0 12px 40px rgba(0, 0, 0, 0.15);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

  --nav-height: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  height: 100%;
}

body {
  font-family: 'Nunito', -apple-system, sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

img, svg { display: block; max-width: 100%; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

/* --- App Shell --- */
.app {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

/* --- Screen System --- */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95) translateY(10px);
  transition: opacity 300ms ease-out, transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
  z-index: 1;
}

.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

#screen-home {
  padding-bottom: 80px;
}

/* --- Ambient Particles --- */
.ambient-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(255, 215, 140, 0.6), transparent);
  border-radius: 50%;
  animation: particleFloat 8s ease-in-out infinite;
}

@keyframes particleFloat {
  0%, 100% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  50% { transform: translateY(-120px) translateX(30px); }
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.06);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: transform var(--transition-fast);
  position: relative;
}

.nav-item:active { transform: scale(0.9); }

.nav-item.active .nav-icon svg { transform: scale(1.15); }

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: navDotAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes navDotAppear {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active .nav-icon svg { stroke: var(--accent-primary); }

.nav-label {
  font-size: 9px;
  font-weight: 600;
  opacity: 0.6;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.nav-item.active .nav-label {
  opacity: 1;
  color: var(--accent-primary);
}

/* --- Status Circles --- */
.status-bar-container {
  display: flex;
  justify-content: space-around;
  padding: 12px 8px;
  gap: 4px;
}

.status-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}

.status-circle-ring {
  width: 58px;
  height: 58px;
  position: relative;
}

.status-circle-ring > svg {
  width: 58px;
  height: 58px;
  transform: rotate(-90deg);
}

.status-circle-ring .track {
  fill: none;
  stroke: #f0ebe5;
  stroke-width: 4;
}

.status-circle-ring .progress {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-circle-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
}

.status-circle-label {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-circle.critical .status-circle-ring {
  animation: statusPulse 1s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.status-circle.full .status-circle-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.3), transparent 70%);
  animation: statusGlow 2s ease-in-out infinite;
}

@keyframes statusGlow {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.02);
  padding: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-medium);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 15px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.3), transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:active::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #FF8FB1);
  color: white;
  box-shadow: 0 4px 16px rgba(255, 107, 157, 0.35);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.35);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--accent-secondary), #FFC870);
  color: white;
  box-shadow: 0 4px 16px rgba(255, 179, 71, 0.35);
}

.btn-sleep {
  background: linear-gradient(135deg, #6B5CE7, #8B7CF7);
  color: white;
  box-shadow: 0 4px 16px rgba(107, 92, 231, 0.35);
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(0.92) translateY(1px); }
.btn-primary { font-size: 16px; }
.food-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.food-card:active { transform: scale(0.95) !important; }

/* --- Header --- */
.screen-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  z-index: 10;
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

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

.back-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen-title {
  font-size: 20px;
  font-weight: 800;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--card-bg);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-medium);
  font-weight: 600;
  font-size: 14px;
  z-index: 9999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* --- Confetti --- */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  top: -10px;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* --- Custom cursor --- */
body.happy-cursor {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='7' cy='6' r='3' fill='%23C8964A'/%3E%3Ccircle cx='17' cy='6' r='3' fill='%23C8964A'/%3E%3Ccircle cx='12' cy='14' r='5' fill='%23C8964A'/%3E%3Ccircle cx='6' cy='18' r='2.5' fill='%23C8964A'/%3E%3Ccircle cx='18' cy='18' r='2.5' fill='%23C8964A'/%3E%3C/svg%3E") 12 12, auto;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

@media (max-width: 375px) {
  :root { font-size: 14px; }
  .status-circle-ring { width: 50px; height: 50px; }
  .status-circle-ring svg { width: 50px; height: 50px; }
}

@media (min-width: 768px) {
  .app {
    max-width: 430px;
    border-radius: var(--radius-xl);
    margin-top: 20px;
    height: calc(100% - 40px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  }
}

/* Tap feedback */
@keyframes tapPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,157,0.4); }
  70% { box-shadow: 0 0 0 12px rgba(255,107,157,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,157,0); }
}
.nav-item:active { animation: tapPulse 0.4s ease; }

/* Card hover lift */
.card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

/* Status bar glow when full */
.status-circle.full .status-circle-ring { filter: drop-shadow(0 0 4px rgba(255,215,0,0.4)); }

/* Make screen-content scroll smooth */
.screen-content { scroll-behavior: smooth; }

/* --- Kawaii Blush & Tongue Animations --- */
.marta-blush { opacity: 0.5; transition: opacity 0.3s; }
.marta-character[data-state="happy"] .marta-blush { opacity: 0.8; }
.marta-tongue { animation: tongueWag 3s ease-in-out infinite; transform-origin: top center; }

/* Premium screen backgrounds */
.screen-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, rgba(255,248,240,0.8) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* Smooth status circle animation */
.status-circle-ring {
  transition: transform 0.3s ease;
}

/* Active nav glow */
.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px rgba(255, 107, 157, 0.3));
}

/* Toast improvements */
.toast {
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  border-radius: 20px;
}

/* Loading animation improvement */
.loading-screen {
  background: linear-gradient(135deg, #FFF8F0 0%, #FFE8D0 50%, #FFF0E0 100%);
}
