/* Biglietto da visita 85 × 55 mm (public/assets/js/card.js).
   Tutte le misure sono multipli di --u: 1 mm in stampa, 1/85 della larghezza nell'anteprima.
   --b è il margine al vivo in mm (3 nel PDF per la tipografia, 0 altrove): fondi e decorazioni arrivano al bordo,
   i testi restano nell'area sicura (.bc-in). */

/* ---------------------------------------------------------------- editor */

.card-editor { display: grid; gap: 28px; }
.card-editor-preview { display: grid; gap: 16px; align-content: start; }
.bc-stage { container-type: inline-size; width: 100%; max-width: 520px; margin: 0 auto; }
.bc-stage .bc { --u: calc(100cqw / 85); border-radius: calc(var(--u) * 1.6); box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 12px 32px -12px rgb(0 0 0 / .25); }
.card-editor-form fieldset { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.card-editor-form legend { font-family: var(--font-heading); font-size: 1.1rem; font-weight: 600; margin-bottom: 10px; }
.bc-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.bc-choice { position: relative; cursor: pointer; }
.bc-choice input { position: absolute; opacity: 0; }
.bc-choice span { display: grid; gap: 2px; height: 100%; padding: 10px 12px; border: 1.5px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); transition: border-color .15s, background .15s; }
.bc-choice small { color: var(--c-muted); font-size: .76rem; line-height: 1.3; }
.bc-choice-note { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-style: normal; font-size: .72rem; font-weight: 600; color: var(--c-primary); }
.bc-choice-note .icon { width: 12px; height: 12px; }
.bc-photo-hook { margin: 0 0 14px; }
.bc-sizes { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 8px; }
.bc-size { display: grid; grid-template-columns: 1fr 110px 42px; align-items: center; gap: 10px; font-size: .86rem; }
.bc-size input { width: 100%; accent-color: var(--c-primary); }
.bc-size output { font-variant-numeric: tabular-nums; color: var(--c-muted); text-align: right; font-size: .8rem; }
.bc-choice input:checked + span { border-color: var(--c-primary); background: var(--c-primary-soft); }
.bc-choice input:focus-visible + span, .bc-swatch input:focus-visible + span { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.bc-swatches { display: flex; flex-wrap: wrap; gap: 10px 12px; }
.bc-swatch { display: grid; justify-items: center; gap: 4px; cursor: pointer; position: relative; }
.bc-swatch input { position: absolute; opacity: 0; }
.bc-swatch span { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--s1) 55%, var(--s2) 55%); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); }
.bc-swatch input:checked + span { box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-primary); }
.bc-swatch small { font-size: .72rem; color: var(--c-muted); }
.bc-custom { align-items: center; margin-top: 14px; }
.bc-custom input[type=color] { width: 38px; height: 28px; padding: 0; border: 1px solid var(--c-border); border-radius: 8px; background: none; cursor: pointer; }
.bc-name-grid { display: grid; grid-template-columns: 130px 1fr 1fr; gap: 0 12px; }
.bc-help { font-size: .88rem; color: var(--c-muted); max-width: 520px; margin: 0 auto; }
.bc-help summary { cursor: pointer; color: var(--c-primary); font-weight: 600; text-align: center; }
.bc-hook { display: flex; gap: 14px; align-items: flex-start; margin-top: 12px; padding: 16px; border-radius: var(--r-md); background: var(--c-accent-soft); border: 1px solid color-mix(in oklab, var(--c-accent) 45%, var(--c-border)); }
.bc-hook .feature-icon { margin: 0; }
.bc-hook > div { display: grid; gap: 6px; justify-items: start; }
.bc-after { margin-top: 20px; text-align: center; }
.bc-after .btn { margin-top: 6px; }

