/*
 * Cookie banner, cookie settings and confirmation toast.
 * Markup: theme/components/consent-banner.php. Behaviour: assets/js/cookie-consent.js.
 *
 * B127 (2026-11-05): rewritten to designWork/Area Redesign Options/Cookie Consent.dc.html.
 * The prototype is dark only, so the consent layer keeps its dark palette on both site
 * themes (as the card did before). Replaces the earlier 890-line layered stylesheet; the
 * old version is kept in the B127 checkpoint.
 * The card's bottom offset above the dock is set in bones-look.css (QA B107 B2).
 */
.db-consent,
.db-consent-toast {
  --cc-card: #111319;
  --cc-modal: #0f1117;
  --cc-well: #0b0c10;
  --cc-line: rgba(157, 182, 255, .25);
  --cc-rule: rgba(255, 255, 255, .07);
  --cc-btn-line: rgba(255, 255, 255, .2);
  --cc-ink: #fff;
  --cc-body: #c9cdd8;
  --cc-muted: #a3a9b8;
  --cc-faint: #8b93a7;
  --cc-link: #9db6ff;
  --cc-code: #cfdcff;
  --cc-blue: #2563ff;
  --cc-blue-soft: rgba(37, 99, 255, .18);
  --cc-glow: radial-gradient(90% 80% at 0% 0%, rgba(37, 99, 255, .14), transparent 70%);
  --cc-edge: clamp(12px, 3vw, 28px);
  --cc-font: "Geist", ui-sans-serif, system-ui, sans-serif;
  --cc-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family: var(--cc-font);
  -webkit-font-smoothing: antialiased;
}

.db-consent {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

.db-consent[hidden],
.db-consent [hidden],
.db-consent-toast [hidden] {
  display: none !important;
}

.db-consent *,
.db-consent-toast * {
  box-sizing: border-box;
}

.db-consent h2,
.db-consent h3,
.db-consent p {
  margin: 0;
  font-family: var(--cc-font);
  text-transform: none;
}

.db-consent a {
  color: var(--cc-link);
  text-decoration: none;
}

.db-consent a:hover {
  color: var(--cc-ink);
}

.db-consent button {
  font-family: var(--cc-font);
  cursor: pointer;
  margin: 0;
}

.db-consent :is(a, button, input):focus-visible,
.db-consent-toast button:focus-visible {
  outline: 2px solid var(--cc-link);
  outline-offset: 2px;
}

/* Buttons */
.db-consent-btn {
  height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--cc-btn-line);
  background: var(--cc-well);
  color: var(--cc-ink);
  font: 500 15px/1 var(--cc-font);
  transition: border-color .15s ease, background-color .15s ease;
}

.db-consent-btn:hover {
  border-color: rgba(255, 255, 255, .45);
}

.db-consent-btn--ghost {
  height: 44px;
  background: transparent;
  font-size: 14.5px;
}

.db-consent-btn--primary {
  height: 44px;
  padding: 0 24px;
  border: 0;
  background: var(--cc-blue);
  font-size: 14.5px;
  box-shadow: 0 10px 24px -10px rgba(37, 99, 255, .9);
}

.db-consent-btn--primary:hover {
  background: #1f55e0;
}

/* Banner card */
.db-consent-card {
  position: absolute;
  left: var(--cc-edge);
  bottom: var(--cc-edge);
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  border-radius: 22px;
  background: var(--cc-card);
  border: 1px solid var(--cc-line);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .85);
  pointer-events: auto;
}

.db-consent-card__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 22px 18px;
  background: var(--cc-glow);
}

.db-consent-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-consent-card__icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--cc-blue-soft);
  border: 1px solid rgba(37, 99, 255, .5);
  color: var(--cc-link);
}

.db-consent-card h2 {
  font: 600 17px/1.3 var(--cc-font);
  letter-spacing: 0;
  color: var(--cc-ink);
}

.db-consent-card p {
  font: 400 14.5px/1.55 var(--cc-font);
  color: var(--cc-body);
}

.db-consent-card p strong {
  font-weight: 400;
  color: var(--cc-ink);
}

.db-consent-card__link {
  align-self: flex-start;
  font: 500 13.5px/1.4 var(--cc-font);
}

.db-consent-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 22px 20px;
}

.db-consent-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.db-consent-details-trigger {
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cc-link);
  font: 500 14px/1 var(--cc-font);
}

.db-consent-details-trigger:hover {
  color: var(--cc-ink);
}

/* Settings dialog */
.db-consent__overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 9, .7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.db-consent.is-details .db-consent__overlay {
  display: block;
}

.db-consent-modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  display: flex;
  pointer-events: auto;
}

.db-consent-modal__shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  border-radius: 24px;
  background: var(--cc-modal);
  border: 1px solid var(--cc-line);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .9);
  overflow: hidden;
}

.db-consent-modal__header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--cc-rule);
  background: radial-gradient(90% 100% at 0% 0%, rgba(37, 99, 255, .14), transparent 70%);
}

.db-consent-modal__header > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.db-consent-modal__header h2 {
  font: 600 26px/1.2 var(--cc-font);
  letter-spacing: -.02em;
  color: var(--cc-ink);
}

.db-consent-modal__header p {
  font: 400 14.5px/1.55 var(--cc-font);
  color: var(--cc-muted);
}

