// Modifiers.
//
// Styleguide 3.1

@use "sass:math";

// Colour variables used in this file.
$light-gray-background: $color-hector !default;
$light-gray-background-2: $color-paris !default;
$divider-background: $color-iphis !default;
$grid-border-color: $color-paris !default;
$grid-border-type: solid $grid-border-color !default;
$grid-border-width: 2px !default;
$arrow-margin-right: 2% !default;
$arrow-margin-top: 6% !default;
$arrow-border-width: 9px !default;
$arrow-border: $arrow-border-width solid transparent !default;
$arrow-down-color: lighten($color-achillies, 10%) !default;
$stripe-background-color: rgba(0, 0, 0, 0.57) !default;
$tile-padding-top: 70px !default;
$tile-padding-bottom: 70px !default;
$tiles-spacing: 10px !default;
$tile-title-font-size-desktop: 2.8125rem !default;
$tile-title-font-size-mobile: 1.6875rem !default;
$header-into-columns-padding-y: 3.875rem !default;
$theme-invert-text-color: $color-cassandra !default;
$line-background-alter: $color-nestor !default;
$two-columned-header-line-margin: 0.625rem !default;

.full-width {
  .expandable-content {
    width: 100%;
    max-width: 100%;
  }

  &.with-tiles {
    .expandable-content {
      @include media-breakpoint-up(lg) {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
      }
    }
  }
}

.with-divider {
  .slick-track {
    height: 100%;
  }

  .list-item-wrapper {
    &::before {
      position: absolute;
      background-color: $divider-background;
      width: 1px;
      height: 100%;
      left: 0;
      top: 0;
      content: " ";
    }

    &:first-child::before,
    &[aria-hidden="true"] + [aria-hidden="false"]::before,
    &[aria-hidden="false"] + [aria-hidden="true"]::before {
      display: none;
    }
  }
}

.with-grid {
  .expandable-content {
    width: 100%;
    max-width: 100%;
    position: relative;

    &::before,
    &::after {
      height: $grid-border-width;
      background-color: $grid-border-color;
      position: absolute;
      width: 100%;
      content: "";
      z-index: 1;
      left: 0;
    }

    &::after {
      margin-top: -2px;
    }

    .single-boxes-wrapper {
      justify-content: center;
    }

    .list-item-wrapper {
      border-bottom: $grid-border-width $grid-border-type;
      border-right: $grid-border-width $grid-border-type;
      &:last-child {
        border: none;
      }
    }

    .field--type-entity-reference {
      margin: 0;
    }
    .xs-grid-row-end-item {
      @include media-breakpoint-down(xs) {
        border-right: none;
      }
    }

    .sm-grid-row-end-item {
      @include media-breakpoint-only(sm) {
        border-right: none;
      }
    }

    .md-grid-row-end-item {
      @include media-breakpoint-up(md) {
        border-right: none;
      }
    }
  }
}

