/* =====================================================
   WHAT?studio v2 — Signature moment #1
   Scanner: confronto interattivo prima/dopo (Product Scan 360°)
   Nessuna libreria. Reveal via --pos (0–100) impostata da scanner.js.
   ===================================================== */

/* la sezione segue subito il page-hero: niente doppio respiro, lo stage sale su */
.scan-section { padding-top: 0; }
.scan-section .section-head { margin-bottom: var(--space-8); max-width: 62ch; }

.scanner {
    --pos: 60%;              /* posizione scan-line, riscritta da JS in % */
    --beam-w: 2px;
    --glow: 44px;
    max-width: var(--container);
    margin-inline: auto;
}

/* ---------- Stage ---------- */
.scanner__stage {
    position: relative;
    aspect-ratio: 16 / 9;
    max-height: 72vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    cursor: ew-resize;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    isolation: isolate;
}
/* vignetta: tiene insieme la cornice anche con immagini scure */
.scanner__stage::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.55);
}
.scanner__stage:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 3px;
}

/* ---------- Layer prima / dopo ---------- */
.scanner__layer { position: absolute; inset: 0; }
.scanner__layer img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-user-drag: none;
}

/* DOPO sta sopra, rivelato da sinistra fino a --pos */
.scanner__layer--after {
    clip-path: inset(0 calc(100% - var(--pos)) 0 0);
    will-change: clip-path;
}
/* micro-parallax: il "mondo" dopo respira mentre lo riveli */
.scanner__layer--after img { transform: scale(1.06); }

/* ---------- Etichette ---------- */
.scanner__tag {
    position: absolute;
    bottom: var(--space-4);
    padding: 0.4rem 0.85rem;
    font-size: var(--fs-overline);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    font-weight: 700;
    border-radius: var(--radius-pill);
    background: rgba(10, 10, 15, 0.66);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    z-index: 4;
    pointer-events: none;
}
/* DOPO e' rivelato da sinistra -> etichetta a sinistra; PRIMA resta a destra */
.scanner__tag--after  { left: var(--space-4); color: #fff; border-color: var(--red); }
.scanner__tag--before { right: var(--space-4); color: var(--text-secondary); }
@media (prefers-reduced-transparency: reduce) {
    .scanner__tag { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ---------- Scan beam ---------- */
.scanner__beam {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--pos);
    width: 0;
    z-index: 3;
    pointer-events: none;
}
/* nucleo linea + glow */
.scanner__beam::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--beam-w) / -2);
    width: var(--beam-w);
    background: var(--red);
    box-shadow:
        0 0 var(--glow) 4px var(--red-glow),
        0 0 12px 1px rgba(255, 0, 0, 0.8);
}
/* banda "digitalizzazione": grana che scorre sul filo */
.scanner__beam::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--beam-w) / -2);
    width: 90px;
    background:
        repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0 1px, transparent 1px 4px),
        linear-gradient(90deg, rgba(255, 0, 0, 0.22), transparent 78%);
    mix-blend-mode: screen;
    animation: scan-grain 0.5s steps(4) infinite;
}
@keyframes scan-grain { to { background-position: 0 8px, 0 0; } }

.scanner__handle {
    position: absolute;
    top: 50%;
    left: 0;
    translate: -50% -50%;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(10, 10, 15, 0.72);
    border: 1.5px solid var(--red);
    box-shadow: 0 0 24px var(--red-glow), var(--shadow-md);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
}
.scanner__handle svg { display: block; }

/* ---------- Piede: hint ---------- */
.scanner__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-6);
}
.scanner__hint {
    font-size: var(--fs-small);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    transition: opacity var(--dur) var(--ease);
}
.scanner__hint::before {
    content: "";
    width: 26px;
    height: 1px;
    background: var(--red);
    animation: scrollcue 1.8s var(--ease-in-out) infinite;
}
.scanner.is-touched .scanner__hint { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
    .scanner__beam::after,
    .scanner__hint::before { animation: none; }
}
@media (max-width: 640px) {
    .scanner__stage { aspect-ratio: 4 / 5; }
    .scanner__handle { width: 44px; height: 44px; }
}
