:root {
  --ink: #4a3b5c;
  --ink-soft: #6f5f80;
  --paper: #fff8ef;
  --pink: #ff9eb5;
  --peach: #ffc49b;
  --butter: #ffe08a;
  --mint: #a8e6c3;
  --sky: #a9d8f2;
  --lilac: #c9b6f2;
  --hand: "Gaegu", "Patrick Hand", "Comic Sans MS", cursive;
  --body: "Patrick Hand", "Gaegu", "Comic Sans MS", cursive;
  --head-w: clamp(118px, 15vw, 160px);
  /* beren-doodle is 509x600 */
  --head-h: calc(var(--head-w) * 600 / 509);
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 5vw, 3rem) 1.25rem;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  line-height: 1.4;
  background:
    radial-gradient(circle at 12% 18%, #ffe3ec 0, transparent 38%),
    radial-gradient(circle at 88% 82%, #dff1ff 0, transparent 40%),
    radial-gradient(circle at 85% 12%, #fff1c9 0, transparent 30%),
    radial-gradient(circle at 10% 90%, #e4f8ec 0, transparent 35%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Faint crayon-paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(rgba(74, 59, 92, 0.08) 1px, transparent 1.2px);
  background-size: 18px 18px;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Background doodles ---------- */

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.doodle {
  position: absolute;
  overflow: visible;
  filter: url(#wobble);
}

.moon {
  top: 5%;
  right: 7%;
  width: clamp(64px, 9vw, 120px);
  height: clamp(64px, 9vw, 120px);
  animation: rock 7s ease-in-out infinite;
  transform-origin: 50% 60%;
}

.cloud {
  width: clamp(110px, 16vw, 210px);
  height: clamp(64px, 9.3vw, 122px);
  animation: drift 14s ease-in-out infinite;
}
.cloud--1 { top: 8%; left: 6%; }
.cloud--2 { top: 30%; right: -2%; width: clamp(90px, 12vw, 160px); animation-duration: 18s; animation-delay: -4s; opacity: 0.9; }
.cloud--3 { bottom: 20%; left: -2%; width: clamp(90px, 11vw, 150px); animation-duration: 16s; animation-delay: -8s; opacity: 0.85; }
.cloud--4 { bottom: 7%; right: 10%; animation-duration: 20s; animation-delay: -2s; }

.star {
  width: clamp(26px, 3vw, 42px);
  height: clamp(26px, 3vw, 42px);
  animation: twinkle 3.2s ease-in-out infinite;
}
.star--1 { top: 22%; left: 22%; color: var(--butter); }
.star--2 { top: 12%; left: 46%; color: var(--pink); animation-delay: -1.1s; width: 24px; height: 24px; }
.star--3 { top: 20%; right: 22%; color: var(--lilac); animation-delay: -2s; }
.star--4 { bottom: 30%; right: 26%; color: var(--mint); animation-delay: -0.6s; }
.star--5 { bottom: 12%; left: 30%; color: var(--peach); animation-delay: -2.6s; }

.sparkle {
  width: 22px;
  height: 22px;
  animation: twinkle 2.6s ease-in-out infinite;
}
.sparkle--1 { top: 40%; left: 10%; color: var(--sky); animation-delay: -0.4s; }
.sparkle--2 { top: 6%; left: 30%; color: var(--mint); animation-delay: -1.4s; }
.sparkle--3 { bottom: 38%; right: 8%; color: var(--butter); animation-delay: -2.1s; }
.sparkle--4 { bottom: 5%; left: 52%; color: var(--pink); animation-delay: -0.9s; }

.heart {
  width: clamp(28px, 3vw, 40px);
  height: clamp(26px, 2.8vw, 37px);
  animation: bob 5s ease-in-out infinite;
}
.heart--1 { top: 52%; left: 5%; color: var(--pink); }
.heart--2 { top: 46%; right: 16%; color: #ffb3c6; animation-delay: -1.8s; }
.heart--3 { bottom: 24%; left: 18%; color: var(--peach); animation-delay: -3s; }

.swirl {
  width: 56px;
  height: 38px;
  opacity: 0.8;
}
.swirl--1 { top: 64%; right: 4%; color: var(--lilac); transform: rotate(-12deg); }
.swirl--2 { top: 32%; left: 15%; color: var(--sky); transform: rotate(160deg); }

.rattle {
  bottom: 30%;
  left: 7%;
  width: 46px;
  height: 62px;
  animation: rock 4s ease-in-out infinite;
  transform-origin: 50% 90%;
}

/* ---------- Card ---------- */

.card {
  position: relative;
  z-index: 1;
  width: min(100%, 40rem);
  padding: clamp(1.75rem, 5vw, 3.25rem) clamp(1.25rem, 5vw, 3.5rem);
  padding-top: calc(var(--head-h) / 2 + clamp(1rem, 3vw, 1.75rem));
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
  border: 3px solid var(--ink);
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
  box-shadow: 8px 10px 0 rgba(201, 182, 242, 0.55);
  backdrop-filter: blur(2px);
  animation: pop-in 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.hello {
  margin: 0;
  font-size: clamp(1.2rem, 1rem + 0.9vw, 1.6rem);
  color: var(--ink-soft);
  transform: rotate(-2deg);
}

/* Sits outside the card and overlaps its top edge */
.baby {
  position: relative;
  z-index: 100;
  isolation: isolate;
  display: block;
  flex: none;
  width: var(--head-w);
  margin: 0 auto calc(var(--head-h) / -2);
}

.baby img {
  display: block;
  width: var(--head-w);
  max-width: 100%;
  height: auto;
  -webkit-transform-origin: 50% 100%;
  transform-origin: 50% 100%;
  will-change: transform;
  -webkit-animation: sway 4s ease-in-out infinite alternate;
  animation: sway 4s ease-in-out infinite alternate;
}

.name {
  margin: 0.1em 0 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(4.5rem, 3rem + 10vw, 9.5rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
}

.letters {
  display: inline-flex;
  gap: 0.02em;
}

.letters span {
  display: inline-block;
  text-shadow:
    3px 3px 0 var(--ink),
    -1px -1px 0 var(--ink),
    1px -1px 0 var(--ink),
    -1px 1px 0 var(--ink);
  animation: wiggle 4s ease-in-out infinite;
}
.letters span:nth-child(1) { color: var(--pink);  --r: -6deg; animation-delay: 0s; }
.letters span:nth-child(2) { color: var(--peach); --r: 4deg;  animation-delay: -0.8s; }
.letters span:nth-child(3) { color: var(--butter); --r: -3deg; animation-delay: -1.6s; }
.letters span:nth-child(4) { color: var(--mint);  --r: 5deg;  animation-delay: -2.4s; }
.letters span:nth-child(5) { color: var(--sky);   --r: -4deg; animation-delay: -3.2s; }

.underline {
  display: block;
  width: min(80%, 20rem);
  height: 1.5rem;
  margin: 0.15rem auto 0;
  color: var(--lilac);
  overflow: visible;
  filter: url(#wobble);
}

.tagline {
  margin: 1rem 0 1.5rem;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem);
  line-height: 1.15;
  text-wrap: balance;
}

.sign {
  position: relative;
  display: inline-block;
  margin: 0.25rem auto 1.5rem;
  padding: 0.85rem 1.6rem 0.75rem;
  background: #fff3c4;
  border: 2.5px dashed var(--ink);
  border-radius: 14px 6px 16px 8px;
  transform: rotate(-2.5deg);
  box-shadow: 4px 5px 0 rgba(255, 158, 181, 0.45);
}

.sign p {
  margin: 0;
  font-size: clamp(1.4rem, 1.15rem + 1vw, 1.8rem);
  letter-spacing: 0.03em;
}

.sign .sign-sub {
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  letter-spacing: 0;
  color: var(--ink-soft);
}

.tape {
  position: absolute;
  top: -12px;
  width: 58px;
  height: 20px;
  opacity: 0.85;
  background: repeating-linear-gradient(
    45deg,
    var(--pink) 0 6px,
    #ffd6e0 6px 12px
  );
}
.tape--left { left: -16px; transform: rotate(-28deg); }
.tape--right {
  right: -16px;
  transform: rotate(24deg);
  background: repeating-linear-gradient(45deg, var(--mint) 0 6px, #dcf6e7 6px 12px);
}

.born {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: clamp(1.05rem, 1rem + 0.3vw, 1.25rem);
  color: var(--ink-soft);
}

.born-heart {
  width: 1.2em;
  height: 1.1em;
  color: var(--pink);
  overflow: visible;
  animation: beat 1.6s ease-in-out infinite;
}

.footer {
  position: relative;
  z-index: 1;
  margin-top: 1.5rem;
  font-family: var(--hand);
  font-size: 1.1rem;
  color: var(--ink-soft);
}
.footer p { margin: 0; }

/* ---------- Animations ---------- */

@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(24px, -10px); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(0.7) rotate(18deg); opacity: 0.55; }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-12px) rotate(6deg); }
}

@keyframes rock {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(var(--r)) translateY(0); }
  50% { transform: rotate(calc(var(--r) * -1)) translateY(-4px); }
}

@-webkit-keyframes sway {
  from { -webkit-transform: rotate(-6deg); transform: rotate(-6deg); }
  to { -webkit-transform: rotate(6deg); transform: rotate(6deg); }
}

@keyframes sway {
  from { -webkit-transform: rotate(-6deg); transform: rotate(-6deg); }
  to { -webkit-transform: rotate(6deg); transform: rotate(6deg); }
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.2); }
  30% { transform: scale(1); }
  45% { transform: scale(1.12); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92) rotate(-1deg); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .card {
    box-shadow: 5px 6px 0 rgba(201, 182, 242, 0.55);
  }
  .cloud--2, .cloud--3, .swirl, .heart--2, .star--4, .sparkle--3, .rattle {
    display: none;
  }
  .moon { top: 2%; right: 4%; }
  .cloud--1 { top: 2%; left: -4%; }
  .cloud--4 { bottom: 1%; right: -4%; }
  .star--1 { top: 13%; left: 6%; }
  .star--2 { top: 4%; left: 44%; }
  .star--3 { top: 14%; right: 6%; }
  .star--5 { bottom: 5%; left: 10%; }
  .heart--1 { top: auto; bottom: 12%; left: 4%; }
  .heart--3 { bottom: 3%; left: 40%; }
}

@media (max-height: 800px) {
  body { padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .card {
    padding-top: calc(var(--head-h) / 2 + 1rem);
    padding-bottom: 1.75rem;
  }
  .footer { margin-top: 0.75rem; }
}

@media (max-height: 560px) and (orientation: landscape) {
  body { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    -webkit-animation: none !important;
    animation: none !important;
    transition: none !important;
  }
}
