/* Moovie Night — dark, high-contrast, warm orange accent. */

:root {
  --bg: #0b0a10;
  --bg-2: #12101a;
  --panel: #17141f;
  --panel-2: #1e1a29;
  --line: #2c2740;
  --line-soft: #241f33;
  --ink: #ece9f5;
  --ink-dim: #a49dc0;
  --ink-faint: #6f688a;
  /* The accent pair. The token names are historical — the app was Halloween-only
     when they were chosen, and "pumpkin" stuck because renaming ~20 usages buys
     nothing a reader cannot get from this comment. The VALUE is a warm orange
     that suits any category; changing it here changes every accent at once. */
  --pumpkin: #ff7a2f;
  --pumpkin-deep: #d64d10;
  --acid: #9dff5c;
  --blood: #e0384f;
  --radius: 14px;
  --shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.9);
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', var(--sans);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(255, 122, 47, 0.13), transparent 62%),
    radial-gradient(900px 520px at 92% 4%, rgba(157, 255, 92, 0.055), transparent 58%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- chrome */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(14px, 4vw, 34px);
  background: rgba(11, 10, 16, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; cursor: pointer; padding: 4px 2px;
  color: var(--ink); font-family: var(--display); font-weight: 700;
  font-size: 17px; letter-spacing: -0.01em;
}
.brand-mark { font-size: 19px; filter: drop-shadow(0 0 12px rgba(255, 122, 47, 0.45)); }
.brand-text em { font-style: normal; color: var(--pumpkin); }

.topnav { display: flex; gap: 4px; margin-left: auto; }
.navlink {
  background: none; border: 1px solid transparent; cursor: pointer;
  color: var(--ink-dim); font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 13px; border-radius: 9px; transition: 0.16s ease;
}
.navlink:hover { color: var(--ink); background: var(--panel); }
.navlink.active { color: var(--pumpkin); background: var(--panel); border-color: var(--line); }

.identity { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line-soft); }
.who { font-size: 13px; color: var(--ink-dim); font-family: var(--mono); }
.who::before { content: '◈ '; color: var(--acid); }

@media (max-width: 640px) {
  .brand-text { display: none; }
  .identity { border-left: 0; padding-left: 0; }
  .who { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------------------------------------------------------------- layout */

#app { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: clamp(18px, 4vw, 40px) clamp(14px, 4vw, 34px) 60px; position: relative; z-index: 1; }
.view { animation: fade 0.28s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--pumpkin); margin: 0 0 10px;
}
h1 { font-family: var(--display); font-size: clamp(27px, 5vw, 44px); line-height: 1.1; letter-spacing: -0.025em; margin: 0 0 14px; }
h3 { font-family: var(--display); font-size: 17px; margin: 0 0 12px; letter-spacing: -0.01em; }
.lede { color: var(--ink-dim); max-width: 62ch; margin: 0 0 24px; font-size: 15.5px; }
.muted { color: var(--ink-dim); }
.small { font-size: 13.5px; }
.fine { font-size: 12.5px; color: var(--ink-faint); margin: 16px 0 0; max-width: 46ch; }
.error { color: var(--blood); font-size: 14px; margin: 14px 0 0; }

/* ---------------------------------------------------------------- buttons */

.primary {
  background: linear-gradient(180deg, var(--pumpkin), var(--pumpkin-deep));
  color: #180d05; border: 0; border-radius: 11px;
  font: inherit; font-weight: 700; font-size: 15px;
  padding: 12px 22px; cursor: pointer;
  box-shadow: 0 10px 26px -12px rgba(255, 122, 47, 0.85);
  transition: 0.16s ease;
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary:active { transform: none; }
.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.primary.compact { padding: 9px 16px; font-size: 14px; }

.ghost {
  background: transparent; color: var(--ink-dim); border: 1px solid var(--line);
  border-radius: 9px; font: inherit; font-size: 13.5px; padding: 8px 14px;
  cursor: pointer; transition: 0.16s ease;
}
.ghost:hover { color: var(--ink); border-color: var(--pumpkin); background: var(--panel); }

/* ---------------------------------------------------------------- join */

.join-card { max-width: 620px; padding-top: clamp(10px, 6vh, 60px); }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 7px; font-weight: 500; }
.field input {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); font: inherit; font-size: 16px; padding: 11px 14px;
  transition: 0.16s ease;
}
.field input:focus { outline: none; border-color: var(--pumpkin); box-shadow: 0 0 0 3px rgba(255, 122, 47, 0.16); }
.field input::placeholder { color: var(--ink-faint); }

/* ---------------------------------------------------------------- progress */

.progress-wrap { margin-bottom: 22px; }
.progress-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; margin-bottom: 7px; color: var(--ink-dim); }
.progress-track { height: 5px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line-soft); }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--pumpkin-deep), var(--pumpkin), var(--acid)); transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ---------------------------------------------------------------- arena */

.arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; }

