/*
 * Cookie consent: main <dialog> element
 */

.cookie-consent {
  --cookie-consent-style: true;
  --cookie-consent-primary-color: buttonface;
  --cookie-consent-primary-text-color: buttontext;
  --cookie-consent-light-color: color-mix(in srgb, buttontext, transparent 80%);
  --cookie-content-max-width: 60em;

  color-scheme: light dark;

  border: 0;
  padding: 0;
}

@media (prefers-color-scheme: dark) {
  .cookie-consent {
  }
  .cookie-consent__text,
  .cookie-type__text {
    color: color-mix(in srgb, windowtext, transparent 10%);
  }
}

.cookie-consent[open] {
  display: flex;
  justify-content: center;
}

.cookie-consent:modal {
  max-width: min(calc(100% - 2em), var(--cookie-content-max-width));
  box-shadow: 0 0 4em rgba(0,0,0,.5);
  border-radius: 8px;
}

.cookie-consent:not(:modal) {
  position: fixed;
  width: initial;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100% - 2em);
  box-shadow: 0 0 4em rgba(0,0,0,.5);
}
.cookie-consent:not(:modal) .cookie-consent__container {
  max-width: var(--cookie-content-max-width);
}

.cookie-consent::backdrop {
  background-image: linear-gradient(
    rgba(0,0,0,.5),
    rgba(0,0,0,.7)
  );
}

.cookie-consent__wrapper {
  display: flex;
  padding: 1em;
}

.cookie-consent__container {
  display: flex;
  flex-flow: column;
}
.cookie-consent__container[hidden] {
  display: none;
}

.cookie-consent__container {
  padding: 1em 0 1em 1em;
}

.cookie-consent__content,
.cookie-consent__buttons {
  padding-right: 1em;
}


/*
 * Scrollbar styling for overflowed contents
 */

.cookie-consent__content {
  --cookie-consent-scrollbar-track-color: buttonface;
  --cookie-consent-scrollbar-thumb-color: var(--cookie-consent-light-color);
  overflow-y: auto;
}

@supports not selector(::-webkit-scrollbar) {
  .cookie-consent__content {
    scrollbar-width: thin;
    scrollbar-color: var(--cookie-consent-scrollbar-thumb-color) var(--cookie-consent-scrollbar-track-color);
  }
}

.cookie-consent__content::-webkit-scrollbar {
  width: .25em;
}
.cookie-consent__content::-webkit-scrollbar-track {
  background: var(--cookie-consent-scrollbar-track-color);
  border-radius: .25em;
}
.cookie-consent__content::-webkit-scrollbar-thumb {
  background: var(--cookie-consent-scrollbar-thumb-color);
  border-radius: .25em;
}

.cookie-consent__title {
  margin-top: 0;
}

/* Reset style for links without anchor */
.cookie-consent__content a:not([href]) {
  color: initial;
  text-decoration: initial;
  border: initial;
}

.cookie-consent__buttons {
  display: flex;
  margin-top: 1em;
  flex-direction: row-reverse;
  align-items: center;
  gap: 1.5em;
}

.cookie-consent__button {
  color: inherit;
  cursor: pointer;
}
.cookie-consent__button--primary {
  border: 0;
  background: var(--cookie-consent-primary-color);
  color: var(--cookie-consent-primary-text-color);
  padding: .5em 1em;
}
.cookie-consent__button--primary:focus-visible {
  border: 0;
  outline: 0;
}


/*
 * Mobile responsiveness
 */

@media (max-width: 600px) {
  .cookie-consent {
    font-size: .875em;
  }

  /* Button alignment */
  .cookie-consent__buttons {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1em;
  }
  .cookie-consent__button--accept-all {
    order: 3;
    flex: 100%;
  }

  /* Fade away texts, expandable on click */
  .cookie-type__description:not(.cookie-type__description--expanded) {
    max-height: 5.5em;
    overflow: hidden;
    mask-image: linear-gradient(180deg, #000 50%, transparent);
    -webkit-mask-image: linear-gradient(180deg, #000 50%, transparent);
  }
}

@media (max-width: 320px) {
  .cookie-consent:modal {
    max-width: calc(100% - 1em);
  }
  .cookie-consent__wrapper {
    padding: 0;
  }
}


/*
 * Customize cookie types: title and toggle button alignment
 */

.cookie-type__title-wrapper {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: end;
}
.cookie-type__label {
  font-weight: bold;
}


/*
 * Simple <dialog> polyfill
 */

.cookie-consent--dialog-polyfill {
  display: none;
  color-scheme: light;
  background: #fff;
  color: #000;
}
.cookie-consent--dialog-polyfill[open] {
  display: flex;
}


/*
 * Style checkbox as a toggle button
 */

.cookie-type__toggle {
  display: inline-block;
  cursor: pointer;
  position: relative;
  font: 1em/1 sans-serif;
  font-weight: 600;
  width: 4em;
  user-select: none;
}
.cookie-type__toggle input {
  /* Don't hide to keep the element focusable */
  position: absolute;
  clip: rect(0,0,0,0);
}

.cookie-type__toggle span:before{
  transition: margin 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.cookie-type__toggle span:after{
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1), font-size 0s linear, padding-top 0s linear, padding-bottom 0s linear;
}

/* Button */
.cookie-type__toggle input + span {
  display: block;
}
.cookie-type__toggle span:before {
  content: "";
  box-sizing: border-box;
  position: absolute;
  z-index: 1;
  width: 2em;  /* Element size is 2 * 1em as defined by span:after */
  height: 2em;
  left: 0;
  top: 0;
  border: .25em solid transparent;
  border-radius: 1em;

  background: #fff;
  background-clip: content-box;
}
.cookie-type__toggle input:disabled + span:before {
  opacity: .5;
}
.cookie-type__toggle input:checked + span:before {
  transform: translateX(-100%);  /* Element width */
  margin-left: 100%;  /* Container width */
}

/* Text */
.cookie-type__toggle span:after {
  content: "\a0";
  box-sizing: border-box;
  display: block;
  padding: .5em;
  padding-left: .25em;
  padding-right: 1em;
  border-radius: 2em;
  /*background: rgba(0,0,0,.1);*/
  background: var(--cookie-consent-light-color);
/*  color: rgba(0,0,0,.5);*/
/*  color: color-mix(in srgb, buttontext, transparent 50%);*/
  color: color-mix(in srgb, var(--cookie-consent-primary-text-color), transparent 50%);
  text-align: right;
}
.cookie-type__toggle input:checked + span:after {
  content: "\a0";
  background: var(--cookie-consent-primary-color);
  text-align: left;
  padding-left: 1em;
  padding-right: .25em;
}
.cookie-type__toggle input:disabled + span:after {
  /*background: rgba(0,0,0,.1);*/
  opacity: .5;
}

.cookie-type__toggle span[data-off]:after {
  content: attr(data-off);
}
.cookie-type__toggle input:checked + span[data-on]:after {
  content: attr(data-on);
}

.cookie-type__toggle input:focus + span {
  outline: -webkit-focus-ring-color auto 5px;
}
.cookie-type__toggle:hover input:focus + span {
  outline: none;
}
