/* animations.css — letters sliding in, clippings dropping, the PUBLISHED stamp thump. */

/* Each screen fades in softly. */
.screen > * {
  animation: fade-in 0.35s ease both;
}

/* Envelopes slide onto the desk one after another (--i is set per letter). */
.envelope {
  animation: slide-in 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.15) backwards;
  animation-delay: calc(var(--i, 0) * 120ms + 80ms);
}

/* Clippings drop onto the page. */
.clipping {
  animation: drop-in 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.2) backwards;
  animation-delay: calc(var(--i, 0) * 140ms + 150ms);
}

/* The letter unfolds when opened. */
.letter-dialog[open] .letter-paper {
  animation: unfold 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.menu-dialog[open] .menu-paper,
.confirm-dialog[open] .confirm-paper {
  animation: fade-in 0.2s ease both;
}

/* The little "Answered" stamp lands with a thump. */
.envelope.is-answered .stamp--answered {
  animation: stamp-small 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.stamp--new {
  animation: stamp-small 0.45s 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

/* ── Publish overlay ───────────────────────────────────────────────────── */
.publish-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 12, 6, 0.7);
  animation: fade-in 0.25s ease both;
}
.publish-overlay.is-leaving {
  animation: fade-out 0.45s ease both;
}
.publish-sheet {
  position: relative;
  width: min(520px, 100%);
  padding: 28px 28px 36px;
  background: var(--paper) var(--paper-texture);
  box-shadow: var(--shadow-lift);
  animation: sheet-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.publish-overlay:not(.is-leaving) .publish-sheet {
  /* the whole sheet jolts when the stamp hits */
  animation:
    sheet-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1) both,
    jolt 0.25s 1.05s ease-out;
}
.publish-title {
  font-family: var(--font-headline);
  font-weight: 900;
  font-size: 2rem;
  border-bottom: 3px double var(--rule);
  margin-bottom: 12px;
}
.publish-list {
  list-style: none;
  display: grid;
  gap: 10px;
}
.publish-list li {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px dotted var(--ink-faint);
}
.publish-list strong {
  font-family: var(--font-headline);
}
.publish-list span {
  font-family: var(--font-type);
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.stamp--published {
  position: absolute;
  top: 46%;
  left: 50%;
  font-size: clamp(2rem, 9vw, 3.4rem);
  padding: 6px 22px;
  border-width: 6px;
  color: var(--stamp-red);
  transform: translate(-50%, -50%) rotate(-14deg);
  animation: stamp-thump 0.38s 0.8s cubic-bezier(0.4, 1.7, 0.5, 1) both;
}

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translate(-60px, -120px) rotate(-18deg);
  }
}
@keyframes drop-in {
  from {
    opacity: 0;
    transform: translateY(-24px) rotate(calc(var(--tilt, 0deg) * -3)) scale(1.04);
  }
}
@keyframes unfold {
  from {
    opacity: 0;
    transform: translateY(30px) scaleY(0.85) rotate(-1.5deg);
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(40px) rotate(2deg);
  }
}
@keyframes stamp-thump {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-14deg) scale(3.2);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-14deg) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-14deg) scale(1);
  }
}
@keyframes stamp-small {
  0% {
    opacity: 0;
    scale: 2.4;
  }
  100% {
    opacity: 1;
    scale: 1;
  }
}
@keyframes jolt {
  30% {
    transform: translate(2px, 3px) rotate(0.4deg);
  }
  60% {
    transform: translate(-2px, -1px) rotate(-0.3deg);
  }
}
@keyframes bubble-up {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  15% {
    opacity: 1;
    transform: translateY(-6px);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-22px);
  }
}
@keyframes pulse {
  50% {
    transform: scale(1.06);
  }
}
.meter.pulse .meter-track {
  animation: pulse 0.5s ease 2;
}
@keyframes blink {
  to {
    visibility: hidden;
  }
}

/* Respect people who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
