/* ============================================================
   CARTA COLLEZIONABILE — cornici e luci per le 4 rarità.
   Variabili impostate da carta.js mentre la carta si muove:
   --mx/--my posizione della luce (0–100%), --rx/--ry rotazione,
   --dist 0–1 distanza dal centro, --att 0/1 carta "attiva".
   ============================================================ */
:root { --emblema: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='o' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1c2'/%3E%3Cstop offset='.5' stop-color='%23e6b04f'/%3E%3Cstop offset='1' stop-color='%239a6516'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='none' stroke='url%28%23o%29' stroke-width='2.2'%3E%3Ccircle cx='50' cy='50' r='44'/%3E%3Ccircle cx='50' cy='50' r='36' stroke-width='1.2'/%3E%3C/g%3E%3Cg fill='url%28%23o%29'%3E%3Cpath d='M50 8 56 44 92 50 56 56 50 92 44 56 8 50 44 44Z'/%3E%3Cpath d='M50 26 53 47 74 50 53 53 50 74 47 53 26 50 47 47Z' fill='%230c1120' opacity='.55'/%3E%3Cpath d='M50 34 66 50 50 66 34 50Z' opacity='.9' transform='rotate%2845 50 50%29 scale%28.55%29 translate%2841 41%29'/%3E%3C/g%3E%3Ccircle cx='50' cy='50' r='5' fill='%23fff6d8'/%3E%3C/svg%3E"); --ic-cenere: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='55%25' r='55%25'%3E%3Cstop offset='0' stop-color='%23fff2c7'/%3E%3Cstop offset='.35' stop-color='%23ffb04a'/%3E%3Cstop offset='.8' stop-color='%23e2531c'/%3E%3Cstop offset='1' stop-color='%238c2410'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cpath d='M12 2.6 19.2 7.6 17.6 17 12 21.4 6.4 17 4.8 7.6Z' fill='url%28%23g%29' stroke='%235a1808' stroke-width='1.1' stroke-linejoin='round'/%3E%3Cpath d='M12 2.6 12 21.4M4.8 7.6 12 11.4 19.2 7.6M6.4 17 12 11.4 17.6 17' fill='none' stroke='%237a2a0c' stroke-width='.7' opacity='.55'/%3E%3Cpath d='M12 5.2 15.6 7.9 12 10 8.4 7.9Z' fill='%23fff8de' opacity='.55'/%3E%3Ccircle cx='20.6' cy='3.6' r='1.1' fill='%23ffc46b'/%3E%3Ccircle cx='3.4' cy='4.8' r='.7' fill='%23ff9a4a'/%3E%3C/svg%3E"); }
.carta {
  --mx: 50%; --my: 50%; --rx: 0deg; --ry: 0deg; --dist: 0; --att: 0;
  --larg: 240px;
  width: var(--larg); aspect-ratio: 63 / 88;
  perspective: 900px;
  font-family: "Cinzel", Georgia, serif;
  user-select: none; -webkit-user-select: none;
  container-type: inline-size;
}
.c-interno {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(var(--rx)) rotateX(var(--ry));
  border-radius: 4.5cqw;
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 2cqw 6cqw rgb(0 0 0 / .45);
}
.carta.muove .c-interno { transition: none; }

/* --- Cornice (lo spessore cambia con la rarità) --- */
.c-cornice {
  position: absolute; inset: 0; border-radius: inherit;
  background: var(--metallo);
  box-shadow: inset 0 0 0 .6cqw rgb(255 255 255 / .25), inset 0 0 0 1.2cqw rgb(0 0 0 / .25);
}
.c-cornice::after { /* filo interno attorno alla foto */
  content: ""; position: absolute; inset: var(--bordo); bottom: var(--bordo-basso);
  border-radius: 2.5cqw; box-shadow: 0 0 0 .8cqw var(--filo), 0 0 0 1.4cqw rgb(0 0 0 / .45);
}
.c-foto {
  position: absolute; inset: var(--bordo); bottom: var(--bordo-basso);
  border-radius: 2.5cqw; overflow: hidden; background: #1a1d24;
  transform: translateZ(1px);
}
.c-foto img { width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scale(1.06) translate(calc((50% - var(--mx)) * .05), calc((50% - var(--my)) * .05)); }

/* --- Elementi in rilievo --- */
.c-num, .c-nome, .c-gemme { position: absolute; transform: translateZ(var(--rilievo, 18px)); }
.c-num {
  top: calc(var(--bordo) + 2cqw); left: calc(var(--bordo) + 2cqw);
  padding: 1cqw 3cqw; border-radius: 99px; font: 700 5.2cqw/1 "Cinzel", Georgia, serif;
  color: var(--inchiostro); background: var(--placca); letter-spacing: .04em;
  box-shadow: 0 .8cqw 2cqw rgb(0 0 0 / .5), inset 0 .4cqw 0 rgb(255 255 255 / .4);
}
.c-nome {
  left: 6cqw; right: 6cqw; bottom: calc(var(--bordo-basso) - 8cqw);
  height: 13cqw; display: grid; place-items: center; text-align: center;
  padding: 0 4cqw; border-radius: 2cqw;
  font: 700 6.4cqw/1.05 "Cinzel", Georgia, serif; color: var(--inchiostro);
  background: var(--placca); text-wrap: balance;
  box-shadow: 0 1.2cqw 3cqw rgb(0 0 0 / .55), inset 0 .5cqw 0 rgb(255 255 255 / .45), inset 0 -.5cqw 0 rgb(0 0 0 / .25);
}
.c-gemme { left: 0; right: 0; bottom: 3.2cqw; display: flex; justify-content: center; gap: 1.6cqw; --rilievo: 10px; }
.c-gemme i { width: 3.6cqw; height: 3.6cqw; rotate: 45deg; border-radius: .6cqw;
  background: var(--gemma); box-shadow: 0 0 2cqw var(--gemma), inset 0 .5cqw 0 rgb(255 255 255 / .6); }

/* --- Luci --- */
.c-holo, .c-luce, .c-brillio { position: absolute; pointer-events: none; border-radius: inherit; }
.c-luce { /* riflesso che segue il dito: presente su tutte */
  inset: 0; transform: translateZ(22px); mix-blend-mode: overlay;
  background: radial-gradient(farthest-corner circle at var(--mx) var(--my),
     rgb(255 255 255 / calc(.15 + var(--intensita, .3) * .6)) 0%, rgb(255 255 255 / 0) 45%, rgb(0 0 0 / .25) 110%);
  opacity: calc(.35 + var(--att) * .65); transition: opacity .3s;
}
.c-holo, .c-brillio { inset: var(--bordo); bottom: var(--bordo-basso); border-radius: 2.5cqw; transform: translateZ(2px); opacity: 0; }

/* ======================= COMUNE ======================= */
.r-comune {
  --bordo: 4cqw; --bordo-basso: 15cqw; --intensita: .15;
  --metallo: linear-gradient(160deg, #8a8f99, #5b6069 45%, #9aa0a9 70%, #4c5058);
  --filo: #c9ccd2; --placca: linear-gradient(#e7e8eb, #b9bcc3); --inchiostro: #24272d; --gemma: #b9bec7;
}

/* ======================== RARA ======================== */
.r-rara {
  --bordo: 4.5cqw; --bordo-basso: 16cqw; --intensita: .35;
  --metallo: linear-gradient(155deg, #dbe7f7, #6f8fb8 28%, #2b4a78 50%, #8fb1dc 72%, #3a5d8f);
  --filo: #e5efff; --placca: linear-gradient(#f4f8ff, #a9c1e4); --inchiostro: #12274a; --gemma: #5fb2ff;
}
.r-rara .c-cornice { background:
  linear-gradient(115deg, transparent 38%, rgb(255 255 255 / .5) 50%, transparent 62%) calc(100% - var(--mx)) 0 / 250% 100% no-repeat, var(--metallo); }
.r-rara .c-holo { /* fascia di luce blu: gradiente fisso e morbido che scorre, nessun bordo netto */
  opacity: calc(var(--att) * .5); mix-blend-mode: color-dodge;
  background: linear-gradient(110deg, transparent 35%, rgb(140 200 255 / .25) 43%, rgb(140 200 255 / .7) 50%, rgb(140 200 255 / .25) 57%, transparent 65%);
  background-size: 300% 100%;
  background-position: calc(100% - var(--mx)) 0; }

/* ======================= EPICA ======================== */
.r-epica {
  --bordo: 5cqw; --bordo-basso: 17cqw; --intensita: .38;
  --metallo: linear-gradient(150deg, #f1d9ff, #9b4fd6 22%, #3c1268 48%, #b77df0 70%, #4a1a80);
  --filo: #f3e3ff; --placca: linear-gradient(#fbf3ff, #c9a2ef); --inchiostro: #2c0b4f; --gemma: #d07bff;
}
.r-epica .c-cornice { background:
  repeating-linear-gradient(45deg, rgb(255 255 255 / .07) 0 1cqw, transparent 1cqw 2.4cqw), var(--metallo); }
.r-epica .c-cornice::before, .r-leggendaria .c-cornice::before { /* fregi negli angoli */
  content: ""; position: absolute; inset: 1.4cqw; border-radius: 3.5cqw;
  background:
    radial-gradient(circle at 0 0, var(--filo) 0 2cqw, transparent 2.2cqw),
    radial-gradient(circle at 100% 0, var(--filo) 0 2cqw, transparent 2.2cqw),
    radial-gradient(circle at 0 100%, var(--filo) 0 2cqw, transparent 2.2cqw),
    radial-gradient(circle at 100% 100%, var(--filo) 0 2cqw, transparent 2.2cqw);
  border: .5cqw solid rgb(255 255 255 / .35); opacity: .9;
}
.r-epica .c-holo { /* fascia arcobaleno morbida, visibile solo vicino alla luce */
  opacity: calc(.06 + var(--att) * .42); mix-blend-mode: color-dodge;
  background: linear-gradient(115deg, transparent 15%, #ff8ec4 30%, #ffe08f 40%, #8fffd0 50%, #8fd4ff 60%, #c9a2ff 70%, transparent 85%);
  background-size: 250% 250%;
  background-position: calc(100% - var(--mx)) calc(100% - var(--my));
  filter: saturate(.9) brightness(.75);
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0, rgb(0 0 0 / .35) 45%, transparent 75%);
          mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0, rgb(0 0 0 / .35) 45%, transparent 75%); }

/* ==================== LEGGENDARIA ===================== */
.r-leggendaria {
  --bordo: 5.5cqw; --bordo-basso: 18cqw; --intensita: .45;
  --metallo: linear-gradient(145deg, #fff4c4, #e1a93b 20%, #8a5512 42%, #ffe08a 58%, #b9781c 78%, #fff0b0);
  --filo: #fff6d2; --placca: linear-gradient(#fffbe8, #f0c766 60%, #c9912c); --inchiostro: #3d2504; --gemma: #ffd75e;
  --rilievo: 26px;
}
.r-leggendaria .c-cornice { background:
  repeating-conic-gradient(from 0deg at 50% 50%, rgb(255 255 255 / .08) 0 2deg, transparent 2deg 6deg),
  linear-gradient(calc(100deg + var(--rx) * 3), transparent 25%, rgb(255 255 255 / .4) 45%, transparent 60%),
  var(--metallo); }
.r-leggendaria .c-interno::before { /* aura dorata: anima solo quando la carta è grande (.viva) */
  content: ""; position: absolute; inset: -2.5cqw; border-radius: 7cqw; transform: translateZ(-1px);
  background: conic-gradient(from var(--ang, 0deg), #ffdf7e, #ff9e3d, #fff6c9, #ffcf4a, #ffdf7e);
  filter: blur(3.5cqw); opacity: .3;
}
.carta.viva.r-leggendaria .c-interno::before { animation: aura 12s linear infinite; }
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes aura { to { --ang: 360deg; } }
.r-leggendaria .c-holo { /* riflesso iridescente delicato + alone caldo dove batte la luce */
  opacity: calc(.1 + var(--att) * .45); mix-blend-mode: color-dodge;
  background:
    radial-gradient(circle at var(--mx) var(--my), rgb(255 236 180 / .55), transparent 40%),
    linear-gradient(125deg, transparent 20%, #ffb0d8 35%, #ffe7a0 45%, #b0ffe0 55%, #b0dcff 65%, transparent 80%);
  background-size: 100% 100%, 220% 220%;
  background-position: center, calc(100% - var(--mx)) calc(100% - var(--my));
  filter: saturate(.75) brightness(.7);
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0, rgb(0 0 0 / .4) 50%, transparent 85%);
          mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0, rgb(0 0 0 / .4) 50%, transparent 85%); }
.r-leggendaria .c-brillio { /* poche scintille fini, solo attorno alla luce */
  opacity: calc(.15 + var(--att) * .4); mix-blend-mode: screen;
  background-image:
    radial-gradient(circle, rgb(255 255 255 / .9) 0 .3cqw, transparent .55cqw),
    radial-gradient(circle, rgb(255 240 190 / .8) 0 .22cqw, transparent .45cqw);
  background-size: 14cqw 17cqw, 19cqw 11cqw;
  background-position: calc(var(--mx) * -.2) calc(var(--my) * -.2), calc(var(--mx) * .25) calc(var(--my) * .15);
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0, transparent 35%);
          mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0, transparent 35%); }

/* --- Carta non posseduta (album) --- */
.carta.mancante .c-foto { background: repeating-linear-gradient(135deg, #1b1e25 0 8px, #20242c 8px 16px); }
.carta.mancante .c-cornice { filter: grayscale(1) brightness(.45); }
.carta.mancante .c-num { filter: grayscale(1); opacity: .7; }
.carta.mancante .c-foto::after { content: "?"; position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 30cqw/1 "Cinzel", Georgia, serif; color: rgb(255 255 255 / .08); }
.carta.vuota .c-foto::after { content: "Foto mancante"; position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 5cqw/1 system-ui, sans-serif; color: rgb(255 255 255 / .35); }

@media (prefers-reduced-motion: reduce) {
  .c-interno { transition: none; }
  .carta.viva.r-leggendaria .c-interno::before { animation: none; }
}

/* Interruttore "Muovi le carte" */
.scelta-movimento { display: grid; gap: 8px; }
.scelta-titolo { font-size: 14px; color: var(--testo-2, #a3abbb); }
.segmenti { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--pannello-2, #1f2430); border-radius: 10px; padding: 4px; }
.segmenti button { border: 0; background: none; color: var(--testo-2, #a3abbb); border-radius: 8px; padding: 8px; min-height: 40px; font: 600 14px system-ui, sans-serif; }
.segmenti button[aria-checked="true"] { background: var(--pannello, #171b24); color: var(--testo, #eef0f4); box-shadow: inset 0 0 0 1px var(--oro, #f2c35b); }
.scelta-nota { margin: 0; min-height: 0; }
.scelta-nota:empty { display: none; }

/* --- Miniature nitide ---
   Il 3D (perspective + preserve-3d + translateZ) fa disegnare la carta come immagine a bassa
   risoluzione: le miniature restano piatte, il 3D vale solo per la carta grande (.viva). */
.carta:not(.viva) { perspective: none; }
.carta:not(.viva) .c-interno { transform: none; transform-style: flat; transition: none; }
.carta:not(.viva) .c-interno > * { transform: none !important; }
.carta:not(.viva) .c-foto img { transform: none; }

/* --- Dorso della carta (apertura pacchetto) --- */
.carta-retro { width: var(--larg, 240px); aspect-ratio: 63 / 88; border-radius: 4.5cqw; container-type: inline-size; position: relative;
  background:
    radial-gradient(circle at 50% 50%, rgb(242 195 91 / .25), transparent 45%),
    repeating-conic-gradient(from 45deg at 50% 50%, rgb(242 195 91 / .07) 0 15deg, transparent 15deg 30deg),
    linear-gradient(160deg, #1d2742, #0c1120 60%, #1a1530);
  box-shadow: inset 0 0 0 2.4cqw #2a2f45, inset 0 0 0 3cqw #c9a14a, inset 0 0 0 4cqw #2a2f45, 0 2cqw 6cqw rgb(0 0 0 / .5); }
.carta-retro::after { content: ""; position: absolute; inset: 0; margin: auto; width: 46%; aspect-ratio: 1;
  background: var(--emblema) center / contain no-repeat; filter: drop-shadow(0 0 3cqw rgb(242 195 91 / .45)); }