.db-consent-modal__close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .15);
  background: transparent;
  color: var(--cc-ink);
  font: 400 18px/1 var(--cc-font);
}

.db-consent-modal__close:hover {
  border-color: rgba(255, 255, 255, .4);
}

.db-consent-modal__content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 26px;
}

.db-consent-category {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 0;
  border-bottom: 1px solid var(--cc-rule);
}

.db-consent-category__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}

.db-consent-category__text {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.db-consent-category h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font: 600 16px/1.3 var(--cc-font);
  letter-spacing: 0;
  color: var(--cc-ink);
}

.db-consent-category p {
  font: 400 14px/1.5 var(--cc-font);
  color: var(--cc-muted);
}

.db-consent-status {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--cc-faint);
  font: 500 10px/1.5 var(--cc-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.db-consent-status.is-on {
  background: var(--cc-blue-soft);
  color: var(--cc-code);
}

/* Switch: native checkbox drawn as a 52×30 track with a 22px knob. */
.db-consent-switch {
  position: relative;
  flex: none;
  display: block;
  width: 52px;
  height: 30px;
  cursor: pointer;
}

.db-consent-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
  z-index: 1;
}

.db-consent-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .15);
  background: #1a1e29;
  transition: background-color .2s ease, border-color .2s ease;
}

.db-consent-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cc-faint);
  color: var(--cc-blue);
  font: 600 11px/22px var(--cc-font);
  text-align: center;
  transition: transform .2s ease, background-color .2s ease;
}

.db-consent-switch input:checked + span {
  background: var(--cc-blue);
  border-color: var(--cc-blue);
}

.db-consent-switch input:checked + span::after {
  content: "✓";
  background: #fff;
  transform: translateX(22px);
}

.db-consent-switch input:focus-visible + span {
  outline: 2px solid var(--cc-link);
  outline-offset: 2px;
}

.db-consent-switch--locked {
  cursor: not-allowed;
}

.db-consent-switch--locked input:checked + span {
  background: rgba(37, 99, 255, .35);
}

.db-consent-cookie-toggle {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cc-link);
  font: 500 13.5px/1.6 var(--cc-font);
}

.db-consent-cookie-toggle:hover {
  color: var(--cc-ink);
}

.db-consent-rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 12px;
  background: var(--cc-well);
  border: 1px solid rgba(255, 255, 255, .08);
  overflow: hidden;
}

.db-consent-rows li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 12px;
  margin: 0;
  padding: 11px 14px;
  border-top: 1px solid rgba(255, 255, 255, .05);
}

.db-consent-rows li:first-child {
  border-top: 0;
}

.db-consent-rows li::before {
  content: none;
}

.db-consent-rows__id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.db-consent-rows__name {
  font: 500 12.5px/1.45 var(--cc-mono);
  color: var(--cc-code);
  overflow-wrap: anywhere;
}

.db-consent-rows__meta {
  font: 400 12px/1.45 var(--cc-font);
  color: var(--cc-faint);
}

.db-consent-rows__purpose {
  font: 400 13px/1.5 var(--cc-font);
  color: var(--cc-body);
}

.db-consent-note {
  margin: 16px 0 8px !important;
  font: 400 13px/1.55 var(--cc-font) !important;
  color: var(--cc-faint);
}

.db-consent-modal__footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 16px 26px;
  border-top: 1px solid var(--cc-rule);
  background: var(--cc-well);
}

.db-consent-modal__spacer {
  flex: 1;
  min-width: 8px;
}

/* Confirmation toast */
.db-consent-toast {
  position: fixed;
  left: var(--cc-edge);
  bottom: calc(var(--bl-dock-space, var(--cc-edge)) + env(safe-area-inset-bottom, 0px));
  z-index: 9998;
  max-width: calc(100vw - 24px);
}

.db-consent-toast__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  border-radius: 999px;
  background: var(--cc-card);
  border: 1px solid rgba(157, 182, 255, .3);
  box-shadow: 0 20px 50px -16px rgba(0, 0, 0, .8);
}

.db-consent-toast__inner svg {
  flex: none;
}

.db-consent-toast__text {
  font: 400 14px/1.4 var(--cc-font);
  color: #e8eaf0;
}

.db-consent-toast__change {
  flex: none;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .15);
  background: transparent;
  color: var(--cc-link);
  font: 500 12.5px/1.2 var(--cc-font);
  cursor: pointer;
}

.db-consent-toast__change:hover {
  color: #fff;
}

@media (prefers-reduced-motion: no-preference) {
  .db-consent-card,
  .db-consent-toast__inner {
    animation: db-consent-rise .28s ease-out both;
  }

  @keyframes db-consent-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .db-consent *,
  .db-consent-toast * {
    transition: none !important;
  }
}

/* Phones: wider rows stack, footer buttons fill the width. */
@media (max-width: 560px) {
  .db-consent-modal__header {
    padding: 20px 18px 16px;
  }

  .db-consent-modal__header h2 {
    font-size: 22px;
  }

  .db-consent-modal__content {
    padding: 6px 18px;
  }

  .db-consent-rows li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .db-consent-modal__footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 14px 18px;
  }

  .db-consent-modal__spacer {
    display: none;
  }

  .db-consent-btn--primary {
    grid-column: 1 / -1;
    order: -1;
  }

  .db-consent-toast__inner {
    border-radius: 18px;
  }
}
