/* The year in review (src/review.ts): a story of cards over the page,
 * printed on paper or bound in bookcloth and stamped in gold foil. Each
 * card has its own entrance; every element's resting style is its last
 * frame, so with motion reduced (style.css stops all animation) the cards
 * simply stand, and no bar fills to move them on. On a phone the story
 * fills the screen inside its safe areas; on a wider screen it is a
 * phone-shaped card on the dimmed page. Sizes inside are in cqw, the
 * width of that card. */

.review {
  --cream: #f6eedd;
  --gold: #e2c06e;
  --foil: linear-gradient(
    105deg,
    #9a7425 0%,
    #f4dc94 22%,
    #b98e33 40%,
    #fbecb8 55%,
    #a07a2a 75%,
    #e7c873 100%
  );
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: #120d09d0;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  animation: rv-fade 0.3s ease both;
}
.review .phone {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  container-type: size;
  touch-action: none;
  background: #1a1410;
}
@media (min-width: 600px) and (min-height: 600px) {
  .review .phone {
    width: auto;
    height: min(92dvh, 880px);
    aspect-ratio: 9 / 19.5;
    border-radius: 32px;
    box-shadow:
      0 0 0 1px #ffffff14,
      0 40px 100px #000c;
    animation: rv-lift 0.5s var(--glide) both;
  }
}
.review .paper {
  color: var(--ink);
}
.review .cloth {
  color: var(--cream);
}

/* The bars, one a card: those seen are full, the current one fills (its
   end moves the story on) and stops while a finger holds the card. */
.review .bars {
  position: absolute;
  z-index: 2;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}
.review .bars span {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 22%, transparent);
}
.review .bars i {
  display: block;
  height: 100%;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
}
.review .bars .seen i,
.review .bars .on i {
  transform: none;
}
.review .bars .on i {
  animation: rv-dwell 6s linear both;
}
.review.held .bars .on i {
  animation-play-state: paused;
}
.review .shut {
  position: absolute;
  z-index: 2;
  top: calc(env(safe-area-inset-top) + 20px);
  right: 6px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: 300 30px/1 var(--sans);
}

