/* Shared cookie-preferences component — loaded on every public page
   (index.html, contact.html, expertise.html, and the three legal pages).
   Built and controlled entirely by js/cookie-consent.js; the mount point
   (#cookie-consent-root) is an empty div in each page's own markup. Two
   distinct surfaces: a small, non-blocking first-visit banner (bottom
   bar, page stays scrollable/usable behind it) and a proper centred modal
   for the detailed preference panel (scroll-locked, focus-trapped, same
   conventions as the site's other drawers/modals). Ink/Paper/Graphite/
   Line only — no colour, no icons, no shadow, no gradient. */

:root {
  --cookie-surface: color-mix(in srgb, var(--cb-color-ink) 8%, var(--cb-color-paper));
  --cookie-surface-text: #4f4d49;
}

/* ---- Compact first-visit banner ---- */

.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  justify-content: center;
  padding: var(--cb-space-4);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner__panel {
  width: 100%;
  /* 860px -> 740px (~14% reduction) and var(--cb-space-5) 32px -> 28px
     padding (~12.5% reduction) — a modest, discreet scale-down, not a
     redesign. Neither existing token lands inside the requested 10-15%
     padding-reduction range (--cb-space-4 at 24px is a 25% cut), so this
     one dimension uses a literal value instead of forcing a token that
     would overshoot the target. Colours, radius and typography below are
     all untouched. */
  max-width: 740px;
  background: var(--cb-color-paper);
  border: var(--cb-border-width) solid var(--cb-color-line);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  /* 32px -> 26px — a slight tightening of the gap between the text block
     and the action buttons, per brief ("slightly"), short of the fuller
     10-15% cuts applied to width/padding above. */
  gap: 26px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 320ms var(--cb-ease-standard), transform 320ms var(--cb-ease-standard);
}

.cookie-banner.is-open .cookie-banner__panel {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .cookie-banner__panel {
    transition: opacity 200ms var(--cb-ease-standard);
    transform: none;
  }
}

.cookie-banner__text {
  flex: 1 1 320px;
}

.cookie-banner__heading {
  margin: 0;
  font-family: var(--cb-font-sans);
  font-weight: var(--cb-weight-medium);
  font-size: var(--cb-text-subheading-size);
  color: var(--cb-color-ink);
}

.cookie-banner__copy {
  margin: var(--cb-space-2) 0 0;
  max-width: 60ch;
  font-size: var(--cb-text-small-size);
  line-height: 1.6;
  color: var(--cb-color-text-secondary);
}

.cookie-banner__actions {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cb-space-4);
  justify-content: flex-end;
}

@media (max-width: 40rem) {
  .cookie-banner__actions {
    justify-content: flex-start;
    width: 100%;
  }
}

.cookie-banner__manage-link {
  appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--cb-font-sans);
  font-weight: var(--cb-weight-medium);
  font-size: var(--cb-text-small-size);
  color: var(--cb-color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.cookie-banner__manage-link:hover,
.cookie-banner__manage-link:focus-visible {
  color: var(--cb-color-ink);
}

/* ---- Shared button styling — Accept/Reject deliberately comparable in
   size and prominence (brief: never make Reject harder to find). ---- */
.cookie-btn {
  appearance: none;
  cursor: pointer;
  font-family: var(--cb-font-sans);
  font-weight: var(--cb-weight-medium);
  font-size: var(--cb-text-small-size);
  padding: 12px 20px;
  border-radius: var(--cb-radius-pill);
  white-space: nowrap;
  transition: background-color 160ms var(--cb-ease-standard), color 160ms var(--cb-ease-standard), border-color 160ms var(--cb-ease-standard);
}

.cookie-btn--solid {
  border: var(--cb-border-width) solid var(--cb-color-ink);
  background: var(--cb-color-ink);
  color: var(--cb-color-paper);
}

.cookie-btn--solid:hover,
.cookie-btn--solid:focus-visible {
  background: color-mix(in srgb, var(--cb-color-ink) 85%, var(--cb-color-paper));
}

.cookie-btn--ghost {
  border: var(--cb-border-width) solid var(--cb-color-ink);
  background: transparent;
  color: var(--cb-color-ink);
}

.cookie-btn--ghost:hover,
.cookie-btn--ghost:focus-visible {
  background: color-mix(in srgb, var(--cb-color-ink) 6%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .cookie-btn {
    transition: none;
  }
}

/* ---- Detailed preferences modal — same architecture as the reusable
   Expertise modal (fixed, centred, Paper panel, dimmed Ink backdrop,
   [inert] as the closed-state source of truth), reproduced here rather
   than shared, since this component must work on pages that don't load
   expertise.js at all. ---- */
.cookie-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cookie-modal[inert] {
  display: none;
}

.cookie-modal__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--cb-color-ink) 55%, transparent);
  opacity: 0;
  transition: opacity 260ms var(--cb-ease-standard);
}

