/* ──────────────────────────────────────────────────────────────────────────
   Consent Modal (project-045)
   Visual parity with .age-gate-dialog. Owns its own CSS surface; reuses
   tokens from shell.css :root.
   ────────────────────────────────────────────────────────────────────────── */

.consent-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--modal-backdrop);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 200ms ease;
}

.consent-modal-backdrop.visible {
  opacity: 1;
}

.consent-modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 901;
  width: min(480px, calc(100% - 32px));
  max-height: calc(100vh - 48px); /* fallback for browsers without dvh */
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 32px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--modal-surface-top), var(--modal-surface-bottom));
  border: 1px solid var(--modal-border-strong);
  box-shadow: var(--modal-shadow-premium);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.95);
  transition: opacity 250ms ease-out, transform 250ms ease-out;
}

.consent-modal-dialog.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.consent-modal-dialog.closing {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity 200ms ease;
}

/* ── Eyebrow ─────────────────────────────────────────────────────────── */

.consent-modal-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-bottom: 8px;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--primary-dim);
  color: var(--primary-glow);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.consent-modal-title {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ── Scroll wrap ─────────────────────────────────────────────────────── */

.consent-scroll-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  background: var(--field-surface);
  overflow: hidden;
}

.consent-scroll {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  max-height: 180px;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) var(--border);
}

.consent-scroll--preferences {
  max-height: 360px;
}

.consent-scroll::-webkit-scrollbar {
  width: 6px;
}

.consent-scroll::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 3px;
}

.consent-scroll::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
  opacity: 0.4;
}

.consent-scroll-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), var(--field-surface) 90%);
  transition: opacity 140ms ease;
}

.consent-scroll-fade.hidden {
  opacity: 0;
  visibility: hidden;
}

/* ── Body copy ───────────────────────────────────────────────────────── */

.consent-modal-body {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.6;
}

.consent-modal-body p {
  margin: 0 0 12px;
}

.consent-modal-body p:last-child {
  margin-bottom: 0;
}

.consent-modal-body a {
  color: var(--primary-glow);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Three-button row (primary view) ─────────────────────────────────── */

.consent-modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ───── EDPB Guidelines 03/2022 visual-equivalence note ─────────────────
   Accept All and Decline All MUST share height, padding, border-radius,
   and font weight. Brand-purple accent on Accept All is allowed because
   click target and tap area are visually equivalent to Decline All.
   Preferences is a genuine secondary (config tier, not a consent
   decision) per EDPB carve-out. Do not regress this without legal sign-off.
   ──────────────────────────────────────────────────────────────────── */

.consent-modal-btn-primary {
  flex: 1;
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 200ms ease, border-color 200ms ease,
              transform 100ms ease, box-shadow 150ms ease;
}

.consent-modal-btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-ring);
}

.consent-modal-btn-primary:active {
  transform: scale(0.97);
}

.consent-modal-btn-primary--prefs {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--text-muted);
}
.consent-modal-btn-primary--prefs:hover {
  background: transparent;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.consent-modal-btn-primary--prefs:active {
  transform: none;
}

.consent-modal-btn-primary--decline {
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.consent-modal-btn-primary--decline:hover {
  background: var(--field-surface-hover);
  border-color: var(--border-strong);
}

.consent-modal-btn-primary--accept {
  background: var(--primary);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}
.consent-modal-btn-primary--accept:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.5);
}

/* ── Preferences rows ────────────────────────────────────────────────── */

.consent-pref-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--modal-border-soft);
}

.consent-pref-row:first-child {
  border-top: none;
}

.consent-pref-row-content {
  min-width: 0;
}

.consent-pref-row-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.consent-pref-row-description {
  margin-top: 4px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.5;
}