.card {
  position: relative; text-align: left; cursor: pointer;
  background: linear-gradient(165deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 20px 18px; color: var(--ink); font: inherit;
  display: flex; flex-direction: column;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.18s, box-shadow 0.18s, background 0.18s;
  overflow: hidden;
}
.card::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--radius);
  background: radial-gradient(420px 200px at 50% 118%, rgba(255, 122, 47, 0.16), transparent 70%);
  opacity: 0; transition: opacity 0.22s ease; pointer-events: none;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px); border-color: var(--pumpkin);
  box-shadow: var(--shadow); outline: none;
}
.card:hover::after, .card:focus-visible::after { opacity: 1; }
.card.chosen { border-color: var(--acid); box-shadow: 0 0 0 2px rgba(157, 255, 92, 0.35), var(--shadow); }
.card.rejected { opacity: 0.34; transform: scale(0.985); }

.card-index {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--pumpkin); letter-spacing: 0.14em;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 7px; align-self: flex-start; margin-bottom: 14px;
  background: rgba(11, 10, 16, 0.7);
  position: absolute; top: 14px; left: 16px; z-index: 3;
  backdrop-filter: blur(6px);
}

/* ---------------------------------------------------------------- poster */

.poster {
  position: relative; width: 100%; aspect-ratio: 2 / 3;
  margin: -22px -20px 16px; width: calc(100% + 40px);
  border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
  background: linear-gradient(150deg, #241d33, #14111d);
  flex-shrink: 0;
}
.poster img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card:hover .poster img { transform: scale(1.035); }

/* Typographic stand-in when no artwork was fetched. */
.poster-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; text-align: center;
  background:
    repeating-linear-gradient(45deg, rgba(255, 122, 47, 0.045) 0 12px, transparent 12px 24px),
    radial-gradient(circle at 50% 40%, rgba(255, 122, 47, 0.14), transparent 68%),
    linear-gradient(155deg, #221b30, #12101a);
}
.pf-title {
  font-family: var(--display); font-weight: 700; font-size: 17px;
  line-height: 1.2; letter-spacing: -0.015em; color: var(--ink);
  text-wrap: balance;
}
.pf-year { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); letter-spacing: 0.1em; }
.poster-fallback::before {
  content: '🎃'; position: absolute; top: 14px; left: 0; right: 0;
  font-size: 22px; opacity: 0.28;
}

.card-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.card-title { font-family: var(--display); font-size: clamp(20px, 2.4vw, 27px); line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 5px; }
.card-year { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); margin: 0 0 12px; }
.card-blurb { font-size: 14px; color: var(--ink-dim); margin: 0 0 16px; flex: 1; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.tags li {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em;
  color: var(--ink-faint); background: var(--panel-2);
  border: 1px solid var(--line-soft); border-radius: 99px; padding: 3px 9px;
}
.pick-hint {
  margin-top: 16px; font-size: 12.5px; font-weight: 600;
  color: var(--pumpkin); opacity: 0; transform: translateY(4px);
  transition: 0.18s ease;
}
.card:hover .pick-hint, .card:focus-visible .pick-hint { opacity: 1; transform: none; }

.vs { display: flex; align-items: center; justify-content: center; }
.vs span {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.12em;
  writing-mode: vertical-rl;
}

.arena-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.matchup-reason { font-family: var(--mono); font-size: 11.5px; }
.foot-actions { display: flex; gap: 9px; }

@media (max-width: 720px) {
  .arena { grid-template-columns: 1fr; gap: 11px; }
  .vs { padding: 2px 0; }
  .vs span { writing-mode: horizontal-tb; }
  .card { min-height: 0; padding: 18px 16px 15px; }
  .card-index { top: 10px; left: 12px; }
  /* On phones, poster + blurb on one card is taller than the viewport, so the
     art is cropped to a banner and the text does the work. */
  .poster {
    aspect-ratio: 16 / 9; margin: -18px -16px 14px; width: calc(100% + 32px);
  }
  .poster img { object-position: center 28%; }
  .card-blurb { font-size: 13.5px; }
  .pick-hint { display: none; }
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(10px);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 18px; font-size: 13.5px;
  font-family: var(--mono); color: var(--ink); z-index: 40;
  box-shadow: var(--shadow); opacity: 0; transition: 0.22s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------------------------------------------------------------- results */

.results-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 11px; margin-bottom: 28px; }
.stat {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 14px 16px;
}
.stat .n { font-family: var(--display); font-size: 25px; font-weight: 700; letter-spacing: -0.02em; display: block; }
.stat .k { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-faint); }
.stat.accent .n { color: var(--pumpkin); }

.rank-list { list-style: none; padding: 0; margin: 0 0 34px; counter-reset: r; }
.rank-row {
  display: grid; grid-template-columns: 42px 40px 1fr auto; gap: 14px;
  align-items: center; padding: 10px 15px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 11px; margin-bottom: 7px;
  transition: 0.15s ease;
}
.rank-row:hover { border-color: var(--line); background: var(--panel-2); }
.rank-row.top { border-color: rgba(255, 122, 47, 0.4); background: linear-gradient(100deg, rgba(255, 122, 47, 0.09), var(--panel) 55%); }

