/* ============================================================
 * 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 (cookie-consent.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 `--cc-` so they don't collide with
 * the per-page CSS variables (`--bg`, `--line`, etc.) on
 * pages that scope different palettes inside specific blocks.
 * ============================================================ */

:root {
  --cc-bg: #ffffff;
  --cc-bg-dim: #fafafa;
  --cc-text: #050505;
  --cc-text-soft: #1a1a1a;
  --cc-muted: #5f5f5f;
  --cc-muted-2: #8a8a8a;
  --cc-line: rgba(0, 0, 0, 0.08);
  --cc-line-mid: rgba(0, 0, 0, 0.12);
  --cc-line-strong: rgba(0, 0, 0, 0.18);
  --cc-sage: #7dbf96;
  --cc-sage-deep: #2c7a4f;
  --cc-mist: #f1f3f7;
  --cc-font-heading: 'Darker Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cc-font-body: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cc-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.
 * ────────────────────────────────────────────────────────── */
.cc-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 720px;
  margin: 0 auto;
  z-index: 9999;
  background: var(--cc-bg);
  border: 1px solid var(--cc-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: 20px 22px;
  font-family: var(--cc-font-body);
  color: var(--cc-text-soft);
  font-size: 14px;
  line-height: 1.55;
  display: none;
  flex-direction: column;
  gap: 16px;
  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(20px, env(safe-area-inset-bottom));
}
.cc-banner[data-open="true"] {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.cc-banner__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.cc-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(--cc-sage-deep);
  display: grid;
  place-items: center;
}
.cc-banner__icon svg { display: block; }

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

.cc-banner__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  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 `cc-` 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.
 * ────────────────────────────────────────────────────────── */
.cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 44px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid var(--cc-line-strong);
  background: rgba(255, 255, 255, 0.7);
  color: #050505;
  font-family: var(--cc-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;
}
.cc-btn:hover { transform: translateY(-1px); border-color: rgba(0, 0, 0, 0.32); }
.cc-btn:focus-visible {
  outline: 2px solid var(--cc-sage-deep);
  outline-offset: 2px;
}
.cc-btn--primary {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.cc-btn--primary:hover {
  background: #1a1a1a;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}
.cc-btn--ghost {
  background: transparent;
  border-color: var(--cc-line-mid);
  color: var(--cc-text-soft);
}
.cc-btn--link {
  background: transparent;
  border: none;
  color: var(--cc-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;
}
.cc-btn--link:hover {
  color: var(--cc-text);
  text-decoration-color: var(--cc-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: 600px) {
  .cc-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 18px;
    border-radius: 14px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .cc-banner__head { gap: 12px; }
  .cc-banner__icon { width: 34px; height: 34px; }
  .cc-banner__title { font-size: 17px; }
  .cc-banner__actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .cc-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.
 * ────────────────────────────────────────────────────────── */
.cc-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;
}
.cc-modal[data-open="true"] { display: flex; opacity: 1; }

.cc-modal__panel {
  background: var(--cc-bg);
  border: 1px solid var(--cc-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(--cc-font-body);
  color: var(--cc-text-soft);
  display: flex;
  flex-direction: column;
}
.cc-modal__head {
  padding: 22px 24px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.cc-modal__title {
  font-family: var(--cc-font-heading);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--cc-text);
  margin: 0;
  line-height: 1.15;
}
.cc-modal__lede {
  padding: 0 24px 12px;
  margin: 0;
  color: var(--cc-muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.cc-modal__lede a {
  color: var(--cc-text);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}
/* Close button — mirror `.nav__hamburger` (transparent
   surface, line-strong border, 12 px radius, sage hover) so
   the close affordance reads as part of the same brand
   family as the rest of the chrome. Scaled to 36 × 36 px
   because a 44 × 44 hit-area in the modal header crowds the
   title; the visual treatment is identical. */
.cc-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--cc-line-strong);
  border-radius: 12px;
  color: #050505;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}
.cc-modal__close:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: #050505;
}
.cc-modal__close:focus-visible {
  outline: 2px solid var(--cc-sage-deep);
  outline-offset: 2px;
}
.cc-modal__close svg { display: block; }

.cc-modal__list {
  padding: 12px 24px 4px;
  display: grid;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.cc-modal__row {
  border: 1px solid var(--cc-line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--cc-bg-dim);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
}
.cc-modal__row-title {
  font-weight: 600;
  color: var(--cc-text);
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  cursor: pointer;
  user-select: none;
}
.cc-modal__row-locked {
  font-family: var(--cc-font-mono);
  font-size: 10.5px;
  color: var(--cc-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;
}
.cc-modal__row-body {
  grid-column: 1 / -1;
  font-size: 12.75px;
  color: var(--cc-muted);
  margin: 4px 0 0;
  line-height: 1.6;
}
.cc-modal__row-body code {
  font-family: var(--cc-font-mono);
  font-size: 11.5px;
  background: var(--cc-mist);
  padding: 1px 6px;
  border-radius: 5px;
  color: #2a2a2a;
  border: 1px solid var(--cc-line);
}

/* Switch — pure CSS toggle that wraps a real <input
   type="checkbox"> so it stays keyboard-accessible and works
   with form-state APIs. */
.cc-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-block;
}
.cc-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.cc-switch input:disabled { cursor: not-allowed; }
.cc-switch__track {
  position: absolute;
  inset: 0;
  background: #d8d8d8;
  border-radius: 999px;
  transition: background 0.18s ease;
  pointer-events: none;
}
.cc-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);
}
.cc-switch input:checked ~ .cc-switch__track { background: var(--cc-sage-deep); }
.cc-switch input:checked ~ .cc-switch__track .cc-switch__thumb { transform: translateX(18px); }
.cc-switch input:focus-visible ~ .cc-switch__track {
  outline: 2px solid var(--cc-sage-deep);
  outline-offset: 2px;
}
.cc-switch input:disabled ~ .cc-switch__track {
  background: var(--cc-sage);
  opacity: 0.55;
}

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

@media (max-width: 540px) {
  .cc-modal { padding: 12px; }
  .cc-modal__panel { border-radius: 18px; }
  .cc-modal__head { padding: 20px 20px 4px; }
  .cc-modal__lede { padding: 0 20px 10px; font-size: 13px; }
  .cc-modal__list { padding: 10px 20px 4px; }
  .cc-modal__foot {
    padding: 12px 20px 20px;
    flex-direction: column-reverse;
  }
  .cc-modal__foot .cc-btn { width: 100%; }
  .cc-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) {
  .cc-banner,
  .cc-modal,
  .cc-switch__track,
  .cc-switch__thumb,
  .cc-btn { transition: none; }
  .cc-banner { transform: none; }
}
