/* ============================================================
 * EgisAI cookie consent — banner + preferences modal
 *
 * Shared styling for the privacy consent surface on every
 * marketing page. Mirrors the homepage's design system
 * (Roboto / Darker Grotesque, sage-deep accent, 12–16 px
 * border-radius, white-on-line-mid cards) so the banner reads
 * as part of the site rather than a third-party widget.
 *
 * The script (egis-prefs.js) injects the DOM lazily — none
 * of these selectors apply until a banner or modal is mounted,
 * so the CSS is inert by default.
 *
 * Token names are prefixed `--egp-` so they don't collide with
 * the per-page CSS variables (`--bg`, `--line`, etc.) on
 * pages that scope different palettes inside specific blocks.
 * ============================================================ */

:root {
  --egp-bg: #ffffff;
  --egp-bg-dim: #fafafa;
  --egp-text: #050505;
  --egp-text-soft: #1a1a1a;
  --egp-muted: #5f5f5f;
  --egp-muted-2: #8a8a8a;
  --egp-line: rgba(0, 0, 0, 0.08);
  --egp-line-mid: rgba(0, 0, 0, 0.12);
  --egp-line-strong: rgba(0, 0, 0, 0.18);
  --egp-sage: #7dbf96;
  --egp-sage-deep: #2c7a4f;
  --egp-mist: #f1f3f7;
  --egp-font-heading: 'Darker Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --egp-font-body: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --egp-font-mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ──────────────────────────────────────────────────────────
 * Banner — bottom-fixed card, never covers more than ~30 % of
 * the viewport on phones, never blocks scrolling on any device.
 * Centered with `left: 50%; transform: translateX(-50%)` so
 * the slide-in animation stays GPU-accelerated and centered
 * at the same time.
 * ────────────────────────────────────────────────────────── */
.egp-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 1180px;
  margin: 0 auto;
  z-index: 9999;
  background: var(--egp-bg);
  border: 1px solid var(--egp-line-mid);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 18px 24px;
  font-family: var(--egp-font-body);
  color: var(--egp-text-soft);
  font-size: 14px;
  line-height: 1.55;
  display: none;
  /* Wide layout: text on the left, actions on the right, so the
     copy spans the full width and reads on as few lines as
     possible. Collapses to a vertical stack on phones below. */
  flex-direction: row;
  align-items: center;
  gap: 24px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  /* Respect notched devices on iOS; without this the banner
     can sit under the home-indicator on iPhone X+. */
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}
.egp-banner[data-open="true"] {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.egp-banner__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.egp-banner__icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(125, 191, 150, 0.18);
  border: 1px solid rgba(125, 191, 150, 0.4);
  color: var(--egp-sage-deep);
  display: grid;
  place-items: center;
}
.egp-banner__icon svg { display: block; }