.rank-thumb {
  width: 40px; aspect-ratio: 2 / 3; border-radius: 5px; overflow: hidden;
  background: linear-gradient(150deg, #241d33, #14111d);
  border: 1px solid var(--line-soft); flex-shrink: 0;
}
.rank-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rank-thumb.empty-thumb::after {
  content: '🎃'; display: grid; place-items: center; height: 100%;
  font-size: 15px; opacity: 0.3;
}

.rank-num { font-family: var(--mono); font-size: 13px; color: var(--ink-faint); font-weight: 600; }
.rank-row.top .rank-num { color: var(--pumpkin); }
.rank-main { min-width: 0; }
.rank-title { font-family: var(--display); font-size: 16.5px; font-weight: 500; letter-spacing: -0.012em; }
.rank-title .yr { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); margin-left: 7px; font-weight: 400; }
.rank-tags { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); margin-top: 3px; }
.rank-tags span + span::before { content: ' · '; }
.rank-stats { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.rank-rating { font-size: 15px; font-weight: 600; color: var(--ink); }
.rank-record { color: var(--ink-faint); font-size: 11px; margin-top: 2px; }
.rank-delta { font-size: 11px; }
.up { color: var(--acid); }
.down { color: var(--blood); }

.bar { height: 3px; background: var(--panel-2); border-radius: 99px; margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pumpkin-deep), var(--pumpkin)); }

.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.divergence-list, .feed, .voters { list-style: none; padding: 0; margin: 0; }
.divergence-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.divergence-list li:last-child { border-bottom: 0; }
.divergence-list .d { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.feed li { font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink-dim); font-family: var(--mono); }
.feed li:last-child { border-bottom: 0; }
.feed b { color: var(--ink); font-weight: 600; }
.feed .won { color: var(--acid); }
.voters li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.voters li:last-child { border-bottom: 0; }
.voters .c { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

.empty { color: var(--ink-faint); font-size: 14px; padding: 18px 0; text-align: center; font-family: var(--mono); }

/* ---------------------------------------------------------------- loading */

/* Posters are hotlinked, so a card isn't ready until its image decodes.
   The skeleton keeps the layout stable and signals progress instead of
   showing a half-empty card. */
.card.skeleton {
  pointer-events: none;
  border-color: var(--line-soft);
}
.card.skeleton .poster-fallback,
.card.skeleton .card-title,
.card.skeleton .card-year,
.card.skeleton .card-blurb,
.card.skeleton .tags {
  visibility: hidden;
}
.card.skeleton .poster::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.055) 40%,
    rgba(255, 255, 255, 0.055) 50%,
    transparent 70%
  );
  background-size: 220% 100%;
  animation: shimmer 1.15s linear infinite;
}
@keyframes shimmer {
  from { background-position: 180% 0; }
  to   { background-position: -60% 0; }
}

/* A spinner sits over the arena while a pair is in flight. */
#arena { position: relative; }
#arena.loading::before {
  content: '';
  position: absolute; top: 50%; left: 50%; z-index: 5;
  width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border: 2.5px solid var(--line);
  border-top-color: var(--pumpkin);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#arena.loading .poster {
  background: linear-gradient(150deg, #241d33, #14111d);
}

/* Keep the card footprint steady so nothing jumps when art arrives. */
.poster { background-color: #14111d; }

@media (prefers-reduced-motion: reduce) {
  .card.skeleton .poster::after { animation: none; }
  #arena.loading::before { animation-duration: 1.6s; }
}

/* ---------------------------------------------------------------- footer */

.foot {
  border-top: 1px solid var(--line-soft); padding: 16px clamp(14px, 4vw, 34px);
  display: flex; gap: 9px; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  position: relative; z-index: 1;
}
.foot .dot { opacity: 0.5; }
.foot code { background: var(--panel); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
/* ---------------------------------------------------------------- categories */

/*
 * The category switcher.
 *
 * Rendered twice — once on the join screen (before a voter exists) and once above
 * the voting progress bar — so the styling has to work in both places. It is a
 * wrapping row of chips rather than a <select> because there are only ever a
 * handful of categories and the counts are worth showing; a native select cannot
 * show a per-option count without a custom renderer.
 */
.cat-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 4px;
}

.cat-picker-inline {
  margin: 0 0 16px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.cat-chip:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

.cat-chip:focus-visible {
  outline: 2px solid var(--pumpkin);
  outline-offset: 2px;
}

/*
 * The active chip is filled rather than merely outlined, so the current pool is
 * obvious at a glance on a phone — the difference between two outline weights is
 * invisible in daylight.
 */
.cat-chip.active {
  border-color: var(--pumpkin);
  background: color-mix(in srgb, var(--pumpkin) 16%, var(--panel-2));
  color: var(--ink);
}

.cat-emoji {
  font-size: 15px;
  line-height: 1;
}

.cat-count {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
}

.cat-chip.active .cat-count {
  color: var(--pumpkin);
}