.with-price {
  flex-direction: column;

  &.stripe-sidebar {
    @include media-breakpoint-up(lg) {
      .item-1 & {
        margin-right: 140px;
      }
      .item-2 & {
        margin-left: 140px;
      }
    }

    .with-price-stripe {
      background-color: $stripe-background-color;
      min-width: 170px;
      height: 100%;
      padding: 0;
      position: absolute;
      top: 0;

      .item-1 & {
        right: 0;
        @include media-breakpoint-down(md) {
          right: 0;
          .with-price-wrapper {
            justify-content: flex-end;
            padding-right: 7vw;
          }
        }
        @include media-breakpoint-down(sm) {
          padding-right: math.div($grid-gutter-width, 2);
        }
      }

      .item-2 & {
        left: 0;
        @include media-breakpoint-down(md) {
          left: 0;
          .with-price-wrapper {
            justify-content: flex-start;
            padding-left: 7vw;
          }
        }
        @include media-breakpoint-down(sm) {
          padding-left: math.div($grid-gutter-width, 2);
        }
      }

      @include media-breakpoint-down(md) {
        height: 70px;
        width: 50vw;
        bottom: 0;
        top: unset;
      }

      @include media-breakpoint-down(xs) {
        right: unset;
        left: 0;
        width: 100%;
      }

      .with-price-wrapper {
        top: 50%;
        color: $white;
        text-align: center;
        position: absolute;
        margin-top: 0;
        left: 0;
        transform: translateY(-50%);
        height: 100px;
        width: 100%;

        @include media-breakpoint-down(md) {
          text-align: left;
          height: 70px;
          padding-left: 30px;
          line-height: 35px;
          display: flex;
          align-items: center;
        }

        @include media-breakpoint-down(xs) {
          .item-1 &, .item-2 & {
            justify-content: flex-start;
            padding-right: math.div($grid-gutter-width, 2);
            padding-left: math.div($grid-gutter-width, 2);
          }
        }

        .with-price-data {
          padding-bottom: 3.8vh;
          font-size: 1.7rem;

          @include media-breakpoint-down(md) {
            padding-bottom: unset;
          }
        }

        .with-price-currency,
        .with-price-timestamp {
          display: none;
        }

        .with-price-percentage {
          color: $white;
        }

        .with-price-arrow {
          margin-top: $arrow-margin-top;
        }
      }

    }
  }

  .with-price-stripe {
    .with-price-wrapper {
      color: $color-cassandra;
      margin-top: 1.5rem;

      .with-price-data {
        display: block;
        font-weight: bold;
        font-size: 3vh;
        clear: right;
        @include media-breakpoint-down(md) {
          display: inline-block;
          padding-right: 20px;
          vertical-align: middle;
          padding-bottom: unset;
        }

        .spinner-border {
          font-size: 1rem;
          color: $color-achillies;
          @include media-breakpoint-down(md) {
            left: 30px;
          }
        }
      }

      .with-price-percentage,
      .with-price-timestamp {
        font-size: 0.9rem;
      }

      .with-price-arrow {
        width: 0;
        height: 0;
        display: inline-block;
        margin-right: $arrow-margin-right;
        border-left: $arrow-border;
        border-right: $arrow-border;

      }

      &.up {
        .change {
          color: $color-serpedon;
        }

        .with-price-arrow {
          border-bottom: 16px solid $color-serpedon;
        }
      }

      &.down {
        .change {
          color: $arrow-down-color;
        }

        .with-price-arrow {
          border-top: 16px solid $arrow-down-color;
        }
      }

      .with-price-timestamp {
        margin-top: 2rem;
        text-align: center;
      }
    }
  }
}

.tile {
  transform: scale(1);
  transition: 0.3s;

  @include media-breakpoint-down(md) {
    margin-bottom: $tiles-spacing;
  }

  &::before {
    content: none;
  }

  &:hover {
    transform: scale(1.01);
    transition: 0.3s;
  }

  &.wrapper-d_p_single_text_block {
    height: 100%;
  }

  .d-p-text-block {
    margin-bottom: 0;
  }

  // Override default values.
  &.padding-top-default {
    > .paragraph:not(.content-moved-inside),
    > .content-moved-inside .content-inside-wrapper {
      padding-top: $tile-padding-top;
    }
  }
  &.padding-bottom-default {
    > .paragraph:not(.content-moved-inside),
    > .content-moved-inside .content-inside-wrapper {
      padding-bottom: $tile-padding-bottom;
    }
  }

  .paragraph {

    .field--name-field-d-main-title {
      text-align: center;
      font-size: $tile-title-font-size-desktop;
      @include media-breakpoint-down(lg) {
        font-size: $tile-title-font-size-mobile;
      }

      &::after {
        margin: 7px auto;
      }
    }
  }

  .field--type-link {
    a {
      &,
      &:not(.disabled):active,
      &:not(:disabled):active:focus,
      &:active,
      &:hover {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 100%;
        background: none;
        border: none;
        text-indent: -9999px;
        max-width: none;
        box-shadow: none;
      }
    }
  }
}

