/*
 * Primitive comuni a tutte le carte.
 * Sistema di coordinate: 1px = 0,1 mm (una carta 63×88 mm misura 630×880 px).
 * L'anteprima scala la carta con transform, quindi il layout è identico in anteprima ed export.
 */

.cg-card {
    position: relative;
    flex: none;
    overflow: hidden;
    isolation: isolate;
    color: #111;
    background: #fff;
    line-height: 1.2;
    text-align: left;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
    user-select: none;
    -webkit-user-select: none;
}

.cg-card *,
.cg-card *::before,
.cg-card *::after { box-sizing: border-box; }

.cg-card p { margin: 0; }
.cg-card img { max-width: none; }

.cg-face,
.cg-layers {
    position: absolute;
    inset: 0;
}

.cg-layers {
    z-index: 50;
    pointer-events: none;
}

/* ---- Livelli liberi (testi, immagini, forme) ---- */

.cg-layer {
    position: absolute;
    transform-origin: 50% 50%;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.cg-layer--image img,
.cg-layer--svg > svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cg-layer--svg { white-space: normal; }

.cg-layer--text { paint-order: stroke fill; }

/* ---- Box immagine con zoom e spostamento ---- */

.cg-art {
    position: absolute;
    overflow: hidden;
}

.cg-art-img {
    position: absolute;
    display: block;
    max-width: none;
    pointer-events: none;
}

.cg-art-img.is-fallback {
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cg-art.is-empty {
    background:
        radial-gradient(120% 90% at 28% 18%, rgba(255, 255, 255, 0.3), transparent 60%),
        linear-gradient(160deg, #6b7a9c, #2a3350);
}

.cg-art-hint { display: none; }

/* ---- Solo nell'editor ---- */

.is-editable .cg-layer { pointer-events: auto; cursor: move; }
.is-editable .cg-art { cursor: grab; }

.is-editable .cg-art.is-empty { cursor: pointer; }

.is-editable .cg-art.is-empty .cg-art-hint {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
    padding: 10%;
    font: 600 24px/1.25 'Inter', system-ui, sans-serif;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.cg-art-hint .bi { font-size: 2.4em; opacity: 0.85; }

.is-editable [data-field]:hover {
    outline: 3px dashed rgba(139, 108, 255, 0.95);
    outline-offset: 2px;
}

.is-editable .cg-art[data-field]:hover { outline-offset: -3px; }

.is-editable [data-field].is-flash {
    animation: cg-flash 0.9s ease-out;
}

@keyframes cg-flash {
    0% { box-shadow: 0 0 0 0 rgba(139, 108, 255, 0.9); }
    100% { box-shadow: 0 0 0 18px rgba(139, 108, 255, 0); }
}

/* ---- Adattamento testi (Scripts/Core/Fit.js) ---- */

.fit-inner {
    display: inline-block;
    white-space: nowrap;
    transform-origin: 0 50%;
}

[data-fit="compress"],
[data-fit="shrink"] { white-space: nowrap; }

[data-fit="box"] { overflow: hidden; }
