/* ============================================================
   MOSSUCCA - Consenso cookie (banner, preferenze, contenuti bloccati)
   Usa le variabili di style.css
   ============================================================ */
.cookie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.cookie-btn--solid {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

.cookie-btn--solid:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-white);
}

.cookie-btn--solid-dark {
  background: var(--color-navy);
  border-color: var(--color-navy);
  color: var(--color-white);
}

.cookie-btn--solid-dark:hover {
  background: var(--color-navy-alt);
  border-color: var(--color-navy-alt);
}

.cookie-btn--outline {
  background: transparent;
  border-color: var(--color-navy);
  color: var(--color-navy);
}

.cookie-btn--outline:hover {
  background: var(--color-navy);
  color: var(--color-white);
}

.cookie-btn--link {
  background: transparent;
  color: var(--color-heading);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cookie-btn--link:hover {
  color: var(--color-primary);
}

.cookie-btn:focus-visible,
.cookie-banner__close:focus-visible,
.cookie-prefs__close:focus-visible,
.cookie-switch input:focus-visible + .cookie-switch__track {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
}

/* Banner */
.cookie-banner {
  position: fixed;
  left: 1.5rem;
  bottom: 1.5rem;
  z-index: 1300;
  width: min(560px, calc(100vw - 3rem));
  padding: 1.75rem 1.75rem 1.5rem;
  background: var(--color-white);
  border-top: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(26, 35, 50, 0.25);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.cookie-banner[hidden],
.cookie-prefs[hidden] {
  display: none;
}

.cookie-banner.is-visible {
  opacity: 1;
  transform: none;
}

.cookie-banner__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.cookie-banner__close:hover {
  background: var(--color-bg-gray);
  color: var(--color-heading);
}

.cookie-banner__title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 2rem 0.6rem 0;
}

.cookie-banner__text {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: 1.25rem;
}

.cookie-banner__text a,
.cookie-prefs__intro a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cookie-banner__actions,
.cookie-prefs__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
}

.cookie-banner__actions .cookie-btn--link {
  margin-right: auto;
}

/* Preferenze */
.cookie-prefs {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.cookie-prefs__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 29, 41, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cookie-prefs__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.3s ease, transform 0.3s ease;
  outline: none;
}

.cookie-prefs.is-open .cookie-prefs__backdrop,
.cookie-prefs.is-open .cookie-prefs__dialog {
  opacity: 1;
  transform: none;
}

.cookie-prefs-open,
.cookie-prefs-open body {
  overflow: hidden;
}

.cookie-prefs__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.cookie-prefs__title {
  font-size: 1.25rem;
  font-weight: 700;
}

.cookie-prefs__close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.cookie-prefs__close:hover {
  background: var(--color-bg-gray);
  color: var(--color-heading);
}

.cookie-prefs__body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.cookie-prefs__intro {
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.cookie-category {
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
}

.cookie-category__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.cookie-category__name {
  font-size: 1rem;
  font-weight: 600;
}

.cookie-category__always {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2f855a;
}

.cookie-category__desc {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--color-text-muted);
  margin: 0;
}

.cookie-prefs__footer {
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

/* Interruttore */
.cookie-switch {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  cursor: pointer;
}

.cookie-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.cookie-switch__track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: #a0aec0;
  transition: background-color var(--transition-fast);
}

.cookie-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.cookie-switch input:checked + .cookie-switch__track {
  background: var(--color-primary);
}

.cookie-switch input:checked + .cookie-switch__track::after {
  transform: translateX(20px);
}

/* Contenuti esterni bloccati fino al consenso */
.consent-embed {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--color-bg-gray);
}

.consent-embed iframe:not([src]) {
  display: none;
}

.consent-embed__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem 1.5rem;
  text-align: center;
  background:
    radial-gradient(circle at 30% 30%, rgba(196, 18, 48, 0.07), transparent 55%),
    repeating-linear-gradient(45deg, var(--color-bg-light) 0 14px, var(--color-bg-gray) 14px 28px);
}

.consent-embed.is-loaded .consent-embed__placeholder {
  display: none;
}

.consent-embed__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-white);
  color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.consent-embed__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-heading);
  margin: 0;
}

.consent-embed__text {
  max-width: 440px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--color-text);
  margin: 0;
}

.consent-embed__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* Footer: "Preferenze cookie" è un <button> con l'aspetto dei link legali */
.footer__legal .footer__cookie-settings {
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.footer__legal .footer__cookie-settings:hover {
  color: var(--color-text-white-muted);
}

/* Cookie policy: tabella dei cookie */
.cookie-table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.cookie-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.cookie-table th,
.cookie-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border-light);
}

.cookie-table th {
  background: var(--color-bg-light);
  font-weight: 600;
  color: var(--color-heading);
}

.cookie-table tr:last-child td {
  border-bottom: none;
}

.cookie-table code {
  font-size: 0.8125rem;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .cookie-banner {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    width: auto;
    padding: 1.5rem 1.25rem 1.25rem;
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
  }

  .cookie-banner__actions .cookie-btn--solid,
  .cookie-banner__actions .cookie-btn--solid-dark {
    flex: 1 1 0;
  }

  .cookie-banner__actions .cookie-btn--link {
    order: 3;
    width: 100%;
    margin: 0;
  }

  .cookie-prefs {
    padding: 0;
    align-items: end;
  }

  .cookie-prefs__dialog {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .cookie-prefs__footer .cookie-btn {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-banner,
  .cookie-prefs__backdrop,
  .cookie-prefs__dialog {
    transition: none;
  }
}
