/* ============================================
   WHAT SHOULD WE WATCH? — Styles
   Theater-dark, warm, playful movie night vibe
   ============================================ */

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

:root {
  --bg-dark: #0d0d1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  --surface: #16213e;
  --butter: #f5c518;
  --butter-glow: #f5c51840;
  --cherry: #e74c5e;
  --popcorn: #f8f0e3;
  --warm-white: #e8e0d4;
  --text-primary: #f0ece4;
  --text-secondary: #9a95a8;
  --text-muted: #6b6680;
  --star: #f5c518;
  --success: #4ecdc4;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px var(--butter-glow);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ============================================
   Screens — stacked, fade in/out
   ============================================ */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   Film grain overlay
   ============================================ */

.film-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  z-index: 9999;
}

/* ============================================
   Start Screen
   ============================================ */

.start-content {
  text-align: center;
  max-width: 420px;
  padding: 20px;
}

.logo-area {
  margin-bottom: 48px;
}

.logo-popcorn {
  font-size: 72px;
  display: block;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

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

.start-content h1 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--popcorn);
  margin-bottom: 12px;
}

.tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--butter);
  color: #1a1a2e;
  border: none;
  padding: 18px 48px;
  font-size: 1.2rem;
  font-weight: 800;
  font-family: var(--font);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px var(--butter-glow); }
  50% { box-shadow: 0 0 40px var(--butter-glow), 0 0 60px rgba(245,197,24,0.15); }
}

.btn-arrow {
  transition: transform 0.2s ease;
}

.btn-primary:hover .btn-arrow {
  transform: translateX(4px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid rgba(255,255,255,0.08);
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-1px);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.btn-back:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

/* ============================================
   Quiz Screen
   ============================================ */

.quiz-container {
  width: 100%;
  max-width: 540px;
  padding: 20px;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--butter);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 20%;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.quiz-question-area {
  position: relative;
  min-height: 400px;
}

.quiz-question {
  animation: slideIn 0.4s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-30px); }
}

.quiz-question.exiting {
  animation: slideOut 0.3s ease forwards;
}

.question-emoji {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.question-text {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 28px;
  color: var(--popcorn);
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.answer-btn {
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  color: var(--text-primary);
}

.answer-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--butter);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.answer-btn:active {
  transform: translateY(0);
}

.answer-btn.selected {
  background: rgba(245, 197, 24, 0.12);
  border-color: var(--butter);
  box-shadow: 0 0 20px var(--butter-glow);
}

.answer-emoji {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.answer-label {
  font-size: 0.95rem;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.answer-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  line-height: 1.3;
}

/* ============================================
   Loading Screen
   ============================================ */

.loading-content {
  text-align: center;
}

.loading-reel {
  margin-bottom: 24px;
}

.reel-spinner {
  font-size: 64px;
  animation: spin 2s linear infinite;
  display: inline-block;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--popcorn);
  margin-bottom: 8px;
}

.loading-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* ============================================
   Results Screen
   ============================================ */

#screen-results {
  justify-content: flex-start;
  padding-top: 40px;
  padding-bottom: 40px;
}

.results-container {
  width: 100%;
  max-width: 900px;
  padding: 0 20px;
}

.results-header {
  text-align: center;
  margin-bottom: 32px;
}

.results-header h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--popcorn);
  margin-bottom: 8px;
}

.results-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.movie-card {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  animation: cardIn 0.5s ease backwards;
}

.movie-card:nth-child(1) { animation-delay: 0.05s; }
.movie-card:nth-child(2) { animation-delay: 0.1s; }
.movie-card:nth-child(3) { animation-delay: 0.15s; }
.movie-card:nth-child(4) { animation-delay: 0.2s; }
.movie-card:nth-child(5) { animation-delay: 0.25s; }
.movie-card:nth-child(6) { animation-delay: 0.3s; }
.movie-card:nth-child(7) { animation-delay: 0.35s; }
.movie-card:nth-child(8) { animation-delay: 0.4s; }

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

.movie-card:hover {
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.movie-card.noped {
  animation: nopeOut 0.4s ease forwards;
}

@keyframes nopeOut {
  to { opacity: 0; transform: translateX(-60px) scale(0.95); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

.movie-poster {
  width: 110px;
  height: 165px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
  position: relative;
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.movie-card:hover .movie-poster img {
  transform: scale(1.05);
}

.movie-poster-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: var(--surface);
}

.movie-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.movie-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--popcorn);
}

.movie-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.movie-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--star);
  font-weight: 700;
}

.movie-rating .star {
  font-size: 0.9em;
}

.movie-overview {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.movie-why {
  font-size: 0.82rem;
  color: var(--butter);
  font-weight: 600;
  font-style: italic;
  margin-top: auto;
  padding-top: 4px;
}

/* Card action buttons */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

.card-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

.card-action-btn:hover {
  transform: translateY(-1px);
}

.btn-icon {
  font-size: 0.85rem;
}

@media (max-width: 639px) {
  .btn-text {
    display: none;
  }
  .card-action-btn {
    padding: 6px 10px;
  }
  .btn-icon {
    font-size: 1rem;
  }
}

.btn-seen:hover, .btn-seen.active {
  background: rgba(78, 205, 196, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.btn-nope:hover {
  background: rgba(231, 76, 94, 0.15);
  border-color: var(--cherry);
  color: var(--cherry);
}

.btn-pick:hover {
  background: rgba(245, 197, 24, 0.15);
  border-color: var(--butter);
  color: var(--butter);
}

/* Seen badge on poster */
.seen-badge-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(78, 205, 196, 0.85);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  font-family: var(--font);
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.03em;
}

/* Include-seen toggle */
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  cursor: pointer;
  user-select: none;
}

.toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(78, 205, 196, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--success);
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* ============================================
   Pick Overlay (Confetti!)
   ============================================ */

.pick-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 26, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

.pick-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pick-content {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1001;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.pick-card {
  background: var(--bg-card);
  border: 2px solid var(--butter);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  position: relative;
  z-index: 1002;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.pick-emoji {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
}

.pick-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--butter);
  margin-bottom: 16px;
}

.pick-movie-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--popcorn);
  margin-bottom: 4px;
}

.pick-movie-year {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.pick-card .btn-primary {
  width: 100%;
}

/* ============================================
   History Screen
   ============================================ */

#screen-history {
  justify-content: flex-start;
  padding-top: 40px;
}

.history-container {
  width: 100%;
  max-width: 540px;
  padding: 0 20px;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.history-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--popcorn);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.05);
}

.history-poster {
  width: 48px;
  height: 72px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
}

.history-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-details {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--popcorn);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.history-empty.hidden {
  display: none;
}

.empty-emoji {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

/* ============================================
   Responsive — Tablet+
   ============================================ */

@media (min-width: 640px) {
  .start-content h1 {
    font-size: 3.4rem;
  }

  .question-text {
    font-size: 1.8rem;
  }

  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .movie-card {
    grid-template-columns: 120px 1fr;
  }

  .movie-poster {
    width: 120px;
    height: 180px;
  }
}

@media (min-width: 960px) {
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .movie-card {
    grid-template-columns: 130px 1fr;
  }

  .movie-poster {
    width: 130px;
    height: 195px;
  }
}

/* ============================================
   Utility
   ============================================ */

.hidden {
  display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  color: var(--text-primary);
  padding: 14px 28px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow);
  z-index: 2000;
  transition: transform 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
