/* Totem Buttons Manager - griglia home totem */

.totem-wrap {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--tb-pad, 16px);
    background: var(--tb-bg, #fff);
}

.totem-wrap * {
    box-sizing: border-box;
}

.totem-wrap.is-fullscreen {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
}

.totem-grid {
    display: grid;
    grid-template-columns: repeat(var(--tb-cols, 4), minmax(0, 1fr));
    gap: var(--tb-gap, 16px);
    width: 100%;
}

/* In fullscreen la griglia non deve mai superare l'altezza dello schermo:
   lato tessera = (altezza utile - somma gap) / righe */
.totem-wrap.is-fullscreen .totem-grid {
    max-width: calc(
        (
            (100dvh - (2 * var(--tb-pad, 16px)) - ((var(--tb-rows, 2) - 1) * var(--tb-gap, 16px))) / var(--tb-rows, 2)
        ) * var(--tb-cols, 4) + ((var(--tb-cols, 4) - 1) * var(--tb-gap, 16px))
    );
}

.totem-tile {
    position: relative;
    display: flex;
    align-items: flex-end;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--tb-radius, 12px);
    background-color: #e9e9e9;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease;
    -webkit-tap-highlight-color: transparent;
}

a.totem-tile:hover,
a.totem-tile:focus-visible {
    transform: scale(1.015);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}

a.totem-tile:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

a.totem-tile:active {
    transform: scale(.985);
}

.totem-veil {
    position: absolute;
    inset: 0;
    display: block;
    pointer-events: none;
}

.totem-text {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    padding: 6%;
    color: inherit;
    text-align: center;
    line-height: 1.15;
}

.totem-title {
    display: block;
    font-size: clamp(16px, 2.4vw, 40px);
    font-weight: 700;
    letter-spacing: -.01em;
}

.totem-sub {
    display: block;
    margin-top: .3em;
    font-size: clamp(12px, 1.3vw, 22px);
    font-weight: 400;
    opacity: .9;
}

/* Totem in verticale: griglia ribaltata */
@media (max-aspect-ratio: 1/1) {
    .totem-grid {
        grid-template-columns: repeat(var(--tb-cols-p, 2), minmax(0, 1fr));
    }

    .totem-wrap.is-fullscreen .totem-grid {
        max-width: calc(
            (
                (100dvh - (2 * var(--tb-pad, 16px)) - ((var(--tb-rows-p, 4) - 1) * var(--tb-gap, 16px))) / var(--tb-rows-p, 4)
            ) * var(--tb-cols-p, 2) + ((var(--tb-cols-p, 2) - 1) * var(--tb-gap, 16px))
        );
    }

    .totem-title {
        font-size: clamp(15px, 4.2vw, 34px);
    }

    .totem-sub {
        font-size: clamp(11px, 2.4vw, 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .totem-tile {
        transition: none;
    }

    a.totem-tile:hover,
    a.totem-tile:active,
    a.totem-tile:focus-visible {
        transform: none;
    }
}

/* -----------------------------------------------------------------
   Video di attesa (1.4.2 - 02/09/2026)
   ----------------------------------------------------------------- */

.totem-idle {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    background: #000;
    -webkit-tap-highlight-color: transparent;
}

.totem-idle.is-on {
    display: block;
}

.totem-idle-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    pointer-events: none;
}

/* YouTube: l'iframe copre lo schermo e non riceve tocchi, cosi' il tocco
   arriva all'overlay che chiude il video. Nessun comando raggiungibile. */
.totem-idle-frame {
    display: block;
    width: 100vw;
    height: 100vh;
    border: 0;
    background: #000;
    pointer-events: none;
}

/* Il 16:9 di YouTube su uno schermo verticale lascerebbe bande enormi:
   si ingrandisce finche' riempie, tagliando i lati. */
.totem-idle-youtube {
    overflow: hidden;
}

.totem-idle-youtube .totem-idle-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 177.78vh;   /* 16/9 dell'altezza */
    min-width: 100vw;
    height: 56.25vw;   /* 9/16 della larghezza */
    min-height: 100vh;
    transform: translate(-50%, -50%);
}
