/**
 * Tracking Consent Overlay
 * --------------------------------------------------
 * This is not included in the EdGEL CSS.  It is only used in the <uoe-consent> custom element.
 */

@use "sass:math";

@use "../settings" as *;
@use "../tools" as *;

@import "bootstrap/scss/vendor/rfs";

// Lifted from the Bootstrap _reboot partial.
*,
*::before,
*::after {
  box-sizing: border-box;
}

:host {
  display: block;
  padding-bottom: edgel-rem-px(3);
  font-family: $font-family-sans-serif;
  font-weight: $font-weight-base;
  @include font-size($font-size-base);
  line-height: $line-height-base;

  @if $enable-smooth-scroll {
    @media (prefers-reduced-motion: no-preference) {
      scroll-behavior: smooth;
    }
  }
}

.uoe-backdrop {
  @include overlay-backdrop($zindex-modal-backdrop, $modal-backdrop-bg, $modal-backdrop-opacity);
}

.uoe-jar {
  --#{$prefix}consent-banner-padding: #{$modal-inner-padding};
  --#{$prefix}consent-banner-margin: #{$modal-dialog-margin};
  --#{$prefix}consent-banner-box-shadow: #{$box-shadow-sm};

  @include edgel-reset-button();
  @include reset-text();

  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  display: none;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  line-height: $line-height-base;
  outline: 0;

  p {
    margin-top: 0;
    margin-bottom: $paragraph-margin-bottom;
  }
}

