/* ============================================================
   PrezzoTop — Banner Indice di Convenienza
   Versione: 5.0.0

   Contiene tutti gli stili che nella versione precedente erano
   concatenati inline dentro render_banner() (circa 4 KB di
   attributi style="" per ogni banner, ripetuti in ogni voce di
   cache) più il blocco $banner_mobile_css, che era una stringa
   PHP statica stampata a ogni pageview.

   Le uniche parti dinamiche restano due variabili CSS impostate
   sul contenitore dal PHP:
     --ptop-c        colore della fascia
     --ptop-c-light  variante chiara
   ============================================================ */

.ptop-banner {
    --ptop-c: #6C4176;
    --ptop-c-light: #a78bfa;
    --bn-surface: #fff;
    --bn-border: #e5e7eb;
    --bn-muted: #9ca3af;
    --bn-text: #111827;

    background: var(--bn-surface);
    border: 1px solid var(--bn-border);
    border-left: 4px solid var(--ptop-c);
    border-radius: 0 10px 10px 0;
    margin: 12px 0;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .06);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    overflow: hidden;
}

/* Variante premium (score >= 90) */
.ptop-banner--premium {
    --bn-border: #AFA9EC;
    --bn-muted: #7F77DD;
    --bn-text: #26215C;

    border-width: 1.5px;
    border-left: 6px solid #7F77DD;
    border-radius: 0 12px 12px 0;
    box-shadow: none;
    transition: background .7s ease;
}

/* ────────────────────────────────────────────
   LOADER (animato da ptop-banner.js)
──────────────────────────────────────────── */

.ptop-bn-loader { padding: 18px 18px 16px; }

.ptop-bn-ldr-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.ptop-bn-ldr-brand { display: flex; align-items: center; gap: 7px; }

.ptop-bn-ldr-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ptop-c);
    flex-shrink: 0;
    animation: ptop-pulse 1.4s ease-in-out infinite;
}

@keyframes ptop-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .3; }
}

.ptop-bn-ldr-kicker {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #9ca3af;
}

.ptop-bn-ldr-pct {
    font-size: 11px;
    font-weight: 700;
    color: var(--ptop-c);
    min-width: 34px;
    text-align: right;
    opacity: 0;
    transition: opacity .3s;
}

.ptop-bn-ldr-pricerow {
    display: flex;
    align-items: baseline;
    justify-content: center;
    /*
     * flex-wrap: wrap permette alla pill "miglior prezzo" di scendere
     * su una riga propria quando lo spazio è poco, invece di comprimere
     * il prezzo fino a spezzarlo.
     */
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 14px;
    min-height: 52px;
}

.ptop-bn-ldr-curr {
    font-size: clamp(15px, 4.5vw, 20px);
    white-space: nowrap;
    font-weight: 700;
    color: #9ca3af;
    opacity: 0;
    transition: opacity .4s;
}

