/* Consent banner + preference modal (JS/consent.js). Loads on every page, so it is
   fully self-contained: every rule is namespaced .tp-consent-* and every var() carries
   a literal fallback — pages define different token subsets and the visual gate fails
   hard on an unresolved var(). Dark mode: the public (body.dark, per-page CSS) and
   console (body.console.dark, app-shell.css) palettes both flip to the same literal
   surface/border/text values, so the single body.dark block below covers both — the
   console always has both classes.
   Z-order: bar 450 sits above page chrome (nav 200, chat launcher 50) but below page
   modals (500) — a dialog the user opened outranks a passive prompt. The consent
   modal itself is 700: user-invoked, so it outranks everything. */

/* Self-containment includes hiding: these display rules would beat the UA's
   author-overridable [hidden]{display:none} on any page that loads neither
   styles.css nor nav.css (both carry the global enforcement). Every page today
   loads one of them, but a future standalone page (e.g. an error page) must not
   un-hide a dismissed banner by omission. */
.tp-consent-bar[hidden],
.tp-consent-overlay[hidden] { display: none !important; }

.tp-consent-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 450;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 14px 20px;
  background: var(--white, #ffffff);
  color: var(--text, #0f1f4b);
  border: 1px solid var(--gray-light, #e8edf6);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 32px rgba(30, 58, 138, 0.18);
  font-size: 0.88rem;
  line-height: 1.45;
}
.tp-consent-bar-text { flex: 1 1 auto; min-width: 220px; }
.tp-consent-bar-text strong { color: var(--ink, #020C45); }
.tp-consent-bar-text a { color: var(--blue, #3b82f6); text-decoration: underline; }
.tp-consent-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Accept and Reject carry identical visual weight — ICO: rejecting must be as easy
   as accepting. Only "Manage preferences" is quieter. */
.tp-consent-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius, 8px);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tp-consent-primary {
  background: var(--blue, #3b82f6);
  border-color: var(--blue, #3b82f6);
  color: #ffffff;
}
.tp-consent-primary:hover { background: var(--blue-dark, #1d4ed8); border-color: var(--blue-dark, #1d4ed8); }
.tp-consent-quiet {
  background: transparent;
  border-color: var(--gray-mid, #c4cfe3);
  color: var(--text, #0f1f4b);
}
.tp-consent-quiet:hover { border-color: var(--blue, #3b82f6); color: var(--blue, #3b82f6); }
.tp-consent-btn:focus-visible { outline: 2px solid var(--blue, #3b82f6); outline-offset: 2px; }

/* ---- preference modal ---- */
.tp-consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 12, 69, 0.45);
}
.tp-consent-modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--white, #ffffff);
  color: var(--text, #0f1f4b);
  border: 1px solid var(--gray-light, #e8edf6);
  border-radius: var(--radius, 8px);
  box-shadow: 0 12px 48px rgba(2, 12, 69, 0.25);
  padding: 24px;
}
.tp-consent-modal h2 {
  margin: 0 0 8px;
  font-family: 'Sora', 'DM Sans', sans-serif;
  font-size: 1.15rem;
  color: var(--ink, #020C45);
}
.tp-consent-intro { margin: 0 0 16px; font-size: 0.87rem; line-height: 1.5; color: var(--text-muted, #64748b); }
.tp-consent-intro a { color: var(--blue, #3b82f6); text-decoration: underline; }

.tp-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--gray-light, #e8edf6);
}
.tp-consent-row-text { flex: 1 1 auto; }
.tp-consent-row-text strong { display: block; font-size: 0.92rem; color: var(--ink, #020C45); margin-bottom: 2px; }
.tp-consent-row-text span { font-size: 0.82rem; line-height: 1.45; color: var(--text-muted, #64748b); }

/* Switch: a real checkbox for semantics, drawn as a track + thumb. */
.tp-consent-switch { position: relative; flex-shrink: 0; margin-top: 2px; cursor: pointer; }
.tp-consent-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: inherit; }
.tp-consent-track {
  display: block;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--gray-mid, #c4cfe3);
  transition: background 0.15s ease;
}
.tp-consent-track::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  margin: 3px;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(2, 12, 69, 0.3);
}
.tp-consent-switch input:checked + .tp-consent-track { background: var(--blue, #3b82f6); }
.tp-consent-switch input:checked + .tp-consent-track::after { transform: translateX(18px); }
.tp-consent-switch input:focus-visible + .tp-consent-track { outline: 2px solid var(--blue, #3b82f6); outline-offset: 2px; }
.tp-consent-locked { cursor: not-allowed; opacity: 0.6; }
.tp-consent-sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tp-consent-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-light, #e8edf6);
}

/* Both dark palettes share these literals (faq/viewJobs/… body.dark and app-shell
   body.console.dark), so one block restyles the banner everywhere. */
body.dark .tp-consent-bar,
body.dark .tp-consent-modal {
  background: #111a38;
  color: #dbe4f8;
  border-color: #26325c;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
body.dark .tp-consent-bar-text strong,
body.dark .tp-consent-modal h2,
body.dark .tp-consent-row-text strong { color: #e8eefc; }
body.dark .tp-consent-intro,
body.dark .tp-consent-row-text span { color: #93a3c8; }
body.dark .tp-consent-bar-text a,
body.dark .tp-consent-intro a { color: #50A2FF; }
body.dark .tp-consent-row,
body.dark .tp-consent-modal-actions { border-top-color: #26325c; }
body.dark .tp-consent-quiet { border-color: #34426e; color: #dbe4f8; }
body.dark .tp-consent-quiet:hover { border-color: #50A2FF; color: #50A2FF; }
body.dark .tp-consent-track { background: #34426e; }

/* Compact on small screens; keep the signup form's submit reachable — the bar hugs
   the bottom but stays shallow and the page remains scrollable behind it. */
@media (max-width: 640px) {
  .tp-consent-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
    font-size: 0.82rem;
  }
  .tp-consent-bar-actions { justify-content: stretch; }
  .tp-consent-bar-actions .tp-consent-btn { flex: 1 1 auto; }
  .tp-consent-modal { padding: 18px; }
}
