/* ============================================================================
   Banner cookie + pannello "Preferenze cookie" (D0071 §1.3)
   ----------------------------------------------------------------------------
   File SEPARATO da main.css di proposito: il CSS servito dal sito e' un build
   con hash (dist/static/main-D-hUiRpk.css) che non va toccato a mano, e non
   esiste uno script di build. Questo file vive in due copie identiche:
     frontend/styles/cookie-consent.css   (sorgente)
     dist/static/cookie-consent.css       (servito)
   Si modificano insieme.

   Usa le variabili del tema definite in main.css (--bg-2, --border, --text,
   --muted, --red, --font-display): cosi' il tema chiaro (html[data-theme=light])
   viene gratis, salvo le poche ombre/tracce ritoccate in fondo.

   Il BANNER non e' un cookie wall: niente overlay, il sito sotto resta usabile.
   Solo il PANNELLO preferenze e' modale (backdrop + focus trap nel JS).
   ============================================================================ */

/* ---------- Banner in basso (non modale) ---------- */
.cc-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 120;
  max-width: 920px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: space-between;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 22px; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  animation: cc-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cc-banner[hidden], .cc-dialog[hidden] { display: none; }
@keyframes cc-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

.cc-banner-text { flex: 1; min-width: 260px; }
.cc-banner-text strong { font-family: var(--font-display); font-size: 14px; display: block; margin-bottom: 4px; }
.cc-banner-text p { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.55; }
.cc-banner-text a { color: var(--red); }
.cc-banner-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.cc-banner-actions .btn { font-size: 13px; padding: 10px 20px; cursor: pointer; }

/* ---------- Pannello preferenze (modale) ---------- */
.cc-dialog {
  position: fixed; inset: 0; z-index: 130;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.cc-dialog-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.cc-panel {
  position: relative; width: 100%; max-width: 580px;
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 26px 22px; box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.7);
  animation: cc-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}
.cc-panel h2 { font-family: var(--font-display); font-size: 20px; margin: 0 40px 6px 0; }
.cc-panel-intro { font-size: 14px; color: var(--muted); margin: 0 0 18px; line-height: 1.55; }
.cc-panel-intro a { color: var(--red); }

.cc-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s ease-out;
}
.cc-close:hover { color: var(--text); border-color: var(--red); }

/* Una riga per categoria: testo a sinistra, interruttore a destra */
.cc-category {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.cc-category h3 { font-family: var(--font-display); font-size: 15px; margin: 0 0 4px; color: var(--text); }
.cc-category p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }
.cc-category .cc-always { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--red); margin-left: 8px; font-weight: 600; }

/* Interruttore: il checkbox vero resta nel DOM (accessibile, tastiera), la
   traccia e' disegnata sullo span accanto. */
.cc-switch { position: relative; flex-shrink: 0; width: 44px; height: 24px; margin-top: 2px; display: block; }
.cc-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.cc-switch-track {
  position: absolute; inset: 0; border-radius: 12px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid var(--border);
  transition: background 0.2s ease-out, border-color 0.2s ease-out;
}
.cc-switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease-out;
}
.cc-switch input:checked + .cc-switch-track { background: var(--red); border-color: var(--red); }
.cc-switch input:checked + .cc-switch-track::after { transform: translateX(20px); }
.cc-switch input:disabled { cursor: not-allowed; }
.cc-switch input:disabled + .cc-switch-track { opacity: 0.6; }
.cc-switch input:focus-visible + .cc-switch-track { outline: 2px solid var(--red); outline-offset: 2px; }

/* Testo solo per screen reader */
.cc-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.cc-panel-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.cc-panel-actions .btn { font-size: 13px; padding: 10px 20px; cursor: pointer; }

/* Blocco dello scroll di pagina mentre il pannello e' aperto (classe messa
   sull'<html> dal JS). */
html.cc-dialog-open { overflow: hidden; }

/* ---------- Tema chiaro ---------- */
html[data-theme="light"] .cc-banner,
html[data-theme="light"] .cc-panel { box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.25); }
html[data-theme="light"] .cc-dialog-backdrop { background: rgba(20, 16, 14, 0.35); }
html[data-theme="light"] .cc-switch-track { background: rgba(15, 15, 15, 0.15); }
html[data-theme="light"] .cc-switch input:checked + .cc-switch-track { background: var(--red); }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .cc-banner { flex-direction: column; align-items: stretch; gap: 14px; }
  .cc-banner-actions { justify-content: stretch; }
  .cc-banner-actions .btn { flex: 1; justify-content: center; }
  .cc-panel { padding: 22px 18px 18px; border-radius: 14px; }
  .cc-panel-actions .btn { flex: 1; justify-content: center; }
}
