/*
 * Nexus Consent: the estate chrome's tokens (--nxc-*), else the body's colours, else theme presets. Light and dark
 * follow html[data-theme]. Logical properties only (RTL). The card is fixed at z-index 99990, below Readabler
 * (99998, 99999); the choices panel is a top-layer popover (above any fixed header).
 */
.nexus-consent,
.nexus-consent-embed,
.nexus-consent-table,
.nexus-consent-mine,
.nexus-consent-page,
.nexus-consent-choices,
.nexus-consent-link {
  /* The theme's own page colours first (read from the body by the banner script), then its presets, then ours. */
  --nexus-consent-bg: var(--nexus-consent-theme-bg, var(--wp--preset--color--elevated, var(--nxc-color-surface)));
  --nexus-consent-fg: var(--nexus-consent-theme-fg, var(--wp--preset--color--ink, var(--nxc-color-fg)));
  /* With the theme's colours in use, secondary text and lines take its text colour too, so contrast holds in any mode. */
  --nexus-consent-muted: var(--nexus-consent-theme-fg, var(--wp--preset--color--ink-muted, var(--nxc-color-fg-muted)));
  --nexus-consent-line: var(--nexus-consent-theme-fg, var(--wp--preset--color--hairline-strong, var(--nxc-color-border)));
  --nexus-consent-space-2: var(--wp--preset--spacing--2, var(--nxc-space-2));
  --nexus-consent-space-3: var(--wp--preset--spacing--3, var(--nxc-space-3));
  --nexus-consent-space-4: var(--wp--preset--spacing--4, var(--nxc-space-4));
  --nexus-consent-space-5: var(--wp--preset--spacing--5, var(--nxc-space-5));
  --nexus-consent-text: var(--wp--preset--font-size--m, var(--nxc-font-size));
  --nexus-consent-small: var(--wp--preset--font-size--s, var(--nxc-font-size));
  --nexus-consent-title: var(--wp--preset--font-size--l, var(--nxc-font-size));
  --nexus-consent-radius: var(--nxc-radius);
  --nexus-consent-measure: var(--wp--style--global--content-size, 100%);
}

