/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600&display=swap');

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Fredoka', sans-serif;
  background: linear-gradient(to bottom right, #fdf6e3, #d1e8ff);
  color: #333;
  padding: 20px;
  min-height: 100vh;
  animation: fadeIn 0.6s ease-out;
  position: relative;
}

/* Background Floating Dots */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle, rgba(93, 63, 211, 0.05) 2px, transparent 2px);
  background-size: 40px 40px;
  z-index: -1;
  animation: floatBG 20s linear infinite;
  opacity: 0.4;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.8rem;
  color: #5d3fd3;
  text-shadow: 1px 1px #fff;
}

header p {
  font-size: 1.2rem;
  margin-top: 10px;
  color: #555;
}

/* Section Banner */
.section-banner {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  background: #00B6F1;
  padding: 10px 24px;
  border-radius: 30px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  display: inline-block;
  transform: rotate(-1.5deg);
  margin: 0 auto 20px;
  text-align: center;
}

/* Grid Layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

/* Story Card */
.story-card {
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.story-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.story-card:active {
  transform: scale(0.97);
}

.story-image-wrapper {
  width: 100%;
  height: 240px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: #fff;
}

.story-image-wrapper img {
  height: 100%;
  width: auto;
  object-fit: contain;
  display: block;
}

.story-card h3 {
  font-size: 1.3rem;
  color: #333;
  padding: 12px;
  text-align: center;
  background-color: #fff;
  flex-shrink: 0;
}

/* Navigation Arrows */
.nav-arrow {
  background-color: #5d3fd3;
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: background 0.3s;
}

.nav-arrow:hover {
  background-color: #7a5ef1;
}

.nav-arrow:active {
  transform: scale(0.97);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 40px;
}

footer a {
  text-decoration: none;
  font-size: 1rem;
  color: white;
  background: #5d3fd3;
  padding: 12px 24px;
  border-radius: 25px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: background 0.3s, transform 0.2s ease;
}

footer a:hover {
  background: #7a5ef1;
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(93, 63, 211, 0.3);
}

footer a:active {
  transform: scale(0.97);
}

/* Form */
form {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

form label {
  display: block;
  margin: 20px 0 8px;
  font-weight: bold;
  font-size: 1.1rem;
}

form input[type="text"] {
  padding: 10px;
  width: 100%;
  border: 2px solid #ccc;
  border-radius: 10px;
  font-size: 1rem;
}

/* Avatar Grid */
.avatar-grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
}

.avatar-grid label {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 140px;
  cursor: pointer;
}

.avatar-grid input[type="radio"] {
  position: absolute;
  top: 10px;
  left: 10px;
  transform: scale(1.3);
  z-index: 2;
}

.avatar-grid img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 15px;
  border: 2px solid #ddd;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, outline 0.2s;
}

.avatar-grid input[type="radio"]:checked + img {
  outline: 3px solid #5d3fd3;
  outline-offset: -3px;
}

/* Submit Button */
form button[type="submit"] {
  margin-top: 30px;
  padding: 12px 20px;
  background: #5d3fd3;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s ease;
}

form button[type="submit"]:hover {
  background: #4a32b8;
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(93, 63, 211, 0.3);
}

form button[type="submit"]:active {
  transform: scale(0.97);
}

/* Scene Elements */
.scene-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.story-card-scene {
  position: relative;
  width: 340px;
  border-radius: 15px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#story-image {
  width: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  margin: 20px 0;
}

#avatar-image {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid #5d3fd3;
  object-fit: cover;
  background-color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: none;
}

/* Text & Choices */
#story-text-container {
  max-width: 700px;
  text-align: center;
  font-size: 1.2rem;
  line-height: 1.6;
  padding: 20px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#choices-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

#choices-container button {
  padding: 10px 16px;
  font-size: 1rem;
  border: none;
  background: #5d3fd3;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s ease;
}

#choices-container button:hover {
  background: #4a32b8;
  transform: scale(1.05);
}

#choices-container button:active {
  transform: scale(0.97);
}

#story-title {
  text-align: center;
  margin-bottom: 20px;
  font-size: 2rem;
}

#story-text, #story-image {
  opacity: 0;
  transition: opacity 0.4s ease;
}

#story-image[src*="soaring.png"] {
  height: 420px;
  width: 100%;
  object-fit: cover;
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Mobile Responsive */
@media (max-width: 600px) {
  header h1 {
    font-size: 2rem;
  }

  #story-text-container {
    font-size: 1rem;
    padding: 15px;
  }

  .story-card {
    border-radius: 12px;
  }

  #choices-container button {
    padding: 8px 14px;
    font-size: 0.95rem;
  }

  .avatar-grid label {
    width: 100px;
  }

  .avatar-grid img {
    height: 100px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatBG {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100px 100px;
  }
}

.hero-banner {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.hero-img {
  width: 100%;
  max-width: 200px;
  height: auto;
  border-radius: 20px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

@media (max-width: 200px) {
  .hero-img {
    max-width: 90%;
  }
}

#music-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #5d3fd3;
  color: white;
  border: none;
  font-size: 1.5rem;
  padding: 10px 14px;
  border-radius: 50%;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 1000;
  transition: background 0.3s ease;
}

#music-toggle:hover {
  background: #7a5ef1;
}

#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom right, #d1e8ff, #fdf6e3);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 9999;
}

.splash-content {
  text-align: center;
}

