/* ============================================
   ANIMAI — Consulto Interattivo Premium
   ============================================ */

.consulto { display: flex; flex-direction: column; min-height: 100vh; background: radial-gradient(ellipse at 50% 0%, #14082e 0%, #0d0620 45%, #0A0A0F 100%); }
.consulto__header { position: sticky; top: 0; z-index: 30; background: rgba(10,10,15,0.85); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255,255,255,0.05); padding: 1rem 0; }
.consulto__header .container { display: flex; align-items: center; justify-content: space-between; }
.consulto__back { font-size: 0.8125rem; color: rgba(245,240,235,0.5); }
.consulto__back:hover { color: #F5F0EB; }
.consulto__guida-nome { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 1rem; background: linear-gradient(135deg, #A78BFA, #D4A574); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-decoration: none; position: relative; z-index: 1; padding-left: 2px; }
.consulto__guida { display: flex; align-items: center; gap: 0.75rem; }
.consulto__crediti { font-size: 0.6875rem; padding: 0.25rem 0.625rem; border-radius: 999px; background: rgba(167,139,250,0.12); color: #A78BFA; white-space: nowrap; }
.consulto__crediti.low { background: rgba(245,158,11,0.15); color: #FBBF24; }

/* Paywall */
.paywall {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: 0.75rem; padding: 2.5rem 2rem; margin: 1.5rem auto; max-width: 480px;
    border-radius: 20px; background: rgba(255,255,255,0.03);
    border: 1px solid rgba(212,165,116,0.25);
    box-shadow: 0 0 60px rgba(107,33,168,0.2);
    animation: msgIn 0.5s ease;
}
.paywall__avatar { font-size: 2.5rem; margin-bottom: 0.25rem; }
.paywall__title { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 1.125rem; color: #F5F0EB; line-height: 1.4; }
.paywall__sub { font-size: 0.875rem; color: rgba(245,240,235,0.55); line-height: 1.5; margin-bottom: 1rem; }
.paywall__actions { display: flex; flex-direction: column; gap: 0.625rem; width: 100%; }
.paywall__btn {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.875rem 1.5rem; border-radius: 12px; font-weight: 600; font-size: 0.9375rem;
    transition: all 0.3s; position: relative;
}
.paywall__btn--primary { background: linear-gradient(135deg,#D4A574,#B8860B); color: #0A0A0F; }
.paywall__btn--primary:hover { box-shadow: 0 0 24px rgba(212,165,116,0.35); transform: translateY(-1px); }
.paywall__btn--ghost { background: transparent; border: 1px solid rgba(245,240,235,0.15); color: #F5F0EB; }
.paywall__btn--ghost:hover { border-color: rgba(212,165,116,0.5); background: rgba(212,165,116,0.05); }
.paywall__arrow { margin-left: auto; opacity: 0.6; }
.consulto__body { flex: 1; padding-bottom: 120px; max-width: 780px; }

/* Chat */
.consulto__chat { display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem 0; }
.chat-msg { display: flex; max-width: 85%; animation: msgIn 0.4s ease; }
@keyframes msgIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
.chat-msg--user { align-self: flex-end; margin-left: auto; }
.chat-msg--ai { align-self: flex-start; }
.chat-msg__bubble { padding: 1rem 1.25rem; border-radius: 18px; font-size: 0.9375rem; line-height: 1.7; }
.chat-msg--user .chat-msg__bubble { background: linear-gradient(135deg, #6B21A8, #7C3AED); color: #F5F0EB; border-bottom-right-radius: 5px; }
.chat-msg--ai .chat-msg__bubble { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-bottom-left-radius: 5px; color: rgba(245,240,235,0.75); }
.chat-msg--ai .chat-msg__bubble p { margin-bottom: 0.75rem; }
.chat-msg--ai .chat-msg__bubble p:last-child { margin-bottom: 0; }
.chat-msg--ai .chat-msg__bubble strong { color: #F5F0EB; }
.chat-msg--ai .chat-msg__bubble a { color: #A78BFA; text-decoration: underline; }
.chat-msg .error { color: #EF4444; }
.typing-dots { display: flex; gap: 5px; padding: 4px 0; }
.typing-dots span { width: 8px; height: 8px; border-radius: 50%; background: #A78BFA; animation: tp 1.4s infinite; }
.typing-dots span:nth-child(2){animation-delay:.2s} .typing-dots span:nth-child(3){animation-delay:.4s}
@keyframes tp { 0%,60%,100%{opacity:.3;transform:scale(.8)} 30%{opacity:1;transform:scale(1)} }

/* ============================================
   SCELTA STESA (3/4/7)
   ============================================ */
.stesa-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 1rem 0 2rem; animation: msgIn 0.5s ease; }
.stesa-btn {
    display: flex; flex-direction: column; align-items: center; gap: 0.375rem;
    padding: 1.5rem 1rem; border-radius: 18px;
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(12px); cursor: pointer; text-align: center;
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), border-color 0.3s, box-shadow 0.4s;
}
.stesa-btn:hover { transform: translateY(-6px); border-color: rgba(212,165,116,0.5); box-shadow: 0 12px 40px rgba(107,33,168,0.3), 0 0 50px rgba(212,165,116,0.1); }
.stesa-btn.suggested { border-color: rgba(212,165,116,0.6); background: rgba(212,165,116,0.06); box-shadow: 0 0 30px rgba(212,165,116,0.15); }
.stesa-btn.suggested::before { content: 'Consigliata'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: 0.625rem; font-weight: 600; padding: 0.125rem 0.625rem; border-radius: 999px; background: linear-gradient(135deg,#D4A574,#B8860B); color: #0A0A0F; white-space: nowrap; }
.stesa-btn { position: relative; }
.stesa-btn__num { font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 700; background: linear-gradient(135deg, #D4A574, #F59E0B); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stesa-btn__label { font-weight: 600; font-size: 0.9375rem; }
.stesa-btn__desc { font-size: 0.6875rem; color: rgba(245,240,235,0.45); line-height: 1.3; }

/* ============================================
   SLOTS (dove volano le carte)
   ============================================ */
.slots-area { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; padding: 1.5rem 0; }
.card-slot {
    width: 100px; height: 165px; border-radius: 12px;
    border: 1.5px dashed rgba(167,139,250,0.25);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
    position: relative; transition: all 0.3s ease;
}
.card-slot__num { font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 700; color: rgba(167,139,250,0.4); }
.card-slot__label { font-size: 0.625rem; color: rgba(245,240,235,0.4); text-align: center; padding: 0 4px; }
.card-slot.filled { border: none; }
.slots-area--7 { max-width: 640px; margin: 0 auto; }
.slots-area--7 .card-slot { width: 82px; height: 135px; }

/* Slot card (rivelata) */
.slot-card {
    width: 100%; height: 100%; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 10px; position: relative;
    border: 1.5px solid rgba(212,165,116,0.5);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 40px rgba(107,33,168,0.2),
                inset 0 0 30px rgba(212,165,116,0.06);
    animation: slotReveal 0.5s ease;
    overflow: hidden;
}
/* Pattern decorativo sovrapposto */
.slot-card::before, .flying-card__front::before {
    content: ''; position: absolute; inset: 0; border-radius: inherit; opacity: 0.07;
    background:
        radial-gradient(circle at 50% 30%, rgba(212,165,116,0.5) 0%, transparent 50%),
        repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 30deg, rgba(212,165,116,0.15) 30deg 32deg);
    pointer-events: none;
}
/* Angoli decorativi */
.slot-card::after, .flying-card__front::after {
    content: '✦'; position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: flex-end;
    padding: 6px 8px; font-size: 0.5rem; color: rgba(212,165,116,0.2); pointer-events: none;
}
@keyframes slotReveal { from{opacity:0;transform:scale(0.9)} to{opacity:1;transform:scale(1)} }
.slot-card.reversed { border-color: rgba(180,60,60,0.45); box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 30px rgba(180,60,60,0.15), inset 0 0 30px rgba(180,60,60,0.05); }
.slot-card.reversed .ff-sym, .slot-card.reversed .ff-name, .slot-card.reversed .ff-num { transform: rotate(180deg); }

/* Card face styles — gradienti più ricchi */
.slot-card--maggiore, .flying-card__front--maggiore { background: linear-gradient(170deg, #1e0d38 0%, #130730 40%, #0c0420 100%); }
.slot-card--bastoni, .flying-card__front--bastoni { background: linear-gradient(170deg, #201408 0%, #301c0a 50%, #1a0f04 100%); }
.slot-card--coppe, .flying-card__front--coppe { background: linear-gradient(170deg, #0a1e32 0%, #0c1e38 50%, #06142a 100%); }
.slot-card--spade, .flying-card__front--spade { background: linear-gradient(170deg, #1a1c24 0%, #262830 50%, #16181e 100%); }
.slot-card--denari, .flying-card__front--denari { background: linear-gradient(170deg, #221c08 0%, #302808 50%, #1a1604 100%); }

/* Cornice doppia ornamentale */
.ff-frame { position: absolute; inset: 5px; border: 1px solid rgba(212,165,116,0.3); border-radius: 8px; pointer-events: none; }
.ff-frame::before { content:''; position:absolute; inset:3px; border:0.5px solid rgba(212,165,116,0.12); border-radius:6px; }
.ff-frame::after { content:''; position:absolute; inset:-1px; border:0.5px solid rgba(212,165,116,0.08); border-radius:9px; }

/* Numero carta — più elegante */
.ff-num { position: absolute; top: 10px; left: 10px; font-family: 'Cormorant Garamond','Cormorant',serif; font-size: 0.75rem; font-weight: 600; color: rgba(212,165,116,0.5); font-style: italic; }

/* Simbolo SVG — dimensionato e colorato */
.ff-sym { display: inline-block; width: 2.5rem; height: 2.5rem; color: rgba(212,165,116,0.85); margin-bottom: 0.35rem; filter: drop-shadow(0 0 8px rgba(212,165,116,0.35)); }
.ff-sym svg { width: 100%; height: 100%; }
.slot-card--bastoni .ff-sym, .flying-card__front--bastoni .ff-sym { color: rgba(230,140,60,0.9); filter: drop-shadow(0 0 10px rgba(230,140,60,0.3)); }
.slot-card--coppe .ff-sym, .flying-card__front--coppe .ff-sym { color: rgba(100,180,230,0.9); filter: drop-shadow(0 0 10px rgba(100,180,230,0.3)); }
.slot-card--spade .ff-sym, .flying-card__front--spade .ff-sym { color: rgba(180,190,210,0.9); filter: drop-shadow(0 0 10px rgba(180,190,210,0.3)); }
.slot-card--denari .ff-sym, .flying-card__front--denari .ff-sym { color: rgba(230,200,80,0.9); filter: drop-shadow(0 0 10px rgba(230,200,80,0.3)); }

/* Nome carta — tipografia premium */
.ff-name { font-family: 'Outfit',sans-serif; font-size: 0.5rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(212,165,116,0.85); text-align: center; line-height: 1.3; max-width: 90%; }

/* Orientamento */
.ff-orient { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); font-family: 'Outfit',sans-serif; font-size: 0.4375rem; text-transform: uppercase; letter-spacing: 0.12em; padding: 1px 6px; border-radius: 3px; }
.slot-card:not(.reversed) .ff-orient { color: rgba(100,200,150,0.6); background: rgba(100,200,150,0.08); }
.slot-card.reversed .ff-orient { color: rgba(230,90,90,0.6); background: rgba(230,90,90,0.08); }

/* ============================================
   MAZZO A VENTAGLIO
   ============================================ */
.deck-area { text-align: center; padding: 1rem 0 3rem; animation: msgIn 0.5s ease; }
.deck-area__hint { font-size: 0.9375rem; color: rgba(245,240,235,0.6); margin-bottom: 2.5rem; transition: all 0.3s; }
.deck-fan { position: relative; height: 260px; display: flex; justify-content: center; align-items: flex-start; }

.deck-card {
    position: absolute; width: 82px; height: 136px;
    transform-origin: center 300px;
    transform: rotate(var(--angle));
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
    animation: deckDeal 0.5s ease backwards;
    animation-delay: calc(var(--i) * 0.02s);
}
@keyframes deckDeal { from{opacity:0;transform:rotate(var(--angle)) translateY(40px)} to{opacity:1;transform:rotate(var(--angle))} }
.deck-card:hover { transform: rotate(var(--angle)) translateY(-30px) scale(1.1); z-index: 100 !important; }
.deck-card.picked { pointer-events: none; }

.deck-card__inner { width: 100%; height: 100%; }
.deck-card__back {
    width: 100%; height: 100%; border-radius: 10px;
    background: linear-gradient(145deg, #1a0a2e 0%, #0d0620 100%);
    border: 1.5px solid rgba(212,165,116,0.3);
    display: flex; align-items: center; justify-content: center; position: relative;
    box-shadow: 0 3px 16px rgba(0,0,0,0.5);
}
.deck-card__back-border { position: absolute; inset: 5px; border: 1px solid rgba(212,165,116,0.2); border-radius: 7px; }
.deck-card__back-sym { font-size: 1.5rem; color: rgba(212,165,116,0.45); text-shadow: 0 0 12px rgba(212,165,116,0.3); }
.deck-card:hover .deck-card__back { border-color: rgba(212,165,116,0.6); box-shadow: 0 8px 30px rgba(107,33,168,0.4), 0 0 40px rgba(212,165,116,0.15); }

/* ============================================
   FLYING CARD (volo verso slot)
   ============================================ */
.flying-card { position: fixed; z-index: 500; pointer-events: none; }
.flying-card.flying { transition: transform 0.7s cubic-bezier(0.5, 0, 0.2, 1); }
.flying-card__inner { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(0.4,0,0.2,1); }
.flying-card__inner.flipped { transform: rotateY(180deg); }
.flying-card__inner.flipped.reversed { transform: rotateY(180deg) rotate(180deg); }
.flying-card__back, .flying-card__front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 10px; overflow: hidden; }
.flying-card__back { background: linear-gradient(145deg,#1a0a2e,#0d0620); border: 1.5px solid rgba(212,165,116,0.35); display: flex; align-items: center; justify-content: center; }
.flying-card__front { transform: rotateY(180deg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px; border: 1.5px solid rgba(212,165,116,0.5); box-shadow: 0 0 40px rgba(107,33,168,0.3), inset 0 0 30px rgba(212,165,116,0.06); position: relative; overflow: hidden; }

/* ============================================
   INPUT follow-up
   ============================================ */
.consulto__input-area { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(10,10,15,0.95); backdrop-filter: blur(12px); border-top: 1px solid rgba(255,255,255,0.04); padding: 1rem 0; z-index: 30; }
.consulto__form { display: flex; gap: 0.75rem; align-items: flex-end; max-width: 780px; margin: 0 auto; }
.consulto__input { flex: 1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 0.75rem 1rem; color: #F5F0EB; font-size: 0.9375rem; outline: none; resize: none; max-height: 120px; font-family: 'Inter',sans-serif; }
.consulto__input::placeholder { color: rgba(245,240,235,0.3); }
.consulto__input:focus { border-color: #A78BFA; }
.consulto__send { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg,#D4A574,#B8860B); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #0A0A0F; }
.consulto__send:hover { box-shadow: 0 0 16px rgba(212,165,116,0.3); }
.consulto__send:disabled { opacity: 0.4; }
.consulto__disclaimer { text-align: center; font-size: 0.6875rem; color: rgba(245,240,235,0.3); margin-top: 0.5rem; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .stesa-choice { grid-template-columns: 1fr; }
    .deck-card { width: 62px; height: 104px; }
    .chat-msg { max-width: 92%; }
    .slots-area--7 .card-slot { width: 70px; height: 116px; }

    /* Campo followup compatto su mobile */
    .consulto__input { font-size: 0.8125rem; padding: 0.6rem 0.75rem; }
    .consulto__send { width: 38px; height: 38px; }

    /* Voce-control: posizionato in alto a destra nell'header */
    .consulto__header .container { position: relative; }
    .voce-control {
        position: absolute;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        margin-left: 0;
    }
}
@media (max-width: 480px) {
    .card-slot { width: 82px; height: 135px; }
    .deck-fan { height: 160px; }
    .deck-card { width: 52px; height: 88px; transform-origin: center 200px; }
    .ff-sym { font-size: 1.5rem; }
}


/* ============================================================
   VOCE DELLA CARTOMANTE — avatar, controllo, respiro, immersivo
   ============================================================ */

/* Avatar nell'header guida */
.consulto__guida { display: flex; align-items: center; gap: 0.6rem; flex-wrap: nowrap; flex-direction: row; }
.consulto__avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background-size: cover; background-position: center;
    background-color: #1a1230;
    flex: 0 0 40px;
    box-shadow: 0 0 0 2px rgba(167,139,250,0.25), 0 0 14px -4px rgba(167,139,250,0.5);
    transition: box-shadow 0.4s ease, transform 0.4s ease, opacity 0.3s ease;
    display: none;
    align-self: center;
}
.consulto__avatar.is-ready {
    display: inline-flex;
    vertical-align: middle;
}

/* Avatar accanto al messaggio parlato */
.chat-msg--voce { display: flex; align-items: flex-start; gap: 0.7rem; }
.chat-msg__avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background-size: cover; background-position: center;
    background-color: #1a1230;
    flex: 0 0 auto;
    margin-top: 2px;
    box-shadow: 0 0 0 2px rgba(167,139,250,0.22), 0 0 16px -6px rgba(167,139,250,0.6);
    transition: box-shadow 0.4s ease, transform 0.4s ease;
}

/* Respiro luminoso mentre parla */
.consulto__avatar.is-speaking,
.chat-msg--voce.is-focus .chat-msg__avatar {
    animation: voceBreath 2.4s ease-in-out infinite;
}
@keyframes voceBreath {
    0%,100% { transform: scale(1);    box-shadow: 0 0 0 2px rgba(212,165,116,0.30), 0 0 16px -4px rgba(167,139,250,0.55); }
    50%     { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(212,165,116,0.55), 0 0 30px 0   rgba(167,139,250,0.85); }
}

/* Testo con cursore typing */
.voce-text { white-space: pre-wrap; }
.voce-text.is-typing::after {
    content: '';
    display: inline-block;
    width: 2px; height: 1.05em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: var(--oro, #D4A574);
    animation: voceCaret 1s steps(1) infinite;
}
@keyframes voceCaret { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }

/* Controllo audio elegante */
.voce-control {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(167,139,250,0.2);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.voce-btn {
    display: grid; place-items: center;
    width: 30px; height: 30px;
    padding: 0; border: none; border-radius: 50%;
    background: transparent;
    color: var(--viola-light, #A78BFA);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.voce-btn svg { width: 17px; height: 17px; }
.voce-btn:hover:not(:disabled) { background: rgba(167,139,250,0.16); color: #fff; transform: translateY(-1px); }
.voce-btn:disabled { opacity: 0.35; cursor: default; }
.voce-control.is-off .voce-btn[data-act="toggle"] { color: rgba(255,255,255,0.4); }

/* ---- Modalità immersiva: il resto si attenua, luce su avatar/messaggio/carte ---- */
#consultoApp .consulto__header,
#consultoApp .consulto__input-area,
#consultoApp .chat-msg {
    transition: opacity 0.6s ease, filter 0.6s ease;
}
#consultoApp.is-immersive .consulto__header,
#consultoApp.is-immersive .consulto__input-area,
#consultoApp.is-immersive .chat-msg:not(.is-focus) {
    opacity: 0.3;
    filter: blur(0.6px);
}
#consultoApp.is-immersive .chat-msg--voce.is-focus .chat-msg__bubble {
    box-shadow: 0 0 44px -6px rgba(124,58,237,0.45);
}

@media (prefers-reduced-motion: reduce) {
    .consulto__avatar.is-speaking,
    .chat-msg--voce.is-focus .chat-msg__avatar { animation: none; }
    .voce-text.is-typing::after { animation: none; opacity: 0; }
}