.ptop-bn-ldr-price {
    /*
     * FIX: la dimensione era fissa a 42px. Un prezzo a quattro cifre
     * con i centesimi (€4.145,32) occupa circa 280px a quella misura:
     * dentro la card, su un viewport da 360px, il testo andava a capo
     * spezzandosi a metà numero. clamp() lo fa rimpicciolire quanto
     * serve sui telefoni stretti restando grande sui monitor, e
     * white-space: nowrap garantisce che non si spezzi comunque mai.
     */
    font-size: clamp(26px, 9vw, 42px);
    font-weight: 900;
    letter-spacing: -.04em;
    color: var(--ptop-c);
    opacity: 0;
    transition: opacity .4s;
    line-height: 1;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ptop-bn-ldr-lock {
    font-size: 12px;
    font-weight: 700;
    color: #10b981;
    opacity: 0;
    transition: opacity .5s;
    align-self: center;
    margin-left: 4px;
    white-space: nowrap;
}

.ptop-bn-ldr-track {
    height: 5px;
    background: var(--bn-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 14px;
}

.ptop-bn-ldr-bar {
    height: 100%;
    width: 0;
    background: var(--ptop-c);
    border-radius: 999px;
    transition: width .7s cubic-bezier(.4, 0, .2, 1);
}

.ptop-bn-ldr-msgrow {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 20px;
}

.ptop-bn-ldr-icon {
    flex-shrink: 0;
    opacity: 0;
    color: var(--ptop-c);
    transition: opacity .3s;
}

.ptop-bn-ldr-msg {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    opacity: 0;
    transition: opacity .35s;
}

.ptop-bn-ldr-steps { display: flex; gap: 4px; margin-top: 14px; }

.ptop-bn-ldr-step {
    height: 3px;
    flex: 1;
    border-radius: 999px;
    background: var(--bn-border);
    transition: background .4s, flex .4s;
}

.ptop-bn-ldr-step.is-active { background: var(--ptop-c); flex: 2; }

/* ────────────────────────────────────────────
   CONTENUTO
──────────────────────────────────────────── */

.ptop-bn-content { opacity: 0; transition: opacity .4s ease; }
.ptop-bn-content.is-ready { opacity: 1; }

.ptop-bn-row {
    display: flex;
    gap: 10px;
    padding: 11px 14px 10px;
    align-items: center;
}

.ptop-bn-gauge-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.ptop-bn-gauge { display: block; }
.ptop-bn-arc-bg { stroke: #f3f4f6; }
.ptop-banner--premium .ptop-bn-arc-bg { stroke: #AFA9EC; }
.ptop-bn-arc { stroke: var(--ptop-c); transition: stroke-dashoffset .9s cubic-bezier(.4, 0, .2, 1); }
.ptop-bn-num { fill: var(--ptop-c); font-family: system-ui, sans-serif; }

.ptop-bn-gauge-max {
    font-size: 9px;
    color: var(--bn-muted);
    line-height: 1;
}

.ptop-bn-main { flex: 1; min-width: 0; }

.ptop-bn-frase {
    font-size: 13px;
    font-weight: 700;
    color: var(--bn-text);
    line-height: 1.3;
}

.ptop-bn-sub {
    font-size: 11px;
    color: var(--ptop-c);
    font-weight: 600;
    margin-top: 2px;
    min-height: 14px;
}

.ptop-bn-scale {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    margin-top: 6px;
}

.ptop-bn-seg {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    transition: background .3s, transform .3s;
    transform-origin: bottom center;
}

.ptop-banner--premium .ptop-bn-seg { background: #AFA9EC; }

/* Tutti i segmenti fino al livello raggiunto */
.ptop-bn-seg.is-filled { background: var(--seg-c); }

/* L'ultimo raggiunto è leggermente più alto: indica il punto esatto */
.ptop-bn-seg.is-active { height: 9px; }

.ptop-bn-content .ptop-bn-seg.is-filled { transform: scaleY(0); }
.ptop-bn-content.is-ready .ptop-bn-seg.is-filled { transform: scaleY(1); }

.ptop-bn-scale-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--ptop-c);
    margin-top: 2px;
    opacity: 0;
    transition: opacity .3s;
}

.ptop-bn-content.is-ready .ptop-bn-scale-label { opacity: 1; }

.ptop-bn-prices {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    white-space: nowrap;
}

.ptop-bn-price-lbl {
    font-size: 9px;
    color: var(--bn-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.ptop-bn-price-val {
    font-size: clamp(15px, 4.6vw, 18px);
    font-weight: 800;
    color: var(--ptop-c);
    letter-spacing: -.02em;
    white-space: nowrap;
}

.ptop-bn-price-min { font-size: 10px; color: var(--bn-muted); }

.ptop-bn-track {
    height: 3px;
    background: #f3f4f6;
    margin: 0 14px;
    border-radius: 999px;
    overflow: hidden;
}

.ptop-banner--premium .ptop-bn-track { background: #AFA9EC; }

.ptop-bn-bar {
    height: 100%;
    background: var(--ptop-c);
    border-radius: 999px;
    transition: width .8s cubic-bezier(.4, 0, .2, 1);
}

.ptop-bn-offers { padding: 8px 14px 0; }

/* ────────────────────────────────────────────
   AZIONI
──────────────────────────────────────────── */

.ptop-bn-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-top: .5px solid #f3f4f6;
    margin-top: 10px;
}

.ptop-banner--premium .ptop-bn-actions { border-top-color: #AFA9EC; }

.ptop-bn-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    border-radius: 8px;
    padding: 7px 13px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    border: 1px solid var(--bn-border);
    background: #f9fafb;
    color: #6C4176;
}

.ptop-banner--premium .ptop-bn-btn { background: #fff; color: #3C3489; border-width: 1.5px; }

.ptop-bn-btn--alert {
    background: #C04A5A;
    border-color: #C04A5A;
    color: #fff;
}

.ptop-bn-chv {
    display: inline-block;
    transition: transform .2s;
    font-size: 9px;
}

.ptop-bn-btn[aria-expanded="true"] .ptop-bn-chv { transform: rotate(180deg); }

.ptop-bn-spacer { flex: 1; }

.ptop-bn-ts { font-size: 10px; color: #d1d5db; }
.ptop-banner--premium .ptop-bn-ts { color: #7F77DD; }

/* ────────────────────────────────────────────
   PANNELLO DETTAGLI
──────────────────────────────────────────── */

.ptop-bn-detail[hidden],
.ptop-bn-alert[hidden] { display: none; }

.ptop-bn-detail-inner {
    padding: 14px 16px 16px;
    border-top: 1px solid #f3f4f6;
}

.ptop-banner--premium .ptop-bn-detail-inner { border-top-color: #AFA9EC; }

.ptop-bn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.ptop-bn-cell {
    background: #f9fafb;
    border-radius: 8px;
    padding: 9px 11px;
}

.ptop-banner--premium .ptop-bn-cell { background: #EEEDFE; }

.ptop-bn-cell-lbl {
    display: block;
    font-size: 9px;
    color: var(--bn-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 3px;
}

.ptop-bn-cell-val {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: var(--bn-text);
}

.ptop-bn-cell-val.is-accent { color: var(--ptop-c); }
.ptop-bn-cell-val.is-small  { font-size: 13px; }
.ptop-bn-cell-val small     { font-size: 10px; color: var(--bn-muted); font-weight: 600; }

.ptop-bn-trend { margin-bottom: 8px; }

.ptop-bn-trend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 8px 8px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}

.ptop-banner--premium .ptop-bn-trend-row { background: #EEEDFE; color: #26215C; border-bottom-color: #AFA9EC; }

.ptop-bn-trend-arrow { font-size: 15px; font-weight: 700; }
.ptop-bn-trend-row.is-down .ptop-bn-trend-arrow { color: #059669; }
.ptop-bn-trend-row.is-up   .ptop-bn-trend-arrow { color: #ea580c; }
.ptop-bn-trend-row.is-stable .ptop-bn-trend-arrow { color: #6b7280; }

.ptop-bn-trend-prev {
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 0 0 8px 8px;
    font-size: 11px;
    color: #6b7280;
}

.ptop-banner--premium .ptop-bn-trend-prev { background: #EEEDFE; color: #534AB7; }

.ptop-bn-footnote {
    margin-top: 10px;
    font-size: 10px;
    color: var(--bn-muted);
    text-align: right;
}

.ptop-bn-alert {
    padding: 16px 18px 18px;
    border-top: 1px solid #f3f4f6;
    background: #fafbfc;
}

.ptop-banner--premium .ptop-bn-alert { background: #E8E7FD; border-top-color: #AFA9EC; }

/* ────────────────────────────────────────────
   BLOCCO OFFERTE CONTENT EGG
   Estratto 1:1 dal blocco $banner_mobile_css.
──────────────────────────────────────────── */

.ptop-bn-offer-btn { display: inline-flex !important; }

.ptop-bn-offer-btn .container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

.ptop-bn-offer-btn .row { gap: 0 !important; margin: 0 !important; }

.ptop-bn-offer-btn .col {
    display: none;               /* nasconde tutti i bottoni… */
    flex: 0 0 auto !important;
    padding: 0 !important;
    margin: 0 !important;
}

.ptop-bn-offer-btn .col:first-child { display: block; } /* …tranne il primo */

.ptop-bn-offer-btn .d-grid { display: block !important; }

.ptop-bn-offer-btn button,
.ptop-bn-offer-btn a.btn {
    padding: 5px 10px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    margin: 0 !important;
}

/* ────────────────────────────────────────────
   MOBILE
──────────────────────────────────────────── */

@media (max-width: 640px) {
    .ptop-banner { margin: 8px 0; }

    .ptop-bn-row { padding: 10px 12px 8px; gap: 10px; }

    .ptop-bn-gauge { width: 48px; height: 48px; }

    .ptop-bn-frase { font-size: 12px; line-height: 1.3; }
    .ptop-bn-sub   { font-size: 11px; margin-top: 2px; }

    .ptop-bn-price-lbl { font-size: 9px; }
    .ptop-bn-price-min { font-size: 10px; white-space: nowrap; }

    /* Su schermi molto stretti la pill scompare: il prezzo ha priorità. */
    @media (max-width: 380px) {
        .ptop-bn-ldr-lock { display: none; }
    }

    .ptop-bn-track   { margin: 0 12px; }
    .ptop-bn-actions { padding: 8px 12px; gap: 6px; }

    .ptop-bn-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ────────────────────────────────────────────
   RIDUZIONE MOVIMENTO
   Mancava del tutto nella versione precedente: il
   loader animava comunque, ignorando le preferenze
   di accessibilità del sistema.
──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .ptop-banner *,
    .ptop-bn-content,
    .ptop-bn-arc {
        transition: none !important;
        animation: none !important;
    }
    .ptop-bn-content { opacity: 1 !important; }
    .ptop-bn-loader  { display: none !important; }
    .ptop-bn-seg.is-active { transform: scaleY(1) !important; }
    .ptop-bn-scale-label   { opacity: 1 !important; }
}

/* ────────────────────────────────────────────
   VALORE COMPLESSIVO (qualità × convenienza)
──────────────────────────────────────────── */

.ptop-bn-btn--value {
    background: #f5f3ff;
    border-color: #ddd6fe;
    color: #5b21b6;
}

.ptop-bn-btn-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #6C4176;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ptop-bn-value[hidden] { display: none; }

.ptop-bn-value-inner {
    padding: 16px 18px 18px;
    border-top: 1px solid #f3f4f6;
    background: #fbfaff;
}

.ptop-bn-value-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.ptop-bn-value-num {
    font-size: 40px;
    font-weight: 900;
    letter-spacing: -.05em;
    line-height: 1;
    color: #5b21b6;
    font-variant-numeric: tabular-nums;
}

.ptop-bn-value-num small { font-size: 14px; font-weight: 600; color: #a1a1aa; }

.ptop-bn-value-label {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #111827;
}

.ptop-bn-value-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.ptop-bn-value-parts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.ptop-bn-value-part {
    background: #fff;
    border: 1px solid #ece9f5;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ptop-bn-value-part-lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #a1a1aa;
}

.ptop-bn-value-part-val {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.03em;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

.ptop-bn-value-part-val small { font-size: 11px; font-weight: 600; color: #a1a1aa; }
.ptop-bn-value-part-w { font-size: 10px; color: #9ca3af; }

.ptop-bn-value-verdict {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.65;
    color: #374151;
}

.ptop-bn-value-note {
    margin: 0;
    font-size: 11px;
    line-height: 1.55;
    color: #9ca3af;
}

@media (max-width: 640px) {
    .ptop-bn-value-parts { grid-template-columns: 1fr; }
    .ptop-bn-value-num { font-size: 34px; }
}
