/**
 * Side embed paragraph.
 */

@use "sass:math";

// Colour variables used in this paragraph.
$d-p-side-embed-background-color: $color-agamemnon !default;
$d-p-side-embed-background-color-secondary: darken($d-p-side-embed-background-color, 15%) !default;
$d-p-side-embed-embed-background-color: $color-cassandra !default;
$d-p-side-embed-text-color: $color-odysseus !default;
$d-p-side-embed-link-color: $color-nestor !default;
$d-p-side-embed-link-hover-color: darken($d-p-side-embed-link-color, 5%) !default;
$d-p-side-embed-line-color: $color-nestor !default;
$d-p-side-embed-link-color-inverted: $color-agamemnon !default;
$d-p-side-embed-line-color-inverted: $color-agamemnon !default;
$d-p-side-embed-header-color: $color-odysseus !default;
$d-p-side-embed-full-text-color: $color-cassandra !default;
$d-p-side-embed-theme-invert-text-color: $color-cassandra !default;

// Margins, paddings and sizing.
$d-p-side-embed-fields-padding-y: 3.5% !default;
$d-p-side-embed-fields-full-padding-y: 30px !default;
$d-p-side-embed-fields-padding-x: 30px !default;
$d-p-side-embed-mobile-height: 18.75rem !default;
$d-p-side-embed-text-desktop-padding-y: 2rem !default;
$d-p-side-embed-text-mobile-padding: 7% !default;
$d-p-side-embed-text-width: 35.625rem !default;
$d-p-side-embed-half-padding: 10% !default; // Spacing between content and half of the screen
$d-p-side-embed-mobile-height: 300px !default; // This value must be set, otherwise embed won't be visible.
$d-p-side-embed-desktop-height: auto !default; // You can set fixed height of embed here.
$d-p-side-embed-long-text-margin-bottom: 0 !default;

// Override default values.
.padding-top-default {
  .paragraph--type--d-p-side-embed {
    .content-inside-wrapper {
      padding-top: $d-p-side-embed-text-mobile-padding;
    }
    @include media-breakpoint-up(md) {
      .embed-side {
        &-left,
        &-right, {
          .content-inside-wrapper {
            padding-top: $d-p-side-embed-fields-padding-y;
          }
        }
        &-full {
          .content-inside-wrapper {
            padding-top: $d-p-side-embed-fields-full-padding-y;
          }
        }
      }
    }
  }
}
.padding-bottom-default {
  .paragraph--type--d-p-side-embed {
    .content-inside-wrapper {
      padding-bottom: $d-p-side-embed-text-mobile-padding;
    }

    @include media-breakpoint-up(md) {
      .embed-side {
        &-left,
        &-right, {
          .content-inside-wrapper {
            padding-bottom: $d-p-side-embed-fields-padding-y;
          }
        }
        &-full {
          .content-inside-wrapper {
            padding-bottom: $d-p-side-embed-fields-full-padding-y;
          }
        }
      }
    }
  }
}

.theme-default {
  .paragraph--type--d-p-side-embed {
    .embed-side-full,
    .embed-side-right {
      .d-p-side-embed-content {
        background: $d-p-side-embed-background-color;
      }
    }
    .embed-side-left {
      .d-p-side-embed-content {
        background: $d-p-side-embed-background-color-secondary;
      }
    }

    .d-p-side-embed-content {
      color: $d-p-side-embed-text-color;
    }

    .field--name-field-d-main-title {
      color: $d-p-side-embed-header-color;
    }
    .field--name-field-d-long-text {
      @for $index from 1 through 6 {
        h#{$index}{
          color: $d-p-side-embed-text-color;
        }
      }
    }
    a:not(.btn) {
      color: $d-p-side-embed-link-color;

      @at-root .theme-secondary & {
        color: $d-p-side-embed-link-color-inverted;
      }

      &:hover {
        color: $d-p-side-embed-link-hover-color;
      }
    }
    a:not(.btn) {
      color: $d-p-side-embed-link-color;

      @at-root .theme-secondary & {
        color: $d-p-side-embed-link-color-inverted;
      }

      &:hover {
        color: $d-p-side-embed-link-hover-color;
      }
    }
  }
}

.paragraph--type--d-p-side-embed {
  $root: &;

  .embed-side-full {
    position: relative;

    .d-p-side-embed-embed {
      width: 100%;
      height: 100%;

      &.google-maps-wrapper {
        .google-maps-embed {
          height: 100%;
          width: 100%;
        }
      }
    }

    .d-p-side-embed-content {

      .d-p-side-embed-content-fields {
        width: 600px; // Half of container.
      }
    }

    @include media-breakpoint-up(md) {

      .d-p-side-embed-content {
        margin: 2*$d-p-side-embed-fields-padding-y 0;

        .d-p-side-embed-content-fields {
          padding-left: $d-p-side-embed-fields-padding-x;
          padding-right: $d-p-side-embed-fields-padding-x;
        }
      }

      .d-p-side-embed-embed {
        position: absolute;
        background: none;
      }
    }
  }

  .field--name-field-d-main-title {
    @include font-main-header;
    text-align: left;

    &::after {
      @include decoration-header-line($d-p-side-embed-line-color, $d-p-side-embed-line-color-inverted);
    }

    &:last-child::after {
      display: none;
    }
  }

  .field--name-field-d-long-text {

    strong {
      color: $d-p-side-embed-text-color;
    }

    margin-bottom: $d-p-side-embed-long-text-margin-bottom;
  }

  .d-p-side-embed-embed {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 0;
    padding-right: 0;
    position: relative;
    height: $d-p-side-embed-desktop-height;
    background: $d-p-side-embed-embed-background-color;

    @include media-breakpoint-down(sm) {
      min-height: $d-p-side-embed-mobile-height;
    }

    > * {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      &.facebook-embed {
        position: static;
        max-width: 100%;
      }
      .vimeo-embed,
      &.vimeo-embed {
        z-index: 2;
      }
    }
  }

  @include media-breakpoint-up(md) {

    .d-p-side-embed-content {
      display: flex;
      align-items: center;
      padding-left: 0;
      padding-right: 0;

      .d-p-side-embed-content-fields {
        width: $d-p-side-embed-text-width;
      }
    }

    .embed-side {
      &-right {
        .d-p-side-embed-content {
          justify-content: flex-end;
          order: 1;
        }
        .d-p-side-embed-embed {
          order: 2;
        }
        .d-p-side-embed-content-fields {
          padding-right: $d-p-side-embed-half-padding;
          padding-left: (math.div($grid-gutter-width, 2));
        }
      }
      &-left {
        .d-p-side-embed-content {
          justify-content: flex-start;
        }
        .d-p-side-embed-content-fields {
          padding-left: $d-p-side-embed-half-padding;
          padding-right: (math.div($grid-gutter-width, 2));
        }
      }
    }
  }
}