.cookie-modal.is-open .cookie-modal__backdrop {
  opacity: 1;
}

.cookie-modal__panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow: hidden;
  border-radius: var(--cb-radius-modal);
  background: var(--cb-color-paper);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 260ms var(--cb-ease-standard), transform 260ms var(--cb-ease-standard);
}

.cookie-modal.is-open .cookie-modal__panel {
  opacity: 1;
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .cookie-modal__backdrop,
  .cookie-modal__panel {
    transition: opacity 200ms var(--cb-ease-standard);
  }

  .cookie-modal__panel {
    transform: none;
  }
}

@media (max-width: 30rem) {
  .cookie-modal {
    padding: 0;
  }

  .cookie-modal__panel {
    max-width: none;
    height: 100%;
    max-height: none;
    /* Global design-consistency pass: was a literal 20px (the standard-card
       radius, not this component's own 24px modal radius) — the same panel
       as above, just its bottom corners squared off for the full-height
       mobile sheet, so it now reuses that same modal token instead of a
       smaller unrelated one. */
    border-radius: var(--cb-radius-modal) var(--cb-radius-modal) 0 0;
  }
}

.cookie-modal__close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 1;
  appearance: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cookie-surface);
  color: var(--cb-color-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cookie-modal__close:hover {
  background: color-mix(in srgb, var(--cb-color-ink) 14%, var(--cb-color-paper));
}

.cookie-modal__close svg {
  width: 16px;
  height: 16px;
}

.cookie-modal__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 56px 32px 32px;
}

.cookie-modal__title {
  margin: var(--cb-space-2) 0 0;
  font-family: var(--cb-font-sans);
  font-weight: var(--cb-weight-medium);
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--cb-color-ink);
}

.cookie-modal__intro {
  margin: var(--cb-space-3) 0 0;
  font-size: var(--cb-text-small-size);
  line-height: 1.6;
  color: var(--cb-color-text-secondary);
}

.cookie-modal__categories {
  margin: var(--cb-space-6) 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.cookie-modal__category {
  padding-block: var(--cb-space-4);
  border-top: var(--cb-border-width) solid var(--cb-color-line);
}

.cookie-modal__category:last-child {
  border-bottom: var(--cb-border-width) solid var(--cb-color-line);
}

.cookie-modal__category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cb-space-4);
}

.cookie-modal__category-label {
  margin: 0;
  font-family: var(--cb-font-sans);
  font-weight: var(--cb-weight-medium);
  font-size: var(--cb-text-body-size);
  color: var(--cb-color-ink);
}

.cookie-modal__category-state {
  flex: 0 0 auto;
  font-size: var(--cb-text-label-size);
  letter-spacing: var(--cb-text-label-tracking);
  text-transform: uppercase;
  color: var(--cookie-surface-text);
}

.cookie-modal__category-desc {
  margin: var(--cb-space-2) 0 0;
  font-size: var(--cb-text-small-size);
  line-height: 1.6;
  color: var(--cb-color-text-secondary);
}

/* Toggle — plain, monochrome, used only when an optional (non-required)
   category exists. None currently do (see js/cookie-consent.js), but the
   control is fully implemented so adding one later needs no new CSS. */
.cookie-toggle {
  flex: 0 0 auto;
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
}

.cookie-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.cookie-toggle__track {
  position: absolute;
  inset: 0;
  border-radius: var(--cb-radius-pill);
  background: var(--cookie-surface);
  transition: background-color 160ms var(--cb-ease-standard);
}

.cookie-toggle__track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cb-color-paper);
  transition: transform 160ms var(--cb-ease-standard);
}

.cookie-toggle input:checked + .cookie-toggle__track {
  background: var(--cb-color-ink);
}

.cookie-toggle input:checked + .cookie-toggle__track::before {
  transform: translateX(16px);
}

.cookie-toggle input:focus-visible + .cookie-toggle__track {
  outline: 2px solid var(--cb-color-ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .cookie-toggle__track,
  .cookie-toggle__track::before {
    transition: none;
  }
}

.cookie-modal__policy-link {
  display: inline-block;
  margin-top: var(--cb-space-5);
  font-size: var(--cb-text-small-size);
  color: var(--cb-color-ink);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.cookie-modal__policy-link:hover,
.cookie-modal__policy-link:focus-visible {
  color: var(--cb-color-text-secondary);
}

.cookie-modal__actions {
  margin-top: var(--cb-space-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--cb-space-3);
}
