
@mixin zigzag-colour($colour){
  background: linear-gradient( 45deg, transparent 33.333%, $colour 33.333%, $colour 66.667%, transparent 66.667% ),
      linear-gradient( -45deg, transparent 33.333%, $colour 33.333%, $colour 66.667%, transparent 66.667% );

  background: 
    -webkit-linear-gradient( 45deg, transparent 33.333%, $colour 33.333%, $colour 66.667%, transparent 66.667% ), 
    -webkit-linear-gradient( -45deg, transparent 33.333%, $colour 33.333%, $colour 66.667%, transparent 66.667% );
    background-size: 20px 40px;
}

%zigzag {
  content: "";
  display: block;
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 10px;
  @include zigzag-colour($colour-dark-blue);
  background-color: transparent;
}

.paragraph.story {
  width: 100%;
  padding: 90px 0 75px;

  picture img {
    display: block;
  }

  .story__outer-wrapper {
    @include container;
    position: relative;
    overflow: hidden;
  }

  .story__fundraiser-title {
    @include span(12);
    text-align: center;
    h2 {
      margin-bottom: 40px;
    }
  }

  .story__beneficiary-wrapper,
  .story__fundraiser-wrapper {
    @include span(12);
    position: relative;
    text-align: center;
    overflow: hidden;

    @include breakpoint($screen-md) {
      @include span(6);
    }

    @include breakpoint($screen-lg) {
      @include span(6);
      width: calc( #{span(6)} + #{gutter()} );
      overflow: visible;
      margin-right: 0;
    }

    .story__fundraiser-title,
    .story__beneficiary-title {
      margin: 0 0 10px;
    }

    .story__fundraiser-image,
    .story__fundraiser-copy,
    .story__beneficiary-image,
    .story__beneficiary-copy {
      width: 100%;
      float: left;

      @include breakpoint($screen-lg) {
        width: 50%;
      }
    }

    .story__fundraiser-copy,
    .story__beneficiary-copy {

      padding: 30px;
      position: relative;

      h3 {
        font-size: 60px;
        line-height: 50px;
        margin-bottom: 0;
        font-family: $font-medium;
      }

      span {
        font-size: 18px;
        line-height: 18px;
        font-family: $font-black;
      }

      p {
        font-size: 15px;
        line-height: 20px;
      }

      /* Ensure the differences in copy length between the 
      2 sides don't make for different heights */
      @include breakpoint($screen-md-only) {
        min-height: 225px;
      }
    }

    .story__fundraiser-copy {
      background-color: inherit;

      /* Zig zag pattern */
      &:after {
        @extend %zigzag;
        bottom: -1px;
        top: auto;
        content: none;

        @include breakpoint($screen-md) {
          content: "";
          height: 10px;
          top: -10px;
        }

        @include breakpoint($screen-lg) {
          content: none;
        }
      }
    }

    .story__beneficiary-copy {

      /* Make space for zigzag */
      padding-top: 40px;
    
      &:after {
        @extend %zigzag;
        @include zigzag-colour($colour-dark-blue);
        top: 0;

        @include breakpoint($screen-md) {
          background-color: transparent !important;
          height: 10px;
          top: -10px;
        }

        @include breakpoint($screen-lg) {
          top: 0;
          left: -10px;
          width: 10px;
          height: 400px;
          background-size: 40px 20px;
        }
      }
    }

    /* Explicitly set the zigzag colour with our mixin as it can't inherit */
    &.bg--blue {
      .story__fundraiser-copy:after { @include zigzag-colour($colour-blue); }
      .story__beneficiary-copy:after { background-color: $colour-blue; }
    } 

    &.bg--red {
      .story__fundraiser-copy:after { @include zigzag-colour($colour-red); }
      .story__beneficiary-copy:after { background-color: $colour-red; }
    } 

    &.bg--pink {
      .story__fundraiser-copy:after { @include zigzag-colour($colour-pink); }
      .story__beneficiary-copy:after { background-color: $colour-pink; }
    } 

    &.bg--yellow {
      .story__fundraiser-copy:after { @include zigzag-colour($colour-yellow); }
      .story__beneficiary-copy:after { background-color: $colour-yellow; }
    }
    &.bg--white {
      .story__fundraiser-copy:after { @include zigzag-colour($colour-white); }
      .story__beneficiary-copy:after { background-color: $colour-white; }
    } 
  }

  .story__fundraiser-wrapper .story__fundraiser-copy,
  .story__beneficiary-wrapper .story__beneficiary-copy {
    @include breakpoint($screen-md) {
      padding: 40px 30px 10px;
    }
  }

  /* Beneficiary side only  */
  .story__beneficiary-wrapper {
    // Override the background colour, but allow text colour to inherit to match the fundraiser side
    background-color: $colour-dark-blue !important;
    text-align: center;

    /* Medium breakpoint, changes order of image and copy */
    @include breakpoint($screen-md-only) {
      display: -webkit-box;
      display: -moz-box;
      display: -ms-flexbox;
      display: -webkit-flex;
      display: flex;
      -webkit-box-orient: vertical;
      -moz-box-orient: vertical;
      -webkit-flex-direction: column;
      -ms-flex-direction: column;
      flex-direction: column;
      /* optional */
      -webkit-box-align: start;
      -moz-box-align: start;
      -ms-flex-align: start;
      -webkit-align-items: flex-start;
      align-items: flex-start;

      .story__beneficiary-copy {
        -webkit-box-ordinal-group: 2;
        -moz-box-ordinal-group: 2;
        -ms-flex-order: 2;
        -webkit-order: 2;
        order: 2;
      }

      .story__beneficiary-image {
        -webkit-box-ordinal-group: 1;
        -moz-box-ordinal-group: 1;
        -ms-flex-order: 1;
        -webkit-order: 1;
        order: 1;
      }
    }

    @include breakpoint($screen-lg) {
      margin-left: 0;
    }
  }
}

/* Text colours changed based on background colours specific to Story row */
.story__fundraiser-wrapper,
.story__beneficiary-wrapper {

  &.bg--red,
  &.bg--pink,
  &.bg--yellow {
    .story__fundraiser-title,
    .story__fundraiser-body {
      h3, span, p, a {
      color: $colour-dark-blue;
      }
    }
  }

  &.bg--blue,
  &.bg--red {
    .story__fundraiser-title,
    .story__fundraiser-body {
      h3, span, p, a {
      color: $colour-dark-blue;
      }
    }
  }

  &.bg--blue {
    .story__beneficiary-title, 
    .story__beneficiary-body {
      h3, span, p, a {
        color: $colour-blue;
      }
    } 
  }

  &.bg--red {
    .story__beneficiary-title, 
    .story__beneficiary-body {
      h3, span, p, a {
        color: $colour-red;
      }
    } 
  }

  &.bg--pink {
    .story__beneficiary-title, 
    .story__beneficiary-body {
      h3, span, p, a {
        color: $colour-pink;
      }
    } 
  }

  &.bg--yellow {
    .story__beneficiary-title, 
    .story__beneficiary-body {
      h3, span, p, a {
        color: $colour-yellow;
      }
    } 
  }
  &.bg--white {
    .story__beneficiary-title, 
    .story__beneficiary-body {
      h3, span, p, a {
        color: $colour-white;
      }
    } 
  }
}
