/* ===== DESIGN TOKENS ===== */
:root {
  --bg: #0c0a10;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --surface-active: rgba(249, 168, 212, 0.12);
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);
  --border-active: rgba(249, 168, 212, 0.4);
  --text: #f2f0f5;
  --text-secondary: #a8a0b8;
  --text-muted: #6e6880;
  --accent: #f9a8d4;
  --accent-light: #fbcfe8;
  --cyan: #a7f3d0;
  --green: #a7f3d0;
  --amber: #fcd6b5;
  --pink: #f9a8d4;
  --red: #fca5a5;
  --gradient: linear-gradient(135deg, #c4b5fd, #f9a8d4);
  --gradient-warm: linear-gradient(135deg, #f9a8d4, #fecdd3);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 100px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  transition: color 0.8s ease, background 0.8s ease;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-effects { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  animation: orbFloat 20s ease-in-out infinite;
}
.bg-orb-1 { width: 500px; height: 500px; background: #c4b5fd; top: -150px; left: -100px; animation-delay: 0s; }
.bg-orb-2 { width: 400px; height: 400px; background: #f9a8d4; bottom: -100px; right: -100px; animation-delay: -7s; animation-duration: 25s; }
.bg-orb-3 { width: 300px; height: 300px; background: #fecdd3; top: 50%; left: 50%; transform: translate(-50%, -50%); animation-delay: -14s; animation-duration: 30s; opacity: 0.15; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 40px) scale(0.95); }
  75% { transform: translate(30px, 20px) scale(1.02); }
}

/* ===== BACKGROUND IMAGES ===== */
.bg-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1s ease;
}
.bg-image.visible { opacity: 1; }

.bg-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.8s ease;
}

/* When backgrounds are active, dim the orbs */
body.has-bg-images .bg-orb { opacity: 0.12; }

/* ===== LIGHT THEME (auto-applied on bright backgrounds) ===== */
body.theme-light {
  --surface: rgba(255, 255, 255, 0.45);
  --surface-hover: rgba(255, 255, 255, 0.6);
  --surface-active: rgba(249, 168, 212, 0.15);
  --border: rgba(0, 0, 0, 0.1);
  --border-hover: rgba(0, 0, 0, 0.18);
  --border-active: rgba(249, 168, 212, 0.4);
  --text: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #7a7a95;
}
body.theme-light .bg-overlay {
  background: rgba(240, 240, 248, 0.15);
}
body.theme-light .bg-orb { opacity: 0.08; }
body.theme-light textarea,
body.theme-light input[type="url"],
body.theme-light input[type="text"] {
  background: rgba(255, 255, 255, 0.5);
}
body.theme-light .link-copy input {
  background: rgba(255, 255, 255, 0.6);
}
body.theme-light .option-btn {
  background: rgba(255, 255, 255, 0.35);
}
body.theme-light .toast {
  background: rgba(255, 255, 255, 0.9);
  color: #1a1a2e;
}
body.theme-light .spinner {
  border-color: rgba(0,0,0,0.15);
  border-top-color: #fff;
}

/* ===== LAYOUT ===== */
.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; position: relative; z-index: 1; }
.view { display: none; min-height: 100vh; animation: fadeIn 0.5s var(--ease); }
.view.active { display: flex; align-items: center; justify-content: center; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== HOME VIEW ===== */
.home-container { text-align: center; }
.hero { max-width: 560px; margin: 0 auto; }
.hero-badge {
  display: inline-block;
  padding: 0.4rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  letter-spacing: 0.02em;
}
.hero-title {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}
.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-buttons .btn { text-decoration: none; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.8rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.3s;
}
.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient);
  color: #1a1a2e;
  font-weight: 700;
  box-shadow: 0 4px 24px rgba(249, 168, 212, 0.3);
}
.btn-primary:hover { box-shadow: 0 8px 32px rgba(249, 168, 212, 0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary:disabled::after { display: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); }

.btn-lg { padding: 1rem 2.4rem; font-size: 1.05rem; border-radius: var(--radius); }

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.btn-back:hover { color: var(--text); }

.btn-icon { font-size: 1.15em; }

/* ===== CREATE VIEW ===== */
.create-container { width: 100%; max-width: 960px; }
.view#view-create.active { align-items: flex-start; padding-top: 4rem; }
.section-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 2rem; letter-spacing: -0.02em; }

.create-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }

.create-input-panel, .create-preview-panel {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: background 0.8s ease, border-color 0.8s ease;
}

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

textarea, input[type="url"], input[type="text"] {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color 0.2s;
  outline: none;
}
textarea:focus, input[type="url"]:focus, input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.12);
}
textarea { min-height: 260px; resize: vertical; line-height: 1.7; }
textarea::placeholder, input::placeholder { color: var(--text-muted); }

.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.4rem; display: block; }

/* Link output */
.link-output { margin-top: 1.5rem; }
.link-output label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--green); margin-bottom: 0.5rem; }
.link-copy { display: flex; gap: 0.5rem; }
.link-copy input {
  flex: 1;
  background: rgba(0,0,0,0.4);
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
}
.hidden { display: none !important; }

