@import url("https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=ZCOOL+XiaoWei&family=Noto+Sans+SC:wght@400;500&display=swap");

:root {
  --ink: #2a2a2e;
  --paper: #fbf8f2;
  --paper-deep: #f3eee4;
  --muted: #7a7368;
  --accent: #4aa3e0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 18% 8%, rgba(255, 214, 170, 0.38), transparent 55%),
    radial-gradient(ellipse 70% 45% at 88% 18%, rgba(168, 210, 255, 0.36), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(255, 190, 210, 0.26), transparent 55%),
    linear-gradient(160deg, #efe8dc 0%, #e7f0f5 45%, #f0e6ef 100%);
  background-attachment: fixed;
}

.card-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  gap: 1.15rem;
}

.postcard {
  position: relative;
  width: min(92vw, 560px);
  aspect-ratio: 16 / 10;
  background: linear-gradient(145deg, #fffcf7 0%, var(--paper) 55%, var(--paper-deep) 100%);
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 18px 40px rgba(70, 55, 40, 0.16),
    0 2px 6px rgba(70, 55, 40, 0.08);
  overflow: hidden;
  animation: card-in 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.postcard::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 3px;
  pointer-events: none;
  opacity: 0.55;
  z-index: 2;
  animation: border-glow 4.5s ease-in-out infinite;
}

.paper-grain {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    -12deg,
    transparent,
    transparent 11px,
    rgba(180, 160, 130, 0.035) 11px,
    rgba(180, 160, 130, 0.035) 12px
  );
}

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 4;
  opacity: 0;
  animation: fade-corner 1.2s 0.4s ease forwards;
}

.corner-tl {
  top: 14px;
  left: 14px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}

.corner-br {
  right: 14px;
  bottom: 14px;
  border-bottom: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}

/* layout variants */
.layout-classic .to-line {
  letter-spacing: 0.08em;
}

.layout-classic .wish-col span {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.layout-wide {
  aspect-ratio: 17 / 10;
}

.layout-wide .wish-cols {
  gap: clamp(1.4rem, 4vw, 2.2rem);
  left: 7%;
}

.layout-wide::before {
  border-width: 2px;
}

.layout-cozy {
  aspect-ratio: 5 / 3.35;
  border-radius: 10px;
}

.layout-cozy::before {
  inset: 12px;
  border-radius: 6px;
  border-style: dashed;
}

.layout-cozy .wish-cols {
  left: 9%;
  top: 28%;
}

.layout-cozy .to-line {
  top: 9%;
  left: 8%;
}

.layout-tilt {
  animation: card-in-tilt 1.05s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.layout-tilt .to-line {
  transform: rotate(-1.2deg);
  transform-origin: left center;
}

.layout-tilt .wish-cols {
  transform: rotate(-0.6deg);
  transform-origin: left top;
}

.to-line {
  position: absolute;
  top: 8%;
  left: 7%;
  z-index: 3;
  font-family: "Ma Shan Zheng", cursive;
  font-size: clamp(1.35rem, 4.2vw, 1.9rem);
  letter-spacing: 0.04em;
  animation: rise 0.85s 0.12s ease both;
}

.wish-cols {
  position: absolute;
  left: 8%;
  top: 26%;
  bottom: 14%;
  display: flex;
  gap: clamp(1.1rem, 3.5vw, 1.8rem);
  z-index: 3;
}

.wish-col {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
}

.wish-col span {
  display: block;
  font-family: "Ma Shan Zheng", cursive;
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  line-height: 1.15;
  opacity: 0;
  animation: char-in 0.55s ease forwards;
}

.doodles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.doodles svg {
  position: absolute;
  overflow: visible;
}

.wish-note {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-family: "ZCOOL XiaoWei", serif;
  font-size: clamp(0.82rem, 2.4vw, 0.95rem);
  line-height: 1.65;
  max-width: min(92vw, 28rem);
  animation: rise 0.9s 0.55s ease both;
}

.postcard::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 40%,
    rgba(255, 255, 255, 0.28) 48%,
    transparent 56%
  );
  background-size: 220% 100%;
  animation: sheen 5.5s ease-in-out infinite;
  mix-blend-mode: soft-light;
}

/* doodle motions */
.doodle-float {
  animation: float 5.5s ease-in-out infinite;
}
.doodle-float-slow {
  animation: float 7.8s ease-in-out infinite reverse;
}
.doodle-twinkle {
  animation: twinkle 3.2s ease-in-out infinite;
}
.doodle-drift {
  animation: drift 9s ease-in-out infinite;
}
.doodle-pulse {
  animation: pulse 3.6s ease-in-out infinite;
}
.doodle-spin-slow {
  animation: spin-slow 18s linear infinite;
}
.doodle-orbit {
  animation: orbit-wobble 6s ease-in-out infinite;
}
.doodle-draw {
  animation: draw-fade 4.5s ease-in-out infinite;
}
.doodle-burst {
  animation: burst 3.8s ease-in-out infinite;
}
.doodle-bob {
  animation: bob 4.2s ease-in-out infinite;
}
.doodle-grow {
  animation: grow-sway 5s ease-in-out infinite;
}
.doodle-sway {
  animation: sway 4.8s ease-in-out infinite;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-corner {
  to {
    opacity: 0.55;
  }
}

@keyframes char-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px) rotate(-0.5deg) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
  }
}

@keyframes card-in-tilt {
  from {
    opacity: 0;
    transform: translateY(18px) rotate(-2.2deg) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(-1deg) scale(1);
  }
}

@keyframes border-glow {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-6px, -5px);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes spin-slow {
  to {
    transform: rotate(360deg);
  }
}

@keyframes orbit-wobble {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(8deg);
  }
}

@keyframes draw-fade {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@keyframes burst {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(1deg);
  }
}

@keyframes grow-sway {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-4px) rotate(-2deg);
  }
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-3deg) translateY(0);
  }
  50% {
    transform: rotate(3deg) translateY(-4px);
  }
}

@keyframes sheen {
  0%,
  100% {
    background-position: 120% 0;
  }
  50% {
    background-position: -20% 0;
  }
}

@media (max-width: 520px) {
  .postcard,
  .layout-wide,
  .layout-cozy {
    aspect-ratio: 5 / 4;
  }

  .wish-cols {
    top: 24%;
    left: 6%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .wish-col span {
    opacity: 1;
  }
}

/* —— PDF / print: freeze animations, one postcard per page —— */
@media print {
  @page {
    size: 210mm 148mm;
    margin: 0;
  }

  html,
  body {
    background: #efe8dc !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .wish-col span {
    opacity: 1 !important;
  }

  .corner {
    opacity: 0.55 !important;
  }

  .postcard::after {
    display: none !important;
  }

  .card-page {
    min-height: 148mm;
    height: 148mm;
    padding: 8mm 10mm;
    gap: 6mm;
    box-sizing: border-box;
  }

  .postcard {
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    height: calc(148mm - 28mm);
    box-shadow: none;
  }

  .wish-note {
    max-width: 100%;
    font-size: 9pt;
  }
}

