/*
Cookie settings component. Self-contained, so it can move to the design system as it is.

Anatomy
  .consent                    the fixed card, bottom left
    .consent__view            one of two views: the short banner, or the settings
      .consent__text          body copy
      .consent__actions       the buttons; the primary one sits at the end
      .consent__btn           outlined pill; --primary is the filled one
    .consent__title           settings heading (Fraunces)
    .consent__list / __row    one row per category: label and description, then a switch
    .consent__switch          role="switch" toggle
    .consent__foot            tinted bar under the list: actions, then the privacy note

Tokens (set on .consent; each falls back to the site's own token, then to a plain value)
  --consent-surface  card
  --consent-tint     footer bar and button hover
  --consent-ink      main text and the primary button
  --consent-muted    secondary text
  --consent-line     hairlines and outlines
  --consent-accent   switch when on
  --consent-off      switch when off
  --consent-radius   card corner
*/

.consent {
  --consent-surface: var(--card, #ffffff);
  --consent-tint: var(--paper, #fff9f0);
  --consent-ink: var(--ink, #182b45);
  --consent-muted: var(--ink-soft, #525f70);
  --consent-line: var(--hairline, #78839740);
  --consent-accent: var(--violet, #5b3fd6);
  --consent-off: var(--control, #eae4f3);
  --consent-radius: 28px;

  position: fixed;
  left: calc(16px + env(safe-area-inset-left, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: min(404px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border-radius: var(--consent-radius);
  background: var(--consent-surface);
  color: var(--consent-ink);
  box-shadow:
    var(--card-shadow, 0 10px 22px -6px #182b4521),
    0 18px 40px -12px var(--shadow-lift, #182b4521);
  font-family: var(--font-body, system-ui, sans-serif);
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  transform-origin: bottom left;
  transition:
    opacity 0.35s var(--ease, ease),
    transform 0.4s var(--ease, ease);
}

/* consent.js adds .is-open a frame after un-hiding, and takes it off before hiding again, so the card moves both ways. */
.consent.is-open {
  opacity: 1;
  transform: none;
}

.consent[hidden] {
  display: none;
}

.consent__view {
  padding: 20px;
}

.consent__view--settings {
  padding: 0;
}

.consent__view:not([hidden]) {
  animation: consent-in 0.35s var(--ease, ease);
}

@keyframes consent-in {
  from {
    opacity: 0;
  }
}

.consent__body {
  padding: 24px 24px 20px;
}

.consent__title {
  margin: 0 0 8px;
  font-family: var(--font-display, Georgia, serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.consent__title:focus {
  outline: none;
}

.consent__text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--consent-muted);
}

.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.consent__btn {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--consent-line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--consent-ink);
  cursor: pointer;
  transition:
    background-color 0.25s ease,
    transform 0.3s var(--ease, ease);
}

.consent__btn:hover {
  background: var(--consent-tint);
}

.consent__btn--primary {
  margin-left: auto;
  border-color: var(--consent-ink);
  background: var(--consent-ink);
  color: #ffffff; /* On the ink button, in every theme. */
}

.consent__btn--primary:hover {
  background: var(--consent-ink);
  transform: translateY(-1px);
}

/* The categories */

.consent__list {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--consent-line);
  border-radius: 18px;
  overflow: hidden;
}

.consent__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.consent__row + .consent__row {
  border-top: 1px solid var(--consent-line);
}

.consent__label {
  display: grid;
  gap: 2px;
}

.consent__label strong {
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 16px;
  font-weight: 800;
}

.consent__label span {
  font-size: 13px;
  line-height: 1.4;
  color: var(--consent-muted);
}

.consent__switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--consent-off);
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.consent__switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff; /* The knob, on the track in both states. */
  box-shadow: 0 1px 3px #182b4540;
  transition: transform 0.3s var(--ease, ease);
}

.consent__switch[aria-checked='true'] {
  background: var(--consent-accent);
}

.consent__switch[aria-checked='true']::after {
  transform: translateX(18px);
}

.consent__switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* The bar under the list */

.consent__foot {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--consent-line);
  background: var(--consent-tint);
}

.consent__foot .consent__actions {
  margin-top: 0;
}

.consent__note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--consent-muted);
}

.consent__note a {
  color: var(--consent-ink);
  font-weight: 600;
  text-underline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .consent,
  .consent__view:not([hidden]),
  .consent__switch,
  .consent__switch::after,
  .consent__btn {
    animation: none;
    transition: none;
  }
}
