/* ==========================================================================
   4:5 Vertical Editorial & Vintage Air-Mail Postcard System (Front + Back 3D Flip)
   Shared between Buyer DIY Studio (studio.html) & Recipient Unboxing (index.html)
   ========================================================================== */

.pc-scene {
  width: 100%;
  max-width: 336px;
  aspect-ratio: 4 / 5;
  perspective: 1600px;
  position: relative;
  margin: 0 auto;
  user-select: none;
}

.pc-flipper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 780ms cubic-bezier(0.32, 0.72, 0, 1);
}

.pc-flipper.is-back {
  transform: rotateY(180deg);
}

.pc-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow:
    0 24px 56px rgba(0, 0, 0, 0.52),
    0 0 0 1px rgba(255, 255, 255, 0.22);
  background: #faf6ee;
  color: #2b221c;
}

.pc-back {
  transform: rotateY(180deg);
}

/* Subtle fine paper grain across all postcards */
.pc-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Photo filters */
.pc-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transform-origin: center center;
}
.pc-filter-film { filter: contrast(1.04) saturate(1.08) sepia(0.14) brightness(0.98); }
.pc-filter-frost { filter: contrast(1.03) saturate(0.92) hue-rotate(-6deg) brightness(1.03); }
.pc-filter-retro { filter: contrast(1.08) sepia(0.26) saturate(0.9) brightness(0.96); }

/* Editable photo pan cursor */
.pc-photo-slot.editable { cursor: grab; touch-action: none; }
.pc-photo-slot.editable:active { cursor: grabbing; }

/* ==========================================================================
   TEMPLATE 1: CHRISTMAS FILM MAGAZINE (圣诞胶片画报款 - Warm Ivory + Pine + Burgundy)
   ========================================================================== */
