:root {
  --bg: #f9f9e5;
  --ink: #000;
  --ink-faint: rgb(0 0 0 / 0.2);
  --ink-soft: rgb(0 0 0 / 0.5);
  --red: #da0000;
  --red-faint: rgb(218 0 0 / 0.2);
  --hairline: rgb(0 0 0 / 0.15);

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  --text: clamp(14px, 1.7vw, 36px);
  --gutter: clamp(16px, 1.1vw, 24px);

  /* Same motion language as rdrew.com. */
  --ease-out: cubic-bezier(0.2, 0.75, 0.25, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
  --dur-quick: 0.2s;
  --dur-base: 0.55s;
  --stagger: 80ms;
  --enter-rise: 10px;
}

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

html {
  overflow-y: scroll;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 600 var(--text) / 1.2 var(--mono);
  letter-spacing: -0.04em;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.masthead {
  padding: clamp(32px, 4vw, 84px) var(--gutter) 0;
  text-align: center;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.22em;
  font: 400 clamp(44px, 5.96vw, 126px) / 1 var(--serif);
  letter-spacing: -0.045em;
}

.category {
  padding-bottom: 0.05em;
  border-bottom: 2px solid transparent;
  color: var(--red-faint);
}

.category.is-active {
  border-bottom-color: var(--red);
  color: var(--red);
}

.people {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px clamp(12px, 1.2vw, 24px);
  margin-top: clamp(28px, 2.8vw, 56px);
  font: italic 400 clamp(13px, 1vw, 20px) / 1.2 var(--mono);
  letter-spacing: 0;
}

/* Sized to the text, so "add letterboxd username" fits between the pill's side padding. */
.slot {
  display: flex;
  width: min(100%, 20em);
}

.pill {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
  height: 2.9em;
  padding: 0 2em;
  border: 1px solid rgb(0 0 0 / 0.25);
  border-radius: 0.45em;
  background: rgb(0 0 0 / 0.04);
  color: var(--ink-soft);
  font: inherit;
  text-align: center;
}

input.pill::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}

input.pill:focus {
  border-color: var(--ink-soft);
  outline: none;
}

.person.is-loading {
  opacity: 0.5;
}

.avatar {
  flex: none;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.08);
  object-fit: cover;
}

.remove {
  position: absolute;
  right: 0.35em;
  padding: 0.2em 0.45em;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font: 400 1.2em / 1 var(--mono);
  cursor: pointer;
  transition: color var(--dur-quick) var(--ease-out);
}

.remove:hover {
  color: var(--ink);
}

.compare-button {
  height: 2.9em;
  padding: 0 1.2em;
  border: 0;
  border-radius: 0.45em;
  background: rgb(0 0 0 / 0.05);
  color: var(--ink-soft);
  font: 600 1em / 1 var(--mono);
  cursor: pointer;
  transition: color var(--dur-quick) var(--ease-out);
}

.compare-button:hover {
  color: var(--ink);
}

@media (max-width: 640px) {
  .slot,
  .compare-button {
    width: 100%;
  }
}

.summary {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  min-height: 1.2em;
  margin: clamp(16px, 1.4vw, 28px) 0 0;
  color: var(--ink-soft);
  font-size: clamp(12px, 0.9vw, 18px);
}

.summary strong {
  color: var(--ink);
  font-weight: inherit;
}

/* The taste verdict wraps as one piece. */
.verdict {
  display: inline-block;
}

.controls {
  display: flex;
  justify-content: space-between;
  padding: clamp(32px, 3.6vw, 76px) var(--gutter) 0;
}

.toggle {
  display: flex;
  gap: 0.6em;
}

.toggle button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color var(--dur-quick) var(--ease-out);
}

.toggle button[aria-pressed='true'] {
  color: var(--ink);
}

#films {
  padding: clamp(32px, 4vw, 84px) var(--gutter);
}

.poster {
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  outline: 1px solid var(--hairline);
  outline-offset: -1px;
  background: rgb(0 0 0 / 0.04);
}

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

.poster-empty {
  display: flex;
  align-items: flex-end;
  height: 100%;
  padding: 0.6em;
}

.caption {
  display: block;
  line-height: 1.25;
}

.caption > * {
  display: block;
}

.caption strong {
  font-weight: inherit;
}

.caption-detail {
  color: var(--ink-soft);
}

.caption > .caption-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6em;
}

/* Five empty stars with a filled copy on top, clipped to the rating. */
.stars {
  position: relative;
  letter-spacing: 0;
  white-space: nowrap;
}

.stars::before {
  content: '★★★★★';
  color: var(--ink-faint);
}

.stars::after {
  content: '★★★★★';
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--rating) / 5 * 100%);
  overflow: hidden;
  color: var(--ink);
}

.grid {
  position: relative;
}

.film {
  position: relative;
  display: block;
  container-type: inline-size;
}

.grid .film {
  position: absolute;
}

.film .caption {
  padding-top: 0.6em;
  font-size: 12px;
}

/* With a real pointer, the caption is a cover that slides up over the poster's base. */
@media (hover: hover) and (min-width: 641px) {
  .film {
    overflow: hidden;
  }

  .film .caption {
    position: absolute;
    inset: auto 0 0;
    padding: 0.6em 0.7em;
    background: var(--bg);
    font-size: clamp(10px, 6.5cqi, 18px);
    translate: 0 101%;
    transition: translate var(--dur-quick) var(--ease-in);
  }

  .film:hover .caption,
  .film:focus-visible .caption {
    translate: none;
    transition: translate var(--dur-quick) var(--ease-out);
  }

  .film .caption strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .film .caption-detail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.note {
  margin: 0;
  color: var(--ink-soft);
}

.compare-heads,
.pair-row,
.compare-list li {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(24px, 4vw, 84px);
}

.compare-heads {
  color: var(--ink-soft);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.8em;
  margin: clamp(28px, 3vw, 64px) 0 clamp(14px, 1.4vw, 28px);
  padding-top: 0.7em;
  border-top: 1px solid var(--hairline);
  color: var(--ink-soft);
  font: inherit;
}

.section-head .stars {
  font-size: 1.5em;
}

.section-head strong {
  color: var(--ink);
  font-weight: inherit;
}

.pair-row + .pair-row {
  margin-top: clamp(14px, 1.6vw, 32px);
}

.side {
  display: grid;
  grid-template-columns: repeat(var(--per-side), minmax(0, 1fr));
  gap: clamp(10px, 1.2vw, 24px);
  align-items: start;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list a {
  display: flex;
  align-items: flex-end;
  gap: clamp(16px, 2.1vw, 44px);
  padding-block: 0.5em;
}

.list .poster {
  flex: none;
  width: clamp(72px, 7vw, 150px);
}

.list .caption {
  min-width: 0;
}

@media (max-width: 640px) {
  .compare-list a {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5em;
  }

  .compare-list .caption {
    font-size: 12px;
  }
}

/* Give an element .enter and --i. It rises in when an ancestor gets .is-entered. */
.enter {
  opacity: 0;
  translate: 0 var(--enter-rise);
  transition:
    opacity var(--dur-quick) var(--ease-in),
    translate var(--dur-quick) var(--ease-in);
}

.is-entered .enter {
  opacity: 1;
  translate: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    translate var(--dur-base) var(--ease-out);
  transition-delay: calc(var(--i, 0) * var(--stagger));
}

@media (prefers-reduced-motion: reduce) {
  .enter,
  .is-entered .enter,
  .grid .caption,
  .film:hover .caption,
  .film:focus-visible .caption {
    transition-duration: 0.01s;
    transition-delay: 0s;
  }

  .enter {
    translate: none;
  }
}
