/* ============================================================
   FOOTER LEGALE + INFORMATIVE — AI-Creative-Studio.com
   Estetica coerente con la scena: fondo nero, oro tenue,
   Space Grotesk per le etichette, Manrope per il testo.
   ============================================================ */

:root {
  --lg-gold: #d8c6a7;
  --lg-gold-dim: #8e7859;
  --lg-text: #f5f5f1;
  --lg-muted: #b1bec6;
  --lg-muted-2: #8b9aa3;
  --lg-line: #ffffff1f;
  --lg-panel: #070d12;
}

/* ------------------------------------------------------------
   0. NEUTRALIZZAZIONE DELLO STILE GLOBALE DEI PULSANTI

   La pagina stila ogni <button> come pulsante circolare 38x38
   (sono i comandi Pausa/Ricomincia della scena). I pulsanti
   dell'interfaccia legale sono invece testuali: qui annulliamo
   dimensione, forma e modello di box ereditati da quella regola.
   ------------------------------------------------------------ */
.legal-link,
.doc-link,
.doc-btn {
  width: auto;
  height: auto;
  min-height: 0;
  border-radius: 0;
  display: inline;
  place-items: normal;
  text-align: left;
  backdrop-filter: none;
}

/* ------------------------------------------------------------
   1. BARRA LEGALE IN BASSO
   ------------------------------------------------------------ */
.legalbar {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 22px;
  flex-wrap: wrap;
  padding: 11px 46px 13px;
  font-size: 10.5px;
  letter-spacing: 0.055em;
  color: var(--lg-muted-2);
  background: linear-gradient(to top, #000000d9 35%, #00000000);
  opacity: 0;
  transition: opacity 2s;
  pointer-events: none;
}
.ready .legalbar {
  opacity: 1;
  pointer-events: auto;
}

.legalbar nav {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.legalbar-sep {
  color: var(--lg-gold-dim);
  font-size: 9px;
}

.legalbar-id {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* Pulsanti-link: <button> per accessibilità, resi come link */
.legal-link {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 3px 1px;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: var(--lg-muted-2);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.legal-link:hover {
  color: var(--lg-gold);
  border-bottom-color: #d8c6a75c;
}

/* La scena ha firma e comandi in basso: liberiamo la fascia */
.signature {
  bottom: 64px;
}
.controls {
  bottom: 58px;
}

/* ------------------------------------------------------------
   2. INFORMATIVE (overlay a tutta pagina)
   ------------------------------------------------------------ */
.doc[hidden] {
  display: none;
}
.doc {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start center;
  padding: 24px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #000000d4;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: docFade 0.22s ease both;
}
@keyframes docFade {
  from {
    opacity: 0;
  }
}

.doc-panel {
  width: min(820px, 100%);
  /* Elemento di una griglia: senza min-width:0 la larghezza minima è
     quella del contenuto, e le tabelle allargherebbero il pannello
     oltre il viewport invece di scorrere al proprio interno. */
  min-width: 0;
  max-width: 100%;
  margin: auto 0;
  border: 1px solid var(--lg-line);
  border-radius: 16px;
  background: var(--lg-panel);
  box-shadow: 0 32px 90px #000000b8;
  animation: docRise 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes docRise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ---- testata ---- */
.doc-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--lg-line);
  border-radius: 16px 16px 0 0;
  background: var(--lg-panel);
}
.doc-eyebrow {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid #d8c6a740;
  border-radius: 100px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lg-gold);
}
.doc-head h2 {
  margin: 13px 0 0;
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1.14;
  color: var(--lg-text);
}
.doc-sub {
  margin: 8px 0 0;
  max-width: 62ch;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--lg-muted-2);
}

.doc-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #adbdcb30;
  border-radius: 50%;
  background: #111c2455;
  color: #becbd3;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.doc-close:hover {
  border-color: #d8c6a766;
  color: var(--lg-gold);
}
.doc-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* ---- corpo ---- */
.doc-body {
  padding: 26px 28px 30px;
  min-width: 0;
  font-size: 14px;
  line-height: 1.72;
  color: var(--lg-muted);
}
.doc-body:focus-visible {
  outline: 2px solid #91eeff;
  outline-offset: -4px;
}
.doc-rev {
  margin: 0 0 22px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6f7d85;
}
.doc-body h3 {
  margin: 34px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--lg-line);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--lg-text);
}
.doc-body h3:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.doc-body h4 {
  margin: 22px 0 8px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #dfe6ea;
}
.doc-body p {
  margin: 0 0 13px;
}
.doc-body strong {
  font-weight: 500;
  color: var(--lg-text);
}
.doc-body em {
  font-style: italic;
  color: #c6d0d6;
}
.doc-body ul {
  margin: 10px 0 18px;
  padding-left: 19px;
  display: grid;
  gap: 7px;
}
.doc-body li::marker {
  color: var(--lg-gold-dim);
}
.doc-body a {
  color: var(--lg-gold);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: #d8c6a759;
}
.doc-body a:hover {
  color: #e9c48b;
  text-decoration-color: currentColor;
}
.doc-body kbd {
  padding: 1px 6px;
  border: 1px solid var(--lg-line);
  border-radius: 5px;
  background: #ffffff0f;
  font-family: "Space Grotesk", monospace;
  font-size: 11px;
  color: var(--lg-text);
}

/* link testuale reso da <button> dentro il corpo */
.doc-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: var(--lg-gold);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: #d8c6a759;
}
.doc-link:hover {
  color: #e9c48b;
  text-decoration-color: currentColor;
}

