/* Modelos do cartão (cards/designs.js): faces, foto, legenda e verso, no viewer e nas miniaturas do
   seletor do creator. Cada modelo só troca tokens; a posição da foto e da legenda vem do JS (--p*, --c*),
   em unidades do quadro 300x400, e o texto usa cqw para a miniatura ser o cartão em escala. */

.card-design {
  container-type: inline-size;
  --paper: #fffaf3;
  --card-ink: #3b2a3f;
  --card-muted: #7a6680;
  --card-accent: #b45309;
  --title-font: var(--script);
  --title-weight: 600;
  --title-size: 11.5cqw;
  --title-case: none;
  --title-spacing: 0;
  --title-bg: linear-gradient(90deg, #f472b6, #a855f7 55%, #38bdf8);
  --name-font: var(--display);
  --name-size: 4.4cqw;
  --name-color: var(--card-muted);
  --name-case: uppercase;
  --name-spacing: 0.14em;
  --name-style: normal;
  --name-weight: 600;
  --photo-radius: 12px;
  --photo-ring: 0 0 0 1px rgb(212 162 76 / 0.45), 0 10px 22px rgb(59 42 63 / 0.16);
  --back-inset: 9% 8%;
  --back-title-size: 12.5cqw;
}

.card-design .face {
  position: absolute; inset: 0; border-radius: 22px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--paper); box-shadow: 0 30px 70px rgb(0 0 0 / 0.45);
}
.card-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.card-art.over { z-index: 2; }

