/* engine.css — v4.0 — Find Luna Book Engine Styles */
/* Uses CSS variables set by engine.js from book.json theme */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --book-primary:   #2c5282;
  --book-accent:    #90cdf4;
  --book-text:      #ffffff;
  --book-gradient:  linear-gradient(135deg, #1a3a6e 0%, #2c5282 100%);
  --book-font-display: 'Playfair Display', serif;
  --book-font-body:    'Inter', system-ui, sans-serif;
  --radius-sm:  8px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  40px;
  --radius-full: 9999px;
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.12);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.18);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.25);
  --shadow-glow: 0 0 40px rgba(144,205,244,0.35);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { font-size: 16px; }
body {
  font-family: var(--book-font-body);
  color: var(--book-text);
  background: var(--book-gradient);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── LANG SWITCHER ─────────────────────────────────────────────── */
.lang-switcher-top {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  padding: 12px 16px 0;
}
.lang-btn {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  letter-spacing: 0.3px;
}
.lang-btn:hover { background: rgba(255,255,255,0.25); }
.lang-btn.active { background: var(--book-accent); color: #0f172a; border-color: var(--book-accent); }

/* ─── WELCOME SCREEN ───────────────────────────────────────────── */
.book-welcome {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px;
  gap: 0;
}
.cover-wrap {
  width: min(380px, 85vw);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  margin: 16px 0 20px;
  position: relative;
}
.cover-wrap img {
  width: 100%; height: auto; display: block;
  transition: transform 0.4s ease;
}
.cover-wrap:hover img { transform: scale(1.02); }
.book-title {
  font-family: var(--book-font-display);
  font-size: clamp(32px, 8vw, 64px);
  font-weight: 700;
  text-align: center;
  text-shadow: 0 4px 12px rgba(0,0,0,0.3);
  line-height: 1.1;
  margin-bottom: 10px;
}
.book-subtitle {
  font-size: clamp(16px, 3vw, 20px);
  opacity: 0.85;
  text-align: center;
  margin-bottom: 28px;
  font-style: italic;
}
.book-meta {
  display: flex; gap: 20px; margin-top: 20px;
  font-size: 14px; opacity: 0.7;
}

/* ─── BUTTONS ───────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--book-accent);
  color: #0f172a;
  font-family: var(--book-font-body);
  font-size: 18px; font-weight: 700;
  padding: 16px 40px;
  border: none; border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  transition: all var(--transition);
  min-width: 220px;
  text-decoration: none;
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255,255,255,0.2);
  color: white;
  font-family: var(--book-font-body);
  font-size: 16px; font-weight: 600;
  padding: 14px 32px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: var(--radius-full);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all var(--transition);
  margin-top: 12px;
  min-width: 220px;
}
.btn-secondary:hover { background: rgba(255,255,255,0.3); transform: translateY(-2px); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  color: rgba(255,255,255,0.75);
  font-family: var(--book-font-body);
  font-size: 15px; font-weight: 500;
  padding: 12px 24px;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 12px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: white; border-color: rgba(255,255,255,0.4); }

/* ─── HOW TO PLAY ─────────────────────────────────────────────── */
.book-howto {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px;
  gap: 0;
}
.book-howto h2 {
  font-family: var(--book-font-display);
  font-size: clamp(28px, 6vw, 48px);
  margin-bottom: 28px;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.rules-list {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 480px; width: 100%; margin-bottom: 28px;
}
.rule-item {
  display: flex; align-items: center; gap: 16px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 17px; line-height: 1.4;
  animation: slideIn 0.4s ease backwards;
}
.rule-item:nth-child(1) { animation-delay: 0.05s; }
.rule-item:nth-child(2) { animation-delay: 0.1s; }
.rule-item:nth-child(3) { animation-delay: 0.15s; }
.rule-item:nth-child(4) { animation-delay: 0.2s; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.rule-ico { font-size: 28px; flex-shrink: 0; }

/* ─── SCENE PICKER ─────────────────────────────────────────────── */
.book-picker {
  min-height: 100vh;
  padding: 32px 20px;
  display: flex; flex-direction: column; align-items: center;
}
.book-picker h2 {
  font-family: var(--book-font-display);
  font-size: clamp(24px, 5vw, 40px);
  margin-bottom: 24px;
  text-align: center;
}
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  max-width: 720px; width: 100%;
  margin-bottom: 28px;
}
.scene-thumb {
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  display: flex; flex-direction: column;
}
.scene-thumb:hover { transform: translateY(-4px); border-color: var(--book-accent); box-shadow: var(--shadow-md); }
.scene-thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.scene-thumb span {
  display: block; padding: 10px 8px;
  font-size: 13px; font-weight: 600; color: white; text-align: center;
}

/* ─── SCENE ────────────────────────────────────────────────────── */
.book-scene {
  min-height: 100vh;
  display: flex; flex-direction: column;
  padding: 0 0 24px;
}
.scene-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(8px);
}
.ctrl-btn {
  background: rgba(255,255,255,0.15);
  border: none; border-radius: var(--radius-sm);
  color: white; font-size: 20px;
  width: 40px; height: 40px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.3); }
.progress-badge {
  background: var(--book-accent); color: #0f172a;
  font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: var(--radius-full);
}
.scene-counter-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  font-size: 16px; font-weight: 600;
  color: rgba(255,255,255,0.9);
}
.all-found-badge {
  background: #10b981; color: white;
  padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 700;
  animation: popIn 0.4s var(--bounce);
}
@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.scene-instruction {
  text-align: center;
  font-size: 14px; font-weight: 500;
  opacity: 0.75;
  padding: 4px 16px 8px;
}
.scene-img-wrap {
  position: relative;
  width: min(1000px, 100%);
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  cursor: crosshair;
}
.scene-img-wrap img {
  width: 100%; height: auto; display: block;
  user-select: none;
  -webkit-user-drag: none;
}
#hotspot-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.narration-box {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  margin: 16px auto;
  max-width: 800px;
  font-size: clamp(15px, 2.5vw, 18px);
  line-height: 1.6;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
}
.narration-box p { color: rgba(255,255,255,0.95); }
.scene-controls {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
}
.scene-controls .ctrl-btn { width: 44px; height: 44px; font-size: 22px; }

