/* ============================================================
   What Movie Today? – stylesheet
   Card dimensions are declared as CSS custom properties and
   also read by app.js via getComputedStyle. Keep in sync.
   ============================================================ */

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

/* ----- Design tokens ----- */
:root {
  --bg:           #0a0a0f;
  --bg-card:      #12121e;
  --accent:       #f5c518;
  --accent-glow:  rgba(245, 197, 24, 0.35);
  --text-primary: #ffffff;
  --text-muted:   #8888aa;
  --border:       rgba(255, 255, 255, 0.08);

  /* Card dimensions – READ BY JS */
  --card-width:  130px;
  --card-height: 195px;
  --card-gap:    12px;
}

/* ----- Base ----- */
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ----- Layout ----- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

/* ----- Header ----- */
header {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

header h1 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(3rem, 8vw, 6rem);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--text-primary);
  text-shadow: 0 0 60px var(--accent-glow);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.6rem;
}

/* ----- Loading ----- */
#loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 1rem;
  gap: 1.25rem;
  color: var(--text-muted);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* Error state (replaces loading content) */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  max-width: 480px;
}

.error-state .error-icon { font-size: 2rem; }

.error-state .error-message {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.error-state .error-detail { font-size: 0.85rem; color: #e06060; }

.error-state .error-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  line-height: 1.6;
}

.error-state code {
  background: rgba(255,255,255,0.08);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent);
}

/* ----- Roulette section ----- */
#roulette-section { padding: 1rem 0 2rem; }

.roulette-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 1.5rem 0;
}

/* Side vignettes */
.roulette-wrapper::before,
.roulette-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  width: clamp(60px, 12%, 160px);
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

.roulette-wrapper::before {
  left: 0;
  background: linear-gradient(to right, var(--bg), transparent);
}

.roulette-wrapper::after {
  right: 0;
  background: linear-gradient(to left, var(--bg), transparent);
}

/* Golden selector frame */
.center-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(var(--card-width) + 6px);
  height: calc(var(--card-height) + 6px);
  border: 2px solid var(--accent);
  border-radius: 8px;
  z-index: 11;
  pointer-events: none;
  box-shadow:
    0 0 16px var(--accent-glow),
    inset 0 0 12px rgba(245, 197, 24, 0.1);
}

/* Scrolling strip container */
#roulette-container { overflow: hidden; width: 100%; }

/* The strip itself */
#roulette-strip {
  display: flex;
  gap: var(--card-gap);
  will-change: transform;
  user-select: none;
  /* padding-inline set by JS for centering */
}

/* ----- Movie card (in roulette) ----- */
.roulette-card {
  flex-shrink: 0;
  width: var(--card-width);
}

.roulette-card img {
  display: block;
  width: var(--card-width);
  height: var(--card-height);
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid transparent;
  transition: border-color 0.35s, box-shadow 0.35s;
  background: var(--bg-card);
}

.roulette-card.active img {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}

.card-title {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Result section ----- */
#result-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  margin: 0 auto 4rem;
  max-width: 820px;
  padding: 0 1.25rem;
}

#result-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.result-card {
  display: flex;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  align-items: flex-start;
}

.result-poster-wrapper { position: relative; flex-shrink: 0; }

.result-poster-wrapper img {
  display: block;
  width: 180px;
  height: 270px;
  object-fit: cover;
  border-radius: 10px;
  border: 3px solid var(--accent);
  box-shadow: 0 0 36px var(--accent-glow);
  background: var(--bg-card);
}

.result-rank {
  position: absolute;
  top: -12px;
  left: -12px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.result-info { flex: 1; min-width: 0; }

.result-info h2 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: 0.03em;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: 0.65rem;
}

.result-meta {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.result-year  { color: var(--text-muted); font-size: 0.95rem; }
.result-votes { color: var(--text-muted); font-size: 0.85rem; }

.result-rating {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.result-genres {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.9rem;
}

.result-plot {
  color: #ccccdd;
  font-size: 0.93rem;
  line-height: 1.65;
  margin-bottom: 1.5rem;
}

.result-actions {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.6rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background 0.2s, color 0.2s, transform 0.18s, box-shadow 0.18s, opacity 0.2s;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: #ffd700;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 197, 24, 0.4);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* ----- Footer ----- */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* ----- Utility ----- */
.hidden { display: none !important; }

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--accent); }
  #result-section { transition: none; }
  .btn { transition: none; }
}

/* ----- Responsive ----- */
@media (max-width: 580px) {
  :root {
    --card-width:  96px;
    --card-height: 144px;
    --card-gap:    8px;
  }

  header { padding: 2rem 1rem 1.5rem; }

  .result-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1.25rem;
  }

  .result-meta,
  .result-actions { justify-content: center; }

  .result-poster-wrapper img {
    width: 140px;
    height: 210px;
  }
}