/* Preview */
.create-preview-panel h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 1rem; font-weight: 600; }
.preview-placeholder { color: var(--text-muted); font-style: italic; font-size: 0.9rem; }
.preview-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.25rem; color: var(--accent-light); }
.preview-question { margin-bottom: 1rem; }
.preview-question .pq-text { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.preview-question .pq-option { font-size: 0.82rem; color: var(--text-secondary); padding-left: 1rem; line-height: 1.6; }
.preview-count { font-size: 0.8rem; color: var(--text-muted); margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

/* ===== QUIZ VIEW ===== */
.view#view-quiz.active { align-items: flex-start; padding-top: 3rem; }
.quiz-container { width: 100%; max-width: 600px; margin: 0 auto; }

/* Progress bar */
.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--surface);
  border-radius: 4px;
  margin-bottom: 2rem;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  transition: width 0.5s var(--ease);
  box-shadow: 0 0 12px rgba(249, 168, 212, 0.4);
}
.progress-label {
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Quiz title */
.quiz-title-bar {
  text-align: center;
  margin-bottom: 2rem;
}
.quiz-title-bar h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Name entry */
.name-entry {
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}
.name-entry h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.name-entry p { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.95rem; }
.name-entry input[type="text"] { text-align: center; margin-bottom: 1.25rem; font-size: 1rem; }

/* Question card */
.question-stage { position: relative; overflow: hidden; min-height: 320px; }

.question-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  animation: slideIn 0.4s var(--ease);
  transition: background 0.8s ease, border-color 0.8s ease;
}
.question-card.slide-out-left { animation: slideOutLeft 0.3s var(--ease) forwards; }
.question-card.slide-out-right { animation: slideOutRight 0.3s var(--ease) forwards; }
.question-card.slide-in-left { animation: slideInLeft 0.4s var(--ease); }

@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutLeft { to { opacity: 0; transform: translateX(-40px); } }
@keyframes slideOutRight { to { opacity: 0; transform: translateX(40px); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }

.question-number { font-size: 0.8rem; color: var(--accent-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.75rem; }
.question-text { font-size: 1.5rem; font-weight: 700; line-height: 1.4; margin-bottom: 1.5rem; }

/* Options */
.options-list { display: flex; flex-direction: column; gap: 0.65rem; }
.option-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s var(--ease);
  position: relative;
}
.option-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateX(4px);
}
.option-btn.selected {
  background: var(--surface-active);
  border-color: var(--border-active);
  box-shadow: 0 0 20px rgba(217, 70, 239, 0.15);
}
.option-letter {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.25s var(--ease);
}
.option-btn.selected .option-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.option-text { flex: 1; line-height: 1.4; font-weight: 600; }

/* Navigation */
.question-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 1rem;
}
.nav-spacer { flex: 1; }

/* ===== REVIEW SCREEN ===== */
.review-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  animation: fadeIn 0.5s var(--ease);
  transition: background 0.8s ease, border-color 0.8s ease;
}
.review-card h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.review-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }
.review-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.review-item:last-of-type { border-bottom: none; }
.review-q-num { color: var(--text-muted); font-weight: 600; flex-shrink: 0; min-width: 28px; }
.review-q-text { flex: 1; color: var(--text-secondary); }
.review-answer {
  flex-shrink: 0;
  background: var(--surface-active);
  border: 1px solid var(--border-active);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  color: var(--accent-light);
  font-size: 0.85rem;
}
.review-actions { margin-top: 1.75rem; display: flex; gap: 0.75rem; justify-content: center; }

/* Submit loading */
.btn-loading { pointer-events: none; }
.btn-loading .btn-label { opacity: 0; }
.btn-loading .spinner { display: block; }
.spinner {
  display: none;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  position: absolute;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== DONE VIEW ===== */
.done-container { text-align: center; max-width: 480px; }
.done-icon { font-size: 4rem; margin-bottom: 1.5rem; animation: popIn 0.6s var(--ease-bounce); }
@keyframes popIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.done-container h1 { font-size: 2rem; font-weight: 700; margin-bottom: 0.75rem; letter-spacing: -0.02em; }
.done-container p { color: var(--text-secondary); font-size: 1.05rem; line-height: 1.6; }

/* Confetti */
.confetti-container { position: fixed; inset: 0; z-index: 999; pointer-events: none; overflow: hidden; }
.confetti-particle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  top: 50%; left: 50%;
  animation: confettiBurst 1.2s var(--ease) forwards;
}
@keyframes confettiBurst {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { opacity: 0; }
}

/* ===== ERROR / STATUS TOASTS ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 30, 40, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text);
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: var(--red); }
.toast.success { border-color: rgba(16, 185, 129, 0.4); color: var(--green); }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .create-layout { grid-template-columns: 1fr; }
  .hero-title { font-size: 3rem; }
  .question-card { padding: 1.5rem; }
  .container { padding: 1.5rem 1rem; }
  .view#view-create.active { padding-top: 2rem; }
}