/* ---- tabelle ---- */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 20px;
  font-size: 12.5px;
  line-height: 1.55;
}
.doc-table th {
  padding: 9px 11px;
  border-bottom: 1px solid var(--lg-line);
  background: #ffffff08;
  text-align: left;
  font-family: "Space Grotesk", sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cfd8dd;
}
.doc-table td {
  padding: 10px 11px;
  border-bottom: 1px solid #ffffff12;
  vertical-align: top;
}
.doc-table tr:last-child td {
  border-bottom: 0;
}

/* ---- riquadri ---- */
.doc-box,
.doc-note {
  margin: 16px 0 20px;
  padding: 15px 17px;
  border: 1px solid var(--lg-line);
  border-left: 2px solid var(--lg-gold-dim);
  border-radius: 10px;
  background: #ffffff07;
  font-size: 13.5px;
  line-height: 1.7;
}
.doc-box strong {
  color: var(--lg-text);
}
.doc-note.ok {
  border-left-color: #6fd8a8;
  background: #6fd8a80d;
}
.doc-note.warn {
  border-left-color: #e2a85c;
  background: #e2a85c0f;
}

/* ---- piede ---- */
.doc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px 28px;
  border-top: 1px solid var(--lg-line);
  border-radius: 0 0 16px 16px;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: #6f7d85;
}
.doc-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.doc-btn {
  display: inline-block;
  padding: 7px 13px;
  border: 1px solid #adbdcb30;
  border-radius: 100px;
  text-align: center;
  background: #111c2455;
  font-family: "Manrope", sans-serif;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: #becbd3;
  cursor: pointer;
  transition:
    border-color 0.2s,
    color 0.2s;
}
.doc-btn:hover {
  border-color: #d8c6a766;
  color: var(--lg-gold);
}

/* ------------------------------------------------------------
   3. BANNER COOKIE — reso solo se AICS_ANALYTICS è attivo
   ------------------------------------------------------------ */
.cbanner {
  position: fixed;
  z-index: 35;
  left: 18px;
  right: 18px;
  bottom: 18px;
  max-width: 660px;
  margin-inline: auto;
  padding: 19px 21px;
  border: 1px solid var(--lg-line);
  border-radius: 14px;
  background: #060b0fee;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 22px 60px #000000a6;
  font-size: 13px;
  line-height: 1.62;
  color: var(--lg-muted);
  animation: docRise 0.3s cubic-bezier(0.22, 1, 0.36, 1) 0.6s both;
}
.cbanner p {
  margin: 0 0 15px;
}
.cbanner-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
/* Rifiuta e Accetta hanno identico peso visivo: nessun dark pattern
   (ÚOOÚ, Linee guida cookie del Garante, EDPB 03/2022) */
.cbanner-actions .doc-btn {
  flex: 1 1 auto;
  min-width: 120px;
  text-align: center;
  padding: 10px 14px;
  font-size: 12.5px;
}

/* pannello preferenze */
.cprefs {
  display: grid;
  gap: 10px;
  margin: 4px 0 22px;
}
.cprefs-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--lg-line);
  border-radius: 11px;
  background: #ffffff07;
}
.cprefs-row h4 {
  margin: 0 0 3px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--lg-text);
}
.cprefs-row p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--lg-muted-2);
}
.cprefs-tag {
  margin-left: 7px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lg-gold-dim);
}
.cprefs-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: #6fd8a8;
  cursor: pointer;
}
.cprefs-row input:disabled {
  cursor: default;
  opacity: 0.55;
}

/* ------------------------------------------------------------
   4. ACCESSIBILITÀ E RESPONSIVE
   ------------------------------------------------------------ */
.legal-link:focus-visible,
.doc-link:focus-visible,
.doc-btn:focus-visible,
.doc-close:focus-visible {
  outline: 2px solid #91eeff;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .legalbar {
    padding: 10px 24px 12px;
    font-size: 10px;
    gap: 7px 14px;
  }
  .legalbar nav {
    gap: 6px;
  }
  .signature {
    bottom: 78px;
  }
  .controls {
    bottom: 72px;
  }
  .doc {
    padding: 0;
  }
  .doc-panel {
    min-height: 100%;
    border: 0;
    border-radius: 0;
  }
  .doc-head {
    padding: 18px 20px 15px;
    border-radius: 0;
  }
  .doc-body {
    padding: 22px 20px 26px;
    font-size: 13.5px;
  }
  .doc-foot {
    padding: 14px 20px;
    border-radius: 0;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .doc-nav {
    justify-content: center;
  }
  /* Tabelle scorrevoli su schermi stretti: il blocco resta largo
     quanto il pannello e scorre orizzontalmente al proprio interno. */
  .doc-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .doc-table td,
  .doc-table th {
    min-width: 124px;
  }
}

@media (max-width: 560px) {
  .legalbar {
    justify-content: center;
    text-align: center;
    padding: 9px 18px 11px;
  }
  .legalbar nav {
    justify-content: center;
  }
  .legalbar-id {
    width: 100%;
    text-align: center;
  }
  .signature {
    bottom: 96px;
  }
  .controls {
    bottom: 90px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .doc,
  .doc-panel,
  .cbanner {
    animation: none;
  }
}

/* Stampa: le informative devono restare stampabili */
@media print {
  canvas,
  .brand,
  .message,
  .signature,
  .controls,
  .legalbar,
  .cbanner,
  .doc-close,
  .doc-foot {
    display: none !important;
  }
  .doc {
    position: static;
    display: block;
    overflow: visible;
    padding: 0;
    background: #fff;
    backdrop-filter: none;
  }
  .doc[hidden] {
    display: none !important;
  }
  .doc-panel,
  .doc-head {
    border: 0;
    background: #fff;
    box-shadow: none;
  }
  .doc-head h2,
  .doc-body,
  .doc-body h3,
  .doc-body h4,
  .doc-body strong {
    color: #000;
  }
  .doc-body a {
    color: #000;
  }
}