.uoe-container {
  position: relative;
  width: auto;
  margin: var(--#{$prefix}consent-banner-margin);
  color: $consent-fg;
  // allow clicks to pass through for custom click handling to close modal
  pointer-events: none;
  background-color: $consent-bg;

  // When fading in the modal, animate it to slide down
  .uoe-jar & {
    @include transition($modal-transition);
    transform: $modal-fade-transform;
  }
  .uoe-jar.show & {
    transform: $modal-show-transform;
  }

  // When trying to close, animate focus to scale
  .uoe-jar.modal-static & {
    transform: $modal-scale-transform;
  }
}

.uoe-content {
  position: relative;
  width: 100%; // Ensure `.uoe-content` extends the full width of the parent `.uoe-container`
  padding: $modal-inner-padding var(--#{$prefix}consent-banner-padding);
  // counteract the pointer-events: none; in the .uoe-container
  pointer-events: auto;
  background-clip: padding-box;
  border: 1px solid transparent;
  @include box-shadow(var(--#{$prefix}consent-banner-box-shadow));
  // Remove focus outline from opened modal
  outline: 0;
}

.uoe-list {
  padding-left: 1.5em;
}

/* consent checks and radios copied from bootstrap _form-check.scss */
.uoe-check {
  display: block;
  min-height: $form-check-min-height;
  // Variation from Bootstrap
  padding: space(1) space(3) space(1) ($form-check-padding-start + 1em);
  margin-bottom: space(2);
  @include border-radius($border-radius-lg);

  &:hover,
  &:focus {
    background-color: $consent-btn2-bg-hover;
  }
  &:active {
    background-color: $consent-btn2-bg-active;
  }
  // End of variation from Bootstrap

  .uoe-check-input {
    float: left;
    margin-left: $form-check-padding-start * -1;
  }
}

.uoe-check-input {
  width: $form-check-input-width;
  height: $form-check-input-width;
  // margin-top: line-height minus check height
  // Other margins set to 0 from _reboot: for user-agent resets
  margin: (($line-height-base - $form-check-input-width) * .5) 0 0;
  vertical-align: top;
  appearance: none;
  background-color: $form-check-input-bg;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: $form-check-input-border;
  print-color-adjust: exact; // Keep themed appearance for print
  @include transition($form-check-transition);

  &[type="checkbox"] {
    @include border-radius($form-check-input-border-radius);
  }

  &[type="radio"] {
    // stylelint-disable-next-line property-disallowed-list
    border-radius: $form-check-radio-border-radius;
  }

  &:active {
    filter: $form-check-input-active-filter;
  }

  &:focus {
    border-color: $consent-input-active-bg;
    outline: 0;
    box-shadow: $consent-focus-box-shadow;

  }

  &:checked {
    background-color: $consent-input-active-bg;
    border-color: $consent-input-active-bg;

    &[type="checkbox"] {
      @if $enable-gradients {
        background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$prefix}gradient);
      } @else {
        background-image: escape-svg($form-check-input-checked-bg-image);
      }
    }

    &[type="radio"] {
      @if $enable-gradients {
        background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$prefix}gradient);
      } @else {
        background-image: escape-svg($form-check-radio-checked-bg-image);
      }
    }
  }

  &[type="checkbox"]:indeterminate {
    background-color: $consent-input-active-bg;
    border-color: $consent-input-active-bg;

    @if $enable-gradients {
      background-image: escape-svg($form-check-input-indeterminate-bg-image), var(--#{$prefix}gradient);
    } @else {
      background-image: escape-svg($form-check-input-indeterminate-bg-image);
    }
  }

  &:disabled {
    pointer-events: none;
    filter: none;
    opacity: $form-check-input-disabled-opacity;
  }

  // Use disabled attribute in addition of :disabled pseudo-class
  // See: https://github.com/twbs/bootstrap/issues/28247
  &[disabled],
  &:disabled {
    ~ .uoe-check-label {
      opacity: $form-check-label-disabled-opacity;
    }
  }
}

.uoe-check-label {
  font-weight: 700;
  color: $form-check-label-color;
  cursor: $form-check-label-cursor;
}

// End of bootstrap check copy

.uoe-check-inline {
  display: inline-block;
  margin-right: $form-check-inline-margin-end;
}

.uoe-actions {
  @include margin-top(edgel-rem-px(.6));
  margin-bottom: 0;
  @include list-unstyled();
}

.uoe-actions-item {
  display: inline-block;
  @include margin-top(edgel-rem-px(.4));

  &:not(:last-child) {
    margin-right: $list-inline-padding;
  }
}

.uoe-lid {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 9999;
  @include padding(edgel-rem-px(.5));
  text-align: left;
  background-color: $consent-bg;
}

.uoe-collapse {
  &:not(.show) {
    display: none;
  }
}

.uoe-collapsing {
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  @include transition($consent-jar-transition);
}

@include media-breakpoint-up(sm) {
  .uoe-jar {
    --#{$prefix}consent-banner-padding: #{$modal-inner-padding * 2};
    --#{$prefix}consent-banner-margin: #{$modal-dialog-margin-y-sm-up};
    --#{$prefix}consent-banner-box-shadow: #{$box-shadow};
    --#{$prefix}consent-banner-width: #{$modal-md};
  }

  // Automatically set modal's width for larger viewports
  .uoe-container {
    max-width: var(--#{$prefix}consent-banner-width);
    margin-right: auto;
    margin-left: auto;
  }
}

@include media-breakpoint-up(lg) {
  .uoe-jar {
    --#{$prefix}consent-banner-width: #{$modal-lg};
  }
}

.uoe-btn-lid {
  --#{$prefix}border-width: #{$border-width};

  margin: 0; // reset user-agent styling
  @include button-size(
    $btn-padding-y-sm,
    $btn-padding-x-sm,
    $btn-font-size-sm,
    $border-radius-sm
  );
}

.uoe-btn {
  --#{$prefix}border-width: #{$border-width};

  margin: 0; // reset user-agent styling
  @include button-size(
    $btn-padding-y,
    $btn-padding-x,
    $btn-font-size,
    $border-radius
  );
}

.uoe-btn-primary {
  @include edgel-custom-button(
    $consent-btn1-bg,
    $consent-btn1-bd,
    $consent-btn1-fg,
    $consent-btn1-bg-hover,
    $consent-btn1-bd-hover,
    $consent-btn1-fg-hover,
    $consent-btn1-bg-active,
    $consent-btn1-bd-active
  );
}

.uoe-btn-secondary {
  @include edgel-custom-button(
    $consent-btn2-bg,
    $consent-btn2-bd,
    $consent-btn2-fg,
    $consent-btn2-bg-hover,
    $consent-btn2-bd-hover,
    $consent-btn2-fg-hover,
    $consent-btn2-bg-active,
    $consent-btn2-bd-active
  );
}

.uoe-heading {
  margin: 1rem 0 .5rem; // includes user-agent reset
  @include font-size($font-size-base * 1.35);
  font-weight: 300;
  line-height: 1.2;
  color: $consent-fg;
}

.uoe-link,
.uoe-link:visited {
  color: $consent-link;
  text-decoration: none;
}

.uoe-link:active,
.uoe-link:focus-visible,
.uoe-link:hover {
  color: $consent-link;
  text-decoration: underline;
}

@media print {
  .uoe-jar.show,
  .uoe-lid.show {
    display: none;
  }
}
