/* CANVA STYLE PHOTO POSTCARD ENGINE STYLE */

:root {
  --pc-width: 680px;
  --pc-height: 440px;
  --bg-gradient: radial-gradient(circle at center, #fce4ec 0%, #f8bbd0 100%);
  --paper-bg: #fffdfa;
  --text-color: #2c3e50;
  --border-color: #e0e0e0;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Mali', 'Itim', 'Prompt', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

/* THEMES */
body.theme-romantic_pastel {
  --bg-gradient: radial-gradient(circle at center, #fff0f5 0%, #ffd6e5 100%);
  --paper-bg: #ffffff;
}

body.theme-vintage_sepia {
  --bg-gradient: radial-gradient(circle at center, #f4e8d1 0%, #d7c4a3 100%);
  --paper-bg: #fbf5e6;
  --text-color: #4a3b32;
}

body.theme-sunset_glow {
  --bg-gradient: radial-gradient(circle at center, #ffe0b2 0%, #ffcc80 100%);
  --paper-bg: #fff8e1;
}

body.theme-modern_dark {
  --bg-gradient: radial-gradient(circle at center, #1f2833 0%, #0b0c10 100%);
  --paper-bg: #151c24;
  --text-color: #f0f0f0;
}

.cp-container {
  width: 100%;
  max-width: 800px;
  padding: 20px;
  text-align: center;
}

/* TOP HEADER */
.cp-header-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  padding: 6px 22px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #d63384;
  box-shadow: 0 4px 15px rgba(0,0,0,0.06);
  margin-bottom: 25px;
}

/* 3D POSTCARD FLIP STAGE */
.cp-postcard-stage {
  width: 100%;
  max-width: var(--pc-width);
  height: var(--pc-height);
  margin: 0 auto 30px;
  perspective: 1200px;
  position: relative;
}

.cp-postcard-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  border-radius: 16px;
}

.cp-postcard-card.flipped {
  transform: rotateY(180deg);
}

/* FRONT & BACK SIDES */
.cp-side {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  background: var(--paper-bg);
  box-sizing: border-box;
  overflow: hidden;
  border: 8px solid #ffffff;
}

/* FRONT SIDE LAYOUT */
.cp-side-front {
  padding: 15px;
  display: flex;
  flex-direction: column;
}

.cp-airmail-border {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 10px solid transparent;
  border-image: repeating-linear-gradient(135deg, #e74c3c, #e74c3c 15px, #ffffff 15px, #ffffff 30px, #3498db 30px, #3498db 45px, #ffffff 45px, #ffffff 60px) 15;
  pointer-events: none;
  z-index: 10;
}

.cp-front-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  flex: 1;
  height: 100%;
  align-items: center;
}

.cp-front-img {
  width: 100%;
  height: 100%;
  min-height: 240px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.cp-front-title-overlay {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 10px 28px;
  border-radius: 50px;
  font-family: 'Mali', 'Itim', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: #c71585;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  white-space: nowrap;
  z-index: 5;
}

/* BACK SIDE LAYOUT */
.cp-side-back {
  transform: rotateY(180deg);
  padding: 30px;
  display: flex;
  position: relative;
}

.cp-back-divide-line {
  position: absolute;
  top: 15%;
  bottom: 15%;
  left: 50%;
  width: 2px;
  background: dashed #ccc;
  border-left: 2px dashed #ccc;
}

/* LEFT HALF OF BACK: HANDWRITTEN LETTER */
.cp-back-left {
  width: 48%;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.cp-back-letter-header {
  font-family: 'Mali', 'Itim', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: #d63384;
  margin-bottom: 15px;
}

.cp-back-letter-body {
  font-size: 1.05rem;
  line-height: 1.7;
  white-space: pre-line;
  flex: 1;
}

.cp-back-letter-sender {
  text-align: right;
  font-weight: 600;
  margin-top: 15px;
}

/* RIGHT HALF OF BACK: STAMP & RECIPIENT ADDRESS */
.cp-back-right {
  width: 48%;
  margin-left: auto;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* STAMP TYPES */
.cp-stamp-wrap {
  width: 85px;
  height: 100px;
  border: 2px dashed #bbb;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  position: relative;
}

.cp-stamp-postmark {
  position: absolute;
  top: -15px;
  right: -25px;
  width: 80px;
  height: 80px;
  border: 2px solid #e74c3c;
  border-radius: 50%;
  color: #e74c3c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  transform: rotate(-15deg);
  opacity: 0.85;
  pointer-events: none;
}

.cp-address-lines {
  width: 100%;
  margin-top: auto;
  text-align: left;
}

.cp-address-line {
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  color: #555;
}

/* CONTROL BUTTONS */
.cp-control-bar {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.cp-btn-flip {
  background: linear-gradient(135deg, #ff477e, #c71585);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 14px 36px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(255, 71, 126, 0.4);
  transition: transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cp-btn-flip:hover {
  transform: scale(1.05);
}

.cp-music-btn {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff477e, #ff758c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(255,71,126,0.4);
  cursor: pointer;
  z-index: 999;
  border: none;
}

.cp-music-btn.playing i {
  animation: spin 3s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* RESPONSIVE POSTCARD ASPECT RATIO */
@media (max-width: 720px) {
  .cp-postcard-stage {
    height: 480px;
  }
  .cp-side-back {
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
  }
  .cp-back-divide-line { display: none; }
  .cp-back-left, .cp-back-right {
    width: 100%;
    padding: 0;
  }
  .cp-back-right { margin-top: 20px; }
  .cp-front-title-overlay { font-size: 1.3rem; padding: 6px 18px; }
}
