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

body {
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #fce4ec 0%, #e8eaf6 25%, #e0f7fa 50%, #fff9c4 75%, #f3e5f5 100%);
  background-attachment: fixed;
  color: #4a4a6a;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: 'Bubblegum Sans', cursive; }

.section { display: none; max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.section.active { display: block; animation: fadeIn .4s ease; }

/* ===== FLOATING SHAPES ===== */
.floating-shapes { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.shape { position: absolute; font-size: 2rem; opacity: .25; animation: float 8s ease-in-out infinite; }
.shape-1 { top: 10%; left: 5%; animation-delay: 0s; }
.shape-2 { top: 20%; right: 8%; animation-delay: 1.5s; }
.shape-3 { top: 50%; left: 3%; animation-delay: 3s; }
.shape-4 { top: 70%; right: 5%; animation-delay: 4.5s; }
.shape-5 { top: 85%; left: 15%; animation-delay: 2s; }
.shape-6 { top: 35%; right: 12%; animation-delay: 5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(10deg); }
}

/* ===== WIZARD HEADER ===== */
.wizard-header { text-align: center; position: relative; margin-bottom: 1.5rem; }

.title-rainbow {
  font-size: 2.4rem;
  background: linear-gradient(90deg, #ff6b6b, #ffa502, #f7d794, #55efc4, #74b9ff, #a29bfe, #fd79a8);
  background-size: 300% 300%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbow 4s linear infinite;
}
@keyframes rainbow { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }

.btn-library {
  position: absolute; top: 0; right: 0;
  background: rgba(255,255,255,.7); border: 2px solid #a29bfe;
  border-radius: 2rem; padding: .6rem 1.2rem; font-family: 'Nunito',sans-serif;
  font-weight: 700; font-size: .95rem; color: #6c5ce7; cursor: pointer;
  transition: all .2s;
}
.btn-library:hover { background: #a29bfe; color: #fff; transform: scale(1.05); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 2rem;
}
.progress-step {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.6); border: 3px solid #ddd;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; color: #bbb;
  transition: all .3s; flex-shrink: 0;
}
.progress-step.active { border-color: #6c5ce7; background: #6c5ce7; color: #fff; animation: pulse 1.5s infinite; }
.progress-step.done { border-color: #00b894; background: #00b894; color: #fff; }
.progress-line { width: 40px; height: 4px; background: #ddd; border-radius: 2px; flex-shrink: 0; }

@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(108,92,231,.4)} 50%{box-shadow:0 0 0 10px rgba(108,92,231,0)} }

/* ===== STEP ===== */
.step { animation: slideUp .35s ease; }
.step-question { font-size: 1.6rem; text-align: center; margin-bottom: 1.5rem; color: #6c5ce7; }

/* ===== QCM GRID ===== */
.qcm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1.2rem;
}
.qcm-card {
  background: rgba(255,255,255,.75); backdrop-filter: blur(6px);
  border: 3px solid transparent; border-radius: 1.5rem;
  padding: 1.2rem .8rem; text-align: center; cursor: pointer;
  transition: all .2s; user-select: none;
}
.qcm-card:hover { transform: scale(1.06); border-color: #dfe6e9; box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.qcm-card.selected { border-color: #6c5ce7; transform: scale(1.05); background: rgba(162,155,254,.15); }
.qcm-card .emoji { font-size: 2.2rem; display: block; margin-bottom: .4rem; }
.qcm-card .label { font-weight: 700; font-size: 1rem; }

/* ===== CUSTOM INPUT ===== */
.custom-row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.custom-label { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.custom-input {
  flex: 1; min-width: 200px; padding: .8rem 1.2rem;
  border: 2px solid #dfe6e9; border-radius: 2rem;
  background: rgba(255,255,255,.6); font-family: 'Nunito',sans-serif;
  font-size: 1.1rem; color: #4a4a6a; outline: none; transition: border .2s;
}
.custom-input::placeholder { font-style: italic; color: #b2bec3; }
.custom-input:focus { border-color: #a29bfe; }

/* ===== BUTTONS ===== */
.btn {
  border: none; border-radius: 2rem; padding: .9rem 2rem;
  font-family: 'Nunito',sans-serif; font-weight: 800; font-size: 1.1rem;
  cursor: pointer; transition: all .2s;
}
.btn:hover { transform: scale(1.05); }
.btn-primary { background: #6c5ce7; color: #fff; }
.btn-secondary { background: rgba(255,255,255,.7); color: #6c5ce7; border: 2px solid #a29bfe; }
.btn-magic {
  background: linear-gradient(135deg, #6c5ce7, #fd79a8);
  color: #fff; font-size: 1.25rem; padding: 1rem 2.5rem;
  box-shadow: 0 4px 15px rgba(108,92,231,.35);
}
.btn-magic:hover { box-shadow: 0 6px 25px rgba(108,92,231,.5); }

.wizard-nav { display: flex; justify-content: center; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* ===== LOADING ===== */
.loading-container { text-align: center; padding-top: 15vh; }
.book-animation { position: relative; display: inline-block; margin-bottom: 2rem; }
.book { font-size: 5rem; animation: bookSpin 2s ease-in-out infinite; }
@keyframes bookSpin {
  0%,100% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.1); }
}
.sparkles { position: absolute; inset: -20px; }
.sparkles span {
  position: absolute; font-size: 1.4rem;
  animation: sparkle 1.5s ease-in-out infinite;
}
.sparkles span:nth-child(1) { top: 0; left: 10%; animation-delay: 0s; }
.sparkles span:nth-child(2) { top: 10%; right: 0; animation-delay: .4s; }
.sparkles span:nth-child(3) { bottom: 0; right: 15%; animation-delay: .8s; }
.sparkles span:nth-child(4) { bottom: 10%; left: 0; animation-delay: 1.2s; }
@keyframes sparkle {
  0%,100% { opacity: .3; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.3); }
}
.loading-text { font-size: 1.4rem; font-weight: 700; color: #6c5ce7; }

/* ===== READING ===== */
.story-title { text-align: center; font-size: 2rem; color: #6c5ce7; margin-bottom: 2rem; }
.chapter-card {
  background: #fffdf5; border-radius: 1.5rem;
  padding: 2rem 2.2rem; margin-bottom: 1.5rem;
  box-shadow: 0 4px 15px rgba(0,0,0,.06);
  animation: fadeIn .5s ease both;
}
.chapter-card h3 { color: #fd79a8; margin-bottom: .8rem; font-size: 1.3rem; }
.chapter-card p { line-height: 1.8; font-size: 1.05rem; white-space: pre-wrap; }

/* Chapter images */
.chapter-image-wrapper { margin-bottom: 1rem; border-radius: 1rem; overflow: hidden; min-height: 200px; }
.chapter-image { width: 100%; border-radius: 1rem; display: block; }
.chapter-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 200px; background: linear-gradient(135deg, #f0e6ff 0%, #e6f0ff 100%);
  border-radius: 1rem; gap: .5rem; color: #a29bfe;
}
.placeholder-spinner { font-size: 2.5rem; animation: spin 2s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Image progress */
.image-progress-container { text-align: center; margin-bottom: 1.5rem; }
.image-progress-text { font-size: .95rem; color: #6c5ce7; margin-bottom: .5rem; font-weight: 600; }
.image-progress-bar { height: 8px; background: #e0d4f5; border-radius: 4px; overflow: hidden; }
.image-progress-fill { height: 100%; background: linear-gradient(90deg, #6c5ce7, #a29bfe); border-radius: 4px; width: 0; transition: width .5s ease; }

.reading-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }

/* ===== LIBRARY ===== */
.section-title { text-align: center; font-size: 2rem; color: #6c5ce7; margin-bottom: 1rem; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.library-card {
  background: rgba(255,255,255,.75); border-radius: 1.5rem;
  padding: 1.5rem; cursor: pointer; transition: all .2s;
  border: 2px solid transparent;
}
.library-card:hover { transform: scale(1.03); border-color: #a29bfe; }
.library-card .lc-emoji { font-size: 2rem; }
.library-card .lc-title { font-weight: 800; font-size: 1.1rem; margin: .4rem 0; }
.library-card .lc-date { font-size: .85rem; color: #b2bec3; }
.library-empty { text-align: center; font-size: 1.2rem; color: #b2bec3; margin-top: 3rem; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .title-rainbow { font-size: 1.6rem; }
  .btn-library { position: static; margin-top: .8rem; }
  .qcm-grid { grid-template-columns: repeat(2, 1fr); }
  .progress-line { width: 20px; }
  .progress-step { width: 36px; height: 36px; font-size: .95rem; }
  .chapter-card { padding: 1.2rem; }
}
