/**
 * @file
 * Cookie consent banner and settings dialog, plus the placeholder shown in
 * place of blocked embeds (block "consent-placeholder").
 */

.cookie-consent__banner {
  width: min(42rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 2rem;
  overflow-y: auto;
  color: var(--ncmg-color-text);
  background: var(--ncmg-color-white);
  border: 0;
  border-top: 4px solid var(--ncmg-color-blue);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.cookie-consent__banner[open] {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: cookie-consent-in 0.3s ease-out;
}

.cookie-consent__banner::backdrop,
.cookie-consent__dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

@keyframes cookie-consent-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
}

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

.cookie-consent__title,
.cookie-consent__dialog-title {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ncmg-color-text);
}

.cookie-consent__icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--ncmg-color-red);
}

.cookie-consent__text {
  margin: 0;
  font-size: 0.95rem;
}

.cookie-consent__link {
  font-weight: 700;
  color: var(--ncmg-color-darkred);
  text-decoration: underline;
}

.cookie-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Accept and reject share one style so neither choice is favoured. */
.cookie-consent__button {
  flex: 1 1 10rem;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  color: var(--ncmg-color-white);
  cursor: pointer;
  background: var(--ncmg-color-strong);
  border: 2px solid var(--ncmg-color-strong);
  transition: background var(--ncmg-transition), border-color var(--ncmg-transition);
}

.cookie-consent__button:hover,
.cookie-consent__button:focus-visible {
  background: var(--ncmg-color-red);
  border-color: var(--ncmg-color-red);
}

.cookie-consent__button--secondary {
  color: var(--ncmg-color-text);
  background: transparent;
}

.cookie-consent__button--secondary:hover,
.cookie-consent__button--secondary:focus-visible {
  color: var(--ncmg-color-white);
}

.cookie-consent__button:focus-visible,
.cookie-consent__close:focus-visible,
.cookie-consent__checkbox:focus-visible + .cookie-consent__slider {
  outline: 3px solid var(--ncmg-color-blue);
  outline-offset: 2px;
}

/* Settings dialog. */
.cookie-consent__dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  color: var(--ncmg-color-text);
  border: 0;
  border-top: 4px solid var(--ncmg-color-blue);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.cookie-consent__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.cookie-consent__dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.cookie-consent__close {
  padding: 0 0.25rem;
  font-size: 2rem;
  line-height: 1;
  color: var(--ncmg-color-text);
  cursor: pointer;
  background: none;
  border: 0;
}

.cookie-consent__categories {
  padding: 0;
  margin: 0;
  list-style: none;
}

.cookie-consent__category {
  padding: 1rem 0;
  border-top: 1px solid var(--ncmg-color-gray-25);
}

.cookie-consent__switch {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
}

.cookie-consent__checkbox {
  position: absolute;
  opacity: 0;
}

.cookie-consent__slider {
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  background: var(--ncmg-color-gray-50);
  border-radius: 1rem;
  transition: background var(--ncmg-transition);
}

.cookie-consent__slider::after {
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1.125rem;
  height: 1.125rem;
  content: "";
  background: var(--ncmg-color-white);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform var(--ncmg-transition);
}

.cookie-consent__checkbox:checked + .cookie-consent__slider {
  background: var(--ncmg-color-accent);
}

.cookie-consent__checkbox:checked + .cookie-consent__slider::after {
  transform: translateX(1.25rem);
}

.cookie-consent__checkbox:disabled + .cookie-consent__slider {
  opacity: 0.6;
}

.cookie-consent__always {
  margin-left: 0.5rem;
  font-weight: 400;
  color: var(--ncmg-color-success);
}

.cookie-consent__category-text {
  margin: 0.5rem 0 0 3.5rem;
  font-size: 0.9rem;
}

@media (max-width: 575.98px) {
  .cookie-consent__banner,
  .cookie-consent__form {
    padding: 1.25rem;
  }

  .cookie-consent__button {
    flex-basis: 100%;
  }
}

/* Placeholder in place of a blocked embed. */
.consent-placeholder {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
  text-align: center;
  background: var(--ncmg-color-surface);
  border: 1px dashed var(--ncmg-color-gray-50);
}

.consent-placeholder[hidden] {
  display: none;
}

.consent-placeholder p {
  max-width: 30rem;
  margin: 0;
}

.cookie-consent__title:focus,
.cookie-consent__dialog-title:focus {
  outline: 0;
}

iframe[data-consent-src]:not([src]) {
  display: none;
}