.egp-banner__body { min-width: 0; flex: 1; }
.egp-banner__title {
  font-family: var(--egp-font-heading);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.025em;
  color: var(--egp-text);
  margin: 0 0 6px;
  line-height: 1.15;
}
.egp-banner__text {
  margin: 0;
  color: var(--egp-muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.egp-banner__text strong { color: var(--egp-text); font-weight: 600; }
.egp-banner__text a {
  color: var(--egp-text);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  text-decoration: none;
  transition: border-color 0.16s ease;
}
.egp-banner__text a:hover { border-bottom-color: var(--egp-text); }

.egp-banner__actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}

/* ──────────────────────────────────────────────────────────
 * Buttons — byte-for-byte mirror of the homepage's `.btn`
 * shape (44 px tall, 12 px radius, 14 px Roboto, 0.18 s
 * easing, translucent-white default + filled-dark primary +
 * ghost). The `egp-` prefix keeps us from fighting per-page
 * button styles, but every visible token is the same as
 * `.btn` / `.btn--dark` / `.btn--ghost` in index.html.
 *
 * GDPR / UK PECR / French CNIL guidance is strict:
 * `Accept all` and `Reject all` must have **equivalent
 * prominence** — same size, same affordance, neither styled
 * to look like the obvious default. Both are rendered as
 * pill buttons; only the primary "Accept all" is filled,
 * matching the convention of the rest of the site without
 * making "Reject" look secondary. The "Customize" link is
 * intentionally lighter because it's an additional path,
 * not a competing default.
 * ────────────────────────────────────────────────────────── */
.egp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 44px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid var(--egp-line-strong);
  background: rgba(255, 255, 255, 0.7);
  color: #050505;
  font-family: var(--egp-font-body);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease,
              color 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
  white-space: nowrap;
  text-decoration: none;
}
.egp-btn:hover { transform: translateY(-1px); border-color: rgba(0, 0, 0, 0.32); }
.egp-btn:focus-visible {
  outline: 2px solid var(--egp-sage-deep);
  outline-offset: 2px;
}
.egp-btn--primary {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.egp-btn--primary:hover {
  background: #1a1a1a;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}
.egp-btn--ghost {
  background: transparent;
  border-color: var(--egp-line-mid);
  color: var(--egp-text-soft);
}
.egp-btn--link {
  background: transparent;
  border: none;
  color: var(--egp-muted);
  padding: 0 10px;
  height: 44px;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.2);
  text-underline-offset: 3px;
  font-weight: 500;
}
.egp-btn--link:hover {
  color: var(--egp-text);
  text-decoration-color: var(--egp-text);
  transform: none;
  border-color: transparent;
}

/* Mobile: full-width buttons, stack vertically.
   "Accept all" is rendered last in the DOM so it sits at the
   *bottom* of the stack — the thumb-friendly target — without
   us reordering the source for desktop. */
@media (max-width: 860px) {
  .egp-banner {
    /* Narrow viewports can't fit text + buttons on one row, so
       fall back to the original vertical stack. */
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
}

@media (max-width: 600px) {
  .egp-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 18px;
    border-radius: 14px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .egp-banner__head { gap: 12px; }
  .egp-banner__icon { width: 34px; height: 34px; }
  .egp-banner__title { font-size: 17px; }
  .egp-banner__actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .egp-btn { width: 100%; }
}

/* ──────────────────────────────────────────────────────────
 * Modal — centered overlay with backdrop blur. Shown when the
 * user clicks "Customize" on the banner or "Cookie preferences"
 * from the footer. Includes per-category toggles, a
 * description for each category, and three action buttons
 * with equal prominence (Reject all / Save / Accept all).
 *
 * The panel is its own scroll container so long category
 * descriptions don't blow out the page layout on phones.
 * ────────────────────────────────────────────────────────── */
.egp-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.egp-modal[data-open="true"] { display: flex; opacity: 1; }

.egp-modal__panel {
  background: var(--egp-bg);
  border: 1px solid var(--egp-line-mid);
  border-radius: 22px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28);
  font-family: var(--egp-font-body);
  color: var(--egp-text-soft);
  display: flex;
  flex-direction: column;
}
.egp-modal__head {
  padding: 22px 24px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.egp-modal__title {
  font-family: var(--egp-font-heading);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--egp-text);
  margin: 0;
  line-height: 1.15;
}
.egp-modal__lede {
  padding: 0 24px 12px;
  margin: 0;
  color: var(--egp-muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.egp-modal__lede a {
  color: var(--egp-text);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}
/* Close button — mirror the dashboard's canonical `.modal__close`
   (a circular 36 px chip: borderless, soft neutral fill, dark
   icon, that fills with the brand-primary on hover and spins
   90°). The homepage's primary/active color is black, so the
   hover fill is black with a white icon. This keeps the close
   affordance identical to every other modal in the product. */
.egp-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--egp-mist);
  border: none;
  border-radius: 50%;
  color: #050505;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.16s ease, color 0.16s ease, transform 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.egp-modal__close:hover {
  background: #050505;
  color: #ffffff;
  transform: rotate(90deg);
}
.egp-modal__close:focus-visible {
  outline: 2px solid #050505;
  outline-offset: 2px;
}
.egp-modal__close svg { display: block; }

.egp-modal__list {
  padding: 12px 24px 4px;
  display: grid;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.egp-modal__row {
  border: 1px solid var(--egp-line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--egp-bg-dim);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
}
.egp-modal__row-title {
  font-weight: 600;
  color: var(--egp-text);
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  cursor: pointer;
  user-select: none;
}
.egp-modal__row-locked {
  font-family: var(--egp-font-mono);
  font-size: 10.5px;
  color: var(--egp-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.04);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.06em;
}
.egp-modal__row-body {
  grid-column: 1 / -1;
  font-size: 12.75px;
  color: var(--egp-muted);
  margin: 4px 0 0;
  line-height: 1.6;
}
.egp-modal__row-body code {
  font-family: var(--egp-font-mono);
  font-size: 11.5px;
  background: var(--egp-mist);
  padding: 1px 6px;
  border-radius: 5px;
  color: #2a2a2a;
  border: 1px solid var(--egp-line);
}

/* Switch — pure CSS toggle that wraps a real <input
   type="checkbox"> so it stays keyboard-accessible and works
   with form-state APIs. */
.egp-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-block;
}
.egp-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.egp-switch input:disabled { cursor: not-allowed; }
.egp-switch__track {
  position: absolute;
  inset: 0;
  background: #d8d8d8;
  border-radius: 999px;
  transition: background 0.18s ease;
  pointer-events: none;
}
.egp-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.egp-switch input:checked ~ .egp-switch__track { background: #050505; }
.egp-switch input:checked ~ .egp-switch__track .egp-switch__thumb { transform: translateX(18px); }
.egp-switch input:focus-visible ~ .egp-switch__track {
  outline: 2px solid #050505;
  outline-offset: 2px;
}
/* "Always on" (necessary) toggle: on but locked. A muted black
   reads as enabled-yet-disabled without reintroducing the sage
   accent the rest of the switch theme drops. */
.egp-switch input:disabled ~ .egp-switch__track {
  background: rgba(5, 5, 5, 0.45);
  opacity: 1;
}

.egp-modal__foot {
  padding: 14px 24px 22px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--egp-line);
  margin-top: 8px;
  background: var(--egp-bg);
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}
.egp-modal__foot .egp-btn {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 540px) {
  .egp-modal { padding: 12px; }
  .egp-modal__panel { border-radius: 18px; }
  .egp-modal__head { padding: 20px 20px 4px; }
  .egp-modal__lede { padding: 0 20px 10px; font-size: 13px; }
  .egp-modal__list { padding: 10px 20px 4px; }
  .egp-modal__foot {
    padding: 12px 20px 20px;
    flex-direction: column-reverse;
  }
  .egp-modal__foot .egp-btn { width: 100%; }
  .egp-modal__title { font-size: 21px; }
}

/* Reduced motion — kill the slide-in and the backdrop fade
   for visitors who set the system preference. */
@media (prefers-reduced-motion: reduce) {
  .egp-banner,
  .egp-modal,
  .egp-modal__close,
  .egp-switch__track,
  .egp-switch__thumb,
  .egp-btn { transition: none; }
  .egp-banner { transform: none; }
  .egp-modal__close:hover { transform: none; }
}
