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

// ----------------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------------

/// Admonition flavours
$admonitions: (
  note:                       pencil $clr-blue-a200,
  abstract summary tldr:      text-subject $clr-light-blue-a400,
  info todo:                  information $clr-cyan-a700,
  tip hint important:         fire $clr-teal-a700,
  success check done:         check-circle $clr-green-a700,
  question help faq:          help-circle $clr-light-green-a700,
  warning caution attention:  alert $clr-orange-a400,
  failure fail missing:       close-circle $clr-red-a200,
  danger error:               flash-circle $clr-red-a400,
  bug:                        bug $clr-pink-a400,
  example:                    format-list-numbered $clr-deep-purple-a200,
  quote cite:                 format-quote-close $clr-grey
) !default;

// ----------------------------------------------------------------------------
// Rules: layout
// ----------------------------------------------------------------------------

// Icon definitions
:root {
  @each $names, $props in $admonitions {
    --md-admonition-icon--#{nth($names, 1)}:
      svg-load("bes_theme/#{nth($props, 1)}.svg");
  }
}

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

// Scoped in typesetted content to match specificity of regular content
.md-typeset {

  // Admonition
  .admonition {
    margin: px2em(20px, 12.8px) 0;
    padding: 0 px2rem(12px);
    overflow: hidden;
    color: var(--md-admonition-fg-color);
    font-size: px2rem(12.8px);
    page-break-inside: avoid;
    background-color: var(--md-admonition-bg-color);
    border-left: px2rem(4px) solid $clr-blue-a200;
    border-radius: px2rem(2px);
    box-shadow:
      0 px2rem(4px)   px2rem(10px) hsla(0, 0%, 0%, 0.05),
      0 px2rem(0.5px) px2rem(1px)  hsla(0, 0%, 0%, 0.05);

    // [print]: Omit shadow as it may lead to rendering errors
    @media print {
      box-shadow: none;
    }

    // Adjust for right-to-left languages
    [dir="rtl"] & {
      border-right: px2rem(4px) solid $clr-blue-a200;
      border-left: none;
    }

    // Adjust vertical spacing for nested admonitions
    .admonition {
      margin-top: 1em;
      margin-bottom: 1em;
    }

    // Adjust spacing for contained table wrappers
    .md-typeset__scrollwrap {
      margin: 1em px2rem(-12px);
    }

    // Adjust spacing for contained tables
    .md-typeset__table {
      padding: 0 px2rem(12px);
    }

    // Adjust spacing for single-child tabbed block container
    > .tabbed-set:only-child {
      margin-top: 0;
    }

    // Adjust spacing on last child
    html & > :last-child {
      margin-bottom: px2rem(12px);
    }
  }

  // Admonition title
  .admonition-title {
    position: relative;
    margin: 0 px2rem(-12px) 0 px2rem(-16px);
    padding: px2rem(8px) px2rem(12px) px2rem(8px) px2rem(40px);
    font-weight: 700;
    background-color: transparentize($clr-blue-a200, 0.9);
    border-left: px2rem(4px) solid $clr-blue-a200;

    // Adjust for right-to-left languages
    [dir="rtl"] & {
      margin: 0 px2rem(-16px) 0 px2rem(-12px);
      padding: px2rem(8px) px2rem(40px) px2rem(8px) px2rem(12px);
      border-right: px2rem(4px) solid $clr-blue-a200;
      border-left: none;
    }

    // Adjust spacing for title-only admonitions
    html &:last-child {
      margin-bottom: 0;
    }

    // Admonition icon
    &::before {
      position: absolute;
      left: px2rem(12px);
      width: px2rem(20px);
      height: px2rem(20px);
      background-color: $clr-blue-a200;
      mask-image: var(--md-admonition-icon--note);
      mask-repeat: no-repeat;
      mask-size: contain;
      content: "";

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

    // Adjust spacing on last tabbed block container child - if the tabbed
    // block container is the sole child, it looks better to omit the margin
    + .tabbed-set:last-child {
      margin-top: 0;
    }
  }
}

// ----------------------------------------------------------------------------
// Rules: flavours
// ----------------------------------------------------------------------------

@each $names, $props in $admonitions {
  $name: nth($names, 1);
  $tint: nth($props, 2);

  // Admonition flavour
  .md-typeset .admonition.#{$name} {
    border-color: $tint;
  }

  // Admonition flavour title
  .md-typeset .#{$name} > .admonition-title {
    background-color: transparentize($tint, 0.9);
    border-color: $tint;

    // Admonition icon
    &::before {
      background-color: $tint;
      mask-image: var(--md-admonition-icon--#{$name});
      mask-repeat: no-repeat;
      mask-size: contain;
    }
  }

  // Define synonyms for flavours
  @if length($names) > 1 {
    @for $n from 2 through length($names) {
      .#{nth($names, $n)} {
        @extend .#{$name};
      }
    }
  }
}
