:root {
  --ink: #2b2a33;
  --muted: #6b6878;
  --paper: #fbf5e6;
  --paper-edge: #e8dcc0;
  --accent: #b5452f;
  --sky-top: #9ccbe8;
  --sky-bottom: #f6e7d0;
  --radius: 14px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body.sky { background: linear-gradient(var(--sky-top), var(--sky-bottom)); }
body.desk { background: radial-gradient(circle at 50% 30%, #6e5a48, #3b2f26); }

.stage {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ── Card ───────────────────────────────────────────────── */
.card {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  box-shadow: 0 10px 30px rgba(40, 30, 20, 0.15);
  text-align: center;
}
.card h1 { font-size: 1.5rem; margin: 0 0 12px; font-weight: normal; }
.card p { line-height: 1.55; margin: 0 0 12px; }

.reveal { opacity: 0; transform: translateY(12px); transition: opacity .8s ease, transform .8s ease; }
.reveal.shown { opacity: 1; transform: none; }

.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--muted); }
.hint { color: var(--muted); font-style: italic; }

.btn {
  font: inherit;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  margin-top: 8px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: wait; }

form { display: flex; gap: 8px; margin-top: 16px; }
input[type="text"] {
  flex: 1;
  font: inherit;
  padding: 10px 14px;
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  background: #fff;
}
form .btn { margin-top: 0; }

.feedback { min-height: 1.5em; margin-top: 12px; color: var(--accent); }

.dots { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 8px; justify-content: center; }
.dots li { width: 10px; height: 10px; border-radius: 50%; background: var(--paper-edge); }
.dots li.done { background: var(--accent); }
.dots li.current { background: var(--ink); }

.shake { animation: shake .4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ── Pigeon ─────────────────────────────────────────────── */
.pigeon-slot { width: 220px; }
.pigeon-slot.small { width: 140px; }
.pigeon-slot svg { width: 100%; height: auto; overflow: visible; }

.pigeon .wing {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

/* Flying in from off-screen, wings flapping fast. */
.pigeon-slot.flying .pigeon { animation: fly-in 2.6s cubic-bezier(.2,.7,.3,1) forwards; }
.pigeon-slot.flying .wing { animation: flap .18s ease-in-out infinite alternate; }

/* Perched: gentle bob, occasional lazy wing twitch. */
.pigeon-slot.landed .pigeon { animation: bob 2.4s ease-in-out infinite; }
.pigeon-slot.landed .wing { animation: twitch 5s ease-in-out infinite; }
.pigeon-slot.landed .legs { opacity: 1; }
.pigeon .legs { opacity: 0; transition: opacity .3s; }

@keyframes fly-in {
  0%   { transform: translate(-120vw, -40px) rotate(-8deg); }
  70%  { transform: translate(10px, -10px) rotate(-4deg); }
  100% { transform: translate(0, 0) rotate(0); }
}
@keyframes flap {
  from { transform: scaleY(1); }
  to   { transform: scaleY(-0.6); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@keyframes twitch {
  0%, 90%, 100% { transform: scaleY(1); }
  94%           { transform: scaleY(0.7); }
}

/* ── Letter ─────────────────────────────────────────────── */
.loading { color: #f3e6c4; font-style: italic; }

.letter {
  width: 100%;
  background: var(--paper);
  padding: 48px 44px;
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
  line-height: 1.75;
  font-size: 1.08rem;
  transform-origin: top center;
  animation: unfold 1.1s cubic-bezier(.2,.8,.2,1);
}
.letter .salutation { margin-top: 0; }
.letter .signoff { margin-top: 32px; margin-bottom: 0; }
.letter .signature { font-style: italic; font-size: 1.3rem; margin-top: 4px; }

@keyframes unfold {
  from { transform: perspective(900px) rotateX(-75deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
