/*
 * Highlights della scheda prodotto (webshop/views/prodotti/dettaglio.twig, #tabHighlights): le slide dalla seconda
 * in poi come mosaico, con la galleria a schermo intero (js/highlights.js). In fondo, le schede del tab Manuals.
 * Il mosaico è fatto di blocchi 2 x 2 sempre pieni (Twig\HighlightLayoutExtension): due per riga da 768px, uno sotto.
 * Dentro un blocco: large 2 x 2, wide 2 x 1, tall 1 x 2, small 1 x 1. "row" è l'ultimo blocco quando sono dispari
 * (4 x 1 a tutta riga su desktop, un blocco normale su mobile); "single" è l'unico highlight, centrato e con la foto intera.
 */
.hl {
    margin: 8px 0 24px;
    --gap: 8px;
}
.hl-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--gap);
}
.hl-block {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    grid-auto-flow: dense;
    gap: var(--gap);
    aspect-ratio: 4 / 3; /* celle 4:3, le proporzioni della maggior parte delle foto prodotto */
}
.hl-block--single {
    display: block;
    aspect-ratio: auto;
}
@media (min-width: 768px) {
    .hl {
        --gap: 12px;
    }
    .hl-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .hl-block--row,
    .hl-block--single {
        grid-column: 1 / -1;
    }
    .hl-block--row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-template-rows: minmax(0, 1fr);
        aspect-ratio: 16 / 3;
    }
}

.hl-tile {
    position: relative;
    isolation: isolate; /* la didascalia (z-index 1) resta dentro il riquadro: niente sopra la barra fissa Configure */
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #fff;
    text-align: left;
    background: #fff;
    border: 1px solid #333; /* stacca dal fondo nero anche le foto molto scure */
    border-radius: 6px;
    cursor: zoom-in;
}
.hl-tile--large {
    grid-column: span 2;
    grid-row: span 2;
}
.hl-tile--wide {
    grid-column: span 2;
}
.hl-tile--tall {
    grid-row: span 2;
}
/* un solo highlight: riquadro centrato, alto quanto serve per la foto intera (--ratio = larghezza / altezza) */
.hl-tile--single {
    width: min(100%, 960px, 620px * var(--ratio, 1.5)); /* al massimo 620px di altezza: le foto quadrate restano in vista */
    height: auto;
    margin: 0 auto;
    aspect-ratio: var(--ratio, 1.5);
}
.hl-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s ease;
}
.hl-tile:focus-visible {
    outline: 2px solid #0deaf1;
    outline-offset: 2px;
}

/* didascalia sul fondo della foto, stessa misura su tutti i riquadri: se non sta, si tronca (3 righe nei riquadri
   grandi, 2 negli altri); il testo intero è nella galleria. Il contenitore fa sfumatura e margini, il testo il taglio */
.hl-tile__caption {
    position: absolute;
    inset: auto 0 0;
    z-index: 1;
    padding: 64px 18px 16px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
}
.hl-tile__text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.hl-tile--large .hl-tile__text,
.hl-tile--single .hl-tile__text {
    -webkit-line-clamp: 3;
}
/* slide solo testo: riquadro scuro con il testo in evidenza */
.hl-tile--text {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #111;
    border: 1px solid #222;
}
.hl-tile--text .hl-tile__caption {
    position: static;
    padding: 0;
    font-size: 18px;
    text-align: center;
    background: none;
}
.hl-tile--text .hl-tile__text {
    -webkit-line-clamp: 6;
}
@media (hover: hover) {
    .hl-tile:hover img {
        transform: scale(1.04);
    }
}
@media (max-width: 767px) {
    .hl-tile__caption {
        padding: 48px 12px 10px;
        font-size: 17px;
    }
}

/* ---------- Galleria a schermo intero ---------- */
.hl-lightbox {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    color: #fff;
    background: rgba(0, 0, 0, 0.96);
    border: 0;
}
.hl-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.85);
}
.hl-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}
.hl-lightbox__figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(1200px, calc(100vw - 200px));
    margin: 0;
}
.hl-lightbox__img {
    max-width: 100%;
    max-height: calc(100dvh - 230px);
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    user-select: none;
    transition: opacity .25s ease;
}
/* la foto nuova entra in dissolvenza (classe messa da js/highlights.js finché non è caricata) */
.hl-lightbox__img.is-loading {
    opacity: 0;
}
.hl-lightbox__caption {
    max-width: 760px;
    margin-top: 20px;
    font-size: var(--subtitle-size, 18px);
    line-height: var(--subtitle-line-height, 1.5);
    text-align: center;
}
.hl-lightbox__caption:empty {
    display: none;
}
.hl-lightbox__caption p {
    margin: 0 0 8px;
}
.hl-lightbox__caption p:last-child {
    margin-bottom: 0;
}
.hl-lightbox__counter {
    position: absolute;
    top: 22px;
    left: 24px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
}

