/* ─────────────────────────────────────────────────────────────────
   Ubicuo · Cookie Consent
   Editorial design · LSSI-CE Art. 22.2 + RGPD compliant
   No dark patterns · Reject equal-prominence to Accept
   ───────────────────────────────────────────────────────────────── */

/* Use the same design tokens as the rest of the site, with safe fallbacks
   so this stylesheet works even before the page CSS loads. */
:root {
  --cc-ink: var(--ink, #0E0E0E);
  --cc-paper: var(--paper, #F5F1EA);
  --cc-surface: var(--surface, #FFFFFF);
  --cc-off-white: var(--off-white, #FBFAF6);
  --cc-emerald: var(--emerald, #1C8161);
  --cc-emerald-deep: var(--emerald-deep, #0F4A37);
  --cc-emerald-pale: var(--emerald-pale, #E8F0EA);
  --cc-emerald-glow: var(--emerald-glow, rgba(28, 129, 97, 0.12));
  --cc-mid: var(--mid, #5B5B5B);
  --cc-soft: var(--soft, #9B9B9B);
  --cc-border: var(--border, #E2DDD0);
  --cc-border-strong: var(--border-strong, #C9C2B0);
  --cc-font-display: var(--font-display, "Fraunces", Georgia, serif);
  --cc-font-body: var(--font-body, "Geist", -apple-system, sans-serif);
  --cc-font-mono: var(--font-mono, "Geist Mono", "SF Mono", monospace);
  --cc-shadow-card: 0 1px 2px rgba(14, 14, 14, 0.04), 0 8px 24px rgba(14, 14, 14, 0.08);
  --cc-shadow-modal: 0 1px 2px rgba(14, 14, 14, 0.04), 0 24px 64px rgba(14, 14, 14, 0.18);
  --cc-radius: 16px;
  --cc-radius-sm: 10px;
}

/* ─── Banner (first-visit, bottom-anchored card) ─────────────────── */

.cc-banner {
  position: fixed;
  z-index: 1000;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  right: max(1.5rem, env(safe-area-inset-right, 0px));
  left: auto;
  width: calc(100vw - 3rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-width: 32rem;
  background: var(--cc-surface);
  color: var(--cc-ink);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow-card);
  font-family: var(--cc-font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 280ms cubic-bezier(0.22, 1, 0.36, 1), transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.cc-banner[data-cc-state="visible"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.cc-banner-inner {
  padding: 1.5rem 1.5rem 1.25rem;
}

.cc-banner-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--cc-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cc-emerald);
  margin-bottom: 0.5rem;
}
.cc-banner-eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--cc-emerald);
}

.cc-banner-title {
  font-family: var(--cc-font-display);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--cc-ink);
  margin: 0 0 0.5rem 0;
  font-variation-settings: "opsz" 144;
}
.cc-banner-title em {
  font-style: italic;
  color: var(--cc-emerald);
}

.cc-banner-desc {
  color: var(--cc-mid);
  margin: 0 0 1.125rem 0;
  font-size: 0.875rem;
}
.cc-banner-desc a {
  color: var(--cc-emerald);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.cc-banner-desc a:hover { color: var(--cc-emerald-deep); }

/* Actions: Reject and Accept have EQUAL visual prominence (legal requirement).
   Customize is the third option, less prominent (it's a config gateway). */
.cc-banner-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.cc-banner-actions .cc-btn-tertiary {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}

.cc-btn {
  appearance: none;
  font-family: var(--cc-font-body);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease, transform 100ms ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid transparent;
}
.cc-btn:active { transform: scale(0.98); }

/* Primary = Accept all. Solid emerald. */
.cc-btn-primary {
  background: var(--cc-emerald);
  color: var(--cc-off-white);
  border-color: var(--cc-emerald);
}
.cc-btn-primary:hover { background: var(--cc-emerald-deep); border-color: var(--cc-emerald-deep); }

/* Secondary = Reject all. Outlined, equal weight to primary. */
.cc-btn-secondary {
  background: var(--cc-surface);
  color: var(--cc-ink);
  border-color: var(--cc-ink);
}
.cc-btn-secondary:hover { background: var(--cc-ink); color: var(--cc-off-white); }

/* Tertiary = Customize. Text-style with subtle border. */
.cc-btn-tertiary {
  background: transparent;
  color: var(--cc-mid);
  border-color: var(--cc-border);
  font-weight: 400;
}
.cc-btn-tertiary:hover {
  border-color: var(--cc-emerald);
  color: var(--cc-emerald);
}

/* ─── Modal (granular configuration) ─────────────────────────────── */

.cc-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.cc-modal[data-cc-state="visible"] {
  opacity: 1;
  pointer-events: auto;
}

.cc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 14, 14, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.cc-modal-card {
  position: relative;
  background: var(--cc-surface);
  color: var(--cc-ink);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow-modal);
  width: 100%;
  max-width: 36rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(0.98);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.cc-modal[data-cc-state="visible"] .cc-modal-card {
  transform: translateY(0) scale(1);
}

.cc-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--cc-border);
  padding-bottom: 1.25rem;
}
.cc-modal-header-text {
  flex: 1;
}
.cc-modal-eyebrow {
  font-family: var(--cc-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cc-emerald);
  margin-bottom: 0.375rem;
}
.cc-modal-title {
  font-family: var(--cc-font-display);
  font-weight: 400;
  font-size: 1.375rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--cc-ink);
  margin: 0;
  font-variation-settings: "opsz" 144;
}
.cc-modal-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--cc-mid);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 150ms ease, color 150ms ease;
  flex-shrink: 0;
}
.cc-modal-close:hover {
  background: var(--cc-paper);
  color: var(--cc-ink);
}

.cc-modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.cc-modal-intro {
  font-size: 0.875rem;
  color: var(--cc-mid);
  margin: 0 0 1.25rem 0;
}

/* Category card */
.cc-category {
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius-sm);
  padding: 1rem 1.125rem;
  margin-bottom: 0.75rem;
  background: var(--cc-paper);
  transition: border-color 200ms ease;
}
.cc-category:hover { border-color: var(--cc-border-strong); }
.cc-category:last-child { margin-bottom: 0; }

.cc-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}

.cc-category-name {
  font-family: var(--cc-font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--cc-ink);
  letter-spacing: -0.005em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0; /* allow shrink within flex */
}

.cc-category-required {
  font-family: var(--cc-font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cc-emerald-deep);
  background: var(--cc-emerald-pale);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.cc-category-desc {
  font-size: 0.8125rem;
  color: var(--cc-mid);
  margin: 0;
  line-height: 1.5;
}

.cc-category-providers {
  margin-top: 0.5rem;
  font-family: var(--cc-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  color: var(--cc-soft);
}

/* Toggle switch */
.cc-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.cc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.cc-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--cc-border-strong);
  border-radius: 999px;
  transition: background 200ms ease;
}
.cc-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--cc-off-white);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.cc-toggle input:checked ~ .cc-toggle-track {
  background: var(--cc-emerald);
}
.cc-toggle input:checked ~ .cc-toggle-track .cc-toggle-thumb {
  transform: translateX(20px);
}
.cc-toggle input:focus-visible ~ .cc-toggle-track {
  box-shadow: 0 0 0 3px var(--cc-emerald-glow);
}
.cc-toggle.cc-toggle-disabled {
  cursor: not-allowed;
  opacity: 0.7;
}
.cc-toggle.cc-toggle-disabled .cc-toggle-track {
  background: var(--cc-emerald);
}
.cc-toggle.cc-toggle-disabled .cc-toggle-thumb {
  transform: translateX(20px);
}

.cc-modal-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--cc-border);
}
.cc-modal-footer .cc-btn { width: 100%; }

