/* What just came into the book (arrived.js): a card at the top saying how many and where, and on every new photo a
   gold ring and a small "Nieuw" sticker, in the book, the tray and Je foto's, fading once it has been seen. Gold, so it
   reads apart from the selection's ring and the agent's numbered orange ones. */
:root {
  --fresh: #f0b429;
  --fresh-ink: #3b2a00;
}

/* ---- the card, under the top bar, over the book, Je foto's and the ways alike */
.arrived {
  position: fixed;
  z-index: 60;
  top: calc(max(var(--top-bottom, 0px), var(--safe-top)) + 10px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 10px 10px 10px 14px;
  border-radius: 20px;
  background: rgb(255 253 249 / 0.96);
  box-shadow:
    0 0 0 1px rgb(36 34 31 / 0.06),
    0 18px 44px -16px rgb(40 30 20 / 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-family: var(--ui-font);
  opacity: 0;
  transform: translate(-50%, -18px) scale(0.96);
  transition:
    opacity 0.25s var(--ease),
    transform 0.5s cubic-bezier(0.34, 1.4, 0.5, 1);
}
.arrived[hidden] {
  display: none;
}
.arrived.is-in {
  opacity: 1;
  transform: translate(-50%, 0);
}
.arrived.is-leaving {
  transition-duration: 0.25s;
  transform: translate(-50%, -10px) scale(0.98);
}
/* the photos that came, a little fanned pile of polaroids landing one after the other */
.arrived-pile {
  position: relative;
  flex: none;
  width: 58px;
  height: 46px;
}
.arrived-pile img {
  position: absolute;
  top: 3px;
  left: 9px;
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 2.5px solid #fff;
  border-bottom-width: 7px;
  border-radius: 2px;
  box-shadow: 0 4px 10px -4px rgb(40 30 20 / 0.5);
  opacity: 0;
  transform: translateY(-16px) rotate(var(--tilt)) scale(1.15);
}
.arrived-pile img:nth-child(1) {
  --tilt: -11deg;
  left: 0;
}
.arrived-pile img:nth-child(2) {
  --tilt: 8deg;
  left: 17px;
}
.arrived-pile img:nth-child(3) {
  --tilt: -2deg;
}
.arrived.is-in .arrived-pile img {
  animation: arrived-land 0.5s cubic-bezier(0.34, 1.5, 0.5, 1) both;
}
.arrived.is-in .arrived-pile img:nth-child(2) {
  animation-delay: 0.12s;
}
.arrived.is-in .arrived-pile img:nth-child(3) {
  animation-delay: 0.24s;
}
@keyframes arrived-land {
  to {
    opacity: 1;
    transform: rotate(var(--tilt));
  }
}
/* a gold tick on the pile: it's done */
.arrived-pile::after {
  content: '';
  position: absolute;
  z-index: 1;
  right: -4px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fresh)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b2a00' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E")
    center / 13px no-repeat;
  box-shadow: 0 0 0 2.5px #fff;
  transform: scale(0);
}
.arrived.is-done .arrived-pile::after {
  animation: arrived-tick 0.4s 0.45s cubic-bezier(0.34, 1.8, 0.5, 1) both;
}
/* while a pick is read: no tick yet, the count beating softly */
.arrived.is-reading .arrived-line {
  font-variant-numeric: tabular-nums;
}
.arrived-show[hidden] {
  display: none;
}
@keyframes arrived-tick {
  to {
    transform: none;
  }
}
.arrived-words {
  display: grid;
  gap: 2px;
  min-width: 0;
  max-width: 34ch;
}
.arrived-title {
  font-size: 15px;
  font-weight: 650;
}
.arrived-line {
  color: var(--quiet);
  font-size: 13px;
  line-height: 1.35;
}
.arrived-show {
  flex: none;
  white-space: nowrap;
}
.arrived-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--quiet);
}
.arrived-close:hover {
  background: rgb(36 34 31 / 0.06);
  color: var(--text);
}
.arrived-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
/* a phone: the words take the room beside the pile, Laat zien under them */
@media (max-width: 599px) {
  .arrived {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px 12px;
    width: calc(100vw - 24px);
    padding: 12px 8px 12px 12px;
  }
  .arrived-words {
    max-width: none;
  }
  .arrived-close {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
  }
  .arrived-show {
    grid-column: 2;
    justify-self: start;
  }
}
/* while a pick is read and none is in yet: one blank polaroid, breathing */
.arrived-pile:empty::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 9px;
  width: 38px;
  height: 38px;
  box-sizing: border-box;
  border: 2.5px solid #fff;
  border-bottom-width: 7px;
  border-radius: 2px;
  background: linear-gradient(160deg, #cfe0dc, #e9d6bf);
  box-shadow: 0 4px 10px -4px rgb(40 30 20 / 0.5);
  rotate: -4deg;
  animation: arrived-wait 1.2s ease-in-out infinite;
}
@keyframes arrived-wait {
  50% {
    translate: 0 -4px;
    rotate: 3deg;
  }
}

