/* ============================================
   Midnight Bakery 🌙 — CSS Custom Properties
   ============================================ */
:root {
  --bg-primary: #1a1118;
  --bg-secondary: #2a1f25;
  --bg-card: #352a30;
  --text-primary: #f5e6d3;
  --text-secondary: #c9a87c;
  --accent-warm: #e8a44a;
  --accent-glow: #f0c674;
  --progress-bg: #4a3a40;
  --progress-fill: #e8a44a;
  --tap-target-min: 48px;
  --transition-speed: 0.4s;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================
   Game Container — viewport-contained
   ============================================ */
.game-container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  max-width: 100vw;
}

/* ============================================
   Screen Sections — only one visible at a time
   ============================================ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-speed) ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.screen-content {
  text-align: center;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
}

/* ============================================
   Intro Screen
   ============================================ */
.intro-title {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  color: var(--accent-glow);
  margin-bottom: 2rem;
  line-height: 1.3;
}

/* ============================================
   Tap Targets — minimum 48x48px
   ============================================ */
.tap-target {
  min-width: var(--tap-target-min);
  min-height: var(--tap-target-min);
  padding: 0.875rem 1.75rem;
  border: 2px solid var(--accent-warm);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: clamp(1rem, 3vw, 1.25rem);
  cursor: pointer;
  transition: background var(--transition-speed) ease, transform 0.15s ease;
}

.tap-target:active {
  transform: scale(0.96);
  background: var(--bg-secondary);
}

/* ============================================
   Oven Screen
   ============================================ */
.oven-instruction {
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.oven-emoji {
  font-size: clamp(3rem, 12vw, 5rem);
  padding: 1rem 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-bar-container {
  width: 100%;
  max-width: 320px;
  height: 24px;
  background: var(--progress-bg);
  border-radius: 12px;
  margin: 1.5rem auto;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-warm), var(--accent-glow));
  border-radius: 12px;
  transition: width 0.3s ease;
}

.month-label {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* ============================================
   Cookie Animation Container
   ============================================ */
.cookie-animation-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

/* ============================================
   Cookie Animation Container
   ============================================ */
.cookie-animation-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.cookie-emoji {
  position: absolute;
  font-size: 1.8rem;
  will-change: transform, opacity;
  animation: cookieFly 1.5s ease-out forwards;
}

@keyframes cookieFly {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot));
    opacity: 0;
  }
}

/* ============================================
   Reveal Screen
   ============================================ */
.baby-emoji {
  font-size: clamp(4rem, 15vw, 6rem);
  margin-bottom: 1.5rem;
  line-height: 1;
  transform: scale(0);
  opacity: 0;
}

.reveal-message {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: var(--accent-glow);
  line-height: 1.4;
  max-width: 360px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(20px);
}

/* Baby pop-out animation — triggers when reveal screen becomes active */
.screen.active .baby-emoji {
  animation: babyPopOut 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Message fade-in — starts after baby pop-out finishes */
.screen.active .reveal-message {
  animation: fadeInUp 0.8s ease-out 1.2s forwards;
}

/* ============================================
   Reveal Keyframes (Req 3.1, 3.2, 3.4)
   ============================================ */
@keyframes babyPopOut {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.9);
  }
  85% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Responsive — ensure no horizontal scroll
   320px–1440px
   ============================================ */
@media (min-width: 768px) {
  .screen-content {
    max-width: 560px;
  }

  .progress-bar-container {
    max-width: 400px;
    height: 28px;
  }
}

@media (min-width: 1024px) {
  .screen-content {
    max-width: 640px;
  }
}

/* Landscape orientation on mobile */
@media (max-height: 480px) and (orientation: landscape) {
  .intro-title {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    margin-bottom: 1rem;
  }

  .oven-emoji {
    font-size: clamp(2rem, 8vw, 3rem);
    padding: 0.5rem 1rem;
  }

  .baby-emoji {
    font-size: clamp(2.5rem, 10vw, 4rem);
    margin-bottom: 0.75rem;
  }

  .progress-bar-container {
    margin: 0.75rem auto;
  }
}
