/* ==========================================================================
   Consent — the banner and the preference centre
   The marketing site and the dealership pages. CAA Console and Passport load
   nothing third-party, so neither shell links this file.

   Drawn in the ecosystem's language on its own (WP4): both pages that link it
   declare CAA Console's --console-* tokens, so the banner follows the device's light or
   dark theme without either page overriding it. It used to be written for the
   old dark surfaces — a rising keyframe, a blurred glass panel, a crimson
   switch — and the marketing site patched each of those back out; the
   dealership pages, which did not, showed all of it.

   Everything here is a real stylesheet rather than injected styles because the
   CSP carries no 'unsafe-inline' (src/worker.js) and tools/worker.test.mjs
   asserts it stays that way. tools/a11y.test.mjs holds it to the same rules as
   site.css: no motion beyond colour, no blur, no gradient.
   ========================================================================== */

/* --- The banner ------------------------------------------------------------
   Bottom-anchored. z-index 90 puts it over a menu sheet (70) and under toasts
   (120): a toast is a reply to something the visitor just did and must not be
   buried by this.
   -------------------------------------------------------------------------- */
.consent {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(var(--bar-inset, 0px) + 16px);
  z-index: 90;
  border: 1px solid var(--console-border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  background: var(--console-surface);
  color: var(--console-ink);
  box-shadow: var(--console-shadow-pop);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  animation: none;
}

/* The configurator's estimate bar sits along the foot of /quote; stack above it. */
body:has(.estimate) .consent {
  bottom: calc(var(--bar-inset, 0px) + 88px);
}

/* On a phone the banner is the first thing over the first screen, and at
   full size it covered a third of it. Same words and the same three equal
   choices, set tighter and on one row. */
@media (max-width: 719px) {
  .consent {
    left: 10px;
    right: 10px;
    bottom: calc(var(--bar-inset, 0px) + 10px);
    padding: 12px 14px;
  }

  .consent__inner {
    gap: 10px;
  }

  .consent__title {
    font-size: 14px;
    margin-bottom: 2px;
  }

  .consent__text {
    font-size: 13px;
    line-height: 1.5;
  }

  .consent__actions {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .consent .btn {
    min-width: 0;
    height: 44px;
    padding-inline: 8px;
    font-size: 13px;
  }
}

@media (min-width: 720px) {
  .consent {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: min(440px, calc(100vw - 48px));
  }
}

.consent__inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.consent__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--console-ink);
  margin-bottom: 6px;
}

.consent__text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--console-ink-2);
}

/* Three buttons of equal weight bar one. Declining is not a secondary action
   dressed down to be missed: "Only necessary" is as easy to press as "Accept". */
.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.consent .btn,
.consent-prefs .btn {
  flex: 1 1 auto;
  min-width: 96px;
  height: 44px;
  padding-inline: 16px;
  border: 1px solid var(--console-border-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--console-ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.consent .btn:hover,
.consent-prefs .btn:hover {
  border-color: var(--console-ink);
  color: var(--console-ink);
}

.consent .btn--primary,
.consent-prefs .btn--primary {
  background: var(--console-primary);
  border-color: var(--console-primary);
  color: var(--console-on-primary);
}

.consent .btn--primary:hover,
.consent-prefs .btn--primary:hover {
  background: var(--console-primary-hover);
  border-color: var(--console-primary-hover);
  color: var(--console-on-primary);
}

/* --- The preference centre ------------------------------------------------- */
.consent-prefs__dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--console-border);
  border-radius: var(--r-md);
  background: var(--console-surface);
  color: var(--console-ink);
  box-shadow: var(--console-shadow-pop);
  overflow: auto;
  overscroll-behavior: contain;
}

.consent-prefs__dialog::backdrop {
  background: var(--console-scrim);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.consent-prefs {
  position: relative;
  padding: 26px 24px 24px;
}

.consent-prefs__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--console-ink-2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.consent-prefs__close:hover {
  color: var(--console-ink);
  background: var(--console-subtle);
}

.consent-prefs__title {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 30px);
  font-weight: 400;
  line-height: 1.15;
  color: var(--console-ink);
  margin: 8px 0 12px;
}

.consent-prefs__lede {
  font-size: 15px;
  line-height: 1.65;
  color: var(--console-ink-2);
}

.consent-prefs__list {
  margin: 22px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.consent-prefs__row {
  padding: 16px 0;
  border-top: 1px solid var(--console-border);
}

.consent-prefs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.consent-prefs__label {
  font-size: 16px;
  font-weight: 600;
  color: var(--console-ink);
}

.consent-prefs__fixed {
  font-size: 13px;
  color: var(--console-ink-2);
  white-space: nowrap;
}

.consent-prefs__summary {
  font-size: 14px;
  line-height: 1.6;
  color: var(--console-ink);
  margin-bottom: 6px;
}

.consent-prefs__detail {
  font-size: 13px;
  line-height: 1.6;
  color: var(--console-ink-2);
}

/* --- The switch -------------------------------------------------------------
   The thumb moves without a transition: motion here is colour only, and a
   thumb that snaps across is as clear as one that slides.
   -------------------------------------------------------------------------- */
.consent-prefs__switch {
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
}

.consent-prefs__switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.consent-prefs__track {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  background: var(--console-selected);
  border: 1px solid var(--console-border-strong);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.consent-prefs__track::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 3px;
  border-radius: var(--r-pill);
  background: var(--console-surface);
  box-shadow: 0 0 0 1px var(--console-border-strong);
}

.consent-prefs__switch input:checked + .consent-prefs__track {
  background: var(--console-primary);
  border-color: var(--console-primary);
}

.consent-prefs__switch input:checked + .consent-prefs__track::after {
  margin-left: 23px;
  background: var(--console-on-primary);
  box-shadow: none;
}

.consent-prefs__switch input:focus-visible + .consent-prefs__track {
  outline: 2px solid var(--console-focus);
  outline-offset: 2px;
}

/* --- Actions and the record ------------------------------------------------ */
.consent-prefs__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--console-border);
}

.consent-prefs__record {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--console-border);
}

.consent-prefs__note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--console-ink-2);
  margin-bottom: 8px;
}

/* The reference is meant to be read aloud down a phone or pasted into an
   email, so it is set where it can be selected whole. */
.consent-prefs__id {
  font-size: 13px;
  line-height: 1.6;
  color: var(--console-ink-2);
  margin-bottom: 12px;
}

.consent-prefs__id code {
  color: var(--console-ink);
  font-family: var(--font-num, inherit);
  font-size: 0.95em;
  word-break: break-all;
}

.consent-prefs__withdraw {
  border: 0;
  padding: 0;
  background: none;
  color: var(--console-danger);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.consent-prefs__withdraw:hover {
  color: var(--console-ink);
}
