/* =====================================================================
   Pannello cookie (inc/consenso.php + assets/js/consenso.js)
   Barra a tutta larghezza in basso; su mobile sta sopra la tabbar.
   Tema chiaro di default, blu notte nelle pagine del gioco (body.theme-rk).
   ===================================================================== */

.wr-cookie,
.wr-cookie-fab {
  --wrc-bg: #fff;
  --wrc-fg: var(--ink, #0d0d10);
  --wrc-muted: #55555f;
  --wrc-line: rgba(15, 23, 42, 0.1);
  --wrc-card: #f6f6f8;
  --wrc-primary: var(--brand, #d13300);
  --wrc-primary-hover: #b02b00;
  --wrc-primary-fg: #fff;
  --wrc-dark: var(--ink, #0d0d10);
  --wrc-dark-fg: #fff;
  --wrc-accent: var(--brand, #d13300);
  --wrc-off: #8a8a94;
  --wrc-bottom: 0px;
}

@media (max-width: 899px) {
  .wr-cookie,
  .wr-cookie-fab {
    --wrc-bottom: calc(var(--tabbar-h, 64px) + env(safe-area-inset-bottom));
  }
}

body.theme-rk .wr-cookie,
body.theme-rk .wr-cookie-fab {
  --wrc-bg: #0f1d47;
  --wrc-fg: #fff;
  --wrc-muted: rgba(255, 255, 255, 0.8);
  --wrc-line: rgba(255, 255, 255, 0.14);
  --wrc-card: rgba(255, 255, 255, 0.06);
  --wrc-primary: #ffc906;
  --wrc-primary-hover: #ffd84a;
  --wrc-primary-fg: #0b1638;
  --wrc-dark: transparent;
  --wrc-dark-fg: #fff;
  --wrc-accent: #ffc906;
  --wrc-off: rgba(255, 255, 255, 0.4);
}

[hidden].wr-cookie,
[hidden].wr-cookie-velo,
[hidden].wr-cookie-fab,
.wr-cookie [data-cookie-vista][hidden] {
  display: none !important;
}

html[data-wr-cookie] body {
  overflow: hidden;
}

/* ---------- velo ---------- */
.wr-cookie-velo {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(13, 13, 16, 0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ---------- barra ---------- */
.wr-cookie {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--wrc-bottom);
  z-index: 96;
  max-height: calc(100vh - var(--wrc-bottom) - 1rem);
  max-height: calc(100dvh - var(--wrc-bottom) - 1rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--wrc-bg);
  color: var(--wrc-fg);
  border-top: 1px solid var(--wrc-line);
  box-shadow: 0 -12px 40px rgba(13, 13, 16, 0.2);
  font-family: var(--font-sans, system-ui, sans-serif);
}

body.theme-rk .wr-cookie {
  border-top: 0;
  box-shadow: inset 0 3px 0 #db0a40, 0 -12px 40px rgba(3, 8, 26, 0.6);
}

@media (max-width: 899px) {
  .wr-cookie {
    border-radius: var(--r-lg, 1.1rem) var(--r-lg, 1.1rem) 0 0;
  }
}

.wr-cookie:focus {
  outline: none;
}

.wr-cookie-inner {
  position: relative;
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 1.5rem 0;
}

@media (min-width: 900px) {
  .wr-cookie-inner {
    width: min(1200px, calc(100% - 96px));
    padding: 2rem 0;
  }
}

.wr-cookie-intro {
  display: grid;
  gap: 1.25rem;
  align-items: center;
}

@media (min-width: 900px) {
  .wr-cookie-intro {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3rem;
  }
}

.wr-cookie-eyebrow {
  margin: 0;
  padding-right: 3rem;
  color: var(--wrc-accent);
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wr-cookie-title {
  margin: 0.4rem 0 0;
  padding-right: 3rem;
  color: var(--wrc-fg);
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

@media (min-width: 900px) {
  .wr-cookie-title {
    font-size: 1.6rem;
  }
}

.wr-cookie-text {
  max-width: 48rem;
  margin: 0.6rem 0 0;
  color: var(--wrc-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.wr-cookie-foot {
  margin: 0.75rem 0 0;
  color: var(--wrc-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.wr-cookie-foot a {
  color: var(--wrc-fg);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wr-cookie-foot a:hover {
  color: var(--wrc-accent);
}

/* ---------- bottoni ---------- */
.wr-cookie-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

@media (min-width: 560px) {
  .wr-cookie-actions {
    flex-direction: row;
    align-items: center;
  }
}

.wr-cookie-actions--wide {
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--wrc-line);
  column-gap: 1.25rem;
}

.wr-cookie-actions--wide .wr-cookie-foot {
  margin: 0;
}

@media (min-width: 560px) {
  .wr-cookie-actions--wide .wr-cookie-foot {
    margin-left: auto;
    text-align: right;
  }
}

.wr-cookie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.5rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.wr-cookie-btn:active {
  transform: scale(0.98);
}

.wr-cookie-btn--primary {
  background: var(--wrc-primary);
  color: var(--wrc-primary-fg);
}

.wr-cookie-btn--primary:hover {
  background: var(--wrc-primary-hover);
}

.wr-cookie-btn--dark {
  background: var(--wrc-dark);
  color: var(--wrc-dark-fg);
  border-color: var(--wrc-dark);
}

body.theme-rk .wr-cookie-btn--dark {
  border-color: rgba(255, 255, 255, 0.7);
}

.wr-cookie-btn--dark:hover {
  background: #24242b;
}

body.theme-rk .wr-cookie-btn--dark:hover {
  background: rgba(255, 255, 255, 0.1);
}

.wr-cookie-link {
  min-height: 44px;
  padding: 0 0.5rem;
  border: 0;
  background: none;
  color: var(--wrc-fg);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.wr-cookie-link:hover {
  color: var(--wrc-accent);
}

@media (max-width: 559px) {
  .wr-cookie-btn {
    width: 100%;
  }
}

.wr-cookie-close {
  position: absolute;
  top: 1rem;
  right: -0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--wrc-muted);
  cursor: pointer;
}

.wr-cookie-close:hover {
  background: var(--wrc-card);
  color: var(--wrc-fg);
}

.wr-cookie-close[hidden] {
  display: none;
}

/* ---------- interruttori ---------- */
.wr-cookie-switches {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

@media (min-width: 700px) {
  .wr-cookie-switches {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }
}

.wr-cookie-switch {
  display: block;
  padding: 0.75rem 1rem 0.9rem;
  border: 1px solid var(--wrc-line);
  border-radius: var(--r-lg, 1.1rem);
  background: var(--wrc-card);
  cursor: pointer;
}

.wr-cookie-switch:has(input:disabled) {
  cursor: default;
}

.wr-cookie-switch-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
}

.wr-cookie-switch-head > strong {
  margin-right: auto;
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.wr-cookie-fisso {
  color: var(--wrc-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wr-cookie-switch-text {
  display: block;
  margin-top: 0.15rem;
  color: var(--wrc-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.wr-cookie-switch-list {
  display: block;
  margin-top: 0.5rem;
  color: var(--wrc-muted);
  font-size: 0.875rem;
  line-height: 1.7;
}

.wr-cookie-switch-list code {
  padding: 0.05rem 0.35rem;
  border-radius: 0.35rem;
  background: var(--wrc-bg);
  color: var(--wrc-fg);
  font-size: 0.8125rem;
}

.wr-cookie-switch input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--wrc-off);
  cursor: pointer;
  transition: background 0.2s;
}

.wr-cookie-switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.wr-cookie-switch input[type="checkbox"]:checked {
  background: var(--wrc-primary);
}

body.theme-rk .wr-cookie-switch input[type="checkbox"]:checked::after {
  background: #0b1638;
}

.wr-cookie-switch input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.wr-cookie-switch input[type="checkbox"]:disabled {
  opacity: 0.55;
  cursor: default;
}

.wr-cookie-switch input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--wrc-accent);
  outline-offset: 3px;
}

.wr-cookie :focus-visible {
  outline: 3px solid var(--wrc-accent);
  outline-offset: 2px;
}

/* ---------- bottone flottante "Cookie" ---------- */
.wr-cookie-fab {
  position: fixed;
  left: 12px;
  bottom: calc(var(--wrc-bottom) + 12px);
  z-index: 58;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.9rem;
  border: 1px solid var(--wrc-line);
  border-radius: 999px;
  background: var(--wrc-bg);
  color: var(--wrc-fg);
  box-shadow: 0 6px 18px rgba(13, 13, 16, 0.14);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.92;
  transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}

.wr-cookie-fab svg {
  color: var(--wrc-accent);
  flex-shrink: 0;
}

.wr-cookie-fab:hover {
  opacity: 1;
  border-color: var(--wrc-accent);
}

body.theme-rk .wr-cookie-fab {
  box-shadow: 0 6px 18px rgba(3, 8, 26, 0.5);
}

/* su mobile solo l'icona: il nome accessibile resta nell'aria-label */
@media (max-width: 899px) {
  .wr-cookie-fab {
    left: 10px;
    bottom: calc(var(--wrc-bottom) + 10px);
    width: 44px;
    padding: 0;
  }

  .wr-cookie-fab span {
    display: none;
  }

  /* pagine con una barra fissa propria sopra la tabbar: il bottone sale sopra di essa */
  body:has(.ev-sticky) .wr-cookie-fab,
  body:has(.rk-mobilebar:not([hidden])) .wr-cookie-fab {
    bottom: calc(var(--wrc-bottom) + 84px);
  }
}

@media print {
  .wr-cookie,
  .wr-cookie-velo,
  .wr-cookie-fab {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wr-cookie-btn,
  .wr-cookie-switch input[type="checkbox"],
  .wr-cookie-switch input[type="checkbox"]::after,
  .wr-cookie-fab {
    transition: none;
  }
}
