/* ============================================================
   COOKIES — banner di consenso "pasticceria" + centro preferenze
   Palette brand: nero · rosa pastello · rosa neon tech.
   Il biscotto sfonda il bordo superiore del banner: la scena
   entra prima del testo e si auto-compone (vedi sweets-fx.js).
   z-index: 150 (sopra drawer 120, sotto skip-link 200)
   ============================================================ */

:root {
  --ck-dough: #dda25c;
  --ck-dough-light: #f7d7a6;
  --ck-cacao: #3a2113;
  --ck-panel: #0e0a0d;
  --ck-panel-2: #150d13;
  --ck-radius: 24px;
}

/* ---------- stage (esterno: gestisce entrata/uscita) ---------- */
.cookie-stage {
  position: fixed;
  left: clamp(14px, 2.4vw, 28px);
  right: clamp(14px, 2.4vw, 28px);
  bottom: clamp(14px, 2.4vw, 28px);
  z-index: 150;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.cookie-stage[data-state="hidden"] { visibility: hidden; }

.cookie-card {
  position: relative;
  pointer-events: auto;
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 4px 26px;
  padding: 26px 28px 24px;
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(255, 46, 136, .1), transparent 55%),
    linear-gradient(160deg, var(--ck-panel-2), var(--ck-panel) 62%);
  border: 1px solid var(--line, rgba(246, 199, 216, .16));
  border-radius: var(--ck-radius);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, .62),
    0 0 0 1px rgba(255, 46, 136, .07),
    0 0 42px rgba(255, 46, 136, .12);
  overflow: visible;
}

