:root {
  --primary: #5b9071;
  --primary-dark: #447a5b;
  --background: #faf9f6;
  --text: #2e2e2e;
  --accent: #f3cfc6;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background) !important; /* ensure explicit light bg for Safari */
}

body {
  margin: 0;
  padding: 1rem;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

/* WebGL Canvas for smooth particle effects */
#animationCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* Transition overlay for GSAP animations */
.transition-overlay {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
  overflow: hidden;
  opacity: 1;
  transition: opacity 1s ease;
}

.screen {
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: transform 1s ease; /* Remove opacity transition - GSAP handles it */
  width: 100%;
  max-width: min(90vw, 500px);
  padding: clamp(1rem, 4vw, 2rem);
  border-radius: 12px;
  display: none;
  margin: auto;
  position: relative;
  z-index: 100;
}

.screen.active {
  transform: translateY(0);
  display: block;
  /* opacity controlled by GSAP */
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  margin-bottom: 1rem;
  font-weight: 300;
  color: var(--primary);
  transition: color 0.3s ease;
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 1rem;
  font-weight: 300;
  color: var(--primary);
  transition: color 0.3s ease;
}

p {
  font-size: clamp(1rem, 3vw, 1.1rem);
  margin-bottom: 1rem;
  max-width: 100%;
  transition: color 0.3s ease;
}

.navigation {
  margin-top: clamp(1.5rem, 4vw, 2rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.continue-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: clamp(0.6rem, 3vw, 0.7rem) clamp(1.2rem, 4vw, 1.4rem);
  border-radius: 8px;
  cursor: pointer;
  font-size: clamp(0.9rem, 3vw, 1rem);
  transition: background 0.3s, transform 0.2s;
  margin: 1rem auto;
  display: block;
  min-width: 120px;
}

.nav-btn {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: clamp(0.5rem, 2.5vw, 0.6rem) clamp(0.8rem, 3vw, 1rem);
  border-radius: 8px;
  cursor: pointer;
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  transition: all 0.3s, transform 0.2s;
  min-width: 80px;
}

.nav-btn:hover, .nav-btn:focus {
  background: var(--primary);
  color: white;
  transform: translateY(-1px);
}

.continue-btn:hover, .continue-btn:focus {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.signature {
  font-style: italic;
  margin-top: 1.5rem;
  color: var(--primary);
  font-size: clamp(0.9rem, 2.8vw, 1rem);
  transition: color 0.3s ease;
}

input {
  padding: clamp(0.6rem, 3vw, 0.8rem) clamp(0.8rem, 3vw, 1rem);
  margin-top: 1rem;
  border: 2px solid var(--primary);
  border-radius: 8px;
  outline: none;
  width: 100%;
  max-width: 300px;
  font-size: clamp(1rem, 3vw, 1.1rem);
  text-align: center;
}

input:focus {
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 3px rgba(91, 144, 113, 0.1);
}

button {
  display: block;
  margin: 1em auto;
  padding: clamp(0.6rem, 3vw, 0.7rem) clamp(1.2rem, 4vw, 1.4rem);
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: clamp(0.9rem, 3vw, 1rem);
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  min-width: 120px;
}

button:hover, button:focus {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.hidden {
  display: none;
  color: #e64b6b;
  margin-top: 0.5em;
  font-size: clamp(0.9rem, 2.8vw, 1rem);
}

.progress-bar {
  position: fixed;
  bottom: clamp(15px, 3vw, 25px);
  left: 50%;
  transform: translateX(-50%);
  width: clamp(150px, 40vw, 250px);
  height: clamp(3px, 1vw, 5px);
  background: rgba(91, 144, 113, 0.2);
  border-radius: 3px;
  overflow: hidden;
  z-index: 100;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.8s ease;
  border-radius: 3px;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }
  
  .screen {
    padding: 1.5rem 1rem;
    max-width: 95vw;
  }
  
  .navigation {
    flex-direction: column-reverse;
    gap: 0.8rem;
  }
  
  .nav-btn, .continue-btn {
    width: 100%;
    max-width: 200px;
  }
  
  input {
    max-width: 100%;
  }
}

/* Large screen adjustments */
@media (min-width: 1200px) {
  .screen {
    max-width: 600px;
    padding: 3rem;
  }
  
  .progress-bar {
    width: 300px;
    bottom: 30px;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  button, .nav-btn, .continue-btn {
    min-height: 44px;
    padding: 0.8rem 1.5rem;
  }
  
  input {
    min-height: 44px;
  }
}

/* Magical transition animations */
.transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

/* Safari compositing helper for overlay videos */
.videoWrap {
  position: relative;
  background: var(--background); /* explicit behind-video bg to avoid black layer */
  transform: translateZ(0);      /* keep in same compositing layer */
  isolation: isolate;            /* local stacking context */
}

.videoWrap video {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;       /* ensure no black paint */
  will-change: transform;        /* compositor hint */
}

/* Safari: make text white while video overlay forces a black backing */
.safari-video-black h1,
.safari-video-black h2,
.safari-video-black p,
.safari-video-black .signature {
  color: #fff !important;
}

.safari-video-black .nav-btn {
  color: #fff !important;
  border-color: #fff !important;
}

.particle-system {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  transition: opacity 1s ease;
}

.particle-system.active {
  opacity: 1;
}

#animationCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Enhanced particle effects using CSS for fallback */
.floating-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
    opacity: 1;
  }
}

.leaf-particle {
  width: 12px;
  height: 12px;
  background: linear-gradient(45deg, #8B4513, #CD853F, #DAA520);
  border-radius: 0 100% 0 100%;
  animation: leafFall 8s linear infinite;
}

.leaf-particle:nth-child(even) {
  background: linear-gradient(45deg, #228B22, #32CD32, #9ACD32);
  border-radius: 100% 0 100% 0;
  animation-duration: 10s;
}

.leaf-particle:nth-child(3n) {
  background: linear-gradient(45deg, #B22222, #DC143C, #FF6347);
  animation-duration: 9s;
}

@keyframes leafFall {
  0% {
    transform: translateY(-100vh) translateX(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) translateX(100px) rotate(360deg);
    opacity: 0;
  }
}

.water-particle {
  width: 3px;
  height: 15px;
  background: linear-gradient(to bottom, rgba(173, 216, 230, 0.8), rgba(135, 206, 235, 0.9));
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: waterDrop 3s linear infinite;
}

@keyframes waterDrop {
  0% {
    transform: translateY(-100vh);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  90% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

.sparkle-particle {
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, #ffd700 0%, #ffed4e 40%, transparent 70%);
  border-radius: 50%;
  animation: sparkleFloat 4s ease-in-out infinite;
  box-shadow: 0 0 6px #ffd700;
}

@keyframes sparkleFloat {
  0%, 100% {
    transform: translateY(0) scale(0);
    opacity: 0;
  }
  25% {
    transform: translateY(-30px) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-15px) scale(0.7);
    opacity: 0.8;
  }
  75% {
    transform: translateY(-45px) scale(1.2);
    opacity: 1;
  }
}

.bird-particle {
  position: absolute;
  animation: birdFly 8s ease-in-out infinite;
}

.bird-wing {
  position: absolute;
  width: 20px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  transform-origin: right center;
}

.bird-wing.left {
  left: -10px;
  animation: wingFlap 0.3s ease-in-out infinite;
}

.bird-wing.right {
  right: -10px;
  animation: wingFlap 0.3s ease-in-out infinite reverse;
}

@keyframes wingFlap {
  0%, 100% {
    transform: rotateZ(0deg);
  }
  50% {
    transform: rotateZ(-30deg);
  }
}

@keyframes birdFly {
  0% {
    transform: translateX(-100px) translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(calc(100vw + 100px)) translateY(-80px);
    opacity: 0;
  }
}

/* Audio controls styling */
.audio-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1002;
}

.audio-toggle {
  position: relative;
  background: rgba(91, 144, 113, 0.95);
  border: none;
  border-radius: 10px; /* rectangular with rounded corners */
  color: #fff;
  font-size: 20px; /* icon size */
  line-height: 1;
  padding: 8px 12px; /* slightly larger than icon, but finger friendly */
  min-height: 44px; /* touch target */
  min-width: 44px;  /* touch target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  backdrop-filter: blur(10px);
}

.audio-toggle:hover {
  background: rgba(91, 144, 113, 1);
  transform: translateY(-1px);
}

/* Keep background the same; indicate mute with a diagonal slash */
.audio-toggle.muted { background: rgba(91, 144, 113, 0.95); }
.audio-toggle.muted::after {
  content: "";
  position: absolute;
  pointer-events: none;
  top: 50%;
  left: 12%;
  width: 76%;
  height: 2px;
  background: #fff;
  transform: rotate(-35deg);
  transform-origin: center;
  opacity: 0.95;
  border-radius: 2px;
}

/* Fade transition for content */
.fade-transition {
  animation: fadeTransition 2s ease-in-out;
}

@keyframes fadeTransition {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}

/* Photo hint icons - floating interactive elements */
.photo-hint {
  position: absolute;
  top: clamp(10px, 3vw, 20px);
  right: clamp(20px, 5vw, 40px);
  font-size: clamp(2rem, 6vw, 3rem);
  cursor: pointer;
  z-index: 150;
  animation: photoHintPulse 2s ease-in-out infinite;
  transition: transform 0.3s ease, filter 0.3s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(91, 144, 113, 0.3));
}

.photo-hint:hover,
.photo-hint:active {
  transform: scale(1.15);
  filter: drop-shadow(0 4px 12px rgba(91, 144, 113, 0.5));
}

@keyframes photoHintPulse {
  0%, 100% {
    transform: scale(1) translateY(0);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.08) translateY(-3px);
    opacity: 1;
  }
}

/* Photo reveal modal */
.photo-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(8px);
  animation: modalFadeIn 0.3s ease;
}

.photo-modal.active {
  display: flex;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.photo-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: photoSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes photoSlideIn {
  from {
    transform: scale(0.8) translateY(30px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.photo-modal-content img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  object-fit: contain;
  background: #fff;
  padding: 8px;
}

.photo-modal-content p {
  margin-top: 1.5rem;
  color: #fff;
  font-size: clamp(1rem, 3vw, 1.2rem);
  text-align: center;
  max-width: 500px;
  padding: 0 1rem;
  line-height: 1.6;
  font-style: italic;
}

.photo-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 3rem;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, color 0.2s ease;
  line-height: 1;
  padding: 0;
  min-width: auto;
  margin: 0;
}

.photo-close:hover,
.photo-close:active {
  transform: scale(1.2) rotate(90deg);
  color: var(--accent);
}

/* Mobile adjustments for photo modal */
@media (max-width: 768px) {
  .photo-hint {
    top: clamp(8px, 2vw, 15px);
    right: clamp(15px, 4vw, 30px);
    font-size: clamp(2.5rem, 8vw, 4rem);
  }
  
  .photo-modal-content {
    max-width: 95%;
  }
  
  .photo-close {
    top: -45px;
    font-size: 2.5rem;
  }
  
  .photo-modal-content img {
    max-height: 60vh;
  }
}