@media (max-width: 520px) {
    .bc-name-grid { grid-template-columns: 1fr 1fr; }
    .bc-name-grid .field:first-child { grid-column: 1 / -1; }
}
@media (min-width: 1000px) {
    .card-editor { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
    .card-editor-preview { position: sticky; top: calc(var(--header-h, 64px) + 16px); order: 2; }
}

/* ---------------------------------------------------------------- post per i social (Area → Post per i social) */

.post-preview { width: 100%; max-width: 480px; margin: 0 auto; }
.post-preview[data-fmt="story"] { max-width: 340px; }
.post-preview canvas { touch-action: none; }
.post-preview canvas.is-dragging { cursor: grabbing !important; }
.post-photo-actions { margin: 10px 0 6px; }
.post-preview canvas { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 14px 36px -14px rgb(0 0 0 / .3); background: var(--c-surface-2); }

/* ---------------------------------------------------------------- biglietto: struttura comune */

.bc {
    --u: 1mm; --b: 0;
    position: relative; overflow: hidden; box-sizing: border-box;
    width: calc(var(--u) * (85 + 2 * var(--b))); height: calc(var(--u) * (55 + 2 * var(--b)));
    background: #fff; color: var(--ink); font-family: 'Inter', system-ui, sans-serif; line-height: 1.25;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.bc *, .bc *::before { box-sizing: border-box; }
.bc-deco { position: absolute; pointer-events: none; }
.bc-in { position: absolute; inset: calc(var(--u) * (var(--b) + 5)); display: flex; }
.bc-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.bc-name { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: calc(var(--u) * 4.6 * var(--fs-name, 1)); line-height: 1.05; letter-spacing: -.01em; }
.bc-name.is-long { font-size: calc(var(--u) * 3.7 * var(--fs-name, 1)); }
.bc-name.is-empty { opacity: .35; }
.bc-title { font-size: calc(var(--u) * 2.6 * var(--fs-title, 1)); font-weight: 600; color: var(--pt); margin-top: calc(var(--u) * 1); }
.bc-albo { font-size: calc(var(--u) * 1.85 * var(--fs-albo, 1)); color: var(--mut); margin-top: calc(var(--u) * .6); }
.bc-line { font-size: calc(var(--u) * 2.05 * var(--fs-line, 1)); color: var(--mut); margin-top: calc(var(--u) * 2); }
.bc-contacts { list-style: none; margin: auto 0 0; padding: 0; display: grid; gap: calc(var(--u) * .9); font-size: calc(var(--u) * 2.15 * var(--fs-contacts, 1)); }
.bc-contacts li { display: flex; align-items: center; gap: calc(var(--u) * 1.4); min-width: 0; }
.bc-contacts span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-contacts svg { width: 1.1em; height: 1.1em; flex: none; color: var(--pt); }

/* retro */
.bc-back .bc-in { align-items: center; gap: calc(var(--u) * 5); }
.bc-qr { flex: none; width: calc(var(--u) * 27); height: calc(var(--u) * 27); padding: calc(var(--u) * 1.2); background: #fff; border-radius: calc(var(--u) * 2); display: grid; place-items: center; }
.bc-qr img { width: 100%; height: 100%; display: block; }
.bc-qr-empty { font-size: calc(var(--u) * 2); color: #777; text-align: center; }
.bc-cta { display: grid; gap: calc(var(--u) * 1.2); min-width: 0; }
.bc-cta strong { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: calc(var(--u) * 3.6); line-height: 1.1; }
.bc-cta span { font-size: calc(var(--u) * 1.9); opacity: .85; overflow-wrap: anywhere; }
.bc-cta em { font-style: normal; font-size: calc(var(--u) * 1.9); opacity: .85; }
.bc-brand { position: absolute; right: 0; bottom: calc(var(--u) * -2); font-size: calc(var(--u) * 1.6); opacity: .7; letter-spacing: .02em; }
.bc-back { background: var(--pb); color: #fff; }

/* ---------------------------------------------------------------- Classico: cerchio decorativo, recapiti in colonna */

.bc-t-classico.bc-front .bc-deco { right: calc(var(--u) * (var(--b) - 16)); top: calc(var(--u) * (var(--b) - 18)); width: calc(var(--u) * 46); height: calc(var(--u) * 46); border-radius: 50%; background: color-mix(in oklab, var(--p) 11%, #fff); }
.bc-t-classico .bc-name::after { content: ""; display: block; width: calc(var(--u) * 8); height: calc(var(--u) * .7); border-radius: 9px; background: var(--a); margin-top: calc(var(--u) * 1.8); }
.bc-t-classico .bc-line { color: var(--pt); font-weight: 600; margin-top: calc(var(--u) * 1.6); }
.bc-t-classico.bc-back .bc-deco { left: calc(var(--u) * (var(--b) - 20)); bottom: calc(var(--u) * (var(--b) - 26)); width: calc(var(--u) * 50); height: calc(var(--u) * 50); border-radius: 50%; background: rgb(255 255 255 / .08); }

/* ---------------------------------------------------------------- Minimal: centrato, maiuscoletto, retro bianco */

.bc-t-minimal .bc-body { align-items: center; text-align: center; justify-content: center; }
.bc-t-minimal .bc-id { margin-top: auto; }
.bc-t-minimal .bc-name { font-family: 'Inter', system-ui, sans-serif; font-weight: 600; letter-spacing: .01em; }
.bc-t-minimal .bc-title { text-transform: uppercase; letter-spacing: .16em; font-size: calc(var(--u) * 1.95 * var(--fs-title, 1)); margin-top: calc(var(--u) * 1.8); }
.bc-t-minimal .bc-albo { margin-top: calc(var(--u) * 1); }
.bc-t-minimal .bc-line { margin-top: calc(var(--u) * 1.4); }
.bc-t-minimal .bc-contacts { margin-top: auto; display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * .6) calc(var(--u) * 3); font-size: calc(var(--u) * 1.95 * var(--fs-contacts, 1)); }
.bc-t-minimal .bc-contacts li:last-child:nth-child(4) { flex-basis: 100%; justify-content: center; }
.bc-t-minimal.bc-front .bc-deco { left: 0; right: 0; bottom: 0; height: calc(var(--u) * (var(--b) + 1.6)); background: var(--p); }
.bc-t-minimal.bc-back { background: #fff; color: var(--ink); }
.bc-t-minimal.bc-back .bc-qr { box-shadow: inset 0 0 0 calc(var(--u) * .3) color-mix(in oklab, var(--p) 25%, #fff); }
.bc-t-minimal.bc-back .bc-cta strong { color: var(--pt); }
.bc-t-minimal.bc-back .bc-deco { left: 0; right: 0; top: 0; height: calc(var(--u) * (var(--b) + 1.6)); background: var(--p); }

/* ---------------------------------------------------------------- Fascia colore: banda a sinistra con le iniziali */

.bc-t-fascia.bc-front .bc-deco { left: 0; top: 0; bottom: 0; width: calc(var(--u) * (var(--b) + 24)); background: var(--pb); display: flex; align-items: center; justify-content: center; padding-left: calc(var(--u) * var(--b)); }
.bc-mono { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: calc(var(--u) * 10); color: #fff; letter-spacing: -.02em; }
.bc-mono::after { content: ""; display: block; width: calc(var(--u) * 6); height: calc(var(--u) * .7); background: var(--a); margin: calc(var(--u) * 1.5) auto 0; border-radius: 9px; }
.bc-t-fascia.bc-front .bc-in { left: calc(var(--u) * (var(--b) + 30)); }
.bc-t-fascia .bc-name { font-family: 'Inter', system-ui, sans-serif; font-weight: 700; font-size: calc(var(--u) * 4.1 * var(--fs-name, 1)); letter-spacing: -.02em; }
.bc-t-fascia .bc-name.is-long { font-size: calc(var(--u) * 3.4 * var(--fs-name, 1)); }
.bc-t-fascia.bc-back .bc-deco { right: 0; top: 0; bottom: 0; width: calc(var(--u) * (var(--b) + 4)); background: var(--a); }

/* ---------------------------------------------------------------- Con foto: cerchio a sinistra */

.bc-t-foto.bc-front .bc-in { align-items: center; gap: calc(var(--u) * 5); }
.bc-photo { flex: none; width: calc(var(--u) * 24); height: calc(var(--u) * 24); border-radius: 50%; overflow: hidden; background: var(--pb); box-shadow: 0 0 0 calc(var(--u) * .8) #fff, 0 0 0 calc(var(--u) * 1.2) color-mix(in oklab, var(--p) 30%, #fff); display: grid; place-items: center; }
.bc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bc-photo span { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: calc(var(--u) * 9); color: #fff; }
.bc-t-foto .bc-body { align-self: stretch; justify-content: center; }
.bc-t-foto .bc-contacts { margin-top: calc(var(--u) * 2.6); }
.bc-t-foto.bc-front .bc-deco { left: 0; top: 0; bottom: 0; width: calc(var(--u) * (var(--b) + 17)); background: color-mix(in oklab, var(--p) 12%, #fff); }

/* ---------------------------------------------------------------- Elegante: fondo scuro, dettagli nel colore d'accento */

.bc-t-elegante { background: var(--dark); color: #F4F1EA; }
.bc-t-elegante .bc-title, .bc-t-elegante .bc-contacts svg { color: var(--at); }
.bc-t-elegante .bc-albo, .bc-t-elegante .bc-line { color: rgb(244 241 234 / .72); }
.bc-t-elegante .bc-name::after { content: ""; display: block; width: calc(var(--u) * 12); height: calc(var(--u) * .25); background: var(--at); margin-top: calc(var(--u) * 2); }
.bc-t-elegante.bc-front .bc-deco, .bc-t-elegante.bc-back .bc-deco { inset: calc(var(--u) * (var(--b) + 2.2)); border: calc(var(--u) * .2) solid color-mix(in oklab, var(--at) 70%, transparent); border-radius: calc(var(--u) * .8); }
.bc-t-elegante.bc-back .bc-cta strong { color: var(--at); }
.bc-t-elegante .bc-brand { bottom: calc(var(--u) * -1.6); }

/* ---------------------------------------------------------------- Ritratto scuro: foto a destra con alone colorato, testi chiari */

.bc-t-ritratto, .bc-t-ritratto.bc-back { background: var(--dark); color: #F4F1EA; }
.bc-t-ritratto.bc-front .bc-in { flex-direction: row-reverse; align-items: center; gap: calc(var(--u) * 5); }
.bc-t-ritratto .bc-body { align-self: stretch; justify-content: center; }
.bc-t-ritratto .bc-photo { width: calc(var(--u) * 25); height: calc(var(--u) * 25); background: var(--pb); box-shadow: 0 0 0 calc(var(--u) * .9) var(--dark), 0 0 0 calc(var(--u) * 1.3) var(--at); }
.bc-t-ritratto .bc-name::after { content: ""; display: block; width: calc(var(--u) * 9); height: calc(var(--u) * .4); border-radius: 9px; background: var(--at); margin-top: calc(var(--u) * 1.8); }
.bc-t-ritratto .bc-title, .bc-t-ritratto .bc-contacts svg { color: var(--at); }
.bc-t-ritratto .bc-albo, .bc-t-ritratto .bc-line { color: rgb(244 241 234 / .72); }
.bc-t-ritratto .bc-contacts { margin-top: calc(var(--u) * 2.6); }
/* alone dietro la foto (fronte) e dietro il QR (retro) */
.bc-t-ritratto.bc-front .bc-deco, .bc-t-ritratto.bc-back .bc-deco { width: calc(var(--u) * 56); height: calc(var(--u) * 56); border-radius: 50%; background: radial-gradient(circle, color-mix(in oklab, var(--p) 60%, transparent) 0%, transparent 68%); }
.bc-t-ritratto.bc-front .bc-deco { right: calc(var(--u) * (var(--b) - 10)); top: calc(var(--u) * (var(--b) - .5)); }
.bc-t-ritratto.bc-back .bc-deco { left: calc(var(--u) * (var(--b) - 10)); top: calc(var(--u) * (var(--b) - .5)); }
.bc-t-ritratto.bc-back .bc-cta strong { color: var(--at); }

/* ---------------------------------------------------------------- stampa */

.bc-print { display: none; }
@media print {
    body.bc-printing > :not(.bc-print) { display: none !important; }
    body.bc-printing { background: #fff !important; margin: 0; padding: 0; }
    body.bc-printing .bc-print { display: block; }
    .bc-sheet { position: relative; width: 210mm; height: 297mm; break-after: page; overflow: hidden; }
    .bc-sheet:last-child { break-after: auto; }
    .bc-slot { position: absolute; width: 85mm; height: 55mm; }
    .bc-mark { position: absolute; border-left: .2mm solid #888; border-top: .2mm solid #888; }
    .bc-page { width: 91mm; height: 61mm; break-after: page; overflow: hidden; }
    .bc-page:last-child { break-after: auto; }
}
