////
///Placeholder for Copyright ///
////

// ----------------------------------------------------------------------------
// Keyframes
// ----------------------------------------------------------------------------

// See https://github.com/squidfunk/Be-Secure/issues/2429
@keyframes hoverfix {
  0% {
    pointer-events: none;
  }
}

// ----------------------------------------------------------------------------
// Rules
// ----------------------------------------------------------------------------

// Icon definitions
:root {
  --md-version-icon: svg-load("fontawesome/solid/caret-down.svg");
}

// ----------------------------------------------------------------------------

// Version selection
.md-version {
  flex-shrink: 0;
  height: px2rem(48px);
  font-size: px2rem(16px);

  // Current selection
  &__current {
    position: relative;
    // Hack: in general, we would use `vertical-align` to align the version at
    // the bottom with the title, but since the list uses absolute positioning,
    // this won't work consistently. Furthermore, we would need to use inline
    // positioning to align the links, which looks jagged.
    top: px2rem(1px);
    margin-right: px2rem(8px);
    margin-left: px2rem(28px);
    color: inherit;
    outline: none;
    cursor: pointer;

    // Adjust for right-to-left languages
    [dir="rtl"] & {
      margin-right: px2rem(28px);
      margin-left: px2rem(8px);
    }

    // Version selection icon
    &::after {
      display: inline-block;
      width: px2rem(8px);
      height: px2rem(12px);
      margin-left: px2rem(8px);
      background-color: currentColor;
      mask-image: var(--md-version-icon);
      mask-repeat: no-repeat;
      content: "";

      // Adjust for right-to-left languages
      [dir="rtl"] & {
        margin-right: px2rem(8px);
        margin-left: initial;
      }
    }
  }

  // Version selection list
  &__list {
    position: absolute;
    top: px2rem(3px);
    z-index: 1;
    max-height: 0;
    margin: px2rem(4px) px2rem(16px);
    padding: 0;
    overflow: auto;
    color: var(--md-default-fg-color);
    list-style-type: none;
    background-color: var(--md-default-bg-color);
    border-radius: px2rem(2px);
    box-shadow:
      0 px2rem(4px) px2rem(10px) hsla(0, 0%, 0%, 0.1),
      0 0           px2rem(1px)  hsla(0, 0%, 0%, 0.25);
    opacity: 0;
    transition:
      max-height 0ms 500ms,
      opacity  250ms 250ms;
    scroll-snap-type: y mandatory;

    // Version selection list on parent focus/hover
    .md-version:focus-within &,
    .md-version:hover & {
      max-height: px2rem(200px);
      opacity: 1;
      transition:
        max-height 0ms,
        opacity  250ms;
    }

    // Fix hover on touch devices
    @media (pointer: coarse) {

      // Switch off on hover
      .md-version:hover & {
        animation: hoverfix 250ms forwards;
      }

      // Enable on focus
      .md-version:focus-within & {
        animation: none;
      }
    }
  }

  // Version selection item
  &__item {
    line-height: px2rem(36px);
  }

  // Version selection link
  &__link {
    display: block;
    width: 100%;
    padding-right: px2rem(24px);
    padding-left: px2rem(12px);
    white-space: nowrap;
    outline: none;
    cursor: pointer;
    transition:
      color            250ms,
      background-color 250ms;
    scroll-snap-align: start;

    // Adjust for right-to-left languages
    [dir="rtl"] & {
      padding-right: px2rem(12px);
      padding-left: px2rem(24px);
    }

    // Link on focus/hover
    &:focus,
    &:hover {
      color: var(--md-accent-fg-color);
    }

    // Link on focus
    &:focus {
      background-color: var(--md-default-fg-color--lightest);
    }
  }
}