.pc-tpl-luminous .pc-front {
  background: linear-gradient(165deg, #fbf5e9 0%, #f3e8d4 100%);
  color: #1c3327;
}
.pc-tpl-luminous .lum-band {
  position: absolute;
  left: 0; right: 0; bottom: 54px;
  height: 58px;
  background: linear-gradient(90deg, #123325 0%, #1c4734 50%, #123325 100%);
  border-top: 1px solid rgba(212, 175, 106, 0.55);
  border-bottom: 1px solid rgba(212, 175, 106, 0.55);
  z-index: 1;
}
.pc-tpl-luminous .lum-photo-wrap {
  position: absolute;
  left: 22px; right: 18px; top: 22px; bottom: 58px;
  background: #fffdf8;
  padding: 7px 7px 24px;
  box-shadow: 0 12px 28px rgba(42, 24, 14, 0.22), 0 0 0 1px rgba(184, 139, 67, 0.24);
  transform: rotate(-1.6deg);
  z-index: 3;
}
.pc-tpl-luminous .lum-photo-inner {
  width: 100%; height: 100%;
  overflow: hidden;
  position: relative;
  background: #172a21;
}
/* 35mm film strip Sprockets in festive pine-burgundy */
.pc-tpl-luminous .lum-film-strip {
  position: absolute;
  left: 10px; bottom: 62px;
  width: 18px; height: 92px;
  background: #8a232b;
  z-index: 2;
  transform: rotate(-7deg);
  background-image: repeating-linear-gradient(to bottom, transparent 0 5px, #faf3e6 5px 10px, transparent 10px 14px);
  padding: 0 4px;
  background-clip: content-box;
}
/* Corner Christmas ticket tag */
.pc-tpl-luminous .lum-tag {
  position: absolute;
  top: 12px; right: 10px;
  z-index: 6;
  background: #8a232b;
  border: 1.2px solid #e7c582;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 9px;
  letter-spacing: 1.4px;
  color: #fff5de;
  transform: rotate(22deg);
  box-shadow: 0 4px 12px rgba(42, 10, 14, 0.28);
}
.pc-tpl-luminous .lum-script {
  position: absolute;
  right: 16px; bottom: 68px;
  z-index: 6;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 27px;
  line-height: 0.94;
  color: #fff6e0;
  text-shadow: 0 2px 14px rgba(18, 30, 22, 0.78);
  text-align: right;
  pointer-events: none;
}
.pc-tpl-luminous .lum-foot {
  position: absolute;
  left: 20px; right: 20px; bottom: 10px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  font-size: 8.5px;
  letter-spacing: 1.8px;
  color: #7c3034;
  border-top: 1px solid rgba(138, 35, 43, 0.22);
  padding-top: 6px;
}
.pc-tpl-luminous .lum-foot-kicker {
  white-space: nowrap;
  flex-shrink: 0;
}
.pc-tpl-luminous .lum-to-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  max-width: 56%;
  line-height: 1.15;
}
.pc-tpl-luminous .lum-to-kicker {
  font-size: 7.5px;
  letter-spacing: 2px;
  opacity: 0.72;
}
.pc-tpl-luminous .lum-to-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #1c3327;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ==========================================================================
   TEMPLATE 2: PINE ARCH WINDOW (雪松烫金拱窗款 - Deep Christmas Pine + Gold Arch)
   ========================================================================== */
.pc-tpl-arch .pc-front {
  background: radial-gradient(ellipse at 50% 30%, #1c4635 0%, #0e281d 68%, #071711 100%);
  color: #f6dca0;
}
.pc-tpl-arch .arch-frame {
  position: absolute;
  inset: 10px;
  border-radius: 9px;
  border: 1px solid rgba(246, 220, 160, 0.42);
  pointer-events: none;
  z-index: 4;
}
.pc-tpl-arch .arch-frame::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 0.5px dashed rgba(246, 220, 160, 0.24);
}
.pc-tpl-arch .arch-top-kicker {
  position: absolute;
  top: 18px; left: 0; right: 0;
  text-align: center;
  font-size: 9px;
  letter-spacing: 2.8px;
  color: rgba(246, 220, 160, 0.85);
  z-index: 5;
  pointer-events: none;
}
.pc-tpl-arch .arch-window-outer {
  position: absolute;
  left: 26px; right: 26px; top: 38px; bottom: 82px;
  border-radius: 145px 145px 8px 8px;
  padding: 6px;
  background: linear-gradient(180deg, #f5ead4, #e5d5b7);
  border: 1.5px solid rgba(246, 220, 160, 0.78);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(140, 102, 46, 0.28);
  z-index: 3;
}
.pc-tpl-arch .arch-photo-inner {
  width: 100%; height: 100%;
  border-radius: 138px 138px 4px 4px;
  overflow: hidden;
  position: relative;
  background: #10241c;
}
.pc-tpl-arch .arch-title-row {
  position: absolute;
  left: 22px; right: 22px; bottom: 44px;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 16.5px;
  letter-spacing: 1px;
  color: #fff4d6;
  z-index: 5;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pc-tpl-arch .arch-words {
  position: absolute;
  left: 22px; right: 22px; bottom: 18px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(246, 220, 160, 0.86);
  font-weight: 500;
  z-index: 5;
  border-top: 1px solid rgba(246, 220, 160, 0.24);
  padding-top: 7px;
}

/* ==========================================================================
   TEMPLATE 3: VINTAGE CHRISTMAS AIR MAIL (复古圣诞红绿航空斜纹款)
   ========================================================================== */
.pc-tpl-airmail .pc-face {
  background: #f5ede0;
  color: #38291e;
}
.pc-air-stripe {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  border-radius: 12px;
  padding: 8px;
  background: repeating-linear-gradient(
    -45deg,
    #942b29 0px, #942b29 10px,
    #f2e8d6 10px, #f2e8d6 18px,
    #1e4a38 18px, #1e4a38 28px,
    #f2e8d6 28px, #f2e8d6 36px
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.pc-tpl-airmail .air-front-inner {
  position: absolute;
  inset: 22px 20px 60px;
  background: #e8dcc6;
  padding: 8px;
  box-shadow: inset 0 0 0 1px rgba(92, 68, 44, 0.28);
}
.pc-tpl-airmail .air-photo-box {
  width: 100%; height: 100%;
  overflow: hidden;
  position: relative;
}
/* Vintage black photo mounting corners */
.pc-corner-tab {
  position: absolute;
  width: 16px; height: 16px;
  background: #3a2b20;
  z-index: 6;
  pointer-events: none;
}
.pc-corner-tab.tl { top: 4px; left: 4px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.pc-corner-tab.tr { top: 4px; right: 4px; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.pc-corner-tab.bl { bottom: 4px; left: 4px; clip-path: polygon(0 0, 0 100%, 100% 100%); }
.pc-corner-tab.br { bottom: 4px; right: 4px; clip-path: polygon(100% 0, 100% 100%, 0 100%); }

.pc-tpl-airmail .air-front-foot {
  position: absolute;
  left: 22px; right: 22px; bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, Georgia, serif;
  font-size: 11px;
  color: #5a4432;
}
.pc-tpl-airmail .air-to-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  max-width: 60%;
  line-height: 1.15;
}
.pc-tpl-airmail .air-to-kicker {
  font-size: 8.5px;
  letter-spacing: 1.8px;
  opacity: 0.72;
  white-space: nowrap;
}
.pc-tpl-airmail .air-to-name {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #38291e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pc-serial-box {
  border: 1px solid rgba(58, 43, 32, 0.55);
  padding: 3px 8px;
  font-size: 10px;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: ui-monospace, Courier, monospace;
}

/* ==========================================================================
   TEMPLATE 4: FRENCH VELVET ARCH (法式丝绒烫金拱窗款 - Luxury Christmas Editorial)
   ========================================================================== */
.pc-tpl-poetic .pc-front {
  background: radial-gradient(ellipse at 50% 35%, #4a1420 0%, #2b0912 68%, #1a050a 100%);
  color: #f6dca0;
}
.pc-tpl-poetic .vel-frame {
  position: absolute;
  inset: 10px;
  border-radius: 9px;
  border: 1px solid rgba(246, 220, 160, 0.42);
  pointer-events: none;
  z-index: 4;
}
.pc-tpl-poetic .vel-frame::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 0.5px dashed rgba(246, 220, 160, 0.24);
}
.pc-tpl-poetic .vel-top {
  position: absolute;
  top: 18px; left: 0; right: 0;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 3.5px;
  color: rgba(246, 220, 160, 0.85);
  z-index: 5;
  pointer-events: none;
}
.pc-tpl-poetic .vel-arch-outer {
  position: absolute;
  left: 30px; right: 30px; top: 38px; bottom: 92px;
  border-radius: 140px 140px 6px 6px;
  padding: 5px;
  border: 1.2px solid rgba(246, 220, 160, 0.65);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(246, 220, 160, 0.22);
  z-index: 3;
}
.pc-tpl-poetic .vel-arch-inner {
  width: 100%; height: 100%;
  border-radius: 134px 134px 4px 4px;
  overflow: hidden;
  position: relative;
  background: #140509;
}
.pc-tpl-poetic .vel-bottom {
  position: absolute;
  left: 20px; right: 20px; bottom: 16px;
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
.pc-tpl-poetic .vel-title {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #fff6db 0%, #f3cf80 55%, #c2913e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 3px;
}
.pc-tpl-poetic .vel-sub {
  font-size: 8px;
  letter-spacing: 2.5px;
  color: rgba(246, 220, 160, 0.65);
}
.pc-tpl-poetic .vel-sub-name {
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: 11.5px;
  letter-spacing: 1.5px;
  color: rgba(255, 244, 212, 0.92);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   SHARED POSTCARD BACK LAYOUT (Postal Code + Stamps + Wavy Postmark + Handwritten Message)
   ========================================================================== */
.pc-back-inner {
  position: absolute;
  inset: 0;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  z-index: 4;
}
.pc-tpl-airmail .pc-back-inner {
  padding: 22px 22px 20px;
}

.pc-back-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 84px;
  margin-bottom: 8px;
}

.pc-zip-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pc-zip-boxes {
  display: flex;
  gap: 4px;
}
.pc-zip-box {
  width: 16px;
  height: 20px;
  border: 1px solid rgba(85, 68, 52, 0.42);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #554434;
}

.pc-post-header {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #4a3b2e;
}

.pc-route-tag {
  font-size: 10px;
  color: #7c6755;
  letter-spacing: 0.8px;
}

/* Top-Right Dual Postage Stamp Area */
.pc-stamps-slot {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  position: relative;
  z-index: 5;
}

.pc-stamp-frame {
  width: 54px;
  height: 76px;
  border: 1px dashed rgba(120, 96, 72, 0.38);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(255, 255, 255, 0.35);
}
.pc-stamp-frame.filled {
  border: none;
  background: none;
}
.pc-stamp-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.18));
}

/* Wavy Postmark Rider Overlay (sits across stamp edge!) */
.pc-postmark-overlay {
  position: absolute;
  right: 18px;
  top: 28px;
  width: 112px;
  z-index: 9;
  pointer-events: none;
  opacity: 0.84;
  mix-blend-mode: multiply;
  transform-origin: center center;
  transition: transform 280ms cubic-bezier(0.34, 1.42, 0.64, 1), opacity 200ms ease;
}
.pc-postmark-overlay.editable {
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}
.pc-postmark-overlay img {
  width: 100%;
  height: auto;
  display: block;
}

/* Ink pad tint filters on the normalized espresso postmark */
.pm-ink-sepia   { filter: sepia(0.55) saturate(1.4) brightness(0.95); }
.pm-ink-black   { filter: grayscale(1) contrast(1.3) brightness(0.55); }
.pm-ink-crimson { filter: sepia(1) hue-rotate(312deg) saturate(3.4) brightness(0.82); }
.pm-ink-navy    { filter: sepia(1) hue-rotate(175deg) saturate(2.8) brightness(0.75); }

/* Back Message Body + Mini Arch Inset (on arch/poetic templates) */
.pc-back-body {
  flex: 1;
  display: flex;
  gap: 12px;
  position: relative;
  min-height: 0;
}

.pc-mini-arch {
  width: 84px;
  flex-shrink: 0;
  border-radius: 44px 44px 4px 4px;
  overflow: hidden;
  border: 1px solid rgba(120, 96, 72, 0.25);
  display: none;
}
.pc-tpl-arch .pc-mini-arch { display: block; }
.pc-tpl-poetic .pc-mini-arch {
  display: block;
  border-radius: 3px;
  width: 80px;
}

.pc-writing-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pc-salutation {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #2d221a;
}

.pc-lines-text {
  flex: 1;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 26px;
  letter-spacing: 0.5px;
  color: #33261d;
  white-space: pre-wrap;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 25px,
    rgba(135, 108, 78, 0.22) 25px,
    rgba(135, 108, 78, 0.22) 26px
  );
  background-attachment: local;
  scrollbar-width: thin;
}
.pc-lines-text::-webkit-scrollbar { width: 2px; }
.pc-lines-text::-webkit-scrollbar-thumb { background: rgba(135, 108, 78, 0.3); }

/* Handwriting-feel Chinese font options */
.pc-font-kai { font-family: "STKaiti", "KaiTi", "Kaiti SC", "FangSong", serif; font-size: 15px; }
.pc-font-serif { font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif; }
.pc-font-fang { font-family: "STFangsong", "FangSong", "Songti SC", serif; }

.pc-back-foot {
  margin-top: 8px;
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #5c4938;
}

/* ==========================================================================
   FREE-DRAG / ROTATE / SCALE STICKER LAYER
   ========================================================================== */
.pc-stickers-layer {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  overflow: hidden;
}

.pc-sticker-item {
  position: absolute;
  width: 76px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.pc-sticker-item.editable {
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.pc-sticker-item.editable.selected {
  outline: 1.5px dashed #d49b38;
  outline-offset: 4px;
  border-radius: 6px;
}
.pc-sticker-item img, .pc-sticker-item svg {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.2));
}

.stk-ctrl {
  display: none;
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1f1916;
  color: #fae3b4;
  border: 1px solid #fae3b4;
  font-size: 12px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}
.pc-sticker-item.editable.selected .stk-ctrl { display: flex; }
.stk-del { top: -12px; right: -12px; background: #9e2430; color: #fff; border-color: #fff; }
.stk-rot { bottom: -12px; right: -12px; cursor: nwse-resize; }