.card-photo {
  position: absolute; z-index: 1; overflow: hidden;
  left: calc(var(--px) * 100% / 300); top: calc(var(--py) * 100% / 400);
  width: calc(var(--pw) * 100% / 300); height: calc(var(--ph) * 100% / 400);
  border-radius: var(--photo-radius); box-shadow: var(--photo-ring); background: #efe6ee;
}
.card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-photo-missing { height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 20px; color: #8b7a8c; font-size: 0.92rem; text-align: center; }
.card-photo-missing .icon { width: 2em; height: 2em; }
/* Miniatura do seletor: silhueta no lugar da foto. */
.card-photo.placeholder { background: linear-gradient(165deg, #f3e8ff, #fce7f3); }
.card-photo.placeholder::before, .card-photo.placeholder::after { content: ""; position: absolute; left: 50%; translate: -50% 0; background: #dcc6ea; }
.card-photo.placeholder::before { top: 26%; width: 30%; aspect-ratio: 1; border-radius: 50%; }
.card-photo.placeholder::after { top: 62%; width: 62%; height: 60%; border-radius: 50% 50% 0 0; }

.card-caption {
  position: absolute; z-index: 1;
  left: calc(var(--cx) * 100% / 300); top: calc(var(--cy) * 100% / 400);
  width: calc(var(--cw) * 100% / 300); height: calc(var(--ch) * 100% / 400);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1cqw;
  text-align: center; min-width: 0;
}
.cap-title, .card-design .face.back .message-title .script {
  font-family: var(--title-font); font-weight: var(--title-weight);
  text-transform: var(--title-case); letter-spacing: var(--title-spacing);
  background: var(--title-bg); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cap-title { margin: 0; font-size: 2rem; font-size: var(--title-size); line-height: 1.12; padding: 0 0.08em 0.06em; }
.cap-name {
  margin: 0; max-width: 100%; font-size: 0.9rem; font-size: var(--name-size); line-height: 1.2;
  font-family: var(--name-font); font-weight: var(--name-weight); font-style: var(--name-style);
  color: var(--name-color); text-transform: var(--name-case); letter-spacing: var(--name-spacing);
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Premium sem foto: o texto ocupa o centro do cartão. */
.no-photo .cap-title { font-size: calc(var(--title-size) * 1.3); }
.no-photo .cap-name { font-size: calc(var(--name-size) * 1.4); margin-top: 2cqw; }

/* Verso: os tokens do modelo viram os do conteúdo (mensagem, voz, assinatura). */
.card-design .face.back {
  --ink: var(--card-ink); --muted: var(--card-muted); --gold: var(--card-accent);
  --line: color-mix(in srgb, var(--card-ink) 14%, transparent);
  --soft: color-mix(in srgb, var(--card-ink) 6%, transparent);
  color: var(--ink); transform: rotateY(180deg);
}
.back-content {
  position: absolute; inset: var(--back-inset); z-index: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; justify-content: safe center;
  /* Se ainda rolar (render.js encolhe antes), barra fina na cor do cartão em vez da do sistema. */
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--card-accent) 55%, transparent) transparent;
}
.back-content::-webkit-scrollbar { width: 4px; }
.back-content::-webkit-scrollbar-thumb { border-radius: 2px; background: color-mix(in srgb, var(--card-accent) 55%, transparent); }
.back-content::-webkit-scrollbar-track { background: transparent; }
.back-fit { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.back-content .message-title { margin-top: 8px; }
/* O tamanho segue o cartão (cqw), não a tela: no desktop o cartão é estreito e o vw estouraria. */
.back-content .message-title .script { font-size: 2.6rem; font-size: var(--back-title-size); }
.back-content .message-name { font-size: 1.7rem; font-size: 8cqw; }
.back-content .message-text { max-height: none; overflow: visible; font-size: 1rem; margin: 6px 0 10px; }
.back-content .message-signature { margin: 0; }

/* ---------- modelos ---------- */
.card-floral {
  --paper: #fffdf8; --card-ink: #4a2f28; --card-muted: #8a6a5a; --card-accent: #9a6b4f;
  --title-bg: linear-gradient(#4a2f28, #4a2f28);
  --name-font: var(--serif); --name-style: italic; --name-case: none; --name-spacing: 0; --name-size: 6cqw;
  --photo-radius: 50% 50% 12px 12px / 34% 34% 12px 12px;
  --photo-ring: 0 0 0 4px #fffdf8, 0 0 0 5px rgb(125 143 115 / 0.5);
  --back-inset: 13% 11%;
}
.card-baloes {
  --paper: #ffffff; --card-ink: #26232b; --card-muted: #6b6470; --card-accent: #b8901f;
  --title-font: var(--display); --title-weight: 700; --title-size: 7cqw; --title-case: uppercase; --title-spacing: 0.04em;
  --title-bg: linear-gradient(#1f1d24, #1f1d24); --back-title-size: 7.6cqw;
  --name-font: var(--script); --name-size: 9cqw; --name-color: #c9a227; --name-case: none; --name-spacing: 0;
  --photo-radius: 18px; --photo-ring: 0 10px 24px rgb(38 35 43 / 0.14);
  --back-inset: 9% 16% 8% 8%;
}
.card-velas {
  --paper: #fff8ef; --card-ink: #2d2a32; --card-muted: #6d6474; --card-accent: #d9468a;
  --title-bg: linear-gradient(#2d2a32, #2d2a32);
  --name-color: #d9468a;
  --photo-radius: 6px; --photo-ring: 0 0 0 5px #ffffff, 0 10px 22px rgb(45 42 50 / 0.18);
  --back-inset: 20% 9% 8%;
}
.card-confete {
  --paper: #ffffff; --card-ink: #2b2b33; --card-muted: #5f5f6b; --card-accent: #ab47bc;
  --title-font: var(--display); --title-weight: 800; --title-size: 7.4cqw; --title-case: uppercase; --title-spacing: 0.03em; --back-title-size: 7.6cqw;
  --photo-radius: 20px; --photo-ring: 0 0 0 5px #ffffff, 0 10px 24px rgb(43 43 51 / 0.16);
  --back-inset: 10% 9%;
}
/* Uma cor por letra, como letras recortadas; o verso usa o gradiente para não pintar letra a letra. */
.card-confete .cap-title { background: none; color: #2b2b33; }
.card-confete .cap-title span:nth-child(6n + 1) { color: #ef5350; }
.card-confete .cap-title span:nth-child(6n + 2) { color: #42a5f5; }
.card-confete .cap-title span:nth-child(6n + 3) { color: #66bb6a; }
.card-confete .cap-title span:nth-child(6n + 4) { color: #f9a825; }
.card-confete .cap-title span:nth-child(6n + 5) { color: #ab47bc; }
.card-confete .cap-title span:nth-child(6n) { color: #26c6da; }
.card-confete .face.back { --title-bg: linear-gradient(90deg, #ef5350, #f9a825, #66bb6a, #42a5f5, #ab47bc); }
.card-gala {
  --paper: radial-gradient(120% 80% at 50% 0%, #1b2a4a, #0d1526); --card-ink: #f5ecd7; --card-muted: #c9bfa6; --card-accent: #d9b65d;
  --title-font: var(--serif); --title-size: 10cqw; --back-title-size: 11cqw;
  --title-bg: linear-gradient(90deg, #b8923a, #f3e2a9 50%, #b8923a);
  --name-color: #e9dcc0; --name-spacing: 0.24em; --name-size: 4cqw;
  --photo-radius: 50%; --photo-ring: 0 0 0 2px #d9b65d, 0 0 0 6px #111b30, 0 0 0 7px rgb(217 182 93 / 0.6);
  --back-inset: 13% 12%;
}
.card-gala .face.back .voice-note { --accent: #d9b65d; }

/* ---------- seletor de modelos (creator) ---------- */
.card-grid { grid-auto-columns: calc((100% - 30px) / 4); }
@media (max-width: 440px) { .card-grid { grid-auto-columns: calc((100% - 20px) / 3); } }
.field .card-option {
  position: relative; scroll-snap-align: start; display: grid; gap: 8px; cursor: pointer; padding: 6px 6px 8px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--soft); text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.card-option:active { transform: scale(0.98); }
.card-option input { position: absolute; opacity: 0; pointer-events: none; }
.card-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent), 0 10px 30px color-mix(in srgb, var(--accent) 25%, transparent);
}
.card-option:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }
.card-thumb { position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; }
.card-thumb .face { border-radius: inherit; box-shadow: none; }
