/* Proposta isolata per la scheda e l'offerta. Usa i testi e le immagini della pagina. */
@media screen {
    html[data-fascia-mobile] {
        --fascia-lato: clamp(14px, 4.6vw, 22px);
        --fascia-inchiostro: #123750;
        --fascia-link: #174e72;
        --fascia-linea: #dce5eb;
    }
    html[data-fascia-contatto] body #customer-contact-sticky:not([hidden]) {
        display: flex; align-items: center; justify-content: center;
        min-height: 48px; padding: 8px 12px; gap: 0; text-align: center !important;
        font-size: 14px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere;
    }
    html[data-fascia-contatto] body #customer-contact-sticky > .fa { display: none !important; }
    html[data-fascia-contatto] body #customer-contact-sticky > span:not(.fa) { text-align:center; }
    /* Sui telefoni orizzontali più bassi si conserva la griglia compatta del sito. */
    html[data-fascia-breve] #page :is(.customer-intro,.offer-intro) :is(.customer-summary,.customer-summary-address,.offer-intro-copy,.offer-validity,.has-offerte-new),
    html[data-fascia-breve] #page :is(.customer-intro,.offer-intro) .customer-summary-links a {
        box-shadow:none !important; border-color:transparent !important; border-radius:0 !important;
    }
    html[data-fascia-breve] #page :is(.customer-summary-address,.offer-validity,.has-offerte-new,.customer-summary-links a) { background:transparent !important; }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-page-header,
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-page-header > .container {
        width: 100% !important; max-width: none !important; padding: 0 !important; margin: 0 !important;
        background: #fff; border: 0; box-shadow: none;
    }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-page-header .customer-summary {
        display: flex !important; flex-direction: column; align-items: stretch; justify-content: flex-start;
        gap: 9px !important; margin: 0 !important; padding: 13px var(--fascia-lato) 14px !important;
        border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: #fff;
    }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-actions,
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-actions-inner {
        display: block !important; border: 0 !important; padding: 0 !important; margin: 0 !important;
    }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-actions .customer-summary-links {
        display: flex !important; flex-flow: row wrap; align-items: center; justify-content: flex-start;
        width: 100%; gap: 0 16px !important; padding: 0 !important; margin: 0 0 4px !important; border: 0;
    }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-links > :is(a,.has-offerte-new):not([hidden]),
    html[data-fascia-mobile] #page .customer-intro .title.customer .customer-summary-links #scrollToText,
    html[data-fascia-mobile] #page .fascia-mobile-luogo > a {
        display: inline-flex !important; flex: 0 1 auto !important; align-items: center; justify-content: flex-start;
        gap: 5px !important; grid-column: auto !important; width: auto !important; max-width: 100%;
        min-width: 0 !important; min-height: 44px; height: auto; padding: 2px 0 !important; margin: 0 !important;
        border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: none !important;
        font-size: 14px !important; line-height: 1.3; font-weight: 550; text-align: start !important;
        text-decoration: none; white-space: normal; color: var(--fascia-link) !important;
    }
    html[data-fascia-mobile] #page .customer-summary-links > .has-offerte-new:not([hidden]) { color: #003c70 !important; font-weight: 700; }
    html[data-fascia-mobile] #page .customer-summary-links > .has-offerte-new:is([data-customer-offers="empty"],[style*="display: none"],[style*="display:none"]) { display: none !important; }
    html[data-fascia-mobile] #page :is(.customer-summary-links,.fascia-mobile-luogo) > a > .fa {
        display: inline-flex; align-items: center; justify-content: center; flex: none;
        width: 1em !important; height: 1em !important; font-size: 14px !important; line-height: 1;
        margin: 0; color: var(--fascia-link); background: none; border: 0; border-radius: 0;
    }
    html[data-fascia-mobile] #page :is(.customer-summary-links,.fascia-mobile-luogo) > a:focus-visible,
    html[data-fascia-mobile] #page :is(.customer-summary-links,.fascia-mobile-luogo) > a:hover { text-decoration: underline; }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-contact > button[data-target="#modal-contact-form"] {
        width: 100% !important; min-height: 44px; margin: 0 !important; padding: 8px 12px !important;
        border-radius: 9px; box-shadow: none; font-size: 15px; line-height: 1.35; text-align: center;
    }

    html[data-fascia-mobile="cliente"] #page .customer-intro .customer-summary-identity,
    html[data-fascia-mobile="cliente"] #page .customer-intro .customer-summary-copy { display: block !important; }
    html[data-fascia-mobile="cliente"] #page .customer-intro .customer-summary-portrait { display: none !important; }
    html[data-fascia-mobile="cliente"] #page .customer-intro .fascia-mobile-luogo {
        display: flex; align-items: center; justify-content: space-between; gap: 2px 14px; flex-wrap: wrap;
        padding: 0 0 6px; border-bottom: 1px solid var(--fascia-linea);
    }
    html[data-fascia-mobile="cliente"] #page .customer-intro .fascia-mobile-luogo > .customer-summary-address {
        flex: 1 1 164px; display: block; min-width: 0; margin: 0 !important; padding: 0 !important;
        background: none !important; border: 0 !important; box-shadow: none; border-radius: 0; line-height: 1.4;
    }
    html[data-fascia-mobile="cliente"] #page .fascia-mobile-luogo .customer-summary-address-icon { display: none !important; }
    html[data-fascia-mobile="cliente"] #page .fascia-mobile-luogo .customer-address-street { font-size: 14px; font-weight: 650; color: var(--fascia-inchiostro); }
    html[data-fascia-mobile="cliente"] #page .fascia-mobile-luogo .customer-address-locality { font-size: 13px; color: #405b6b; }
    html[data-fascia-mobile="cliente"] #page .customer-intro .customer-summary-copy > h1 { margin: 0 0 5px; color: var(--fascia-inchiostro); }
    html[data-fascia-mobile="cliente"] #page .customer-cover-caption .customer-summary-name { padding-block: 3px; }

    html[data-fascia-mobile="offerta"] #page .offer-page .offer-intro {
        display: grid; grid-template-columns: minmax(0,1fr) !important; grid-template-rows: minmax(0,1fr) auto !important;
        height: var(--offer-opening-height, calc(100svh - var(--offer-top-offset,60px))) !important;
        min-height: min-content; gap: 0 !important; margin: 0; padding: 0 !important; background: #fff;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro > .offer-intro-main { display: none !important; }
    html[data-fascia-mobile="offerta"] #page .offer-intro > .offer-intro-media:not([hidden]) {
        display: block !important; position: relative; grid-area: 1 / 1; align-self: stretch; min-height: 0 !important; overflow: hidden;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro > .offer-intro-media > a {
        position: absolute !important; inset: 0; display: block; min-height: 0; overflow: hidden; border: 0; border-radius: 0;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro > .offer-intro-media img {
        display: block; width: 100%; height: 100%; max-height: none; object-fit: cover; object-position: center 45%;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-intro-gallery-label {
        position: absolute; inset: clamp(0px, calc(50% - 22px), 10px) 12px auto auto; min-height: 44px; padding: 8px 12px;
        max-width: calc(100% - 24px); margin:0; border-radius: 9px; color:#173c56; background:#fff; font-size:13px; line-height:1.35;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro > .offer-customer-header { grid-area: 2 / 1; align-self: stretch; }
    html[data-fascia-mobile="offerta"] #page .offer-intro:not(.offer-intro-has-photo) { grid-template-rows: auto 1fr !important; }
    html[data-fascia-mobile="offerta"] #page .offer-intro:not(.offer-intro-has-photo) > .offer-customer-header { grid-area: 1 / 1; }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-intro-copy {
        display: flex; flex-flow: row wrap; align-items: center; justify-content: space-between; gap: 1px 10px;
        padding: 0 0 7px !important; margin: 0; border: 0; border-bottom: 1px solid var(--fascia-linea);
        border-radius: 0; box-shadow: none; background: none;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-heading { display: contents; }
    html[data-fascia-mobile="offerta"] #page .offer-intro h1.offer-page-title {
        flex: 0 0 100%; width: 100%; margin: 0; padding: 0; color: var(--fascia-inchiostro); text-align: start;
        font-size: clamp(20px, 5.5vw, 26px) !important; font-weight: 750; line-height: 1.18 !important; letter-spacing: -.024em;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro h1.offer-page-title:is(:lang(zh),:lang(ja),:lang(hi)) {
        line-height:1.5 !important; letter-spacing:normal; padding-block:2px;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-validity.scadenza {
        display: inline-flex; flex: 1 1 auto; align-items:center; gap:6px; min-width:0; max-width:100%;
        padding: 0; margin: 2px 0; border: 0; background: none; border-radius: 0; color:#415d70;
        font-size: 13px !important; line-height: 1.4 !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-details-link {
        display: inline-flex; flex:0 0 auto; gap:6px; min-height:44px; max-width:100%; padding:2px 0; margin:0;
        border:0; border-radius:0; background:none; color:#003c70 !important; font-size:14px; line-height:1.25; font-weight:700;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-title-icon { display: none; }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-identity {
        display: grid !important; grid-template-columns: auto minmax(0,1fr); align-items:center; gap:0 10px;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .offer-without-portrait { grid-template-columns:minmax(0,1fr); }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-portrait:not([hidden]) {
        --offer-portrait-size: 42px; grid-row: 1 / span 2; margin:0; float:none;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-copy { display: contents; }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-name {
        margin:0; font-size:16px !important; line-height:1.27 !important; font-weight:700;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-address {
        grid-column:auto; margin:3px 0 0; padding:0; font-size:13px; line-height:1.4; color:#415d70;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .customer-summary-actions .customer-summary-links { border:0; column-gap:10px !important; }
}
@media screen and (max-height:640px) {
    html[data-fascia-mobile] { --fascia-lato: 12px; }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-page-header .customer-summary {
        padding: 7px var(--fascia-lato) 8px !important; gap: 4px !important;
    }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-actions .customer-summary-links { gap:0 12px !important; margin-bottom:1px !important; }
    html[data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-summary-links > :is(a,.has-offerte-new):not([hidden]),
    html[data-fascia-mobile] #page .customer-intro .title.customer .customer-summary-links #scrollToText,
    html[data-fascia-mobile] #page .fascia-mobile-luogo > a { font-size:13px !important; }
}
@media screen and (orientation:landscape) and (max-height:540px) {
    html[data-fascia-mobile] { --fascia-lato: 11px; }
    html[data-fascia-mobile="offerta"] #page .offer-page .offer-intro {
        grid-template-columns:minmax(0,.65fr) minmax(0,1.35fr) !important; grid-template-rows:minmax(min-content,1fr) !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro > .offer-customer-header { grid-area:1 / 2; align-self:center; }
    html[data-fascia-mobile="offerta"] #page .offer-intro:not(.offer-intro-has-photo) { grid-template-columns:minmax(0,1fr) !important; }
    html[data-fascia-mobile="offerta"] #page .offer-intro:not(.offer-intro-has-photo) > .offer-customer-header { grid-area:1 / 1; }
    html[data-fascia-mobile="offerta"] #page .offer-intro h1.offer-page-title { font-size:19px !important; }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-name { font-size:14px !important; }
}
@media screen and (orientation:portrait) and (max-width:380px) and (max-height:540px) {
    html[data-fascia-mobile="offerta"] #page .offer-intro .customer-page-header .customer-summary {
        padding:5px 10px 6px !important; gap:2px !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-intro-copy { padding-bottom:3px !important; }
    html[data-fascia-mobile="offerta"] #page .offer-intro .customer-summary-actions .customer-summary-links { column-gap:5px !important; }
}


/* La fascia dell'offerta ha circa metà schermo. Due righe lasciano spazio alle parole lunghe. */
@media screen and (orientation: landscape) and (min-width: 460px) and (max-width: 550px) and (max-height: 420px) {
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro .offer-customer-header[data-offer-summary]
    .customer-summary-links:has(> a:nth-child(4 of a[href]:not([hidden]))) {
        grid-auto-flow: row;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Il numero e le indicazioni stradali condividono la riga anche con un'etichetta lunga. */
    html[data-fascia-breve="cliente"] #page .customer-intro[data-customer-actions] .customer-summary-links
    > :is(a[data-customer-action="phone"], a[data-customer-action="directions"]) {
        padding-inline: 2px !important;
        column-gap: 2px !important;
    }
}

/* Le coordinate provengono dall'area interna del contenitore dei riquadri della pagina corrente. */
@media screen {
    html[data-comandi-box] {
        --comandi-inizio: max(var(--box-inizio), env(safe-area-inset-left, 0px));
        --comandi-fine: min(var(--box-fine), calc(100% - env(safe-area-inset-right, 0px)));
        --comandi-fondo: calc(12px + env(safe-area-inset-bottom, 0px));
        --comandi-freccia: 48px;
        --comandi-distanza: 20px;
    }

    html[data-comandi-box] body #customer-contact-sticky {
        box-sizing: border-box;
        left: var(--comandi-inizio);
        right: auto;
        bottom: var(--comandi-fondo);
        width: min(360px, calc(var(--comandi-fine) - var(--comandi-inizio) - var(--comandi-freccia) - var(--comandi-distanza)));
        max-width: none;
        min-width: 0;
        min-height: 48px;
        margin: 0;
        padding: 4px 10px;
        justify-content: center;
        align-items: center;
        gap: 0;
        overflow-wrap: anywhere;
        white-space: normal;
        text-align: center !important;
        font-size: 14px;
        line-height: 1.3;
    }
    html[data-comandi-box] body:not(.modal-open) #customer-contact-sticky:not([hidden]) { display: flex; }
    html[data-comandi-box] body #customer-contact-sticky[hidden],
    html[data-comandi-box] body.modal-open #customer-contact-sticky,
    html[data-comandi-box] body:has(#mobile-navigation.in, #mobile-navigation.collapsing, dialog[open], .pswp--open) #customer-contact-sticky,
    html[data-comandi-box] body #customer-contact-sticky > .fa { display: none !important; }
    html[data-comandi-box] #customer-contact-sticky > span:not(.fa) { min-width: 0; text-align: center; }

    html[data-comandi-box] body #top-link-block {
        left: calc(var(--comandi-fine) - var(--comandi-freccia));
        right: auto;
        bottom: var(--comandi-fondo);
        width: var(--comandi-freccia);
        height: max(48px, var(--box-altezza-contatto, 48px));
        margin: 0;
    }
}

@media screen and (orientation: portrait) {
    html[data-comandi-box][data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-page-header .customer-summary {
        padding-inline: var(--comandi-inizio) max(var(--box-margine-destro), env(safe-area-inset-right, 0px)) !important;
    }
    html[data-comandi-box][data-fascia-mobile="offerta"] #page .offer-intro .customer-summary-contact {
        width: 100%;
    }
}

@media screen and (orientation: portrait) and (max-width: 319px) {
    html[data-comandi-box][data-fascia-mobile] #page :is(.customer-intro,.offer-intro) .customer-page-header .customer-summary {
        padding-block: 6px 8px !important;
        gap: 4px !important;
    }
}


/* Sul telefono ruotato la fotografia usa lo spazio che resta sopra il titolo e la scadenza. */
@media screen and (orientation: landscape) and (max-width: 740px) and (max-height: 420px) {
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-has-photo .offer-intro-main {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
        grid-template-areas: "media" "copy";
        gap: 2px;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-has-photo .offer-intro-media:not([hidden]) {
        display: block;
        position: relative;
        grid-area: media;
        min-height: 0;
        overflow: hidden;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-media > a {
        display: block;
        inset: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: 6px;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-media img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center 48%;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-gallery-label {
        position: absolute;
        inset: auto 3px 3px auto;
        max-width: calc(100% - 6px);
        min-height: 0;
        margin: 0;
        padding: 2px 5px;
        border-radius: 4px;
        background: #fff;
        font-size: 12px;
        line-height: 1.25;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-has-photo .offer-intro-copy {
        grid-area: copy;
        min-height: 0;
        padding-block: 3px;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-copy :is(.offer-validity,.offer-expired,.offer-details-link) {
        margin-top: 3px;
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro-copy .offer-validity {
        padding-block: 2px;
    }
}

@media screen and (orientation: landscape) and (max-width: 550px) and (max-height: 340px) {
    html[data-comandi-box][data-fascia-breve="offerta"] #page .offer-page .offer-intro.offer-intro-has-photo.offer-opening-fit {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
    html[data-fascia-breve="offerta"] #page .offer-page .offer-intro .offer-intro-copy h1.offer-page-title {
        font-size: 17px;
        line-height: 1.25;
    }
}


/* Telefoni verticali con poco spazio: data e collegamento condividono la riga sotto al titolo. */
@media screen and (orientation: portrait) and (max-width: 600px) and (max-height: 620px),
       screen and (orientation: portrait) and (max-width: 380px) and (max-height: 700px) {
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-intro-copy {
        display: grid;
        grid-template-columns: minmax(0, 1fr) fit-content(42%);
        grid-template-areas: "titolo titolo" "validita dettagli";
        justify-content: stretch;
        column-gap: 8px;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro h1.offer-page-title {
        grid-area: titolo;
        font-size: 18px !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-validity.scadenza { grid-area: validita; }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-details-link {
        grid-area: dettagli;
        justify-self: end;
        min-width: 0;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-expired { grid-column: 1 / -1; }
}

/* Nei telefoni più piccoli i collegamenti secondari lasciano spazio alla copertina. */
@media screen and (orientation: portrait) {
    /* Mantiene intere anche le parole composte nei titoli delle offerte scadute. */
    html[data-fascia-mobile="offerta"] #page .offer-intro:has(.offer-expired) h1.offer-page-title {
        font-size: clamp(16px, 5vw, 26px) !important;
    }
}
@media screen and (orientation: portrait) and (max-width: 600px) and (max-height: 620px),
       screen and (orientation: portrait) and (max-width: 380px) and (max-height: 700px) {
    html[data-fascia-mobile="offerta"] #page .offer-intro .customer-summary-actions .customer-summary-links > a:not([hidden]) {
        min-height: 30px;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-details-link {
        min-height: 36px;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-expired {
        margin: 0;
        padding: 2px 7px;
        font-size: 13px;
        line-height: 1.32;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-identity {
        column-gap: 6px;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-name {
        font-size: 15px !important;
        line-height: 1.22 !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro .offer-customer-header .customer-summary-address {
        line-height: 1.3;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro:has(.offer-expired) h1.offer-page-title {
        font-size: min(17px, 5.1vw) !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro:has(.offer-expired) .customer-page-header .customer-summary {
        padding-block: 3px !important;
    }
    html[data-fascia-mobile="offerta"] #page .offer-intro:has(.offer-expired) .customer-summary-actions .customer-summary-links > a:not([hidden]) {
        min-height: 26px;
    }
}
