/* Reel Rank — a night at the pictures. */

:root {
  --house: #170d10;        /* the dark auditorium */
  --house-lift: #2a1519;
  --velvet: #6b1624;       /* curtain and marquee red */
  --velvet-deep: #4a0e19;
  --ink-red: #a3202b;      /* rubber-stamp red on the tickets */
  --bulb: #f5b544;         /* marquee bulbs */
  --paper: #eed9ae;        /* ticket stock */
  --ink: #2b1612;
  --cream: #f7ebd3;
  --muted: #bfa48c;

  --row: 5rem;
  --gap: 0.625rem;

  --display: "Limelight", Georgia, serif;
  --print: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --text: "Big Shoulders Text", "Arial Narrow", sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 55% at 50% -12%, #44181f 0%, transparent 70%),
    var(--house);
  color: var(--cream);
  font: 500 1.125rem/1.45 var(--text);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* Film grain over everything; never catches taps. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main,
.topbar,
.footer {
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  padding-inline: 1rem;
}

main { flex: 1; }

:focus-visible {
  outline: 3px solid var(--bulb);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Top bar */

.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-block: 0.625rem 0.5rem;
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 2px solid rgb(245 181 68 / 0.45);
  border-radius: 50%;
  background: transparent;
  color: var(--bulb);
  font: 900 1.25rem/1 var(--print);
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--bulb); }

/* Marquee: the one loud thing on the page */

.marquee {
  position: relative;
  padding: 1.75rem 1.5rem 1.5rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #7d1b2b, var(--velvet) 55%, var(--velvet-deep));
  box-shadow:
    inset 0 0 0 3px #3a0b14,
    0 24px 40px -24px rgb(0 0 0 / 0.9);
  text-align: center;
}

/* A ring of bulbs, drawn as dots and masked down to the frame. */
.marquee::before {
  content: "";
  position: absolute;
  inset: 6px;
  padding: 9px;
  border-radius: 9px;
  background: radial-gradient(circle, #fff1c9 0 1.5px, var(--bulb) 2.5px, transparent 3.6px) center / 15px 15px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  filter: drop-shadow(0 0 3px rgb(245 181 68 / 0.9));
  pointer-events: none;
}

.marquee-title {
  margin: 0;
  font: 400 clamp(2.5rem, 13vw, 3.5rem)/1 var(--display);
  color: #fff4da;
  text-shadow:
    0 0 4px rgb(255 214 140 / 0.9),
    0 0 18px rgb(245 181 68 / 0.55),
    0 0 42px rgb(245 120 60 / 0.35);
}

/* The changeable-letter board: each letter is its own tile. */
.letterboard {
  min-height: 2.75rem;
  margin: 1rem 0 0;
  padding: 0.5rem 0.5rem 0.4375rem;
  border-radius: 3px;
  background: #e9e0cb;
  box-shadow:
    inset 0 3px 0 rgb(0 0 0 / 0.18),
    inset 0 -3px 0 rgb(0 0 0 / 0.18),
    0 0 18px rgb(255 230 180 / 0.25);
  color: #1c1210;
  font: 900 clamp(1.375rem, 7vw, 1.75rem)/1 var(--print);
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem 0.625rem;
}

.letterboard .word {
  display: inline-flex;
  gap: 2px;
  white-space: nowrap;
}

.letterboard .tile {
  display: inline-block;
  min-width: 0.7em;
  padding: 0.12em 0.08em 0.06em;
  background: linear-gradient(#fbf7ee, #ece4d2);
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.25);
  text-align: center;
}

.puzzle-meta {
  margin: 0.875rem 0 0;
  text-align: center;
  color: var(--muted);
}

.instructions {
  margin: 1.25rem 0 0.875rem;
  text-align: center;
}

/* Board: fixed rank numbers beside the tickets that move */

.board {
  scroll-margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0 0.5rem;
}

/* Rows are at least --row tall and all match the tallest ticket, so a title that wraps
   grows every row together and the rank numbers stay level with the tickets. */
.ranks,
.tickets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-rows: 1fr;
  gap: var(--gap);
}

.ranks li {
  scroll-margin-block: 0.75rem;
  display: grid;
  place-items: center;
  font: 400 1.75rem/1 var(--display);
  color: var(--bulb);
  text-shadow: 0 0 10px rgb(245 181 68 / 0.45);
}

/* Ticket stubs */

.ticket {
  --stub: 4rem;
  --notch: 7px;
  position: relative;
  min-height: var(--row);
  display: grid;
  grid-template-columns: var(--stub) 1fr 1.75rem;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgb(163 32 43 / 0.09) 0 var(--stub), transparent var(--stub)),
    var(--paper);
  color: var(--ink);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* Half-moon notches where the stub tears off. */
  -webkit-mask:
    radial-gradient(circle var(--notch) at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle var(--notch) at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle var(--notch) at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}

.ticket:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--house), 0 0 0 6px var(--bulb);
  -webkit-mask: none;
  mask: none;
}

