/* ==========================================================================
   Cookie Consent Banner + Settings Modal
   Uses the existing 037.digital design tokens (Webflow vars + custom)
   ========================================================================== */

/* Local scope vars - resolved from theme tokens with safe fallbacks */
.cc-banner,
.cc-modal {
  --cc-paper: var(--_colors---primary--paper, #f5f4f0);
  --cc-black: var(--_colors---primary--black, #0b0b0b);
  --cc-white: var(--_colors---primary--white, #ffffff);
  --cc-accent: var(--_colors---primary--accent, #c8ff00);
  --cc-radius: var(--border-radius--ultra, 24px);
  --cc-radius-sm: 12px;
  --cc-font-detail: var(--_typography---font-family--detail, 'Inter', system-ui, sans-serif);
  --cc-font-primary: var(--_typography---font-family--primary, 'Inter', system-ui, sans-serif);
}

/* --------- Banner --------- */
.cc-banner {
  position: fixed;
  z-index: 9990;
  left: 1.5rem;
  right: 1.5rem;
  bottom: 1.5rem;
  max-width: 640px;
  margin-left: auto;
  background: var(--cc-paper);
  color: var(--cc-black);
  border-radius: var(--cc-radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.08);
  font-family: var(--cc-font-detail);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.cc-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.cc-banner[hidden] {
  display: none !important;
}

.cc-banner__inner {
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cc-banner__title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-family: var(--cc-font-primary);
}

.cc-banner__text p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  opacity: 0.85;
}

.cc-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* --------- Buttons --------- */
.cc-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-family: var(--cc-font-detail);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  background: transparent;
  color: inherit;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.cc-btn:focus-visible {
  outline: 2px solid var(--cc-accent);
  outline-offset: 2px;
}

.cc-btn--ghost {
  border-color: rgba(0, 0, 0, 0.18);
  color: var(--cc-black);
}

.cc-btn--ghost:hover {
  background: rgba(0, 0, 0, 0.06);
}

.cc-btn--primary {
  background: var(--cc-black);
  color: var(--cc-white);
  border-color: var(--cc-black);
}

.cc-btn--primary:hover {
  transform: translateY(-1px);
  background: #1a1a1a;
}

.cc-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* --------- Modal --------- */
.cc-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--cc-font-detail);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.cc-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cc-modal[hidden] {
  display: none !important;
}

.cc-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.cc-modal__panel {
  position: relative;
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  background: var(--cc-paper);
  color: var(--cc-black);
  border-radius: var(--cc-radius);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
}

.cc-modal.is-visible .cc-modal__panel {
  transform: translateY(0) scale(1);
}

.cc-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cc-modal__title {
  margin: 0;
  font-family: var(--cc-font-primary);
  font-size: 1.125rem;
  font-weight: 600;
}

.cc-modal__close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 8px;
}

.cc-modal__close:hover {
  background: rgba(0, 0, 0, 0.06);
}

.cc-modal__body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.cc-modal__intro {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  opacity: 0.8;
}

.cc-cat {
  padding: 1rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.cc-cat:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.cc-cat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.cc-cat__name {
  margin: 0;
  font-family: var(--cc-font-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.cc-cat__desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  opacity: 0.75;
}

.cc-modal__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.02);
}

/* --------- Toggle switch --------- */
.cc-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-block;
}

.cc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.cc-toggle__slider {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.cc-toggle__slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  left: 3px;
  top: 3px;
  transition: transform 0.2s ease;
}

.cc-toggle input:checked + .cc-toggle__slider {
  background: var(--cc-black);
}

.cc-toggle input:checked + .cc-toggle__slider::before {
  transform: translateX(18px);
}

.cc-toggle.is-locked {
  cursor: not-allowed;
  opacity: 0.7;
}

.cc-toggle.is-locked .cc-toggle__slider {
  background: var(--cc-black);
}

.cc-toggle.is-locked .cc-toggle__slider::before {
  transform: translateX(18px);
}

/* --------- Footer link to reopen settings --------- */
.cc-footer-link {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.cc-footer-link:hover {
  text-decoration: underline;
}

/* --------- Responsive --------- */
@media (max-width: 640px) {
  .cc-banner {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }

  .cc-banner__inner {
    padding: 1rem 1.1rem;
  }

  .cc-banner__actions {
    justify-content: stretch;
  }

  .cc-banner__actions .cc-btn {
    flex: 1 1 auto;
  }

  .cc-modal__panel {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    border-radius: var(--cc-radius-sm);
  }

  .cc-modal__footer {
    flex-direction: column-reverse;
  }

  .cc-modal__footer .cc-btn {
    width: 100%;
  }
}