/* riga neon superiore + briciole sul bordo */
.cookie-card::before {
  content: "";
  position: absolute; inset: -1px -1px auto -1px; height: 2px;
  border-radius: var(--ck-radius) var(--ck-radius) 0 0;
  background: linear-gradient(90deg, transparent, var(--neon, #ff2e88) 22%, var(--pink, #f6c7d8) 58%, transparent);
  opacity: .85;
}
.cookie-card::after {
  content: "";
  position: absolute; top: -7px; left: 34px; right: 34px; height: 8px;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 6% 60%, var(--ck-dough) 1.6px, transparent 2px),
    radial-gradient(circle at 22% 30%, var(--ck-dough-light) 1.2px, transparent 1.8px),
    radial-gradient(circle at 44% 70%, var(--ck-dough) 1.4px, transparent 2px),
    radial-gradient(circle at 63% 26%, #f6c7d8 1.1px, transparent 1.7px),
    radial-gradient(circle at 81% 62%, var(--ck-dough) 1.7px, transparent 2.2px),
    radial-gradient(circle at 94% 34%, var(--ck-dough-light) 1.2px, transparent 1.8px);
  opacity: .8;
}

/* ---------- scena dolci (sfonda il bordo in alto) ---------- */
.cookie-scene {
  position: relative;
  grid-row: 1 / span 2;
  align-self: center;
  margin-top: -46px;
  padding-top: 46px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.cookie-scene .sweet-svg { width: 214px; max-width: 100%; }
.cookie-scene:focus-visible { outline: 2px solid var(--neon, #ff2e88); outline-offset: 6px; border-radius: 18px; }

.cookie-quip {
  position: absolute; bottom: -6px; left: 50%;
  transform: translateX(-50%);
  width: max-content; max-width: 210px;
  font-size: 11.5px; letter-spacing: .02em; line-height: 1.3;
  color: var(--pink, #f6c7d8);
  text-align: center;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.cookie-scene:hover .cookie-quip,
.cookie-stage.is-bitten .cookie-quip { opacity: 1; }

/* ---------- corpo testo ---------- */
.cookie-body { grid-column: 2; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.cookie-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display, "Archivo", sans-serif);
  font-size: 10.5px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase;
  color: var(--neon-2, #ff6fb1);
}
.cookie-eyebrow::before {
  content: ""; width: 22px; height: 1px; background: currentColor; opacity: .7;
}

.cookie-title {
  font-family: var(--font-display, "Archivo", sans-serif);
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.16;
  color: #fff;
  letter-spacing: -.01em;
}
.cookie-title em { font-style: normal; color: var(--pink, #f6c7d8); }

.cookie-desc { font-size: 14px; line-height: 1.6; color: var(--muted, #a89aa1); }
.cookie-desc a { color: var(--pink, #f6c7d8); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.cookie-desc a:hover { color: #fff; }

.cookie-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.cookie-actions .btn { padding: 12px 20px; font-size: 13px; }
.cookie-more {
  background: none; border: 0; cursor: pointer;
  font-family: var(--font-body, inherit); font-size: 13px; font-weight: 600;
  color: var(--pink, #f6c7d8);
  padding: 8px 4px; border-radius: 8px;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-style: dotted;
}
.cookie-more:hover { color: #fff; }
.cookie-more:focus-visible,
.cookie-actions .btn:focus-visible,
.cookie-close:focus-visible,
.cookie-fab:focus-visible,
.ck-row:focus-within { outline: 2px solid var(--neon, #ff2e88); outline-offset: 3px; }

.cookie-foot {
  margin-top: 2px; font-size: 11.5px; color: var(--muted, #a89aa1); letter-spacing: .02em;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
}
.cookie-foot a { color: var(--pink, #f6c7d8); }
.cookie-foot a:hover { color: #fff; text-shadow: 0 0 12px rgba(255, 46, 136, .4); }

.cookie-close {
  position: absolute; top: 12px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(246, 199, 216, .07);
  border: 1px solid var(--line, rgba(246, 199, 216, .16));
  color: var(--pink, #f6c7d8); cursor: pointer;
  font-size: 14px; line-height: 1;
  display: grid; place-content: center;
  transition: background .25s ease, color .25s ease, transform .25s ease;
}
.cookie-close:hover { background: var(--neon, #ff2e88); color: #12060c; transform: rotate(90deg); }

/* ---------- centro preferenze ---------- */
.cookie-prefs {
  grid-column: 1 / -1;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed rgba(246, 199, 216, .22);
  display: grid;
  gap: 10px;
}
.cookie-prefs[hidden] { display: none; }

.ck-prefs-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--muted, #a89aa1);
}
.ck-prefs-head strong {
  font-family: var(--font-display, "Archivo", sans-serif);
  font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--pink, #f6c7d8);
}

.ck-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 14px; align-items: center;
  padding: 12px 14px;
  background: linear-gradient(140deg, rgba(255, 46, 136, .05), rgba(255, 255, 255, .015));
  border: 1px solid rgba(246, 199, 216, .12);
  border-radius: 16px;
  transition: border-color .25s ease, transform .25s ease;
}
.ck-row:hover { border-color: rgba(255, 46, 136, .4); transform: translateY(-1px); }
.ck-row.is-locked { opacity: .82; }

.ck-icon { width: 46px; height: 46px; display: grid; place-items: center; }
.ck-icon .sweet-svg { width: 46px; pointer-events: none; }
.sweet-svg.is-mini { overflow: visible; }

.ck-text { min-width: 0; display: grid; gap: 3px; }
.ck-name {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display, "Archivo", sans-serif);
  font-size: 14.5px; font-weight: 700; color: #fff; letter-spacing: .01em;
}
.ck-tag {
  font-family: var(--font-body, inherit);
  font-size: 9.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 46, 136, .16); color: var(--neon-2, #ff6fb1);
  border: 1px solid rgba(255, 46, 136, .3);
}
.ck-tag.is-always { background: rgba(158, 211, 169, .14); color: #9ed3a9; border-color: rgba(158, 211, 169, .32); }
.ck-note { display: block; font-size: 12.5px; line-height: 1.5; color: var(--muted, #a89aa1); margin-top: 0; }

/* switch accessibile */
.ck-switch { position: relative; width: 52px; height: 30px; flex: none; }
.ck-switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.ck-switch input:disabled { cursor: not-allowed; }
.ck-track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(246, 199, 216, .12);
  border: 1px solid rgba(246, 199, 216, .22);
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease;
  pointer-events: none;
}
.ck-knob {
  position: absolute; top: 4px; left: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(150deg, var(--ck-dough-light), var(--ck-dough));
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  transition: transform .32s cubic-bezier(.34, 1.56, .64, 1), background .3s ease;
  pointer-events: none;
}
/* gocce di cacao sul pomello: è un mini biscotto */
.ck-knob::before, .ck-knob::after {
  content: ""; position: absolute; border-radius: 50%;
  background: var(--ck-cacao);
}
.ck-knob::before { width: 4px; height: 4px; top: 6px; left: 5px; }
.ck-knob::after { width: 3px; height: 3px; bottom: 5px; right: 6px; box-shadow: -6px -3px 0 -1px var(--ck-cacao); }

.ck-switch input:checked + .ck-track {
  background: linear-gradient(120deg, var(--neon, #ff2e88), var(--neon-2, #ff6fb1));
  border-color: transparent;
  box-shadow: 0 0 16px rgba(255, 46, 136, .45);
}
.ck-switch input:checked + .ck-track + .ck-knob { transform: translateX(22px); }
.ck-switch input:focus-visible + .ck-track { outline: 2px solid var(--neon, #ff2e88); outline-offset: 3px; }
.ck-switch input:disabled + .ck-track { background: rgba(158, 211, 169, .22); border-color: rgba(158, 211, 169, .4); box-shadow: none; }
.ck-switch input:disabled + .ck-track + .ck-knob { transform: translateX(22px); filter: grayscale(.25); }

.ck-prefs-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.ck-prefs-actions .btn { padding: 11px 20px; font-size: 13px; }
.ck-hint { font-size: 11.5px; color: var(--muted, #a89aa1); margin-left: auto; }

/* ---------- bottone flottante "rivedi le preferenze" ---------- */
.cookie-fab {
  position: fixed; left: clamp(12px, 2vw, 22px); bottom: clamp(12px, 2vw, 22px);
  z-index: 145;
  width: 56px; height: 56px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #1b1119, #0c0709 70%);
  border: 1px solid rgba(255, 46, 136, .35);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .55), 0 0 22px rgba(255, 46, 136, .22);
  cursor: pointer;
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s ease, border-color .3s ease;
}
.cookie-fab:hover { transform: translateY(-3px) rotate(-8deg); border-color: var(--neon, #ff2e88); box-shadow: 0 16px 34px rgba(0, 0, 0, .6), 0 0 30px rgba(255, 46, 136, .4); }
.cookie-fab:focus-visible { outline: 2px solid var(--neon, #ff2e88); outline-offset: 4px; }
.cookie-fab svg { width: 40px; height: 40px; pointer-events: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6)); }
.cookie-fab[hidden] { display: none; }
.cookie-fab::after {
  content: attr(data-tooltip);
  position: absolute; left: 62px; bottom: 12px;
  white-space: nowrap;
  font-size: 11.5px; letter-spacing: .04em;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(14, 10, 13, .92); color: var(--pink, #f6c7d8);
  border: 1px solid rgba(246, 199, 216, .2);
  opacity: 0; transform: translateX(-6px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.cookie-fab:hover::after, .cookie-fab:focus-visible::after { opacity: 1; transform: translateX(0); }

/* ---------- entrata senza GSAP ---------- */
@keyframes ck-rise {
  from { opacity: 0; transform: translateY(38px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cookie-stage.no-gsap[data-state="visible"] .cookie-card { animation: ck-rise .55s cubic-bezier(.22, 1, .36, 1) both; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .cookie-stage { justify-content: stretch; }
  .cookie-card {
    grid-template-columns: 1fr;
    padding: 22px 20px 20px;
    gap: 0;
    width: 100%;
    border-radius: 22px 22px 0 0;
    bottom: 0;
  }
  .cookie-stage { left: 0; right: 0; bottom: 0; }
  .cookie-scene {
    grid-row: auto;
    justify-self: start;
    margin: -60px 0 -6px;
    padding-top: 40px;
    width: 132px;
  }
  .cookie-scene .sweet-svg { width: 132px; }
  .cookie-body { grid-column: 1; }
  .cookie-prefs { grid-column: 1; }
  .ck-row { grid-template-columns: 40px 1fr auto; gap: 11px; padding: 11px 12px; }
  .ck-icon, .ck-icon .sweet-svg { width: 40px; }
  .ck-hint { margin-left: 0; width: 100%; }
}

@media (max-width: 420px) {
  .cookie-actions .btn { flex: 1 1 100%; }
  .cookie-more { width: 100%; text-align: center; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .cookie-card, .cookie-scene, .cookie-fab, .ck-row, .ck-knob, .ck-track, .cookie-close {
    transition-duration: .01ms !important;
    animation: none !important;
  }
  .cookie-stage.no-gsap[data-state="visible"] .cookie-card { animation: none !important; opacity: 1; }
}
