/* Emmadle
   Each review is a ticket stub: poster and viewing details on top, a
   perforated tear line, then the review. The palette borrows from
   Letterboxd's dark theme: charcoal page, slate panels, and the orange,
   green and blue accents. */

@import url("https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;800&family=Newsreader:ital,opsz,wght@0,6..72,400..500&display=swap");

:root {
  --night: #14181c;   /* page background */
  --slate: #2c3440;   /* ticket panels */
  --bright: #e8eef3;  /* headings and titles */
  --body: #c8d3dd;    /* review text */
  --muted: #99aabb;   /* secondary text */
  --green: #00e054;   /* main buttons and the rating stamp */
  --orange: #ff8000;  /* rewatch stamp */
  --blue: #40bcf4;    /* focus rings and text selection */

  --display: "Big Shoulders Display", "Arial Narrow", "Franklin Gothic Medium", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
}

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

/* game.js hides things with the hidden attribute. Any rule below that sets
   "display" would override it, so this keeps hidden things hidden. */
[hidden] { display: none !important; }

/* Wrapper paragraphs whose only child is hidden shouldn't leave a gap. */
p:has(> [hidden]:only-child) { display: none; }

html {
  background: var(--night);
  color-scheme: dark;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 64rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
  background: var(--night);
  color: var(--bright);
  font: 400 1rem/1.5 var(--serif);
}

::selection { background: var(--blue); color: var(--night); }

:focus-visible {
  outline: .2rem solid var(--blue);
  outline-offset: .2rem;
}

/* ---------- Header and status ---------- */

h1 {
  margin: .5rem 0 .25rem;
  font: 800 clamp(2.5rem, 9vw, 4.75rem)/.95 var(--display);
  color: var(--bright);
  text-wrap: balance;
}

h2 {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  font-weight: 400;
}

h2 p { margin: 0; }

#round {
  font: 600 1.4rem/1.2 var(--display);
  letter-spacing: .03em;
  color: var(--muted);
}

#score {
  display: block;
  font: 800 clamp(2.25rem, 8vw, 3.5rem)/1 var(--display);
  color: var(--bright);
  text-wrap: balance;
}

/* The shareable result, as a ticket with notches on both sides */
#share-score {
  position: relative;
  display: block;
  width: min(100%, 24rem);
  margin-top: 1.5rem;
  padding: 1.5rem 1.75rem;
  background: var(--slate);
  color: var(--bright);
  border-radius: .4rem;
  font: 500 1.15rem/1.6 var(--serif);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

#share-score::before,
#share-score::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: -.75rem;
  border-radius: 50%;
  background: var(--night);
}

#share-score::before { left: -.75rem; }
#share-score::after { right: -.75rem; }

/* ---------- Buttons ---------- */

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

#next-button,
#copy-button,
.card > button {
  min-height: 3.25rem;
  background: var(--green);
  color: var(--night);
  border-radius: .35rem;
  font: 800 1.4rem/1 var(--display);
  letter-spacing: .02em;
}

#next-button,
#copy-button { padding: .6rem 1.75rem; }

#next-button { width: min(100%, 22rem); }
#copy-button { margin-top: 1rem; }

#next-button:active,
#copy-button:active,
.card > button:enabled:active { transform: translateY(1px); }

/* ---------- Cards ---------- */

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  margin-top: .25rem;
}