.stub {
  display: grid;
  place-items: center;
  border-right: 2px dashed rgb(43 22 18 / 0.3);
}

.stub::before {
  content: "★";
  font-size: 1.375rem;
  color: rgb(163 32 43 / 0.35);
}

.stamp {
  display: none;
  width: 3.125rem;
  height: 3.125rem;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px currentColor;
  color: var(--ink-red);
  font: 400 1.25rem/1 var(--display);
  transform: rotate(-8deg);
}

.ticket-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 0.25rem 0.5rem 0.75rem;
}

.title {
  margin: 0;
  font: 800 1.3125rem/1.02 var(--print);
  overflow-wrap: anywhere;
}

.meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.2;
  color: rgb(43 22 18 / 0.75);
}

.year {
  color: var(--ink-red);
  font-weight: 700;
}

.hint-text:empty,
.verdict:empty { display: none; }

.grip {
  align-self: center;
  justify-self: center;
  width: 0.875rem;
  height: 0.75rem;
  background:
    linear-gradient(rgb(43 22 18 / 0.35) 0 0) top / 100% 2px no-repeat,
    linear-gradient(rgb(43 22 18 / 0.35) 0 0) center / 100% 2px no-repeat,
    linear-gradient(rgb(43 22 18 / 0.35) 0 0) bottom / 100% 2px no-repeat;
}

/* Dragging */

.ticket-ghost { opacity: 0.3; }

.ticket-dragging {
  opacity: 1 !important;
  transform: rotate(-1.5deg) scale(1.03);
  box-shadow: 0 18px 30px -12px rgb(0 0 0 / 0.8);
  cursor: grabbing;
}

/* Locked and revealed */

.tickets.locked .ticket { cursor: default; }
.tickets.locked .grip { visibility: hidden; }

.ticket.revealed .stub::before { content: none; }
.ticket.revealed .stamp { display: grid; }

@media (prefers-reduced-motion: no-preference) {
  .ticket.revealed .stamp { animation: stamp 360ms cubic-bezier(0.3, 1.6, 0.5, 1) both; }
}

@keyframes stamp {
  from { opacity: 0; transform: rotate(-18deg) scale(1.9); }
  to { opacity: 1; transform: rotate(-8deg) scale(1); }
}

/* Buttons */

.btn {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font: 700 1.25rem/1.1 var(--text);
  cursor: pointer;
}

.btn-primary {
  border: 0;
  background: var(--bulb);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--house), 0 0 0 4px rgb(245 181 68 / 0.6), 0 0 26px rgb(245 181 68 / 0.25);
}

.btn-primary:hover { background: #ffc35c; }

.btn-ghost {
  border: 2px solid rgb(245 181 68 / 0.45);
  background: transparent;
  color: var(--bulb);
}

.btn-ghost[data-armed] {
  border-color: var(--ink-red);
  background: rgb(163 32 43 / 0.2);
  color: var(--cream);
}

.btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.actions {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Result */

.result {
  margin-top: 1.75rem;
  text-align: center;
}

.score {
  margin: 0;
  font: 400 3.75rem/1 var(--display);
  color: #fff4da;
  text-shadow: 0 0 18px rgb(245 181 68 / 0.45);
}

.out-of {
  font-size: 1.5rem;
  color: var(--muted);
  text-shadow: none;
}

#score-emoji { font-size: 2.25rem; }

.grid {
  margin: 0.75rem 0 1.25rem;
  font-size: 1.75rem;
  letter-spacing: 0.15em;
}

.share-status {
  min-height: 1.5rem;
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.next { margin: 0.25rem 0 0; }

#countdown {
  font: 400 1.375rem/1 var(--display);
  color: var(--bulb);
  font-variant-numeric: tabular-nums;
}

.message {
  margin: 2rem 0;
  text-align: center;
}

/* Netlify's free plan pins a "Powered by Netlify" badge (about 64px tall) to the bottom
   corner; the extra bottom padding lets the footer scroll clear of it. */
.footer {
  padding-block: 2rem 5.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Dialogs */

.dialog {
  width: min(26rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 2px solid var(--velvet);
  border-radius: 12px;
  background: var(--house-lift);
  color: var(--cream);
}

.dialog::backdrop { background: rgb(10 4 6 / 0.78); }

.dialog-inner { padding: 1.5rem 1.375rem 1.375rem; }

.dialog h2 {
  margin: 0 0 0.75rem;
  font: 400 1.875rem/1.1 var(--display);
  color: var(--bulb);
}

.dialog p,
.dialog ul { margin: 0 0 0.875rem; }

.dialog ul { padding-left: 1.25rem; }
.dialog li + li { margin-top: 0.375rem; }

.key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 1rem;
}

.dialog .btn { margin-top: 1.25rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 0;
}

.stats div {
  padding: 0.75rem;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.25);
  text-align: center;
}

.stats dt { color: var(--muted); font-size: 1rem; }

.stats dd {
  margin: 0.25rem 0 0;
  font: 400 2rem/1 var(--display);
  color: #fff4da;
}