/* ─── END SCREEN ───────────────────────────────────────────────── */
.book-end {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 0;
}
.end-confetti {
  font-size: 40px;
  margin-bottom: 16px;
  animation: bounce 1s ease infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-12px); }
}
.book-end h1 {
  font-family: var(--book-font-display);
  font-size: clamp(40px, 10vw, 80px);
  margin-bottom: 16px;
  text-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.book-end p {
  font-size: clamp(18px, 3vw, 24px);
  opacity: 0.9;
  margin-bottom: 10px;
  line-height: 1.4;
}
.book-end .btn-primary { margin: 20px 0 8px; font-size: 20px; }
.book-end .btn-secondary { margin-bottom: 8px; }

/* ─── MINI-GAME ────────────────────────────────────────────────── */
.book-minigame {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.game-area {
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 24px 0;
  min-height: 300px;
  width: 100%; max-width: 600px;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ─── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }

/* ─── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .btn-primary, .btn-secondary { min-width: 180px; font-size: 16px; padding: 14px 28px; }
  .scene-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .rules-list { max-width: 100%; }
  .book-end h1 { font-size: 48px; }
}


/* ─── KEN BURNS (the "breathing" feel) ─── */
@keyframes ken-burns {
  0%   { transform: scale(1.0)   translate(0, 0); }
  50%  { transform: scale(1.05)  translate(-1%, -1%); }
  100% { transform: scale(1.0)   translate(0, 0); }
}
#scene-img {
  animation: ken-burns 20s ease-in-out infinite;
  will-change: transform;
}

/* ─── BGM TOGGLE BUTTON ─── */
.bgm-toggle {
  font-size: 18px !important;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: all 200ms;
}
.bgm-toggle:hover { background: rgba(255,255,255,0.25); }
.bgm-toggle:active { transform: scale(0.93); }

/* ─── ALIVE FEATURES (v6.1 — ported from ZOO gold) ────────────────── */

/* Cover scale-in entry animation */
@keyframes cover-enter {
  0%   { opacity: 0; transform: scale(0.92) translateY(20px); }
  100% { opacity: 1; transform: scale(1)    translateY(0); }
}
.cover-enter {
  animation: cover-enter 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.cover-enter .cover-wrap img,
.cover-enter h1,
.cover-enter p,
.cover-enter button {
  animation: cover-enter 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.cover-enter h1            { animation-delay: 0.15s; }
.cover-enter p             { animation-delay: 0.25s; }
.cover-enter .btn-primary  { animation-delay: 0.35s; }
.cover-enter .btn-secondary{ animation-delay: 0.40s; }

/* Ambient particle layer (themed per book) */
.ambient-particles {
  position: fixed; inset: 0; pointer-events: none;
  z-index: 1; overflow: hidden;
}
.particle {
  position: absolute; bottom: -20px;
  display: flex; align-items: center; justify-content: center;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  user-select: none;
}
@keyframes particle-float {
  0%   { transform: translateY(0)        rotate(0deg); }
  100% { transform: translateY(-110vh)   rotate(360deg); }
}
.particle-firefly,
.particle-sparkle,
.particle-seed,
.particle-star { animation-name: particle-float; }

.particle-bubble {
  animation: particle-float 16s ease-in-out infinite;
  border: 1.5px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), rgba(255,255,255,0.05));
  color: transparent;
  animation-name: particle-bubble-rise;
}
@keyframes particle-bubble-rise {
  0%   { transform: translateY(0)        scale(1); }
  50%  { transform: translateY(-55vh)    scale(1.1); }
  100% { transform: translateY(-110vh)   scale(0.9); }
}

.particle-petal {
  animation: particle-petal-fall 14s linear infinite;
  color: rgba(255,182,193,0.6);
  font-size: 1em;
}
@keyframes particle-petal-fall {
  0%   { transform: translateY(0)        rotate(0deg); }
  100% { transform: translateY(-110vh)   rotate(720deg); }
}

.particle-cloud {
  animation: particle-cloud-drift 30s linear infinite;
  color: rgba(255,255,255,0.4);
  font-size: 1.2em;
}
@keyframes particle-cloud-drift {
  0%   { transform: translateX(-20vw)   translateY(0); }
  100% { transform: translateX(120vw)   translateY(-30vh); }
}

.particle-snow {
  animation: particle-snow-fall 12s linear infinite;
  color: rgba(255,255,255,0.7);
}
@keyframes particle-snow-fall {
  0%   { transform: translateY(0) translateX(0); }
  50%  { transform: translateY(-55vh) translateX(20px); }
  100% { transform: translateY(-110vh) translateX(-20px); }
}

/* Progress bar (per scene) */
.progress-bar-track {
  position: fixed; top: 0; left: 0; right: 0;
  height: 4px; background: rgba(255,255,255,0.15);
  z-index: 50; pointer-events: none;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--book-accent), #ff6b9d);
  transition: width 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 8px var(--book-accent);
}

