/* ============================================================
   Legis — Cookie consent banner
   Values come straight from the Legis Design System. Tokens are
   scoped to .consent instead of :root so the component is
   self-contained and cannot collide with site.css.
   ============================================================ */

.consent {
  --c-accent: #0666FF;
  --c-navy: #0A1230;
  --c-ink: #0A0D16;
  --c-body: #565D70;
  --c-muted: #6E7686;
  --c-surface: #F2F3F7;
  --c-track: #E1E6EF;
  --c-badge-bg: #EEF4FF;
  --c-border: rgba(10, 18, 48, 0.1);
  --c-border-soft: rgba(10, 18, 48, 0.06);
  --c-shadow: 0 26px 60px rgba(10, 18, 48, 0.18);
  --c-ease: cubic-bezier(0.2, 0.65, 0.2, 1);
  --c-sans: 'Instrument Sans', 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --c-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  position: fixed;
  z-index: 900;
  left: 22px;
  bottom: 22px;
  width: min(430px, calc(100vw - 44px));
  font-family: var(--c-sans);
  -webkit-font-smoothing: antialiased;

  /* Hidden state. The element stays in flow (not display:none) so it can
     animate; `hidden` on the markup handles the pre-JS and dismissed cases. */
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.28s var(--c-ease), transform 0.28s var(--c-ease);
}

.consent.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* The banner never blocks the page: no backdrop, no focus trap, and the card
   itself is the only pointer target. */
.consent[hidden] {
  display: none;
}

.consent__card {
  background: #FFFFFF;
  border: 1px solid var(--c-border);
  border-radius: 20px; /* DS: modal radius */
  box-shadow: var(--c-shadow);
  padding: 22px;
}

/* ── Header ───────────────────────────────────────── */

.consent__eyebrow {
  margin: 0 0 10px;
  font-family: var(--c-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.consent__title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--c-navy);
  outline: none;
}

.consent__title:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.consent__body {
  margin: 0 0 18px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: var(--c-body);
  text-wrap: pretty;
}

.consent__body a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.consent__body a:hover {
  color: #06239E;
}

/* ── Categories ───────────────────────────────────── */

.consent__cats {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--c-border-soft);
  border-radius: 16px; /* DS: standard card radius */
  background: #FFFFFF;
  overflow: hidden;
}

.consent__cat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 14px;
}

.consent__cat + .consent__cat {
  border-top: 1px solid var(--c-border-soft);
}

.consent__cat-main {
  flex: 1 1 auto;
  min-width: 0;
}

.consent__cat-title {
  margin: 0 0 3px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--c-ink);
}

.consent__cat-desc {
  margin: 0;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--c-muted);
  text-wrap: pretty;
}

/* "Sempre attivi" — DS mono badge. Deliberately not a disabled switch: a
   control the visitor cannot operate would be theatre. */
.consent__badge {
  flex: 0 0 auto;
  margin-top: 2px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--c-badge-bg);
  color: var(--c-accent);
  font-family: var(--c-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ── Switch ───────────────────────────────────────── */

.consent__switch {
  flex: 0 0 auto;
  position: relative;
  margin-top: 2px;
}

.consent__check {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.consent__track {
  display: block;
  width: 40px;
  height: 23px;
  border-radius: 980px; /* DS: pill */
  background: var(--c-track);
  border: 1px solid rgba(10, 18, 48, 0.08);
  cursor: pointer;
  transition: background 0.22s var(--c-ease), border-color 0.22s var(--c-ease);
}

.consent__track::after {
  content: "";
  display: block;
  width: 17px;
  height: 17px;
  margin: 2px;
  border-radius: 980px;
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(10, 18, 48, 0.08);
  transition: transform 0.22s var(--c-ease);
}

.consent__check:checked + .consent__track {
  background: var(--c-accent);
  border-color: var(--c-accent);
}

.consent__check:checked + .consent__track::after {
  transform: translateX(17px);
}

.consent__check:focus-visible + .consent__track {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
}

/* ── Actions ──────────────────────────────────────── */

/* Equal grid columns: "Rifiuta tutto" and "Accetta tutto" get identical width,
   padding, type and contrast. Only the hue differs, both solid — no
   ghost-button demotion of the refusal. */
.consent__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.consent__btn {
  appearance: none;
  width: 100%;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 980px; /* DS: pill */
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: #FFFFFF;
  cursor: pointer;
  transition: background 0.22s var(--c-ease), box-shadow 0.22s var(--c-ease);
}

.consent__btn--reject {
  background: var(--c-navy);
}

.consent__btn--reject:hover {
  background: var(--c-accent);
}

.consent__btn--accept {
  background: var(--c-accent);
  box-shadow: 0 4px 14px rgba(6, 102, 255, 0.3);
}

.consent__btn--accept:hover {
  background: var(--c-navy);
  box-shadow: none;
}

.consent__btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
}

/* Tertiary: applies whatever the switch currently says. Kept quiet because it
   is a granular action, not a competing accept/reject shortcut. */
.consent__save {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 4px 0 0;
  background: none;
  border: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.22s var(--c-ease);
}

.consent__save:hover {
  color: var(--c-accent);
}

.consent__save:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── Footer trigger (withdrawal path) ─────────────── */

.consent-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.consent-link:hover {
  color: #FFFFFF;
}

/* ── Utilities ────────────────────────────────────── */

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

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 560px) {
  .consent {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }

  .consent__card {
    padding: 18px;
    border-radius: 20px;
  }

  .consent__actions {
    grid-template-columns: 1fr;
  }
}

/* ── Reduced motion ───────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .consent,
  .consent__track,
  .consent__track::after,
  .consent__btn,
  .consent__save {
    transition: none;
  }

  .consent {
    transform: none;
  }
}
