/*
 * Soda Consent – banner, dialog, placeholders. Loaded only when one of them shows. Themes adapt the look through
 * the custom properties below (set them on :root in the theme's stylesheet), not by overriding the rules. The
 * defaults have no specificity, so the theme's values win whichever stylesheet comes first.
 */

:where(:root) {
  --soda-consent-font: inherit;
  --soda-consent-font-heading: var(--soda-consent-font);
  --soda-consent-font-size: 0.9375rem;
  --soda-consent-text: #1b1b1f;
  --soda-consent-text-muted: rgb(27 27 31 / 70%);
  --soda-consent-background: #fff;
  --soda-consent-surface: #f4f4f6;
  --soda-consent-border: rgb(27 27 31 / 12%);
  --soda-consent-link: inherit;
  --soda-consent-legal-link: var(--soda-consent-text-muted);
  --soda-consent-accent: #1b1b1f;
  --soda-consent-accent-hover: #3a3a42;
  --soda-consent-accent-text: #fff;
  --soda-consent-focus: #2f6fed;
  --soda-consent-radius: 0.75rem;
  --soda-consent-button-radius: 0.5rem;
  --soda-consent-button-font-weight: 600;
  --soda-consent-shadow: 0 0.5rem 2.5rem rgb(0 0 0 / 18%);
  --soda-consent-backdrop: rgb(0 0 0 / 45%);
  --soda-consent-z: 100000;
}

.soda-consent,
.soda-consent-dialog,
.soda-consent-placeholder,
.soda-consent-list,
.soda-consent-fab {
  box-sizing: border-box;
  font-family: var(--soda-consent-font);
  font-size: var(--soda-consent-font-size);
  line-height: 1.5;
}

.soda-consent *,
.soda-consent-dialog *,
.soda-consent-placeholder * {
  box-sizing: inherit;
}

/* the theme's text rhythm (a margin above whatever follows a heading, paragraph or list) stays outside: every
   margin in here is set by the rules below */
:is(.soda-consent, .soda-consent-dialog, .soda-consent-placeholder) * {
  margin: 0;
}

