/**
 * consent.css - Nano Commerce cookie-consent banner + preferences.
 *
 * THEME-AGNOSTIC by design: this ships with the platform and runs on every
 * store regardless of its theme, so it does NOT depend on store.css. It is a
 * self-contained, solid (not translucent) surface that stays legible over any
 * background, and it adapts to the visitor's light/dark preference on its own.
 *
 * FULLY SKINNABLE: a designer building a store for their customer can re-brand
 * the whole widget from CSS alone, no markup changes, by overriding these public
 * knobs on :root (or on .nc-consent-root). Each has a "-dark" variant so light
 * and dark can be branded independently; anything left unset keeps the default.
 *
 *   --nc-accent          accent for the primary button + the switch    (#ff4d00)
 *   --nc-accent-ink      text colour ON the accent                     (#ffffff)
 *   --nc-bg        / --nc-bg-dark        panel background        (#ffffff / #17171b)
 *   --nc-fg        / --nc-fg-dark        main text               (#1b1b1f / #f2f2f4)
 *   --nc-muted     / --nc-muted-dark     secondary text          (#55555d / #a6a6b0)
 *   --nc-border    / --nc-border-dark    hairline borders        (light/dark rgba)
 *   --nc-shadow    / --nc-shadow-dark    panel shadow
 *   --nc-radius          corner radius                                    (16px)
 *   --nc-font            font family                             (system stack)
 *
 * Everything else is private (--_x) and derived. No inline scripts or styles are
 * required, so it lives happily inside a strict Content-Security-Policy.
 */