.header-into-columns {
  .d-p-group-of-text-blocks {
    @include media-breakpoint-up(md) {
      .d-p-group-of-text-blocks-header-wrapper {
        display: flex;
        flex-direction: row;
        margin-top: $header-into-columns-padding-y;
        margin-bottom: $header-into-columns-padding-y;

        > .field {
          flex-basis: 100%;
          text-align: left;
          margin-bottom: 0;
        }

        .field--name-field-d-main-title::after {
          margin: $two-columned-header-line-margin auto $two-columned-header-line-margin 0 !important;
        }
      }
    }
  }
}

// TODO: migrate to new spacings
.no-padding-bottom > .paragraph {
  padding-bottom: 0;
}

.no-padding-top > .paragraph {
  padding-top: 0;
}

/*
  Themes styling.
 */
$d-p-themes: () !default;
$d-p-themes: map-merge(
  (
    "custom": (
      background: inherit,
      text: inherit,
      text-bold: inherit,
      set-fields-color: true,
      link-color: inherit,
    ),
    "primary": (
      background: $color-agamemnon,
      text: $color-odysseus,
      text-bold: inherit,
      set-fields-color: true,
      link-color: $color-nestor,
    ),
    "gray": (
      background: $color-paris,
      text: $color-acamas,
      text-bold: $color-cassandra,
      set-fields-color: false,
      link-color: $color-agamemnon,
    ),
    "secondary": (
      background: $color-odysseus,
      text: $color-hecuba,
      text-bold: $color-troilus,
      set-fields-color: false,
      link-color: $color-agamemnon,
    ),
  ),
  $d-p-themes
);

@each $name, $themeSettings in $d-p-themes {
  .theme-#{$name} {
    > .paragraph:not(.content-moved-inside),
    > div[data-geysir-paragraph-id] > .paragraph:not(.content-moved-inside),
    &.theme-custom > .content-moved-inside,
    &.theme-custom > .content-moved-inside > *:not(.content-inside-wrapper),
    > .content-moved-inside .content-inside-wrapper,
    > .paragraph .theme-default > .paragraph,
    > .paragraph .theme-default > div[data-geysir-paragraph-id] > .paragraph {
      background: map-get($themeSettings, "background");
      color: map-get($themeSettings, "text");

      @if map-get($themeSettings, "text-bold") {
        b,
        strong {
          color: map-get($themeSettings, "text-bold");
        }
      }

      @if map-get($themeSettings, "set-fields-color") {
        .field {
          color: map-get($themeSettings, "text");

          &.field--name-field-d-long-text a,
          a.link {
            color: map-get($themeSettings, "link-color");

            span {
              color: map-get($themeSettings, "link-color");
            }
          }
        }
        @for $i from 1 through 6 {
          h#{$i} {
            color: map-get($themeSettings, "text");
          }
        }
      }
    }
  }
}

/*
  Spacings styling.
 */
$d-p-paddings: () !default;
$d-p-paddings-mobile: () !default;
$d-p-paddings-extended: () !default;
$d-p-paddings: map-merge(
    (
      default: 5%,
      small: 2%,
      big: 10%,
      none: 0
    ),
    $d-p-paddings
);

$d-p-paddings-mobile: map-merge(
    (
      default: 10%,
      small: 5%,
      big: 15%,
      none: 0
    ),
    $d-p-paddings-mobile
);

@each $size, $value in $d-p-paddings {
  @each $placement in (top, bottom) {
    .padding-#{$placement}-#{$size} {
      > .paragraph:not(.content-moved-inside),
      > .paragraph.content-moved-inside .content-inside-wrapper {
        padding-#{$placement}: $value;

        @include media-breakpoint-down(sm) {
          padding-#{$placement}: map-get($d-p-paddings-mobile, $size);
        }
      }
    }
  }
}


$d-p-margins: () !default;
$d-p-margins: map-merge(
    (
      small: 2%,
      medium: 5%,
      big: 10%,
      none: 0
    ),
    $d-p-margins
);
@each $size, $value in $d-p-margins {
  @each $placement in (top, bottom) {
    .margin-#{$placement}-#{$size} > .paragraph {
      margin-#{$placement}: $value;
    }
  }
}
