/* Sceneggiatore: scena a dialoghi in stile JRPG 16 bit (vedi sceneggiatore.php / assets/js/sceneggiatore.js).
   Tutte le misure del palco sono in cqw (percentuale della larghezza del palco), cosi' la scena
   scala in blocco su telefono, desktop e schermo intero. */

.scena { max-width: 60rem; margin: 0 auto; }
.scena:fullscreen { max-width: none; display: flex; flex-direction: column; justify-content: center; background: #000; }

.scena__stage {
    position: relative;
    aspect-ratio: 4 / 3;
    container-type: inline-size;
    overflow: hidden;
    background: #000;
    border: 3px solid #0c1040;
    border-radius: 6px;
    font-family: 'DotGothic16', 'MS Gothic', monospace;
    color: #fff;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.scena:fullscreen .scena__stage { width: min(100vw, calc((100vh - 4.5rem) * 4 / 3)); margin: 0 auto; border-radius: 0; }
.scena__stage:focus-visible { outline: 3px solid #f8e9aa; outline-offset: 2px; }

.scena__bg { position: absolute; inset: 0; background-size: cover; background-position: center; }

/* Finestra blu con bordo bianco, come nei menu SNES */
.scena__window,
.scena__bubble {
    background: linear-gradient(180deg, #2c43c8 0%, #101a74 100%);
    border: .4cqw solid #fff;
    border-radius: 1.3cqw;
    box-shadow: 0 0 0 .3cqw #14143c, .7cqw .7cqw 0 .3cqw rgba(0, 0, 0, .45);
    text-shadow: .15cqw .15cqw 0 #000;
}

/* Personaggi */
.scena__cast {
    position: absolute; left: 2cqw; right: 2cqw; bottom: 2.4cqw;
    display: flex; justify-content: center; align-items: flex-end; gap: 2cqw;
    pointer-events: none;
}
.scena__actor {
    width: var(--aw, 16cqw); flex: 0 0 auto;
    transition: transform .2s ease, filter .2s ease;
}
.scena__actor.is-entering { animation: scena-enter .28s ease-out; }
@keyframes scena-enter { from { opacity: 0; transform: translateY(3cqw); } }
.scena__actor.is-dim { filter: brightness(.5) saturate(.75); }
.scena__actor.is-active { transform: translateY(-1.4cqw); }
.scena__frame {
    background: #101a74;
    border: .45cqw solid #fff;
    border-radius: 1cqw;
    box-shadow: 0 0 0 .3cqw #14143c, .6cqw .6cqw 0 .3cqw rgba(0, 0, 0, .45);
    overflow: hidden;
}
.scena__actor.is-active .scena__frame { border-color: #f8e9aa; }
/* Citato nel segmento in corso: acceso come chi parla, ma senza sollevarsi e con cornice azzurra. */
.scena__actor.is-mentioned .scena__frame { border-color: #8fd3ff; box-shadow: 0 0 0 .3cqw #14143c, 0 0 1.6cqw .4cqw rgba(143, 211, 255, .65), .6cqw .6cqw 0 .3cqw rgba(0, 0, 0, .45); }
.scena__frame img { display: block; width: 100%; height: auto; max-height: 30cqw; object-fit: cover; object-position: top; }
.scena__initial {
    display: flex; align-items: center; justify-content: center;
    aspect-ratio: 1; font-size: calc(var(--aw, 16cqw) * .5); color: #fff; text-shadow: .2cqw .2cqw 0 rgba(0, 0, 0, .5);
}
.scena__name {
    padding: .3cqw .5cqw .4cqw; text-align: center; font-size: max(9px, 1.9cqw); line-height: 1.2;
    background: #0a1050; border-top: .3cqw solid #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-shadow: .12cqw .12cqw 0 #000;
}

/* Fumetto */
.scena__bubble {
    position: absolute; width: 58cqw; box-sizing: border-box;
    padding: 1.6cqw 2.2cqw 2cqw;
    font-size: max(11px, 2.1cqw); line-height: 1.5;
    pointer-events: none; z-index: 5;
}
.scena__bubble[hidden] { display: none; }
.scena__bubble-text { min-height: 3.1em; word-break: break-word; }
.scena__c { visibility: hidden; }
.scena__c.on { visibility: visible; }
.scena__it { color: #a8d4ff; font-style: italic; }
.scena__tail {
    position: absolute; bottom: -1.5cqw; width: 2.4cqw; height: 2.4cqw; margin-left: -1.2cqw;
    background: #101a74; border-right: .4cqw solid #fff; border-bottom: .4cqw solid #fff;
    transform: rotate(45deg); box-sizing: border-box;
}
.scena__more { position: absolute; right: 1.6cqw; bottom: .4cqw; font-size: 2cqw; animation: scena-blink .8s steps(2) infinite; visibility: hidden; }
.scena__bubble.is-done .scena__more { visibility: visible; }
@keyframes scena-blink { 50% { opacity: 0; } }

/* Narrazione, Fato e sussurri: nessun parlante, finestra centrata in alto */
.scena__bubble--narr .scena__tail,
.scena__bubble--fato .scena__tail,
.scena__bubble--sussurro .scena__tail { display: none; }
.scena__bubble--narr { text-align: center; }
.scena__bubble--fato { text-align: center; color: #f8e9aa; border-color: #f8e9aa; background: linear-gradient(180deg, #5a1a1a 0%, #2a0a0a 100%); }
.scena__bubble--sussurro { text-align: center; font-style: italic; opacity: .92; background: linear-gradient(180deg, #44486a 0%, #22244a 100%); }

/* Schermate di titolo e di fine */
.scena__overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); }
.scena__overlay[hidden] { display: none; }
.scena__window--title { padding: 3cqw 5cqw; text-align: center; max-width: 80cqw; cursor: default; }
.scena__title { margin: 0 0 1cqw; font-size: max(16px, 4cqw); line-height: 1.25; }
.scena__subtitle { margin: 0 0 2cqw; font-size: max(11px, 2.2cqw); color: #a8d4ff; }
.scena__btn {
    font: inherit; font-size: max(13px, 2.6cqw); color: #14143c; background: #f8e9aa; border: .3cqw solid #fff;
    border-radius: 1cqw; padding: .8cqw 2.4cqw; cursor: pointer; box-shadow: .4cqw .4cqw 0 rgba(0, 0, 0, .5);
}
.scena__btn:hover { background: #fff4c4; }

/* Barra dei controlli sotto il palco */
.scena__controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .5rem; }
.scena:fullscreen .scena__controls { width: min(100vw, calc((100vh - 4.5rem) * 4 / 3)); margin: .5rem auto 0; }
.scena__ctl {
    font-family: 'DotGothic16', monospace; background: #101a74; color: #fff; border: 2px solid #fff; border-radius: 6px;
    padding: .15rem .7rem; min-width: 2.4rem; line-height: 1.6; cursor: pointer;
}
.scena__ctl:hover { background: #2c43c8; }
.scena__ctl[aria-pressed="true"] { background: #f8e9aa; color: #14143c; }
.scena__counter { font-family: 'DotGothic16', monospace; color: var(--ink-soft, #4d7285); padding: 0 .4rem; }
.scena__hint { font-size: .8rem; color: var(--ink-soft, #4d7285); margin: .4rem 0 0; }
.scena:fullscreen .scena__hint { display: none; }
.scena:fullscreen .scena__counter { color: #a8d4ff; }

/* Selettori di sfondo e musica */
.scena-bgpicker { display: flex; flex-wrap: wrap; gap: .75rem; }
.scena-bgpicker__item { position: relative; display: block; width: 180px; cursor: pointer; text-align: center; }
.scena-bgpicker__item input { position: absolute; opacity: 0; }
.scena-bgpicker__item img { display: block; width: 100%; height: auto; border: 3px solid transparent; border-radius: 6px; }
.scena-bgpicker__item input:checked + img { border-color: #1f6f8b; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1f6f8b; }
.scena-bgpicker__item input:focus-visible + img { outline: 2px solid #f8e9aa; outline-offset: 2px; }
.scena-musicpicker { display: flex; flex-direction: column; gap: .5rem; }
.scena-musicpicker__item { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; cursor: pointer; }
.scena-musicpicker__item audio { height: 32px; max-width: 100%; }
