/* ==========================================================================
   THE WISE GUY · Banner consenso cookie + piè di pagina legale
   Usa i token di restyling.css quando ci sono; fallback scuri per le pagine
   che non lo caricano (academy, pagine ponte).
   ========================================================================== */
.twgcc {
  --cc-bg: var(--bg-card-solid, #100b1c);
  --cc-fg: var(--fg-primary, #f8fafc);
  --cc-fg2: var(--fg-secondary, #cbd5e1);
  --cc-muted: var(--fg-muted, #94a3b8);
  --cc-border: var(--border-medium, rgba(255, 255, 255, 0.16));
  --cc-accent: var(--accent-violet-bright, #c084fc);
  --cc-btn-bg: var(--cta-bg, #f8fafc);
  --cc-btn-fg: var(--cta-fg, #09060f);
  --cc-subtle: var(--bg-subtle, rgba(255, 255, 255, 0.04));
  /* Desktop: in basso a destra (Alfred si nasconde mentre il banner è aperto).
     Il banner chiuso si alza da solo sopra i comandi del filmato (consenso.js, EVITA). */
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  background: var(--cc-bg);
  color: var(--cc-fg);
  border: 1px solid var(--cc-border);
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.6);
  font: 14px/1.55 var(--font-sans);
  text-align: left;
}
.twgcc[hidden] { display: none !important; }
.twgcc *, .twgcc *::before, .twgcc *::after { box-sizing: border-box; }
html.twgcc-aperto #alfredLauncher,
html.twgcc-aperto .alfred-launcher { visibility: hidden; }
.twgcc-testa { flex: 0 0 auto; padding: 18px 20px 0; }
.twgcc-titolo {
  margin: 0 40px 6px 0;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--cc-fg);
  outline: none;
}
.twgcc-titolo:focus-visible { outline: 2px solid var(--cc-accent); outline-offset: 3px; border-radius: 4px; }
.twgcc-testo { margin: 0; color: var(--cc-fg2); font-size: 14px; line-height: 1.5; }
.twgcc-link { margin: 6px 0 12px; font-size: 13px; color: var(--cc-muted); }
.twgcc a { color: var(--cc-accent); text-decoration: underline; text-underline-offset: 2px; }
.twgcc-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--cc-fg2);
  cursor: pointer;
  z-index: 1;
}
.twgcc-x:hover { background: var(--cc-subtle); color: var(--cc-fg); }
/* Piede con i bottoni: sempre visibile, anche quando la lista scorre */
.twgcc-azioni {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--cc-bg);
}
.twgcc.is-pannello .twgcc-azioni { border-top: 1px solid var(--cc-border); }
.twgcc-btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  font: 600 14px/1.2 var(--font-sans);
  cursor: pointer;
  border: 1px solid var(--cc-border);
  background: transparent;
  color: var(--cc-fg);
}
/* Rifiuta e Accetta tutti: stessa identica evidenza (Garante 10/06/2021) */
.twgcc-btn--scelta {
  flex: 1 1 110px;
  background: var(--cc-btn-bg);
  color: var(--cc-btn-fg);
  border-color: var(--cc-btn-bg);
}
.twgcc-btn--scelta:hover { filter: brightness(0.92); }
.twgcc-btn--quiet { flex: 1 1 110px; }
.twgcc-btn--quiet:hover { background: var(--cc-subtle); }
.twgcc .twgcc-btn:focus-visible,
.twgcc-x:focus-visible,
.twgcc-switch:focus-visible,
.twgcc-embed .twgcc-btn:focus-visible {
  outline: 3px solid var(--cc-accent);
  outline-offset: 2px;
}
/* Lista categorie: è l'unica parte che scorre */
.twgcc-pannello {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  margin: 0;
  padding: 0 20px 4px;
  display: grid;
  align-content: start;
  gap: 8px;
}
.twgcc-pannello[hidden] { display: none; }
.twgcc.is-pannello { max-height: min(640px, calc(100vh - 120px)); }
.twgcc-riga {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--cc-border);
  border-radius: 12px;
  background: var(--cc-subtle);
}
.twgcc-riga--fissa { grid-template-columns: 1fr; }
.twgcc-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 2px 0 0;
  border-radius: 999px;
  border: 1px solid var(--cc-border);
  background: rgba(148, 163, 184, 0.35);
  cursor: pointer;
  transition: background 0.15s;
}
.twgcc-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
}
.twgcc-switch:checked { background: var(--accent-emerald, #34d399); border-color: transparent; }
.twgcc-switch:checked::after { transform: translateX(18px); }
.twgcc-lab { display: grid; gap: 2px; cursor: pointer; min-height: 26px; }
.twgcc-riga--fissa .twgcc-lab { cursor: default; }
.twgcc-lab strong { font-size: 14px; color: var(--cc-fg); }
.twgcc-desc { font-size: 13px; color: var(--cc-muted); line-height: 1.45; }
.twgcc-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 600 12.5px/1.2 var(--font-sans);
  color: #4ade80;
}
.twgcc-sr {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  .twgcc-switch, .twgcc-switch::after { transition: none; }
}

/* Telefono: ancorato in basso, largo quanto lo schermo meno 24 px.
   In «Personalizza» diventa un foglio dal basso a tutta larghezza, max 85dvh. */

/* Desktop chiuso: barra dock orizzontale compatta in basso (non copre video né note sopra la piega) */
@media (min-width: 601px) {
  .twgcc:not(.is-pannello) {
    left: 16px;
    right: 16px;
    bottom: 10px;
    width: auto;
    max-width: 1320px;
    margin: 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 54px 10px 18px;
  }
  .twgcc:not(.is-pannello) .twgcc-testa { padding: 0; flex: 1 1 auto; min-width: 0; }
  .twgcc:not(.is-pannello) .twgcc-titolo { margin: 0 0 2px; font-size: 14px; line-height: 1.25; }
  .twgcc:not(.is-pannello) .twgcc-testo { font-size: 13px; line-height: 1.35; display: inline; }
  .twgcc:not(.is-pannello) .twgcc-link { margin: 0 0 0 8px; font-size: 12.5px; display: inline; white-space: nowrap; }
  .twgcc:not(.is-pannello) .twgcc-azioni {
    position: static;
    padding: 0;
    flex-wrap: nowrap;
    background: transparent;
    gap: 8px;
  }
  .twgcc:not(.is-pannello) .twgcc-btn { flex: 0 0 auto; white-space: nowrap; padding: 9px 14px; font-size: 13.5px; }
  .twgcc:not(.is-pannello) .twgcc-x { top: 50%; right: 8px; transform: translateY(-50%); }
}

@media (max-width: 600px) {
  .twgcc {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    padding: 0;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    font-size: 13.5px;
  }
  .twgcc-testa { padding: 12px 44px 0 14px; }
  .twgcc:not(.is-pannello) .twgcc-titolo { margin: 0 0 3px; font-size: 14.5px; }
  .twgcc:not(.is-pannello) .twgcc-testo { font-size: 12.5px; line-height: 1.35; }
  .twgcc:not(.is-pannello) .twgcc-link { margin: 4px 0 6px; font-size: 12px; }
  .twgcc-pannello { padding: 0 14px 4px; }
  .twgcc-azioni {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 6px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .twgcc-azioni [data-twgcc="personalizza"] { grid-column: 1 / -1; order: 3; }
  .twgcc.is-pannello {
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    max-height: 85vh;
    max-height: 85dvh;
  }
}

/* ── Segnaposto contenuti esterni (Spotify, YouTube) ───────────────────── */
.twgcc-embed {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 16px;
  border: 1px dashed var(--border-medium, rgba(255, 255, 255, 0.2));
  border-radius: 12px;
  background: var(--bg-subtle, rgba(255, 255, 255, 0.04));
  color: var(--fg-secondary, #cbd5e1);
  font-size: 14px;
}
.twgcc-embed p { margin: 0; }
.twgcc-embed .twgcc-btn { color: var(--fg-primary, #f8fafc); }

/* ── Riga legale nel piè di pagina ─────────────────────────────────────── */
.twg-legal { display: inline; }
.twg-legal-links a,
.twg-legal-links .twg-legal-pref {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline-block;
  padding: 6px 0;
}
.twg-legal-links a:hover { color: var(--accent-violet-bright, #c084fc); }
/* Piè di pagina minimo per le pagine che non ne avevano uno */
.twg-legal-footer {
  margin: 32px auto 0;
  padding: 16px var(--twg-gutter, 24px);
  max-width: var(--twg-container-max, 1360px);
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font: 12.5px/1.6 var(--font-sans);
  color: #94a3b8;
  text-align: center;
}
.twg-legal-footer a { color: inherit; }

/* ── Pagine legali (privacy, cookie, note legali) ─────────────────────────
   Riferimenti di legge: Inter 500 13 px grigio, maiuscole normali.
   Tabelle 14 px; sul telefono ogni riga diventa una scheda. */
.twg-legal-page .eyebrow-tag,
.twg-legal-page .twg-legal-rif {
  font: 500 13px/1.45 var(--font-sans) !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--fg-muted) !important;
}
.twg-legal-tab { width: 100%; border-collapse: collapse; font-size: 14px; }
.twg-legal-tab th {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-medium);
  color: var(--fg-primary); font-weight: 600;
}
.twg-legal-tab td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
@media (max-width: 640px) {
  .twg-legal-tab thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .twg-legal-tab, .twg-legal-tab tbody, .twg-legal-tab tr, .twg-legal-tab td { display: block; width: 100%; }
  .twg-legal-tab tr {
    margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--border-subtle);
    border-radius: 12px; background: var(--bg-subtle);
  }
  .twg-legal-tab td { border: 0; padding: 4px 0; }
  .twg-legal-tab td::before {
    content: attr(data-label); display: block;
    font: 600 12px/1.3 var(--font-sans); color: var(--fg-muted);
  }
}