/* ---- the marks: a gold ring round the photo, breathing twice as it comes, and a sticker on its corner */
.tb-photo.is-fresh + .tb-over::after,
.tb-tray .tb-photo.is-fresh::after {
  opacity: 1;
  transform: none;
  border-width: 4px;
  border-color: var(--fresh);
  box-shadow:
    0 0 0 3px rgb(255 255 255 / 0.9),
    0 0 22px 4px rgb(240 180 41 / 0.45);
  animation: fresh-breathe 1.4s ease-in-out 2;
}
@keyframes fresh-breathe {
  50% {
    box-shadow:
      0 0 0 3px rgb(255 255 255 / 0.9),
      0 0 34px 12px rgb(240 180 41 / 0.6);
  }
}
.tb-fresh,
.tl-fresh {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: var(--fresh);
  color: var(--fresh-ink);
  font: 700 13px/1 var(--ui-font);
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow:
    0 0 0 2px #fff,
    0 4px 10px -3px rgb(40 30 20 / 0.45);
  pointer-events: none;
  rotate: -5deg;
  animation: fresh-pop 0.45s cubic-bezier(0.34, 1.7, 0.5, 1) both;
}
.tb-fresh svg,
.tl-fresh::before {
  width: 12px;
  height: 12px;
  fill: currentColor;
}
/* the book's: the size it reads on screen at any zoom (dpimark.js --tb-mark), on the top left corner of what shows of
   the photo (its over-piece's trim, dpimark.js showOver) */
.tb-fresh {
  left: var(--tb-trim-left, 0px);
  top: var(--tb-trim-top, 0px);
  transform-origin: 0 0;
  scale: var(--tb-mark, 1);
  translate: -10px -12px;
}
.tb.is-overview .tb-fresh {
  translate: -6px -8px;
}
@keyframes fresh-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}
.tb-photo.is-fading + .tb-over::after,
.tb-tray .tb-photo.is-fading::after,
.tb-photo.is-fading .tb-fresh,
.tb-photo.is-fading + .tb-over .tb-fresh {
  opacity: 0;
  animation: none;
  transition: opacity 0.6s ease-out;
}

/* ---- Je foto's: the same ring and sticker on the card */
.tl-card.is-fresh {
  outline: 3px solid var(--fresh);
  outline-offset: 3px;
  box-shadow: 0 0 20px 4px rgb(240 180 41 / 0.45);
}
.tl-fresh {
  top: -9px;
  left: -8px;
}
.tl-fresh::before {
  content: '';
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

@media (prefers-reduced-motion: reduce) {
  .arrived,
  .arrived.is-in .arrived-pile img,
  .arrived.is-done .arrived-pile::after,
  .tb-photo.is-fresh + .tb-over::after,
  .tb-tray .tb-photo.is-fresh::after,
  .tb-fresh,
  .tl-fresh {
    animation-duration: 0.01s;
    transition-duration: 0.01s;
  }
}
