/**
 * Persiva Consent Manager — styles
 * ============================================================================
 * Structure adapted from Silktide Consent Manager v2.0 (MIT), restyled to the
 * persiva.io brand:
 *   #0D7A52 green · #FAF7F2 cream · Plus Jakarta Sans · Cormorant Garamond
 *
 * Every selector is scoped under #pc-wrapper and prefixed `pc-`, so nothing
 * here can collide with Astra, Elementor, Xpro or WooCommerce styles.
 */

#pc-wrapper {
  /* ---- Brand tokens: override these to restyle without touching rules ---- */
  --pc-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --pc-font-heading: 'Cormorant Garamond', Georgia, serif;

  --pc-primary: #0D7A52;
  --pc-primary-hover: #0A6243;
  --pc-primary-text: #FAF7F2;

  --pc-surface: #FFFFFF;
  --pc-surface-alt: #F6F7F8;
  --pc-text: #334155;
  --pc-text-muted: #64748B;
  --pc-border: #E2E8F0;

  --pc-radius: 6px;
  --pc-radius-lg: 10px;
  --pc-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 12px 32px rgba(15, 23, 42, .12);
  --pc-backdrop: rgba(15, 23, 42, .55);
  --pc-backdrop-blur: 4px;
  --pc-focus: #0D7A52;

  /* Above Elementor popups (9999) and most WooCommerce overlays. */
  --pc-z: 2147483000;

  font-family: var(--pc-font);
  color: var(--pc-text);
}

#pc-wrapper *,
#pc-wrapper *::before,
#pc-wrapper *::after { box-sizing: border-box; }

#pc-wrapper .pc-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- backdrop */
#pc-backdrop {
  display: none;
  position: fixed; inset: 0;
  z-index: calc(var(--pc-z) - 1);
  background: var(--pc-backdrop);
  backdrop-filter: blur(var(--pc-backdrop-blur));
  -webkit-backdrop-filter: blur(var(--pc-backdrop-blur));
}

/* ------------------------------------------------------------------ banner */
#pc-banner {
  position: fixed;
  z-index: var(--pc-z);
  width: min(560px, calc(100vw - 32px));
  padding: 24px;
  background: var(--pc-surface);
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-radius-lg);
  box-shadow: var(--pc-shadow);
  animation: pc-slide-up .35s cubic-bezier(.16, 1, .3, 1);
}

#pc-banner.pc-pos-center {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-name: pc-fade-in;
}
#pc-banner.pc-pos-bottom-left   { bottom: 20px; left: 20px; }
#pc-banner.pc-pos-bottom-right  { bottom: 20px; right: 20px; }
#pc-banner.pc-pos-bottom-center { bottom: 20px; left: 50%; transform: translateX(-50%); }

/* The US opt-out notice is informational, so it reads smaller and lighter. */
#pc-banner.pc-banner-compact {
  width: min(400px, calc(100vw - 32px));
  padding: 18px 20px;
}
#pc-banner.pc-banner-compact .pc-banner-body { font-size: 13px; }
#pc-banner.pc-banner-compact .pc-actions { flex-direction: row; flex-wrap: wrap; }

.pc-banner-body { font-size: 14px; line-height: 1.6; }
.pc-banner-body p { margin: 0 0 8px; }
.pc-banner-body p:last-child { margin-bottom: 0; }
.pc-banner-body a { color: var(--pc-primary); text-decoration: underline; }

.pc-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 18px;
}

/* ----------------------------------------------------------------- buttons */
#pc-wrapper .pc-button {
  font-family: var(--pc-font);
  font-size: 13px; font-weight: 600; line-height: 1;
  padding: 11px 18px;
  border-radius: var(--pc-radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  flex: 1 1 auto;
  min-height: 40px;        /* comfortable touch target */
  white-space: nowrap;
}

#pc-wrapper .pc-button-primary {
  background: var(--pc-primary);
  color: var(--pc-primary-text);
}
#pc-wrapper .pc-button-primary:hover { background: var(--pc-primary-hover); }

/* Equal visual weight to "Accept all" — under GDPR, rejecting must be as
   easy as accepting, so this is deliberately not a de-emphasised link. */
#pc-wrapper .pc-button-secondary {
  background: var(--pc-surface);
  color: var(--pc-primary);
  border-color: var(--pc-primary);
}
#pc-wrapper .pc-button-secondary:hover { background: var(--pc-surface-alt); }

#pc-wrapper .pc-button-ghost {
  background: transparent;
  color: var(--pc-text-muted);
  border-color: var(--pc-border);
  flex: 0 1 auto;
}
#pc-wrapper .pc-button-ghost:hover { color: var(--pc-text); border-color: var(--pc-text-muted); }

#pc-wrapper button:focus-visible,
#pc-wrapper a:focus-visible,
#pc-wrapper input:focus-visible + .pc-toggle-track {
  outline: 2px solid var(--pc-focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------- modal */
#pc-modal {
  display: none;
  position: fixed;
  z-index: var(--pc-z);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  background: var(--pc-surface);
  border-radius: var(--pc-radius-lg);
  box-shadow: var(--pc-shadow);
  overflow: hidden;
}