@media (min-width: 48rem) {
  .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card {
  --pad: 1.25rem;
  --poster-w: 6.5rem;
  position: relative;
  display: grid;
  grid-template-columns: var(--poster-w) minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr auto auto;
  grid-template-areas:
    "poster title"
    "poster date"
    "poster stamp"
    "poster ."
    "review review"
    "action action";
  column-gap: 1rem;
  row-gap: .3rem;
  padding: var(--pad);
  background: var(--slate);
  color: var(--bright);
  border-radius: .4rem;
}

@media (min-width: 62rem) {
  .card { --poster-w: 8rem; }
}

.card > img {
  grid-area: poster;
  align-self: start;
  display: block;
  width: var(--poster-w);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: .25rem;
  background: #1f262e;
  outline: 1px solid rgba(255, 255, 255, .14);
  outline-offset: -1px;
  font-size: .75rem;
  line-height: 1.3;
  color: var(--muted);
}

.card > h3 {
  grid-area: title;
  margin: 0;
  font: 800 clamp(1.6rem, 5.5vw, 2.1rem)/1.02 var(--display);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.card [id$="-year"] {
  font-weight: 600;
  color: var(--muted);
}

/* "Watched: date" */
.card > p:not([id]) {
  grid-area: date;
  margin: 0;
  font: 600 1.1rem/1.2 var(--display);
  letter-spacing: .03em;
  color: var(--muted);
}

/* Rewatch badge, like a rubber stamp */
.card [id$="-rewatch"] {
  grid-area: stamp;
  justify-self: start;
  margin-top: .4rem;
  padding: .1rem .55rem .15rem;
  border: .15rem solid var(--orange);
  border-radius: .25rem;
  color: var(--orange);
  font: 800 1.1rem/1.1 var(--display);
  letter-spacing: .06em;
  transform: rotate(-5deg);
}

/* The review sits below a perforated tear line that runs edge to edge,
   with a notch cut out of each side. */
.card [id$="-review"] {
  grid-area: review;
  position: relative;
  margin: .9rem calc(-1 * var(--pad)) 0;
  padding: 1.1rem var(--pad) 0;
  border-top: .125rem dashed rgba(153, 170, 187, .35);
  color: var(--body);
  font: 400 1.075rem/1.6 var(--serif);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.card [id$="-review"]::before,
.card [id$="-review"]::after {
  content: "";
  position: absolute;
  top: -.8125rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--night);
}

.card [id$="-review"]::before { left: -.75rem; }
.card [id$="-review"]::after { right: -.75rem; }

/* The revealed rating is stamped onto the poster. It is positioned over the
   card so showing it doesn't move anything else. */
.card [id$="-rating"] {
  position: absolute;
  z-index: 1;
  top: calc(var(--pad) + .4rem);
  left: calc(var(--pad) + .4rem);
  margin: 0;
  padding: .3rem .55rem .35rem;
  background: var(--green);
  color: var(--night);
  border-radius: .25rem;
  font: 800 1.6rem/1 var(--display);
  transform: rotate(-5deg);
  animation: stamp-in .3s cubic-bezier(.2, 1.4, .4, 1) both;
}

@keyframes stamp-in {
  from { transform: rotate(-5deg) scale(1.8); opacity: 0; }
  to   { transform: rotate(-5deg) scale(1);   opacity: 1; }
}

.card > button {
  grid-area: action;
  width: 100%;
  margin-top: 1.1rem;
  padding: .7rem 1rem;
  transition: background-color .15s;
}

.card > button:disabled {
  background: #38424e;
  color: #7b8a99;
  cursor: not-allowed;
}

/* ---------- After a pick ---------- */

#message {
  order: 2;
  margin: 1.25rem 0 0;
  font: 800 clamp(1.9rem, 6vw, 2.6rem)/1 var(--display);
  color: var(--bright);
}

/* Next stays at the bottom of the screen so it is never scrolled away
   when the two cards are stacked on a phone. */
p:has(> #next-button) {
  order: 3;
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom));
  background: var(--night);
}

/* ---------- TMDB credit ---------- */

body > p:last-of-type {
  order: 4;
  max-width: 34rem;
  margin: auto 0 0;
  padding-top: 2.5rem;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}

body > p:last-of-type img {
  display: block;
  width: 6rem;
  height: auto;
  margin-top: .75rem;
}

/* ---------- Hover, motion ---------- */

@media (hover: hover) {
  #next-button:hover,
  #copy-button:hover,
  .card > button:enabled:hover { background: #4dff88; }
}

@media (prefers-reduced-motion: reduce) {
  .card [id$="-rating"] { animation: none; }
  .card > button { transition: none; }
}