/* ========================================
   webar.css - Stili per il modal WebAR
   ======================================== */

/* Bottone AR nella Hero Section */
.hero-ar-button {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 999;
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-ar-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.hero-ar-button::before {
    content: "📱";
    font-size: 20px;
}

/* Modal WebAR Overlay */
.webar-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.webar-modal-overlay.active {
    display: flex;
}

/* WebAR Container */
.webar-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Close Button */
.webar-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2001;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.webar-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

/* Scanning Overlay */
.webar-scanning-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 2002;
    pointer-events: none;
}

.webar-scanning-overlay.hidden {
    display: none;
}

.scanning-animation {
    width: 100px;
    height: 100px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.scanning-text {
    font-size: 18px;
    opacity: 0.8;
}

/* Instruction Panel */
.webar-instructions {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 15px;
    color: white;
    text-align: center;
    z-index: 2002;
}

.webar-instructions p {
    margin: 0;
    font-size: 14px;
}

/* ========================================
   AR Experience — overlay avatar + fumetto + frecce
   (ar-experience.js). L'overlay lascia passare i click (pointer-events:none):
   solo l'avatar e le frecce sono cliccabili.
   ======================================== */
.ar-overlay {
    position: absolute;
    inset: 0;
    z-index: 2003;
    pointer-events: none;
    display: none;
}

.ar-overlay.active {
    display: block;
}

/* Palco avatar: default fisso in alto-centro. In .follow lo posiziona JS
   (left/top inline) proiettando il marker a schermo. */
.ar-avatar-stage {
    position: absolute;
    left: 50%;
    top: 12%;
    transform: translateX(-50%);
    width: 150px;
    pointer-events: none;
}

.ar-avatar-stage.follow {
    top: 0;
    /* JS imposta left/top ad ogni frame; l'ancora sta SOPRA il marker. */
    transform: translate(-50%, -100%);
    transition: opacity 0.15s ease;
}

.ar-avatar-canvas {
    width: 150px;
    height: 200px;
    position: relative;
}

.ar-avatar-canvas canvas {
    background: transparent !important;
}

.ar-avatar-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    font-size: 12px;
    opacity: 0.8;
}

/* Bottone trasparente sopra l'avatar: cattura il click "start". */
.ar-avatar-hit {
    position: absolute;
    inset: 0;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
}

/* Fumetto "click me to start" */
.ar-speech-bubble {
    position: absolute;
    bottom: calc(100% - 6px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: #fff;
    color: #222;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ar-speech-bubble.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    animation: ar-bubble-bounce 1.6s ease-in-out infinite;
}

.ar-speech-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #fff;
}

@keyframes ar-bubble-bounce {
    0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
    50% { transform: translateX(-50%) translateY(-4px) scale(1); }
}

/* Frecce sezioni (compaiono a fine audio) */
.ar-arrows {
    position: absolute;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 92vw;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.ar-arrows.show {
    opacity: 1;
    pointer-events: auto;
}

.ar-arrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: ar-arrow-in 0.4s ease both;
}

.ar-arrow:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(102, 126, 234, 0.65);
}

.ar-arrow-ico {
    font-size: 16px;
    transform: rotate(-90deg); /* punta verso l'alto/sezione */
}

@keyframes ar-arrow-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile: avatar e frecce piu' compatti */
@media (max-width: 600px) {
    .ar-avatar-stage { width: 120px; }
    .ar-avatar-canvas { width: 120px; height: 160px; }
    .ar-arrow { padding: 8px 12px; font-size: 12px; }
    .ar-arrows { bottom: 80px; gap: 8px; }
}