/*
 * Cookie consent banner + preferences modal.
 *
 * Pulls colors from the existing :root tokens defined in
 * br-market-group.br.css so the banner blends with the site theme
 * (dark surface, whitesmoke text, subtle borders).
 */

.bmg-consent-banner,
.bmg-consent-modal {
  --bmg-consent-bg: var(--bg-primary, #121212);
  --bmg-consent-fg: var(--text-colors--main, whitesmoke);
  --bmg-consent-muted: var(--text-colors--second, #b4b4b4);
  --bmg-consent-border: var(--text-colors--dividers-lines, #2a2a2a);
  --bmg-consent-accent: var(--text-colors--main, whitesmoke);
  --bmg-consent-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  --bmg-consent-radius: 6px;
  --bmg-consent-pad: clamp(1rem, 2.5vw, 1.5rem);
  --bmg-consent-gap: clamp(0.75rem, 2vw, 1.25rem);
  font-family: var(--_text---font-family, 'Satoshi', system-ui, sans-serif);
  color: var(--bmg-consent-fg);
  box-sizing: border-box;
}

.bmg-consent-banner *,
.bmg-consent-banner *::before,
.bmg-consent-banner *::after,
.bmg-consent-modal *,
.bmg-consent-modal *::before,
.bmg-consent-modal *::after {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- *
 * Banner — fixed to bottom of viewport, full width on mobile.
 * ---------------------------------------------------------------- */
.bmg-consent-banner {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9990;
  background: var(--bmg-consent-bg);
  border-top: 1px solid var(--bmg-consent-border);
  box-shadow: var(--bmg-consent-shadow);
  padding: var(--bmg-consent-pad);
}

.bmg-consent-banner[hidden] {
  display: none;
}

.bmg-consent-banner__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bmg-consent-gap);
  justify-content: space-between;
}

.bmg-consent-banner__copy {
  flex: 1 1 320px;
  min-width: 0;
}

.bmg-consent-banner__title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.bmg-consent-banner__text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--bmg-consent-muted);
}

.bmg-consent-banner__link {
  color: var(--bmg-consent-fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bmg-consent-banner__link:hover,
.bmg-consent-banner__link:focus-visible {
  opacity: 0.8;
}

.bmg-consent-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---------------------------------------------------------------- *
 * Buttons (shared between banner + modal).
 * ---------------------------------------------------------------- */
.bmg-consent-btn {
  appearance: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.625rem 1.1rem;
  border-radius: var(--bmg-consent-radius);
  border: 1px solid var(--bmg-consent-border);
  background: transparent;
  color: var(--bmg-consent-fg);
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
  white-space: nowrap;
}

.bmg-consent-btn:hover {
  border-color: var(--bmg-consent-fg);
}

.bmg-consent-btn:focus-visible {
  outline: 2px solid var(--bmg-consent-fg);
  outline-offset: 2px;
}

.bmg-consent-btn:active {
  transform: translateY(1px);
}

.bmg-consent-btn--primary {
  background: var(--bmg-consent-fg);
  color: var(--bmg-consent-bg);
  border-color: var(--bmg-consent-fg);
}

.bmg-consent-btn--primary:hover {
  background: transparent;
  color: var(--bmg-consent-fg);
}

.bmg-consent-btn--ghost {
  background: transparent;
}

/* ---------------------------------------------------------------- *
 * Modal.
 * ---------------------------------------------------------------- */
.bmg-consent-modal[hidden] {
  display: none;
}

.bmg-consent-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2rem);
}

.bmg-consent-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.bmg-consent-modal__panel {
  position: relative;
  width: min(640px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: var(--bmg-consent-bg);
  border: 1px solid var(--bmg-consent-border);
  border-radius: 10px;
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.bmg-consent-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.bmg-consent-modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  outline: none;
}

.bmg-consent-modal__close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--bmg-consent-fg);
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
}

.bmg-consent-modal__close:hover {
  opacity: 0.8;
}

.bmg-consent-modal__close:focus-visible {
  outline: 2px solid var(--bmg-consent-fg);
  outline-offset: 2px;
}

.bmg-consent-modal__desc {
  margin: 0 0 1.25rem;
  color: var(--bmg-consent-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.bmg-consent-modal__categories {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.bmg-consent-row {
  display: block;
  border: 1px solid var(--bmg-consent-border);
  border-radius: var(--bmg-consent-radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}

.bmg-consent-row:hover {
  border-color: var(--bmg-consent-fg);
}

.bmg-consent-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.bmg-consent-row__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.bmg-consent-row__desc {
  display: block;
  color: var(--bmg-consent-muted);
  font-size: 0.825rem;
  line-height: 1.45;
}

.bmg-consent-row__desc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0 0.25rem;
  border-radius: 3px;
}

/* Custom checkbox so we don't rely on UA styles inside dark theme. */
.bmg-consent-row input[type='checkbox'] {
  appearance: none;
  width: 2.5rem;
  height: 1.4rem;
  background: var(--bmg-consent-border);
  border: 1px solid var(--bmg-consent-border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background-color 160ms ease;
  flex: 0 0 auto;
}

.bmg-consent-row input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 2px;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--bmg-consent-fg);
  transform: translateY(-50%);
  transition: left 160ms ease;
}

.bmg-consent-row input[type='checkbox']:checked {
  background: var(--bmg-consent-fg);
}

.bmg-consent-row input[type='checkbox']:checked::after {
  left: calc(100% - 1.2rem);
  background: var(--bmg-consent-bg);
}

.bmg-consent-row input[type='checkbox']:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.bmg-consent-row input[type='checkbox']:focus-visible {
  outline: 2px solid var(--bmg-consent-fg);
  outline-offset: 2px;
}

.bmg-consent-modal__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Lock background scroll while the modal is open. */
body.bmg-consent-modal-open {
  overflow: hidden;
}

/* Honor reduced-motion users. */
@media (prefers-reduced-motion: reduce) {
  .bmg-consent-btn,
  .bmg-consent-row,
  .bmg-consent-row input[type='checkbox'],
  .bmg-consent-row input[type='checkbox']::after {
    transition: none;
  }
}

/* Inline "Cookie preferences" trigger in body copy (e.g. cookie policy). */
.bmg-inline-link {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.bmg-inline-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Tiny screens — stack actions full-width. */
@media (max-width: 520px) {
  .bmg-consent-banner__actions {
    width: 100%;
  }
  .bmg-consent-banner__actions .bmg-consent-btn {
    flex: 1 1 auto;
  }
  .bmg-consent-modal__footer {
    justify-content: stretch;
  }
  .bmg-consent-modal__footer .bmg-consent-btn {
    flex: 1 1 auto;
  }
}