.pc-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 24px 24px 12px;
  border-bottom: 1px solid var(--pc-border);
}
.pc-modal-header h2 {
  font-family: var(--pc-font-heading);
  font-weight: 600;
  font-size: 26px;
  line-height: 1.2;
  margin: 0;
  color: var(--pc-text);
}
.pc-modal-close {
  background: none; border: 0; cursor: pointer;
  color: var(--pc-text-muted);
  padding: 6px; margin: -6px -6px 0 0;
  border-radius: var(--pc-radius);
  line-height: 0;
}
.pc-modal-close:hover { color: var(--pc-text); background: var(--pc-surface-alt); }

.pc-modal-body {
  padding: 16px 24px 8px;
  overflow-y: auto;
  font-size: 14px; line-height: 1.6;
}
.pc-modal-body > p { margin: 0 0 12px; }
.pc-modal-body a { color: var(--pc-primary); }

.pc-record-meta {
  font-size: 12px;
  color: var(--pc-text-muted);
  background: var(--pc-surface-alt);
  border-radius: var(--pc-radius);
  padding: 8px 10px;
  margin: 0 0 12px;
}
.pc-gpc-note { border-left: 3px solid var(--pc-primary); }

/* --------------------------------------------------------- consent toggles */
.pc-fieldset { border: 0; margin: 0; padding: 14px 0; border-top: 1px solid var(--pc-border); }
.pc-fieldset:first-of-type { border-top: 0; }

.pc-legend {
  font-size: 14px; font-weight: 700;
  padding: 0; margin-bottom: 4px;
  color: var(--pc-text);
}

.pc-consent-row { display: flex; align-items: flex-start; gap: 16px; }
.pc-consent-description { flex: 1; font-size: 13px; color: var(--pc-text-muted); line-height: 1.55; }
.pc-consent-description p { margin: 0; }

.pc-toggle { position: relative; flex: 0 0 auto; width: 44px; height: 24px; cursor: pointer; }
.pc-toggle input {
  position: absolute; inset: 0;
  opacity: 0; margin: 0; cursor: pointer; z-index: 2;
  width: 100%; height: 100%;
}
.pc-toggle input:disabled { cursor: not-allowed; }

.pc-toggle-track {
  position: absolute; inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  transition: background-color .18s ease;
}
.pc-toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #FFF;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .25);
  transition: transform .18s ease;
}
.pc-toggle input:checked ~ .pc-toggle-track { background: var(--pc-primary); }
.pc-toggle input:checked ~ .pc-toggle-thumb { transform: translateX(20px); }
.pc-toggle input:disabled ~ .pc-toggle-track { background: var(--pc-primary); opacity: .45; }

.pc-modal-footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--pc-border);
  background: var(--pc-surface-alt);
}
.pc-policy-link {
  font-size: 12px; color: var(--pc-text-muted);
  margin-left: auto; text-decoration: underline;
}
.pc-policy-link:hover { color: var(--pc-primary); }

/* -------------------------------------------------------------------- icon */
#pc-icon {
  display: none;
  position: fixed;
  z-index: calc(var(--pc-z) - 2);
  align-items: center; justify-content: center;
  width: 42px; height: 42px;
  padding: 0;
  background: var(--pc-surface);
  color: var(--pc-primary);
  border: 1px solid var(--pc-border);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .14);
  cursor: pointer;
  opacity: .75;
  transition: opacity .15s ease, transform .15s ease;
}
#pc-icon:hover { opacity: 1; transform: scale(1.06); }
#pc-icon.pc-pos-bottom-left  { bottom: 18px; left: 18px; }
#pc-icon.pc-pos-bottom-right { bottom: 18px; right: 18px; }

/* -------------------------------------------------------------- animations */
@keyframes pc-slide-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pc-fade-in  { from { opacity: 0; transform: translate(-50%, -48%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes pc-nudge {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* The centred banner is already translate-positioned, so it needs its own
   nudge keyframes or the shake would fling it off-centre. */
#pc-banner.pc-nudge { animation: pc-nudge .4s ease; }
#pc-banner.pc-pos-center.pc-nudge { animation: pc-nudge-center .4s ease; }
@keyframes pc-nudge-center {
  0%, 100% { transform: translate(-50%, -50%); }
  20%, 60% { transform: translate(calc(-50% - 7px), -50%); }
  40%, 80% { transform: translate(calc(-50% + 7px), -50%); }
}

/* ------------------------------------------------------------ small screens */
@media (max-width: 520px) {
  #pc-banner {
    width: calc(100vw - 20px);
    left: 10px; right: 10px; bottom: 10px;
    top: auto; transform: none;
    padding: 20px;
  }
  #pc-banner.pc-pos-center { top: auto; left: 10px; transform: none; animation-name: pc-slide-up; }
  #pc-banner.pc-pos-center.pc-nudge { animation: pc-nudge .4s ease; }
  .pc-actions { flex-direction: column; }
  #pc-wrapper .pc-button { width: 100%; flex: 1 1 100%; }
  #pc-modal { width: calc(100vw - 20px); max-height: calc(100vh - 32px); }
  .pc-modal-header h2 { font-size: 22px; }
  .pc-policy-link { margin-left: 0; width: 100%; text-align: center; padding-top: 4px; }
}

/* --------------------------------------------------------------- a11y prefs */
@media (prefers-reduced-motion: reduce) {
  #pc-wrapper *, #pc-banner, #pc-icon {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-contrast: more) {
  #pc-wrapper { --pc-border: #475569; --pc-text-muted: #334155; }
}