/* tokens:start - the only literal colours in this file (the chrome's values are the fallbacks). */
.nexus-consent-root,
.nexus-consent__button {
  --nc-knob-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --nc-text: var(--nxc-text, var(--nexus-consent-theme-fg, var(--wp--preset--color--ink, #111)));
  --nc-bg: var(--nxc-elevated, var(--nexus-consent-theme-bg, var(--wp--preset--color--elevated, #fafafa)));
  --nc-text-2: var(--nxc-text-2, var(--nc-text));
  --nc-muted: var(--nxc-muted, color-mix(in srgb, var(--nc-text) 72%, var(--nc-bg)));
  --nc-line: var(--nxc-line, color-mix(in srgb, var(--nc-text) 12%, transparent));
  --nc-line-strong: var(--nxc-line-strong, color-mix(in srgb, var(--nc-text) 28%, transparent));
  --nc-hover: var(--nxc-hover, color-mix(in srgb, var(--nc-text) 7%, var(--nc-bg)));
  --nc-primary-bg: var(--nxc-primary-bg, var(--nc-text));
  --nc-primary-ink: var(--nxc-primary-ink, var(--nc-bg));
  --nc-primary-hover: var(--nxc-primary-hover, color-mix(in srgb, var(--nc-primary-bg) 85%, var(--nc-bg)));
  --nc-focus: var(--nxc-focus, #1a73e8);
  --nc-sans: var(--nxc-sans, "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
  --nc-mono: var(--nxc-mono, "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  --nc-radius: var(--nxc-radius, 5px);
  --nc-fast: var(--nxc-fast, 120ms);
  --nc-shadow: 0 12px 40px rgba(0, 0, 0, .12);
  --nc-inset: 24px;
  --nc-lift: 0px;
}
html[data-theme="dark"] .nexus-consent-root { --nc-shadow: 0 12px 40px rgba(0, 0, 0, .28); }
@media (prefers-color-scheme: dark) { html[data-theme="auto"] .nexus-consent-root { --nc-shadow: 0 12px 40px rgba(0, 0, 0, .28); } }
/* tokens:end */

.nexus-consent { background: none; color: inherit; }

/* ---- surfaces: the card and the drawer */
.nexus-consent__banner,
.nexus-consent__drawer {
  box-sizing: border-box;
  position: fixed;
  z-index: 99990;
  margin: 0;
  padding: 0;
  border: 1px solid var(--nc-line-strong);
  border-radius: var(--nc-radius);
  background: var(--nc-bg);
  color: var(--nc-text-2);
  box-shadow: var(--nc-shadow);
  font: 400 14px/1.5 var(--nc-sans);
  text-align: start;
  letter-spacing: normal;
  text-transform: none;
}
.nexus-consent__banner[hidden],
.nexus-consent__drawer[hidden] { display: none; }
.nexus-consent__banner:focus,
.nexus-consent__drawer:focus,
.nexus-consent__banner:focus-visible,
.nexus-consent__drawer:focus-visible { outline: none; }
.nexus-consent__banner::backdrop,
.nexus-consent__drawer::backdrop { display: none; }

.nexus-consent__banner {
  inset: auto auto calc(var(--nc-inset) + var(--nc-lift)) var(--nc-inset);
  inset-inline-start: var(--nc-inset);
  inset-inline-end: auto;
  inline-size: min(420px, calc(100vw - 2 * var(--nc-inset)));
  max-block-size: calc(100dvh - 2 * var(--nc-inset));
  overflow: auto;
  padding: 18px 20px 14px;
  animation: nexus-consent-in 160ms ease-out;
}
@keyframes nexus-consent-in { from { opacity: 0; transform: translateY(8px); } }

.nexus-consent__drawer {
  inset: 0 0 0 auto;
  inset-inline-end: 0;
  inset-inline-start: auto;
  inline-size: min(440px, 100vw);
  block-size: 100dvh;
  max-block-size: none;
  border-block: 0;
  border-inline-end: 0;
  border-radius: 0;
  overflow: hidden;
  animation: nexus-consent-drawer 160ms ease-out;
}
.nexus-consent--drawer-start .nexus-consent__drawer {
  inset-inline-start: 0;
  inset-inline-end: auto;
  border-inline-end: 1px solid var(--nc-line-strong);
  border-inline-start: 0;
}
@keyframes nexus-consent-drawer { from { opacity: 0; transform: translateX(16px); } }

/* ---- card content */
.nexus-consent__eyebrow {
  margin: 0 0 8px;
  padding: 0;
  font: 500 11px/1.4 var(--nc-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nexus-consent__notice { margin: 0 0 6px; color: var(--nc-text-2); }
.nexus-consent__details { margin: 0 0 8px; }
.nexus-consent__diff[hidden],
.nexus-consent--diff .nexus-consent__notice:not(.nexus-consent__diff),
.nexus-consent--diff .nexus-consent__details { display: none; }
.nexus-consent__details summary {
  display: inline-block;
  cursor: pointer;
  color: var(--nc-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  list-style: none;
}
.nexus-consent__details summary::-webkit-details-marker { display: none; }
.nexus-consent__details p { margin: 6px 0 0; }
.nexus-consent__links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 14px; }
.nexus-consent-root .nexus-consent__links a,
.nexus-consent-root .nexus-consent__meta a {
  color: var(--nc-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---- buttons: the same size and weight; only Accept all is filled (setting buttonStyle "accent") */
.nexus-consent__actions,
.nexus-consent__foot {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: 8px;
}
.nexus-consent-root button.nexus-consent__button,
button.nexus-consent__button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 40px;
  min-inline-size: 0;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--nc-line-strong);
  border-radius: var(--nc-radius);
  background: transparent;
  color: var(--nc-text);
  font: 500 14px/1.25 var(--nc-sans);
  letter-spacing: normal;
  text-transform: none;
  text-align: center;
  white-space: normal;
  box-shadow: none;
  cursor: pointer;
  transition: background var(--nc-fast), border-color var(--nc-fast);
}
.nexus-consent-root button.nexus-consent__button:hover { background: var(--nc-hover); border-color: var(--nc-text); color: var(--nc-text); }
.nexus-consent-root:not(.nexus-consent--outlined) button.nexus-consent__button--primary {
  border-color: var(--nc-primary-bg);
  background: var(--nc-primary-bg);
  color: var(--nc-primary-ink);
}
.nexus-consent-root:not(.nexus-consent--outlined) button.nexus-consent__button--primary:hover {
  background: var(--nc-primary-hover);
  border-color: var(--nc-primary-hover);
  color: var(--nc-primary-ink);
}
.nexus-consent-root button:focus { outline: none; }
.nexus-consent-root button:focus-visible,
.nexus-consent-root a:focus-visible,
.nexus-consent-root summary:focus-visible,
.nexus-consent-root input:focus-visible {
  outline: 2px solid var(--nc-focus);
  outline-offset: 2px;
}

.nexus-consent-root button.nexus-consent__more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 10px 0 0;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--nc-text);
  font: 500 14px/1.4 var(--nc-sans);
  cursor: pointer;
}
.nexus-consent-root button.nexus-consent__more--quiet { margin: 8px 0 0; color: var(--nc-muted); font-size: 13px; }
.nexus-consent__icon { inline-size: 16px; block-size: 16px; flex: none; transition: transform var(--nc-fast); }
[dir="rtl"] .nexus-consent__more .nexus-consent__icon { transform: scaleX(-1); }
.nexus-consent__more[aria-expanded="true"] .nexus-consent__icon { transform: rotate(90deg); }

/* ---- drawer: sticky header bar, scrolling content, sticky actions */
.nexus-consent__form { display: flex; flex-direction: column; block-size: 100%; margin: 0; }
.nexus-consent__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-block-end: 1px solid var(--nc-line);
}
.nexus-consent__heading { margin: 0; padding: 0; font: 600 16px/1.3 var(--nc-sans); color: var(--nc-text); letter-spacing: normal; text-transform: none; }
.nexus-consent-root button.nexus-consent__x {
  display: inline-grid;
  place-items: center;
  inline-size: 36px;
  block-size: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--nc-radius);
  background: none;
  color: var(--nc-text);
  cursor: pointer;
}
.nexus-consent-root button.nexus-consent__x:hover { background: var(--nc-hover); }
.nexus-consent__x .nexus-consent__icon { inline-size: 18px; block-size: 18px; }
.nexus-consent__scroll { flex: 1 1 auto; overflow: auto; padding: 16px 20px; overscroll-behavior: contain; }
.nexus-consent__foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-block-start: 1px solid var(--nc-line); background: var(--nc-bg); }
.nexus-consent__gpc { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--nc-line); border-radius: var(--nc-radius); color: var(--nc-text); }
.nexus-consent__gpc[hidden] { display: none; }

.nexus-consent__purposes { margin: 8px 0 0; padding: 0; border: 0; min-inline-size: 0; }
.nexus-consent__purpose { padding: 14px 0; border-block-start: 1px solid var(--nc-line); }
.nexus-consent__purpose-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nexus-consent__label { font: 600 14px/1.4 var(--nc-sans); color: var(--nc-text); cursor: pointer; }
.nexus-consent__desc { margin: 4px 0 0; color: var(--nc-muted); font-size: 13px; }
.nexus-consent__always { font: 500 11px/1.4 var(--nc-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--nc-muted); white-space: nowrap; }

/* The switch: an input with role="switch", drawn as a track and a knob. */
.nexus-consent-root input.nexus-consent__switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  inline-size: 40px;
  block-size: 24px;
  margin: 0;
  border: 1px solid var(--nc-line-strong);
  border-radius: 999px;
  background: var(--nc-line-strong);
  cursor: pointer;
  transition: background var(--nc-fast);
}
.nexus-consent-root input.nexus-consent__switch::before {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 18px;
  block-size: 18px;
  border-radius: 50%;
  background: var(--nc-bg);
  box-shadow: var(--nc-knob-shadow);
  transition: transform var(--nc-fast);
}
.nexus-consent-root input.nexus-consent__switch:checked { background: var(--nc-primary-bg); border-color: var(--nc-primary-bg); }
.nexus-consent-root input.nexus-consent__switch:checked::before { transform: translateX(16px); background: var(--nc-primary-ink); }
[dir="rtl"] .nexus-consent-root input.nexus-consent__switch:checked::before { transform: translateX(-16px); }

.nexus-consent__services { margin: 8px 0 0; overflow-x: auto; }
.nexus-consent__services[hidden] { display: none; }
.nexus-consent__services table { inline-size: 100%; border-collapse: collapse; font-size: 12px; }
.nexus-consent__services th,
.nexus-consent__services td { padding: 6px 8px 6px 0; border-block-end: 1px solid var(--nc-line); text-align: start; vertical-align: top; color: var(--nc-text-2); }
.nexus-consent__services thead th { font: 500 11px/1.4 var(--nc-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--nc-muted); }
.nexus-consent__services code { font: 11px/1.5 var(--nc-mono); overflow-wrap: anywhere; background: none; color: inherit; padding: 0; }
.nexus-consent__sub { display: block; font-weight: 400; color: var(--nc-muted); }

.nexus-consent__meta { margin: 8px 0 0; padding: 12px 0 0; border-block-start: 1px solid var(--nc-line); font-size: 12px; color: var(--nc-muted); }
.nexus-consent__meta p { margin: 0 0 6px; }
.nexus-consent__meta [hidden] { display: none; }
.nexus-consent__meta code { font: 12px var(--nc-mono); color: var(--nc-text); background: none; }
.nexus-consent__meta-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.nexus-consent-root button.nexus-consent__textbutton { margin: 0; padding: 0; border: 0; background: none; color: var(--nc-text); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.nexus-consent__textbutton[hidden] { display: none; }

/* Mono and tracking break joined and ideographic scripts: the sans face, no letter-spacing or capitals there. */
.nexus-consent-root:is(:lang(ar), :lang(fa), :lang(hi), :lang(zh), :lang(ja), :lang(ko)) :is(.nexus-consent__eyebrow, .nexus-consent__always, thead th, .nexus-consent-embed__eyebrow) {
  font-family: var(--nc-sans);
  letter-spacing: 0;
  text-transform: none;
}

/* ---- reopen button (setting reopenButton) */
.nexus-consent-root button.nexus-consent__fab {
  position: fixed;
  z-index: 99989;
  inset-block-end: calc(var(--nxc-fab-inset, 72px) + var(--nc-lift));
  inset-inline-start: var(--nc-inset);
  display: inline-grid;
  place-items: center;
  inline-size: 36px;
  block-size: 36px;
  padding: 0;
  border: 1px solid var(--nc-line-strong);
  border-radius: 50%;
  background: var(--nc-bg);
  color: var(--nc-text);
  box-shadow: var(--nc-shadow);
  cursor: pointer;
}
.nexus-consent__fab[hidden] { display: none; }
.nexus-consent__fab .nexus-consent__icon { inline-size: 20px; block-size: 20px; }

/* Readabler's corner button: lift what shares its corner (the script sets the class). */
.nexus-consent--readabler-start { --nc-lift: 56px; }

/* ---- phone: the card is a bottom sheet, the drawer full screen */
@media (max-width: 600px) {
  .nexus-consent-root { --nc-inset: 12px; }
  .nexus-consent--readabler { --nc-lift: 56px; } /* the sheet spans the width: clear Readabler's button in either corner */
  .nexus-consent__banner {
    inset-inline: var(--nc-inset);
    inline-size: auto;
    inset-block-end: calc(var(--nc-inset) + env(safe-area-inset-bottom) + var(--nc-lift));
    padding: 16px 16px 12px;
  }
  .nexus-consent__drawer { inset-inline: 0; inline-size: auto; border: 0; }
  /* Readabler's corner button stays reachable under the full-screen panel. */
  .nexus-consent--readabler .nexus-consent__drawer { block-size: calc(100dvh - 60px); border-block-end: 1px solid var(--nc-line-strong); }
}

.nexus-consent-visually-hidden {
  position: absolute !important; /* stays hidden whatever a theme does to inputs */
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The visitor's "your consent" view (Visitor::panel), in a page or standalone. */
.nexus-consent-mine {
  box-sizing: border-box;
  max-inline-size: var(--nexus-consent-measure);
  color: var(--nexus-consent-fg);
}

.nexus-consent-mine__title {
  font-size: var(--nexus-consent-title);
}

.nexus-consent-mine__id {
  overflow-wrap: anywhere;
}

.nexus-consent-mine__done {
  padding: var(--nexus-consent-space-3);
  border: thin solid var(--nexus-consent-line);
  border-radius: var(--nexus-consent-radius);
  background: var(--nexus-consent-bg);
}

.nexus-consent-mine .nexus-consent-table__table {
  inline-size: 100%;
  margin-block-end: var(--nexus-consent-space-4);
}

.nexus-consent-page__main {
  box-sizing: border-box;
  max-inline-size: var(--nexus-consent-measure);
  margin: 0 auto;
  padding: var(--nexus-consent-space-5) var(--nexus-consent-space-4);
}

/* ---- blocked content placeholder (maps, videos): the same tokens */
.nexus-consent-embed {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  inline-size: 100%;
  min-block-size: 220px;
  padding: 20px;
  border: 1px solid var(--nc-line-strong);
  border-radius: var(--nc-radius);
  background: var(--nc-bg);
  color: var(--nc-text-2);
  font: 400 14px/1.5 var(--nc-sans);
}
.nexus-consent-embed__notice { max-inline-size: 460px; text-align: start; }
.nexus-consent-embed__eyebrow { margin: 0 0 6px; font: 500 11px/1.4 var(--nc-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--nc-muted); overflow-wrap: anywhere; }
.nexus-consent-embed__text { margin: 0 0 12px; }
.nexus-consent-embed__actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.nexus-consent-embed__links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 13px; }
.nexus-consent-embed__links a { color: var(--nc-text); text-decoration: underline; text-underline-offset: 2px; }

/* Persistent "Privacy choices" link. */
.nexus-consent-link {
  color: inherit;
}

/* The fallback line after the theme footer: one small centred link, no surface of its own. */
.nexus-consent-footer-link {
  margin: 0;
  padding-block: var(--nexus-consent-space-2);
  padding-inline: var(--nexus-consent-space-3);
  text-align: center;
  font-size: var(--nexus-consent-small);
  line-height: 1.5;
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}

/* Cookies and services table. */
.nexus-consent-table__scroll {
  overflow-x: auto;
}

.nexus-consent-table__table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: var(--nexus-consent-small);
}

.nexus-consent-table__table caption {
  text-align: start;
  font-weight: bold;
  padding-block-end: var(--nexus-consent-space-2);
}

.nexus-consent-table__table th,
.nexus-consent-table__table td {
  padding: var(--nexus-consent-space-2);
  border-block-end: thin solid var(--nexus-consent-line);
  text-align: start;
  vertical-align: top;
}

.nexus-consent-table__desc {
  display: block;
  font-weight: 400;
  color: var(--nexus-consent-muted);
}

.nexus-consent-table__counsel,
.nexus-consent-table__meta {
  color: var(--nexus-consent-muted);
}

@media (prefers-reduced-motion: reduce) {
  .nexus-consent-root *,
  .nexus-consent__banner,
  .nexus-consent__drawer { transition: none; animation: none; }
}

@media (forced-colors: active) {
  .nexus-consent-root button.nexus-consent__button,
  .nexus-consent__banner,
  .nexus-consent__drawer,
  .nexus-consent-root input.nexus-consent__switch { border-color: CanvasText; }
  .nexus-consent-root input.nexus-consent__switch:checked::before { background: Highlight; }
}

/* Policy pages (1.4.2): section anchors clear the fixed headers; tables in the chrome's lines and type. */
.nexus-consent-policy :is(h2, h3)[id] { scroll-margin-top: calc(var(--nxc-header-h, 64px) + 24px); }
.nexus-consent-policy table { inline-size: 100%; border-collapse: collapse; font-size: 14px; }
.nexus-consent-policy :is(th, td) { padding: 8px 12px 8px 0; border-block-end: 1px solid var(--nxc-line, currentColor); text-align: start; vertical-align: top; }
.nexus-consent-policy thead th { font: 500 11px/1.4 var(--nxc-mono, ui-monospace, monospace); letter-spacing: .08em; text-transform: uppercase; }
.nexus-consent-policy .wp-block-table { overflow-x: auto; }

/* Preference centre (block and shortcode): a plain section of the page, same tokens. */
.nexus-consent-centre {
  color: var(--nexus-consent-fg);
  font-size: var(--nexus-consent-text);
  line-height: 1.5;
}

.nexus-consent-centre__purpose {
  padding-block: var(--nexus-consent-space-3);
  border-block-end: thin solid var(--nexus-consent-line);
}

.nexus-consent-centre__state {
  font-weight: 600;
}