/* A card: centred, inside the safe areas, below the bars. */
.review .card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 64px) 7cqw calc(env(safe-area-inset-bottom) + 32px);
  overflow: hidden;
  text-align: center;
}
.review .card.paper {
  background:
    radial-gradient(
      ellipse at 30% 10%,
      color-mix(in srgb, var(--card) 70%, transparent),
      transparent 60%
    ),
    radial-gradient(ellipse at 80% 100%, #8a5a3314, transparent 55%), var(--paper);
}
/* Bookcloth: a fine weave, lit from above, darker at the edges. */
.review .card.cloth {
  background:
    repeating-linear-gradient(0deg, #0000 0 2px, #00000016 2px 3px),
    repeating-linear-gradient(90deg, #0000 0 2px, #ffffff09 2px 3px),
    radial-gradient(ellipse at 50% 35%, #ffffff1c, #0000 55%, #0000004d 100%), var(--cloth);
}
.review p,
.review h1,
.review h2,
.review ol {
  margin: 0;
}
.review h1,
.review h2,
.review .huge {
  font-family: var(--serif);
  font-weight: 600;
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.review h2 {
  font-size: 11cqw;
  margin-bottom: 10px;
}
.review em {
  font-style: normal;
  color: var(--accent);
}
.review .kicker {
  margin-bottom: 14px;
  font: 600 12px/1.2 var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}
.review .huge {
  font-size: 42cqw;
  font-variant-numeric: lining-nums tabular-nums;
}
.review .unit,
.review .line {
  font: 500 6.4cqw/1.2 var(--serif);
  font-variation-settings: 'SOFT' 100;
}
.review .aside {
  max-width: 30ch;
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.45;
  opacity: 0.8;
}
.review b {
  font-weight: 650;
}

/* Gold foil: a gradient through the letters, its shine passing once
   they are in. */
.review .foil {
  background: var(--foil) 0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 #0000006b);
}
.review .foil.rise {
  animation:
    rv-rise 0.8s var(--glide) both,
    rv-shine 2.4s ease-in-out both;
  animation-delay: calc(var(--i, 0) * 110ms + 250ms), calc(var(--i, 0) * 110ms + 900ms);
}

/* The entrance most text makes: up out of a blur, one after another. */
.review .rise {
  animation: rv-rise 0.8s var(--glide) both;
  animation-delay: calc(var(--i, 0) * 110ms + 250ms);
}

/* The opening: a red cover with a tooled double frame, stamped with the
   year; the flyleaf over it swings open from its hinge. */
.review .opening {
  perspective: 1600px;
  font: 500 8cqw/1.1 var(--serif);
  font-variation-settings: 'SOFT' 100;
}
.review .opening::before {
  content: '';
  position: absolute;
  inset: calc(env(safe-area-inset-top) + 72px) 4.5cqw calc(env(safe-area-inset-bottom) + 18px);
  border: 1.5px solid var(--gold);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 6px transparent,
    inset 0 0 0 7px #e2c06e8c;
}
.review .opening h1 {
  margin: 1cqw 0 2cqw;
  font-size: 38cqw;
}
.review .opening .rise {
  animation-delay: calc(var(--i) * 160ms + 1.3s);
}
.review .opening .foil.rise {
  animation-delay: calc(var(--i) * 160ms + 1.3s), 2s;
}
.review .opening .tilde {
  width: 34cqw;
  height: auto;
  margin: 8cqw 0 -2cqw;
  animation: rv-rise 0.9s var(--spring) 1.9s both;
}
/* The publisher's mark at the foot of the cover. */
.review .imprint {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 34px);
  color: var(--gold);
  font: 600 12px var(--sans);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.review .flyleaf {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    radial-gradient(ellipse at 70% 40%, #ffffff30, transparent 60%),
    linear-gradient(90deg, #0000001a, transparent 6%), #efe5d1;
  color: #5a4a3a;
  transform: rotateY(-180deg);
  transform-origin: left center;
  backface-visibility: hidden;
  animation: rv-open 1.2s cubic-bezier(0.55, 0, 0.25, 1) 0.45s both;
}
.review .flyleaf strong {
  font: 600 13cqw/1 var(--serif);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1;
  color: #7d2f2b;
}
.review .flyleaf span {
  font: 600 12px var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* The count: the numbers above a pile of the books, falling into place. */
.review .tally {
  justify-content: flex-start;
  padding-top: calc(env(safe-area-inset-top) + 13cqh);
}
.review .tally .huge {
  color: var(--accent);
}
.review .tally .line {
  margin-top: 6cqw;
}
.review .heap {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  width: 100%;
  margin-top: auto;
}
.review .lying {
  display: block;
  width: var(--w);
  height: var(--h);
  margin-left: var(--x);
  padding: 0 20px;
  overflow: hidden;
  border-radius: 3px;
  background:
    linear-gradient(
      90deg,
      transparent 8px,
      #e2c06ecc 8px 10px,
      transparent 10px calc(100% - 10px),
      #e2c06ecc calc(100% - 10px) calc(100% - 8px),
      transparent calc(100% - 8px)
    ),
    linear-gradient(#ffffff2e, transparent 45%, #0000003d), var(--cloth);
  box-shadow: 0 1px 1px #00000040;
  color: #f6eeddd9;
  font: 600 9px / var(--h) var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform: rotate(var(--r));
  animation: rv-fall 0.7s cubic-bezier(0.5, 0, 0.6, 1.25) both;
  animation-delay: calc(var(--i) * 130ms + 1s);
}

/* Months: a bookcase, a slot a month, the best one with a ribbon. */
.review .case {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7cqw 3cqw;
  width: 100%;
  margin-top: 9cqw;
}
.review .ledge {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 17cqw;
  padding: 0 4px;
  padding-bottom: 10px; /* the plank and its shadow */
  background:
    linear-gradient(#8a5a33, #6b4426) 0 calc(100% - 4px) / 100% 6px no-repeat,
    linear-gradient(#00000026, transparent) 0 100% / 100% 4px no-repeat;
}
.review .upright {
  flex: 0 1 11px;
  min-width: 3px;
  height: var(--h);
  border-radius: 2px 2px 0 0;
  background:
    linear-gradient(
      transparent 12%,
      #e2c06eb3 12% 15%,
      transparent 15% 82%,
      #e2c06eb3 82% 85%,
      transparent 85%
    ),
    linear-gradient(90deg, #ffffff2e, transparent 50%, #00000033), var(--cloth);
  transform-origin: bottom;
  animation: rv-shelve 0.55s var(--spring) both;
  animation-delay: calc(var(--m) * 70ms + var(--i) * 60ms + 0.7s);
}
.review .slot > span {
  display: block;
  margin-top: 7px;
  font: 600 11px var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.review .best > span {
  margin: 0 18%;
  padding: 3px 0 9px;
  background: var(--accent);
  color: var(--accent-ink);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  animation: rv-ribbon 0.6s var(--spring) 1.8s both;
  transform-origin: top;
}

/* Favourites: covers dealt into a fan; their stars glint now and then. */
.review .fan {
  position: relative;
  width: 100%;
  height: 56cqw;
  margin: 6cqw 0 14cqw;
}
.review .leaf {
  position: absolute;
  left: calc(50% - 15cqw);
  bottom: 0;
  width: 30cqw;
  height: 45cqw;
  transform: rotate(var(--a));
  transform-origin: 50% 180%;
  animation: rv-deal 0.8s var(--spring) both;
  animation-delay: calc(var(--i) * 130ms + 0.5s);
}
.review .jacket {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 10%;
  overflow: hidden;
  border-radius: 2px 5px 5px 2px;
  background: linear-gradient(90deg, #00000033, transparent 8%), var(--cloth);
  box-shadow:
    0 12px 28px #00000073,
    inset 0 0 0 1px #ffffff1a;
  color: var(--cream);
  font: 600 3.4cqw/1.15 var(--serif);
}
.review .jacket img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.review .picks {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 0;
  list-style: none;
  text-align: left;
}
.review .picks li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font: 500 16px/1.3 var(--serif);
}
.review .picks li > span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.review .glint {
  flex: none;
  width: 5.5em;
  font-size: 13px;
  letter-spacing: 0.1em;
  background: linear-gradient(110deg, #e0a92a 40%, #fff6d0 50%, #e0a92a 60%) 100% 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rv-glint 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 200ms);
}

/* Records: library catalogue cards, ruled, with a red line at the head. */
.review .records h2 {
  margin-bottom: 6cqw;
}
.review .slips {
  display: grid;
  gap: 16px;
  width: 100%;
  padding: 0;
  list-style: none;
  text-align: left;
}
.review .slip {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-top: 3px solid var(--accent);
  border-radius: 3px;
  background:
    repeating-linear-gradient(transparent 0 23px, #4a78b522 23px 24px) 0 10px,
    var(--card);
  box-shadow: var(--shadow);
  animation: rv-slip 0.75s var(--spring) both;
  animation-delay: calc(var(--i) * 180ms + 0.6s);
}
.review .slip .jacket {
  flex: none;
  width: 52px;
  height: 78px;
  padding: 5px;
  font-size: 8px;
}
.review .slip div {
  min-width: 0;
}
.review .slip .kicker {
  display: block;
  margin: 0 0 4px;
  font-size: 10px;
}
.review .slip strong {
  display: block;
  font: 600 7.6cqw/1.05 var(--serif);
  font-variation-settings: 'SOFT' 100;
}
.review .slip .about {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Pace: the year as a thread, a gold bead lit for each book as the
   thread runs past it. */
.review .thread {
  position: relative;
  width: 100%;
  height: 30px;
  margin-top: 10cqw;
}
.review .thread::before {
  content: '';
  position: absolute;
  inset: 14px 0 auto;
  height: 2px;
  background: #f6eedd59;
  transform-origin: left;
  animation: rv-draw 1.8s var(--glide) 0.9s both;
}
.review .thread i {
  position: absolute;
  top: 9px;
  left: calc(var(--x) * 100% - 6px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6d0, #e2c06e 45%, #9a7425);
  box-shadow: 0 0 10px #f4dc9480;
  animation: rv-bead 0.5s var(--spring) both;
  animation-delay: calc(var(--x) * 1.8s + 0.9s);
}
.review .axis {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 7cqw;
  font: 600 10px var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.6;
}

/* The close: the seal stamped onto the cloth, Tilde beside it. */
.review .medal {
  position: relative;
  width: 60cqw;
  margin-bottom: 14cqw;
}
.review .seal {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 10px 18px #00000080);
  animation: rv-stamp 0.8s var(--spring) 0.3s both;
}
.review .seal .ring {
  font: 600 10.5px var(--sans);
  fill: #6b4c14;
}
.review .seal .stamp {
  font: 600 40px var(--serif);
  font-variation-settings:
    'SOFT' 100,
    'WONK' 1;
  fill: #5d4010;
}
.review .medal .tilde {
  position: absolute;
  right: -17cqw;
  bottom: -8cqw;
  width: 30cqw;
  height: auto;
  margin: 0;
  animation: rv-rise 0.9s var(--spring) 1s both;
}
.review .closing h2 {
  font-size: 12cqw;
}
.review .share {
  margin-top: 9cqw;
  min-height: 52px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: #2a241d;
  font-weight: 650;
  box-shadow: 0 8px 24px #00000059;
}

@keyframes rv-fade {
  from {
    opacity: 0;
  }
}
@keyframes rv-lift {
  from {
    transform: translateY(24px) scale(0.97);
  }
}
@keyframes rv-dwell {
  from {
    transform: scaleX(0);
  }
}
@keyframes rv-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(6px);
  }
}
@keyframes rv-shine {
  from {
    background-position: 100% 0;
  }
}
@keyframes rv-open {
  from {
    transform: rotateY(0);
  }
}
@keyframes rv-fall {
  from {
    transform: translateY(-110cqh) rotate(calc(var(--r) * -6));
  }
}
@keyframes rv-shelve {
  from {
    opacity: 0;
    transform: translateY(-30px) scaleY(0.6);
  }
}
@keyframes rv-ribbon {
  from {
    transform: scaleY(0);
  }
}
@keyframes rv-deal {
  from {
    opacity: 0;
    transform: translateY(70cqh) rotate(0);
  }
}
@keyframes rv-glint {
  0%,
  60% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}
@keyframes rv-slip {
  from {
    opacity: 0;
    transform: translateY(60px) rotate(var(--r));
  }
}
@keyframes rv-draw {
  from {
    transform: scaleX(0);
  }
}
@keyframes rv-bead {
  from {
    opacity: 0;
    transform: scale(0);
  }
}
@keyframes rv-stamp {
  from {
    opacity: 0;
    transform: scale(1.8) rotate(-25deg);
  }
}