.nc-consent-root {
  --_accent: var(--nc-accent, #ff4d00);
  --_accent-ink: var(--nc-accent-ink, #ffffff);

  /* Surface tokens: public knob first, sensible light default as the fallback. */
  --_bg: var(--nc-bg, #ffffff);
  --_fg: var(--nc-fg, #1b1b1f);
  --_muted: var(--nc-muted, #55555d);
  --_border: var(--nc-border, rgba(0, 0, 0, .12));
  --_border-strong: rgba(0, 0, 0, .22);
  --_track: rgba(0, 0, 0, .16);
  --_hover: rgba(0, 0, 0, .05);
  --_radius: var(--nc-radius, 16px);
  --_shadow: var(--nc-shadow, 0 14px 40px -12px rgba(0, 0, 0, .38), 0 2px 8px -4px rgba(0, 0, 0, .25));
  --_scrim: rgba(15, 15, 20, .5);

  /* Consent must sit above any theme's own nav/drawers/toasts, so it uses a
     deliberately high stacking order (the consent-manager convention). */
  --_z: 2147483600;

  font-family: var(--nc-font, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  color: var(--_fg);
}

@media (prefers-color-scheme: dark) {
  .nc-consent-root {
    --_bg: var(--nc-bg-dark, #17171b);
    --_fg: var(--nc-fg-dark, #f2f2f4);
    --_muted: var(--nc-muted-dark, #a6a6b0);
    --_border: var(--nc-border-dark, rgba(255, 255, 255, .14));
    --_border-strong: rgba(255, 255, 255, .26);
    --_track: rgba(255, 255, 255, .22);
    --_hover: rgba(255, 255, 255, .08);
    --_shadow: var(--nc-shadow-dark, 0 16px 46px -12px rgba(0, 0, 0, .72), 0 2px 8px -4px rgba(0, 0, 0, .6));
    --_scrim: rgba(0, 0, 0, .62);
  }
}

.nc-consent-root *,
.nc-consent-root *::before,
.nc-consent-root *::after {
  box-sizing: border-box;
}

/* ---- Banner -------------------------------------------------------------- */
.nc-consent-banner {
  position: fixed;
  z-index: var(--_z);
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  width: min(680px, calc(100vw - 24px));
  background: var(--_bg);
  color: var(--_fg);
  border: 1px solid var(--_border);
  border-radius: var(--_radius);
  box-shadow: var(--_shadow);
  padding: 20px 22px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .32s cubic-bezier(.22, 1, .36, 1),
              transform .32s cubic-bezier(.22, 1, .36, 1),
              visibility 0s linear .32s;
}
.nc-consent-banner.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity .32s cubic-bezier(.22, 1, .36, 1),
              transform .32s cubic-bezier(.22, 1, .36, 1);
}

.nc-consent-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.nc-consent-text {
  margin: 0 0 16px;
  font-size: .9rem;
  line-height: 1.55;
  color: var(--_muted);
  max-width: 62ch;
}
.nc-consent-text a {
  color: var(--_fg);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.nc-consent-text a:hover { color: var(--_accent); }

.nc-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ---- Buttons (self-contained) ------------------------------------------- */
.nc-btn {
  appearance: none;
  font: inherit;
  font-weight: 650;
  font-size: .9rem;
  line-height: 1;
  border-radius: 11px;
  padding: 12px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter .18s ease, background-color .18s ease, border-color .18s ease, transform .08s ease;
}
.nc-btn:active { transform: translateY(1px); }
.nc-btn:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 2px;
}
.nc-btn--primary {
  background: var(--_accent);
  color: var(--_accent-ink);
  border-color: var(--_accent);
}
.nc-btn--primary:hover { filter: brightness(1.06); }
.nc-btn--secondary {
  background: transparent;
  color: var(--_fg);
  border-color: var(--_border-strong);
}
.nc-btn--secondary:hover { background: var(--_hover); }
.nc-btn--ghost {
  background: transparent;
  color: var(--_muted);
  border-color: transparent;
  padding: 12px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.nc-btn--ghost:hover { color: var(--_fg); }

/* On the banner, push the "Choose" text button to the far side on wide screens. */
.nc-consent-actions .nc-btn--ghost { margin-left: auto; }

/* ---- Preferences dialog -------------------------------------------------- */
.nc-consent-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--_z);
  background: var(--_scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility 0s linear .22s;
}
.nc-consent-scrim.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity .22s ease;
}

.nc-consent-dialog {
  position: fixed;
  z-index: calc(var(--_z) + 1);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.97);
  width: min(480px, calc(100vw - 24px));
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: var(--_bg);
  color: var(--_fg);
  border: 1px solid var(--_border);
  border-radius: calc(var(--_radius) + 2px);
  box-shadow: var(--_shadow);
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .24s cubic-bezier(.22, 1, .36, 1),
              transform .24s cubic-bezier(.22, 1, .36, 1),
              visibility 0s linear .24s;
}
.nc-consent-dialog.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity .24s cubic-bezier(.22, 1, .36, 1),
              transform .24s cubic-bezier(.22, 1, .36, 1);
}

.nc-consent-dialog h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.nc-consent-dialog-intro {
  margin: 0 0 18px;
  font-size: .88rem;
  line-height: 1.55;
  color: var(--_muted);
}

.nc-consent-cat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--_border);
}
.nc-consent-cat-info { flex: 1 1 auto; min-width: 0; }
.nc-consent-cat-info strong {
  display: block;
  font-size: .95rem;
  font-weight: 650;
  margin-bottom: 3px;
}
.nc-consent-cat-info p {
  margin: 0;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--_muted);
}

/* Toggle switch (checkbox), self-contained. */
.nc-switch {
  flex: 0 0 auto;
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  margin-top: 2px;
}
.nc-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.nc-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--_track);
  transition: background-color .2s ease;
}
.nc-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  transition: transform .2s cubic-bezier(.22, 1, .36, 1);
}
.nc-switch input:checked + .nc-switch-track { background: var(--_accent); }
.nc-switch input:checked + .nc-switch-track::after { transform: translateX(20px); }
.nc-switch input:focus-visible + .nc-switch-track {
  outline: 2px solid var(--_accent);
  outline-offset: 2px;
}
.nc-switch input:disabled { cursor: not-allowed; }
.nc-switch input:disabled + .nc-switch-track { opacity: .6; }

.nc-consent-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.nc-consent-dialog-actions .nc-btn { flex: 1 1 auto; text-align: center; justify-content: center; }
.nc-consent-dialog-actions .nc-btn--primary { order: 3; }

/* ---- Small screens ------------------------------------------------------- */
@media (max-width: 520px) {
  .nc-consent-banner { padding: 18px; border-radius: calc(var(--_radius) - 2px); }
  .nc-consent-actions { flex-direction: column; align-items: stretch; }
  .nc-consent-actions .nc-btn { width: 100%; text-align: center; justify-content: center; }
  .nc-consent-actions .nc-btn--ghost { margin-left: 0; order: 4; }
}

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .nc-consent-banner,
  .nc-consent-banner.is-visible,
  .nc-consent-scrim,
  .nc-consent-scrim.is-visible,
  .nc-consent-dialog,
  .nc-consent-dialog.is-visible,
  .nc-switch-track,
  .nc-switch-track::after,
  .nc-btn {
    transition: opacity .001s linear, visibility 0s;
  }
  .nc-consent-banner { transform: translateX(-50%); }
  .nc-consent-dialog { transform: translate(-50%, -50%); }
}
