/* =========================================================
   COOKIE CONSENT — banner, widget flutuante e modal de preferências
   Adaptado do skill "Cookie Consent Banner System" (React/TS) para
   HTML/CSS/JS puro. Usa as mesmas variáveis de cor/tipografia do
   styles.css principal, então precisa ser carregado DEPOIS dele.
   ========================================================= */

:root {
  --cc-z-widget: 9998;
  --cc-z-banner: 9999;
  --cc-z-overlay: 10000;
}

/* ---------- Banner (canto inferior direito) ---------- */
.cc-banner {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: var(--cc-z-banner);
  width: min(400px, calc(100vw - 2.2rem));
  padding: 1.5rem 1.5rem 1.3rem;
  background: var(--paper);
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  box-shadow: 0 24px 50px rgba(4, 16, 38, 0.28);
  display: flex;
  flex-direction: column;
  gap: 1rem;

  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out), visibility 0.4s;
}
.cc-banner.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }

.cc-banner__close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}
.cc-banner__close:hover { color: var(--ink); background: var(--paper-dim); }
.cc-banner__close svg { width: 16px; height: 16px; }

.cc-banner__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 1.4rem 0.35rem 0;
}

.cc-banner__text {
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}
.cc-banner__text a { color: var(--gold-ink); font-weight: 600; text-decoration: underline; }

.cc-banner__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7em 1em;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.2s var(--ease-out), color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}

.cc-btn--primary {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #ecca6f 0%, var(--gold) 55%, #b98730 100%);
  color: var(--night-900);
}
.cc-btn--primary:hover { background: linear-gradient(180deg, #f3d685 0%, var(--gold-hot) 55%, #c99a45 100%); }

.cc-btn--ghost {
  background: transparent;
  border-color: var(--line-light);
  color: var(--ink-soft);
}
.cc-btn--ghost:hover { border-color: var(--gold); color: var(--gold-ink); }

/* ---------- Widget flutuante (reabre as preferências) ---------- */
.cc-widget {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: var(--cc-z-widget);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  background: var(--night-900);
  color: var(--gold-hot);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(2, 8, 20, 0.35);

  opacity: 0;
  visibility: hidden;
  transform: scale(0.6);
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out), visibility 0.3s, background-color 0.2s var(--ease-out);
}
.cc-widget.is-visible { opacity: 1; visibility: visible; transform: scale(1); }
.cc-widget:hover { background: var(--night-800); }
.cc-widget svg { width: 20px; height: 20px; }

/* ---------- Modal de preferências ---------- */
.cc-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--cc-z-overlay);
  background: rgba(3, 12, 30, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;

  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease-out), visibility 0.25s;
}
.cc-overlay.is-visible { opacity: 1; visibility: visible; }

.cc-modal {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px rgba(2, 8, 20, 0.4);
  transform: translateY(20px);
  transition: transform 0.3s var(--ease-out);
}
.cc-overlay.is-visible .cc-modal { transform: translateY(0); }

.cc-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.3rem 1.5rem;
  border-bottom: 1px solid var(--line-light);
}
.cc-modal__header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.cc-modal__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--paper-dim);
  color: var(--ink-soft);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}
.cc-modal__close:hover { color: var(--ink); background: var(--line-light); }
.cc-modal__close svg { width: 16px; height: 16px; }

.cc-modal__body {
  padding: 1.4rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.cc-modal__intro {
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0;
}
.cc-modal__intro a { color: var(--gold-ink); font-weight: 600; text-decoration: underline; }

.cc-category {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line-light);
}
.cc-category:last-child { border-bottom: 0; padding-bottom: 0; }

.cc-category__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.3rem;
}
.cc-category__badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-ink);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.cc-category__text {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
  max-width: 38ch;
}

/* Switch (checkbox estilizado) */
.cc-switch {
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  width: 44px;
  height: 25px;
}
.cc-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.cc-switch__track {
  position: absolute;
  inset: 0;
  background: var(--line-light);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-out);
}
.cc-switch__track::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 19px;
  height: 19px;
  background: var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease-out);
}
.cc-switch input:checked + .cc-switch__track { background: var(--gold); }
.cc-switch input:checked + .cc-switch__track::before { transform: translateX(19px); }
.cc-switch input:disabled + .cc-switch__track { opacity: 0.65; cursor: not-allowed; }
.cc-switch input:focus-visible + .cc-switch__track { outline: 2px solid var(--gold); outline-offset: 2px; }

.cc-modal__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.7rem;
  padding: 1.1rem 1.5rem;
  background: var(--paper-dim);
  border-top: 1px solid var(--line-light);
  border-radius: 0 0 var(--radius) var(--radius);
}
.cc-modal__footer .cc-btn { padding-inline: 1.4rem; }

@media (max-width: 480px) {
  .cc-banner { right: 0.7rem; bottom: 0.7rem; padding: 1.2rem 1.2rem 1.1rem; }
  .cc-widget { right: 0.7rem; bottom: 0.7rem; }
  .cc-modal__footer { justify-content: stretch; }
  .cc-modal__footer .cc-btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-banner, .cc-widget, .cc-overlay, .cc-modal, .cc-switch__track, .cc-switch__track::before {
    transition: none;
  }
}
