/* 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; }
}
