/* L'avviso è fuori dal flusso già al primo rendering; noscript lo riporta nel flusso. */
.cookie-notice {
  box-sizing: border-box;
  position: fixed;
  z-index: 100;
  right: max(.75rem, env(safe-area-inset-right));
  bottom: max(.75rem, env(safe-area-inset-bottom));
  width: min(100% - 2rem, 38rem);
  max-height: 70vh;
  overflow-y: auto;
  margin: 0;
  border: 1px solid #a9c1b5;
  border-radius: 1rem;
  background: #fff;
  color: #303b39;
  font-family: var(--font-body, 'Source Sans 3', sans-serif);
  font-size: 1.125rem;
  line-height: 1.45;
  box-shadow: 0 12px 36px rgba(25, 61, 58, .16);
}

.cookie-notice *,
.cookie-notice *::before,
.cookie-notice *::after {
  box-sizing: border-box;
}

.cookie-notice[hidden],
[data-cookie-open][hidden] {
  display: none !important;
}

.cookie-notice--enhanced {
  position: fixed;
  z-index: 100;
  right: max(.75rem, env(safe-area-inset-right));
  bottom: max(.75rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  width: min(38rem, calc(100% - 1.5rem));
  max-height: min(70vh, 34rem);
  max-height: min(70dvh, 34rem);
  margin: 0;
}

.cookie-notice__header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: .9rem 1rem .35rem 1.15rem;
}

.cookie-notice__header h2 {
  margin: 0;
  padding-top: .35rem;
  color: #214d49;
  font-family: var(--font-heading, 'Nunito Sans', sans-serif);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: normal;
}

.cookie-notice__body {
  min-height: 0;
  padding: .35rem 1.15rem;
}

.cookie-notice--enhanced .cookie-notice__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cookie-notice__body p {
  margin: 0 0 .8rem;
}

.cookie-notice__body p:last-child {
  margin-bottom: 0;
}

.cookie-notice__scroll-hint {
  flex: 0 0 auto;
  margin: 0;
  padding: .35rem 1.15rem 0;
  color: #214d49;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.cookie-notice__scroll-hint[hidden] { display: none; }

.cookie-notice__body a {
  color: #214d49;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .18em;
}

.cookie-notice__close,
.cookie-notice__actions {
  display: none;
}

.cookie-notice--enhanced .cookie-notice__close {
  display: inline-flex;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #9bb5a7;
  border-radius: .55rem;
  background: #fff;
  color: #214d49;
  font: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.cookie-notice--enhanced .cookie-notice__actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-start;
  padding: .75rem 1.15rem 1rem;
}

.cookie-notice__ack {
  min-width: 8rem;
  min-height: 48px;
  padding: .65rem 1.25rem;
  border: 2px solid #214d49;
  border-radius: .65rem;
  background: #214d49;
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
}

.cookie-notice__close:hover { background: #e6efea; }
.cookie-notice__ack:hover { border-color: #193d3a; background: #193d3a; }

.cookie-notice :focus-visible,
.cookie-notice__header h2:focus {
  outline: 3px solid #a9472f;
  outline-offset: 2px;
}

.cookie-notice__noscript {
  margin: .5rem 1.15rem 1rem;
}

.site-footer [data-cookie-open] {
  display: block;
  min-height: 44px;
  padding: .35rem 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: .18em;
  cursor: pointer;
}

.site-footer [data-cookie-open]:hover { text-decoration-thickness: .14em; }
.site-footer [data-cookie-open]:focus-visible { outline: 3px solid #df947f; outline-offset: 4px; }

@media (max-width: 480px) {
  .cookie-notice__header { gap: .25rem; padding: .4rem .5rem .2rem; }
  .cookie-notice__header h2 { font-size: 1.125rem; line-height: 1.2; }
  .cookie-notice__body { padding: .25rem .5rem; }
  .cookie-notice__scroll-hint { padding: .25rem .5rem 0; line-height: 1.2; }
  .cookie-notice--enhanced .cookie-notice__actions { padding: .3rem .5rem .5rem; }
  .cookie-notice--enhanced .cookie-notice__actions { justify-content: stretch; }
  .cookie-notice__ack { width: 100%; min-width: 0; padding: .35rem .5rem; }
}

/* Il banner rimane sopra, mai sulle azioni rapide; la barra include la safe area. */
@media (max-width: 74.999rem) {
  .cookie-notice--enhanced {
    right: max(.75rem, env(safe-area-inset-right, 0px));
    bottom: calc(var(--mobile-contact-space, 8.5rem) + .5rem);
    left: max(.75rem, env(safe-area-inset-left, 0px));
    width: auto;
    max-width: 38rem;
    max-height: min(70vh, 34rem, max(0px, calc(100vh - var(--mobile-contact-space, 8.5rem) - 1.5rem)));
    max-height: min(70dvh, 34rem, max(0px, calc(100dvh - var(--mobile-contact-space, 8.5rem) - 1.5rem)));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.keyboard-open .cookie-notice--enhanced {
    bottom: max(.75rem, env(safe-area-inset-bottom, 0px));
    max-height: min(70vh, 34rem);
    max-height: min(70dvh, 34rem);
  }
}

/* Se l'altezza è ridotta, scorrono insieme titolo, testo e pulsanti. */
@media (max-height: 32rem) {
  .cookie-notice--enhanced { overflow-y: auto; }
  .cookie-notice--enhanced .cookie-notice__body {
    flex: 0 0 auto;
    overflow: visible;
  }
}