.consent-pref-row-meta {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.consent-pref-row-locked-note {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.consent-pref-row-lock-glyph {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
}

.consent-pref-row-gpc-note {
  display: none;
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Strictly Necessary locked-on visual treatment */
.consent-pref-row[data-category="necessary"] .consent-toggle-switch,
.consent-pref-row[data-category="necessary"] .consent-toggle-control {
  opacity: 0.55;
  pointer-events: none;
}

/* GPC-locked Marketing row */
.consent-pref-row[data-category="marketing"][data-gpc-locked="true"] .consent-toggle-control {
  opacity: 0.55;
  pointer-events: none;
}

.consent-pref-row[data-category="marketing"][data-gpc-locked="true"] .consent-pref-row-gpc-note {
  display: block;
}

/* ── Toggle switch (clone of .cycle-enabled-switch recipe) ───────────── */

.consent-toggle-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.consent-toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.consent-toggle-switch {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background-color 150ms ease, border-color 150ms ease;
}

.consent-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}

.consent-toggle-control input:checked + .consent-toggle-switch {
  background: var(--primary);
  border-color: var(--primary);
}

.consent-toggle-control input:checked + .consent-toggle-switch::after {
  transform: translateX(16px);
}

.consent-toggle-control input:focus-visible + .consent-toggle-switch {
  box-shadow: 0 0 0 3px var(--field-ring);
}

/* ── Show vendors disclosure ─────────────────────────────────────────── */

.consent-show-vendors {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--primary-glow);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: inherit;
}

.consent-show-vendors:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-ring);
  border-radius: var(--radius-sm);
}

.consent-show-vendors-chevron {
  transition: transform 200ms ease;
}

.consent-show-vendors[aria-expanded="true"] .consent-show-vendors-chevron {
  transform: rotate(90deg);
}

.consent-vendor-list {
  display: none;
  margin: 12px 0 0;
  padding: 12px;
  background: var(--field-surface);
  border-radius: var(--radius-sm);
  list-style: none;
}

.consent-show-vendors[aria-expanded="true"] + .consent-vendor-list {
  display: block;
}

.consent-vendor-list li {
  list-style: none;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.consent-vendor-list li:last-child {
  margin-bottom: 0;
}

.consent-vendor-list li strong {
  display: block;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 2px;
}

/* ── Preferences sub-view footer ─────────────────────────────────────── */

.consent-pref-footer {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.consent-modal-btn-secondary {
  flex: 0 0 auto;
  height: 52px;
  min-height: 52px;
  padding: 0 24px;
  border: 1px solid var(--field-border-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 200ms ease, transform 100ms ease, box-shadow 150ms ease;
}

.consent-modal-btn-secondary:hover {
  background: var(--field-surface-hover);
}

.consent-modal-btn-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-ring);
}

.consent-modal-btn-secondary:active {
  transform: scale(0.97);
}

.consent-modal-btn-save {
  flex: 1;
  height: 52px;
  min-height: 52px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 200ms ease, transform 100ms ease, box-shadow 150ms ease;
}

.consent-modal-btn-save:hover {
  background: var(--primary-hover);
}

.consent-modal-btn-save:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-ring);
}

.consent-modal-btn-save:active {
  transform: scale(0.97);
}

/* ── Mobile breakpoint ───────────────────────────────────────────────── */

@media (max-width: 480px) {
  .consent-modal-dialog {
    padding: 24px;
  }

  .consent-scroll {
    max-height: 240px;
  }

  /* project-051: column-reverse so visual top→bottom is Accept → Decline → Preferences,
     while DOM tab order stays Preferences → Decline → Accept. */
  .consent-modal-buttons {
    flex-direction: column-reverse;
  }

  .consent-modal-btn-primary {
    width: 100%;
    height: 60px;
    min-height: 60px;
    font-size: 1rem;
  }

  .consent-pref-footer {
    flex-direction: column-reverse;
  }

  .consent-modal-btn-secondary,
  .consent-modal-btn-save {
    width: 100%;
    height: 60px;
    min-height: 60px;
  }
}