.hl-lightbox__btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #fff;
    line-height: 1;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}
.hl-lightbox__btn:focus-visible {
    outline: 2px solid #0deaf1;
    outline-offset: 3px;
}
.hl-lightbox__btn[hidden] {
    display: none;
}
/* chiusura: rossa, ben visibile in alto a destra */
.hl-lightbox__btn--close {
    top: 16px;
    right: 20px;
    width: 48px;
    height: 48px;
    font-size: 22px;
    background: red;
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.35);
}
.hl-lightbox__btn--close:hover,
.hl-lightbox__btn--close:focus-visible {
    background: #ff3b3b;
    transform: rotate(90deg);
}
/* frecce: cerchi scuri traslucidi con bordo sottile, si riempiono di blu al passaggio */
.hl-lightbox__btn--prev,
.hl-lightbox__btn--next {
    top: calc(50% - 32px);
    width: 64px;
    height: 64px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
}
.hl-lightbox__btn--prev:hover,
.hl-lightbox__btn--next:hover,
.hl-lightbox__btn--prev:focus-visible,
.hl-lightbox__btn--next:focus-visible {
    background: blue;
    border-color: blue;
    transform: scale(1.08);
}
.hl-lightbox__btn--prev {
    left: 32px;
}
.hl-lightbox__btn--next {
    right: 32px;
}
@media (max-width: 767px) {
    .hl-lightbox__figure {
        max-width: calc(100vw - 24px);
    }
    .hl-lightbox__img {
        max-height: calc(100dvh - 280px);
    }
    .hl-lightbox__caption {
        padding: 0 8px;
        font-size: 15px;
    }
    .hl-lightbox__btn--close {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }
    /* frecce in basso, a portata di pollice */
    .hl-lightbox__btn--prev,
    .hl-lightbox__btn--next {
        top: auto;
        bottom: 24px;
        width: 56px;
        height: 56px;
    }
    .hl-lightbox__btn--prev {
        left: calc(50% - 68px);
    }
    .hl-lightbox__btn--next {
        right: calc(50% - 68px);
    }
}
@media (prefers-reduced-motion: reduce) {
    .hl-tile img,
    .hl-lightbox__img,
    .hl-lightbox__btn {
        transition: none;
    }
}

/* ---------- Tab Manuals: una scheda per documento ---------- */
.pd-docs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 440px));
    justify-content: center; /* con uno o due documenti le schede restano di misura, centrate */
    gap: 14px;
    max-width: 960px;
    margin: 24px auto 40px;
}
.pd-doc {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(180deg, #161616 0%, #0d0d0d 100%);
    border: 1px solid #262626;
    border-radius: 10px;
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.pd-doc:hover,
.pd-doc:focus-visible {
    color: #fff;
    border-color: #0deaf1;
    box-shadow: 0 10px 30px rgba(13, 234, 241, 0.12);
    transform: translateY(-2px);
    outline: none;
}
.pd-doc__icon {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    color: #fff;
    font-size: 24px;
    background: blue;
    border-radius: 10px;
}
.pd-doc__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.pd-doc__type {
    color: #0deaf1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.pd-doc__name {
    overflow: hidden;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.pd-doc__action {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid blue;
    border-radius: 6px;
    transition: background-color .2s ease;
}
.pd-doc:hover .pd-doc__action,
.pd-doc:focus-visible .pd-doc__action {
    background: blue;
}
.pd-docs__empty {
    grid-column: 1 / -1;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
}
@media (max-width: 575px) {
    .pd-doc {
        padding: 14px;
        gap: 12px;
    }
    .pd-doc__icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .pd-doc__action {
        padding: 6px 10px;
        font-size: 0;
        gap: 0;
    }
    .pd-doc__action i {
        font-size: 14px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .pd-doc {
        transition: none;
    }
}