/* End celebration CTAs */
.end-celebration {
  text-align: center; padding: 60px 24px 40px; position: relative;
}
.end-emoji {
  font-size: clamp(4rem, 15vw, 8rem);
  animation: celebrate 1s ease-in-out infinite;
}
@keyframes celebrate {
  0%, 100% { transform: scale(1)    rotate(0deg); }
  50%      { transform: scale(1.1)  rotate(5deg); }
}
.end-ctas {
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; margin-top: 30px;
  max-width: 320px; margin-left: auto; margin-right: auto;
}
.end-cta {
  width: 100% !important; max-width: 320px;
  font-size: clamp(1rem, 3vw, 1.2rem) !important;
  padding: 14px 24px !important;
  animation: end-cta-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.end-cta:nth-child(1) { animation-delay: 0.1s; }
.end-cta:nth-child(2) { animation-delay: 0.2s; }
.end-cta:nth-child(3) { animation-delay: 0.3s; }
@keyframes end-cta-pop {
  0%   { opacity: 0; transform: translateY(20px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}
.end-confetti {
  font-size: clamp(2rem, 8vw, 3.5rem);
  margin: 0 0 20px;
  animation: end-confetti-shake 0.5s ease-in-out infinite;
}
@keyframes end-confetti-shake {
  0%, 100% { transform: translateX(0)   rotate(0deg); }
  25%      { transform: translateX(-4px) rotate(-3deg); }
  75%      { transform: translateX(4px)  rotate(3deg); }
}