.soda-consent a,
.soda-consent-dialog a,
.soda-consent-placeholder a {
  color: var(--soda-consent-link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.soda-consent :focus-visible,
.soda-consent-dialog :focus-visible,
.soda-consent-placeholder :focus-visible,
.soda-consent-fab:focus-visible {
  outline: 2px solid var(--soda-consent-focus);
  outline-offset: 2px;
}

/* Buttons ----------------------------------------------------------------------------------------------------------- */

.soda-consent__button {
  align-items: center;
  appearance: none;
  background: var(--soda-consent-accent);
  border: 2px solid var(--soda-consent-accent);
  border-radius: var(--soda-consent-button-radius);
  color: var(--soda-consent-accent-text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: var(--soda-consent-button-font-weight);
  justify-content: center;
  line-height: 1.2;
  min-block-size: 2.75rem;
  padding-block: 0.5rem;
  padding-inline: 1rem;
  text-align: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.soda-consent__button:hover {
  background: var(--soda-consent-accent-hover);
  border-color: var(--soda-consent-accent-hover);
}

.soda-consent__button--secondary {
  background: transparent;
  color: var(--soda-consent-text);
}

.soda-consent__button--secondary:hover {
  background: var(--soda-consent-surface);
  border-color: var(--soda-consent-accent);
}

/* Banner ------------------------------------------------------------------------------------------------------------ */

.soda-consent {
  color: var(--soda-consent-text);
  inset-block-end: 0;
  inset-inline: 0;
  padding: 0.75rem;
  pointer-events: none;
  position: fixed;
  z-index: var(--soda-consent-z);
}

.soda-consent__banner {
  background: var(--soda-consent-background);
  border: 1px solid var(--soda-consent-border);
  border-radius: var(--soda-consent-radius);
  box-shadow: var(--soda-consent-shadow);
  display: grid;
  gap: 1rem;
  max-block-size: calc(100dvh - 1.5rem);
  opacity: 0;
  overflow: auto;
  padding: 1.25rem;
  pointer-events: auto;
  transform: translateY(1rem);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.soda-consent[data-visible] .soda-consent__banner {
  opacity: 1;
  transform: none;
}

.soda-consent__title {
  color: inherit;
  font-family: var(--soda-consent-font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.375rem;
}

.soda-consent__text {
  margin: 0;
}

/* privacy policy and imprint: the size of the text next to them, in the muted colour – there, not eye-catching */
.soda-consent__links,
.soda-consent-dialog__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.5rem 0 0;
}

.soda-consent__links a,
.soda-consent-dialog__links a {
  color: var(--soda-consent-legal-link);
}

/* accept, reject and settings in one row; they wrap where the words don't fit (phones, long languages) */
.soda-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.soda-consent__actions .soda-consent__button {
  flex: 1 1 auto;
}

@media (max-width: 767px) {
  .soda-consent__banner {
    gap: 0.75rem;
    padding: 1rem;
  }

  .soda-consent__title {
    font-size: 1.0625rem;
  }

  .soda-consent__text,
  .soda-consent__links {
    font-size: 0.875em;
  }
}

@media (min-width: 768px) {
  .soda-consent[data-layout='box'] {
    inset-inline: auto;
    max-inline-size: 30rem;
    padding: 1rem;
  }

  .soda-consent[data-layout='box'][data-position='left'] {
    inset-inline-start: 0;
  }

  .soda-consent[data-layout='box'][data-position='right'] {
    inset-inline-end: 0;
  }

  .soda-consent[data-layout='box'][data-position='center'] {
    inset-inline: 0;
    margin-inline: auto;
  }

  .soda-consent[data-layout='bar'] {
    padding: 1rem;
  }

  .soda-consent[data-layout='bar'] .soda-consent__banner {
    align-items: center;
    gap: 1.5rem 2.5rem;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-inline: auto;
    max-inline-size: 80rem;
    padding: 1.5rem 2rem;
  }

  .soda-consent[data-layout='bar'] .soda-consent__actions {
    flex-wrap: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .soda-consent__banner {
    transform: none;
    transition: none;
  }
}

/* Dialog ------------------------------------------------------------------------------------------------------------ */

/* the page doesn't scroll behind the dialog – and doesn't shift: its scrollbar's room stays */
html.soda-consent-open {
  overflow: hidden;
  scrollbar-gutter: stable;
}

.soda-consent-dialog {
  background: var(--soda-consent-background);
  border: 0;
  margin: auto;
  border-radius: var(--soda-consent-radius);
  box-shadow: var(--soda-consent-shadow);
  color: var(--soda-consent-text);
  inline-size: min(44rem, calc(100vw - 1.5rem));
  max-block-size: min(48rem, calc(100dvh - 1.5rem));
  max-inline-size: none;
  overflow: hidden;
  padding: 0;
}

.soda-consent-dialog[open] {
  display: flex;
}

.soda-consent-dialog::backdrop {
  background: var(--soda-consent-backdrop);
}

.soda-consent-dialog__inner {
  display: flex;
  flex-direction: column;
  inline-size: 100%;
  max-block-size: inherit;
  min-block-size: 0;
}

.soda-consent-dialog__header {
  align-items: center;
  border-block-end: 1px solid var(--soda-consent-border);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1rem 1.25rem;
}

.soda-consent-dialog__title {
  color: inherit;
  font-family: var(--soda-consent-font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

.soda-consent-dialog__close {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  flex: none;
  font-size: 1.5rem;
  block-size: 2.5rem;
  inline-size: 2.5rem;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.soda-consent-dialog__close svg {
  block-size: 1em;
  display: block;
  flex: none;
  inline-size: 1em;
}

.soda-consent-dialog__close:hover {
  background: var(--soda-consent-surface);
}

.soda-consent-dialog__body {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  padding: 1rem 1.25rem 1.25rem;
}

.soda-consent-dialog__text {
  margin: 0 0 1rem;
}

.soda-consent-dialog__categories,
.soda-consent-category__services {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1fr);
  list-style: none;
  margin: 0;
  padding: 0;
}

.soda-consent-category {
  border: 1px solid var(--soda-consent-border);
  border-radius: calc(var(--soda-consent-radius) * 0.75);
  padding: 1rem;
}

.soda-consent-category__head,
.soda-consent-service__head {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.soda-consent-category__title {
  color: inherit;
  font-family: var(--soda-consent-font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.soda-consent-category__badge {
  color: var(--soda-consent-text-muted);
  flex: none;
  font-size: 0.8125em;
  font-weight: 600;
}

.soda-consent-category__description {
  color: var(--soda-consent-text-muted);
  font-size: 0.9em;
  margin: 0.25rem 0 0;
}

.soda-consent-category__details {
  margin-block-start: 0.5rem;
}

.soda-consent-category__details > summary {
  cursor: pointer;
  font-size: 0.875em;
  font-weight: 600;
  inline-size: fit-content;
  padding-block: 0.25rem;
}

.soda-consent-category__services {
  margin-block-start: 0.5rem;
}

.soda-consent-service {
  background: var(--soda-consent-surface);
  border-radius: calc(var(--soda-consent-radius) * 0.5);
  font-size: 0.875em;
  padding: 0.75rem;
}

.soda-consent-service__name {
  color: inherit;
  font-family: inherit;
  font-size: 1em;
  font-weight: 700;
  margin: 0;
}

.soda-consent-service__description,
.soda-consent-service__meta {
  margin: 0.25rem 0 0;
}

.soda-consent-service__meta {
  color: var(--soda-consent-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.soda-consent-service__cookies {
  container-type: inline-size;
  margin-block-start: 0.5rem;
}

.soda-consent-table {
  border-collapse: collapse;
  font-size: 0.9em;
  inline-size: 100%;
  table-layout: fixed;
}

/* name, purpose, duration, type – fixed shares, so a long cookie name wraps instead of pushing the table wider */
.soda-consent-table th:nth-child(1) {
  inline-size: 30%;
}

.soda-consent-table th:nth-child(2) {
  inline-size: 38%;
}

.soda-consent-table th:nth-child(3),
.soda-consent-table th:nth-child(4) {
  inline-size: 16%;
}

/* the theme's table styles stay outside (cell minimum widths, row borders, header background) */
.soda-consent-table thead,
.soda-consent-table tr {
  background: none;
  border: 0;
}

.soda-consent-table th,
.soda-consent-table td {
  border-block-end: 1px solid var(--soda-consent-border);
  min-inline-size: 0;
  overflow-wrap: anywhere;
  padding: 0.375rem 0.5rem 0.375rem 0;
  text-align: start;
  vertical-align: top;
}

.soda-consent-table th {
  font-weight: 600;
}

/* narrow (phones): one block per cookie – name, purpose, then duration and type in a muted line */
@container (max-width: 30rem) {
  .soda-consent-table,
  .soda-consent-table tbody,
  .soda-consent-table td {
    display: block;
  }

  .soda-consent-table thead {
    block-size: 1px;
    clip-path: inset(50%);
    inline-size: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
  }

  .soda-consent-table tr {
    border-block-end: 1px solid var(--soda-consent-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem 0.5rem;
    padding-block: 0.5rem;
  }

  .soda-consent-table td {
    border: 0;
    padding: 0;
  }

  .soda-consent-table td:nth-child(1),
  .soda-consent-table td:nth-child(2) {
    flex-basis: 100%;
  }

  .soda-consent-table td:nth-child(1) code {
    font-weight: 600;
  }

  .soda-consent-table td:nth-child(3),
  .soda-consent-table td:nth-child(4) {
    color: var(--soda-consent-text-muted);
    flex: 0 0 auto;
    inline-size: auto;
  }

  .soda-consent-table td:nth-child(3)::after {
    content: ' ·';
  }
}

.soda-consent-table code,
.soda-consent-dialog__meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.soda-consent-dialog__meta {
  color: var(--soda-consent-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8125em;
  gap: 0.25rem 1rem;
  margin: 1rem 0 0;
}

.soda-consent-dialog__actions {
  border-block-start: 1px solid var(--soda-consent-border);
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr;
  padding: 1rem 1.25rem;
}

.soda-consent-dialog__actions [data-action='save'] {
  grid-column: 1 / -1;
  order: 3;
}

@media (min-width: 640px) {
  .soda-consent-dialog__actions {
    grid-template-columns: auto auto auto;
    justify-content: end;
  }

  .soda-consent-dialog__actions [data-action='save'] {
    grid-column: auto;
    order: 0;
  }
}

.soda-consent-visually-hidden {
  block-size: 1px;
  clip-path: inset(50%);
  inline-size: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
}

/* Switches ---------------------------------------------------------------------------------------------------------- */

.soda-consent-switch {
  appearance: none;
  background: rgb(120 120 128 / 32%);
  block-size: 1.75rem;
  border-radius: 1rem;
  cursor: pointer;
  flex: none;
  inline-size: 3rem;
  margin: 0;
  position: relative;
  transition: background-color 0.2s ease;
}

.soda-consent-switch::after {
  background: #fff;
  block-size: 1.375rem;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
  content: '';
  inline-size: 1.375rem;
  inset-block-start: 0.1875rem;
  inset-inline-start: 0.1875rem;
  position: absolute;
  transition: transform 0.2s ease;
}

.soda-consent-switch:checked {
  background: var(--soda-consent-accent);
}

.soda-consent-switch:checked::after {
  transform: translateX(1.25rem);
}

[dir='rtl'] .soda-consent-switch:checked::after {
  transform: translateX(-1.25rem);
}

.soda-consent-switch:indeterminate {
  background: color-mix(in srgb, var(--soda-consent-accent) 45%, rgb(120 120 128 / 32%));
}

.soda-consent-switch:indeterminate::after {
  transform: translateX(0.625rem);
}

.soda-consent-switch--small {
  block-size: 1.375rem;
  inline-size: 2.375rem;
}

.soda-consent-switch--small::after {
  block-size: 1rem;
  inline-size: 1rem;
}

.soda-consent-switch--small:checked::after {
  transform: translateX(1rem);
}

@media (prefers-reduced-motion: reduce) {
  .soda-consent-switch,
  .soda-consent-switch::after {
    transition: none;
  }
}

/* Placeholders of blocked content ----------------------------------------------------------------------------------- */

.soda-consent-placeholder {
  align-items: center;
  aspect-ratio: var(--soda-consent-ratio, 16 / 9);
  background: var(--soda-consent-surface);
  border: 1px solid var(--soda-consent-border);
  border-radius: calc(var(--soda-consent-radius) * 0.5);
  color: var(--soda-consent-text);
  container-type: inline-size;
  display: flex;
  inline-size: 100%;
  justify-content: center;
  max-inline-size: 100%;
  overflow: auto;
  padding: 0.75rem;
}

.soda-consent-placeholder--fill,
.soda-consent-placeholder--overlay {
  aspect-ratio: auto;
  border-radius: inherit;
  inset: 0;
  position: absolute;
  z-index: 2;
}

.soda-consent-placeholder--overlay {
  background: color-mix(in srgb, var(--soda-consent-background) 94%, transparent);
  backdrop-filter: blur(6px);
  border: 0;
}

.soda-consent-placeholder__inner {
  max-inline-size: 32rem;
  text-align: center;
}

.soda-consent-placeholder__title {
  font-family: var(--soda-consent-font-heading);
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 0 0 0.375rem;
}

.soda-consent-placeholder__text {
  font-size: 0.875em;
  margin: 0 auto 1rem;
  max-inline-size: 26rem;
  text-wrap: pretty;
}



@container (max-width: 420px) {
  .soda-consent-placeholder__inner {
    font-size: 0.8125rem;
  }

  .soda-consent-placeholder__title {
    font-size: 0.9375rem;
    margin-block-end: 0.25rem;
  }

  .soda-consent-placeholder__text {
    font-size: 0.875em;
    line-height: 1.35;
    margin-block-end: 0.625rem;
  }

  .soda-consent-placeholder .soda-consent__button {
    min-block-size: 2.25rem;
    padding-block: 0.25rem;
    padding-inline: 0.75rem;
  }
}

/* Cookie list (shortcode [soda_consent_list]) ----------------------------------------------------------------------- */

/* closed: the toggle and the settings button side by side; open: the list takes the row, the settings button follows */
.soda-consent-list {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block: 1.5rem;
}

.soda-consent-list > * {
  margin: 0;
}

.soda-consent-list__details[open] {
  flex-basis: 100%;
  margin-block-end: 1rem;
}

.soda-consent-list__toggle {
  box-sizing: border-box;
  gap: 0.5rem;
  list-style: none;
}

.soda-consent-list__toggle::-webkit-details-marker {
  display: none;
}

.soda-consent-list__details[open] .soda-consent-list__show,
.soda-consent-list__details:not([open]) .soda-consent-list__hide {
  display: none;
}

/* Phosphor's caret-down, as a mask: the theme may run the shortcode's output through wp_kses_post, which drops <svg> */
.soda-consent-list__toggle::after {
  background: currentcolor;
  block-size: 1em;
  content: '';
  flex: none;
  inline-size: 1em;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32Z'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: rotate 0.2s;
}

.soda-consent-list__details[open] > .soda-consent-list__toggle::after {
  rotate: 180deg;
}

@media (prefers-reduced-motion: reduce) {
  .soda-consent-list__toggle::after {
    transition: none;
  }
}

.soda-consent-list__body {
  display: grid;
  gap: 2rem;
  margin-block-start: 2rem;
}

.soda-consent-list__title {
  margin: 0 0 0.25rem;
}

.soda-consent-list__description {
  color: var(--soda-consent-text-muted);
  margin: 0 0 1rem;
}

.soda-consent-list__service {
  border-block-start: 1px solid var(--soda-consent-border);
  padding-block: 1rem;
}

.soda-consent-list__service p {
  margin: 0.25rem 0 0;
}

/* a small heading: the page's h4 size would outrank the category above it */
.soda-consent-list .soda-consent-list__service-name {
  font-family: var(--soda-consent-font-heading);
  font-size: 1.0625em;
  font-weight: 600;
  letter-spacing: normal;
  line-height: 1.35;
  margin: 0;
}

/* the service's top line separates it from the next one: no bottom line under its last cookie */
.soda-consent-list .soda-consent-table tbody tr:last-child,
.soda-consent-list .soda-consent-table tbody tr:last-child > td {
  border-block-end: 0;
}

.soda-consent-list .soda-consent-list__service:last-child {
  padding-block-end: 0;
}

.soda-consent-list__meta {
  color: var(--soda-consent-text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9em;
  gap: 0.25rem 1rem;
}