#start-button {
  margin-top: 20px;
  font-size: 1.3rem;
  background: #5d3fd3;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: background 0.3s ease;
}

#start-button:hover {
  background: #7a5ef1;
}

@keyframes bounceIn {
  0% {
    transform: scale(0.8) translateY(30px);
    opacity: 0;
  }
  60% {
    transform: scale(1.1) translateY(-10px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

#avatar-image.bounce-in {
  animation: bounceIn 0.6s ease;
}

#voice-select {
  padding: 8px 16px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: border 0.3s ease;
  appearance: none;
  cursor: pointer;
  max-width: 280px;
}

#voice-select:focus {
  border-color: #5d3fd3;
  outline: none;
  box-shadow: 0 0 5px rgba(93, 63, 211, 0.3);
}

label[for="voice-select"] {
  font-weight: bold;
  font-size: 1.1rem;
  color: #333;
  margin-right: 10px;
}

.voice-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  font-size: 1rem;
}

.voice-picker label {
  font-weight: 600;
  color: #333;
}

/* ✨ Light Sparkle Effect on Hover */
.story-card::after {
  content: "";
  position: absolute;
  top: -5%;
  left: -5%;
  width: 110%;
  height: 110%;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.3) 1px, transparent 2px),
    radial-gradient(circle, rgba(255, 223, 255, 0.3) 1px, transparent 2px),
    radial-gradient(circle, rgba(200, 240, 255, 0.3) 1px, transparent 2px);
  background-size: 15px 15px;
  background-position: 0 0, 5px 5px, 10px 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
  animation: lightSparkleMove 3s linear infinite;
}

.story-card:hover::after {
  opacity: 0.5;
}

@keyframes lightSparkleMove {
  0% {
    background-position: 0 0, 5px 5px, 10px 10px;
  }
  50% {
    background-position: 10px 10px, 0 0, 5px 5px;
  }
  100% {
    background-position: 0 0, 5px 5px, 10px 10px;
  }
}

.sparkle-trail {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.8;
  transform: translate(-50%, -50%);
  animation: sparkleFade 0.6s ease-out forwards;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

@keyframes sparkleFade {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
}

.fun-button {
  background-color: #5d3fd3;
  color: white;
  padding: 14px 28px;
  font-size: 1.1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.fun-button:hover {
  background-color: #7c5eff;
}

/* Random Story Button */
.fun-button {
  background-color: #5d3fd3;
  color: white;
  padding: 14px 28px;
  font-size: 1.1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin-top: 20px;
}

.fun-button:hover {
  background-color: #7c5eff;
}

body {
  cursor: url('assets/images/cursors/wand-cursor.png') 16 0, auto;
}

.sparkle-trail {
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0.8;
  z-index: 9999;
  animation: sparkle-fade 0.6s ease-out forwards;
}

@keyframes sparkle-fade {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}


/* === Story Studio Styling === */

.studio-body {
  font-family: 'Fredoka', sans-serif;
  background: linear-gradient(to bottom right, #ffe0f0, #d0f0ff);
  padding: 40px 20px;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.studio-container {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  padding: 30px;
  max-width: 600px;
  width: 100%;
  animation: fadeIn 0.6s ease-out;
}

.studio-header {
  text-align: center;
  margin-bottom: 20px;
}

.studio-header h1 {
  font-size: 2.5rem;
  color: #5d3fd3;
}

.studio-header p {
  font-size: 1.1rem;
  color: #444;
}

.studio-form label {
  display: block;
  margin-top: 15px;
  font-weight: 600;
  color: #333;
}

.studio-form input,
.studio-form textarea {
  width: 100%;
  padding: 12px;
  margin-top: 5px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
  transition: border 0.2s;
}

.studio-form input:focus,
.studio-form textarea:focus {
  border-color: #5d3fd3;
  outline: none;
}

.sparkle-button {
  background: linear-gradient(to right, #7a5cff, #4fc3f7);
  color: #fff;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  font-size: 1.1rem;
  margin-top: 25px;
  width: 100%;
  cursor: pointer;
  transition: transform 0.2s;
}

.sparkle-button:hover {
  transform: scale(1.05);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-added {
  background-color: #e6ffee;
  transition: background-color 0.6s ease;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
}

/* Fix overlap between Save Cover and Add Scenes buttons */
#new-story-form button {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 15px; /* Ensure spacing from inputs */
}

/* Specific styling for Save Cover */
#new-story-form button.save-cover {
  background-color: #6a38d9;
  color: white;
  margin-bottom: 20px; /* Add spacing below Save Cover */
}

/* Optional: Styling for Add Scenes button if needed */
#add-scenes-button.sparkle-button {
  background: linear-gradient(to right, #00bfff, #1ecbe1);
  color: white;
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  margin: 20px auto;
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: fit-content;
}

#add-scenes-button.sparkle-button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.sticker-tray {
  display: flex;
  gap: 12px;
  padding: 10px;
  overflow-x: auto;
  margin-top: 20px;
  justify-content: center;
}

.sticker-icon {
  width: 60px;
  cursor: grab;
  user-select: none;
  transition: transform 0.2s ease;
}

.sticker-icon:hover {
  transform: scale(1.2);
}

#scene-canvas {
  position: relative;
  display: inline-block;
}

#sticker-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* prevents blocking */
}

.sticker {
  position: absolute;
  width: 60px;
  pointer-events: auto;
  cursor: move;
}