.cc-modal-meta {
  padding: 0 1.5rem 1.25rem;
  font-family: var(--cc-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--cc-soft);
  text-align: center;
}
.cc-modal-meta a {
  color: var(--cc-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cc-modal-meta a:hover { color: var(--cc-emerald); }

/* ─── Mobile (< 600px) ─────────────────────────────────────────────
   Banner becomes full-width bottom sheet, modal goes fullscreen-ish */

@media (max-width: 599px) {
  .cc-banner {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: none;
    border-radius: var(--cc-radius) var(--cc-radius) 0 0;
    border-bottom: none;
  }
  /* Bottom padding lifts content above iPhone home-indicator strip */
  .cc-banner-inner {
    padding: 1.25rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(1.25rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1.25rem + env(safe-area-inset-right, 0px));
  }
  .cc-banner-actions { grid-template-columns: 1fr; }
  .cc-banner-actions .cc-btn-tertiary {
    grid-column: auto;
    margin-top: 0;
  }

  .cc-modal { padding: 0; align-items: flex-end; }
  .cc-modal-card {
    max-width: none;
    max-height: 92vh;
    /* Use dvh when available for true mobile viewport height (excludes URL bar) */
    max-height: 92dvh;
    border-radius: var(--cc-radius) var(--cc-radius) 0 0;
  }
  .cc-modal-header {
    padding: 1.25rem calc(1.25rem + env(safe-area-inset-right, 0px)) 1rem calc(1.25rem + env(safe-area-inset-left, 0px));
  }
  .cc-modal-body {
    padding: 1rem calc(1.25rem + env(safe-area-inset-right, 0px)) 1rem calc(1.25rem + env(safe-area-inset-left, 0px));
  }
  .cc-modal-footer {
    grid-template-columns: 1fr;
    padding: 1rem calc(1.25rem + env(safe-area-inset-right, 0px)) 1.25rem calc(1.25rem + env(safe-area-inset-left, 0px));
    /* Lift footer buttons above home indicator */
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }
  .cc-modal-meta {
    padding: 0 calc(1.25rem + env(safe-area-inset-right, 0px)) 1rem calc(1.25rem + env(safe-area-inset-left, 0px));
  }
}

/* ─── Very narrow phones (< 360px, iPhone SE 1, Galaxy Fold) ──── */
@media (max-width: 359px) {
  .cc-banner-inner { padding-left: 1rem; padding-right: 1rem; }
  .cc-banner-title { font-size: 1.125rem; }
  .cc-banner-desc { font-size: 0.8125rem; }
  .cc-btn { font-size: 0.8125rem; padding: 0.625rem 0.75rem; }
  .cc-modal-title { font-size: 1.1875rem; }
  .cc-category { padding: 0.875rem 1rem; }
  .cc-category-name { font-size: 0.875rem; }
  .cc-category-desc { font-size: 0.75rem; }
  .cc-category-providers { font-size: 0.625rem; word-break: break-word; }
}

/* ─── Phones in landscape (short height) ─────────────────────── */
@media (max-height: 480px) and (max-width: 899px) and (orientation: landscape) {
  .cc-banner { bottom: 0.5rem; right: 0.5rem; max-width: 26rem; }
  .cc-banner-inner { padding: 0.875rem 1rem 0.875rem; }
  .cc-banner-title { font-size: 1rem; margin-bottom: 0.25rem; }
  .cc-banner-desc { font-size: 0.8125rem; margin-bottom: 0.625rem; }
  .cc-banner-actions { grid-template-columns: 1fr 1fr; }
  .cc-banner-actions .cc-btn-tertiary { grid-column: 1 / -1; }
  .cc-btn { min-height: 38px; padding: 0.5rem 0.875rem; }
  .cc-modal-card { max-height: 96vh; }
}

/* ─── Accessibility: focus, reduced motion ─────────────────────── */

.cc-banner *:focus-visible,
.cc-modal *:focus-visible {
  outline: 2px solid var(--cc-emerald);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .cc-banner,
  .cc-modal,
  .cc-modal-card,
  .cc-toggle-thumb,
  .cc-toggle-track,
  .cc-btn {
    transition: opacity 0.01ms !important;
    transform: none !important;
  }
}

/* ─── Body scroll lock when modal open ─────────────────────────── */
body.cc-modal-open { overflow: hidden; }
