/**
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

@import "mixins";

.cu-window {

  @include cu-window($header-height: 37px, $footer-height: 45px);
  color: $color-light;
  $main-background: linear-gradient($color-dark, $color-dark);

  // Header Styles

  .cu-window-header {
    @include not-selectable();
    @include display(flex);
    @include flex-direction(row);
    @include align-items(center);
    padding: 6px 15px;
    &:after {
      bottom: -7px;
      background: url('#{$cu-styles-root}window/default/images/top-left-header.png') no-repeat top left,
        url('#{$cu-styles-root}window/default/images/top-right-header.png') no-repeat top right,
        url('#{$cu-styles-root}window/default/images/top-background.png') no-repeat top center / 100% 44px;
    }
    &:before {
      margin-top: 2px;
      margin-bottom: 6px;
    }
  }

  // Content Styles

  .cu-window-content {
    @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 1px, $color: #000000);
    @include not-selectable();
    padding: 0 10px;
    .cu-window-actions {
      top: 6px;
    }
  }

  @include cu-window-content--header--no-footer {
    &:after {
      background: url('#{$cu-styles-root}window/default/images/bottom-left.png') no-repeat bottom left,
      url('#{$cu-styles-root}window/default/images/bottom-right.png') no-repeat bottom right;
    }
  }

  @include cu-window-content--no-header--footer {
    &:after {
      background: url('#{$cu-styles-root}window/default/images/top-left.png') no-repeat top left,
      url('#{$cu-styles-root}window/default/images/top-right.png') no-repeat top right;
    }
  }

  @include cu-window-content--no-header--no-footer {
    padding-top: 6px;
    padding-bottom: 6px;
    &:after {
      background: url('#{$cu-styles-root}window/default/images/bottom-left.png') no-repeat bottom left,
      url('#{$cu-styles-root}window/default/images/bottom-right.png') no-repeat bottom right,
      url('#{$cu-styles-root}window/default/images/top-left.png') no-repeat top left,
      url('#{$cu-styles-root}window/default/images/top-right.png') no-repeat top right;
    }
  }

  // Footer Styles

  .cu-window-footer {
    @include not-selectable();
    padding-top: 12px;
    padding-bottom: 8px;

    &:after {
      top: -4px;
      background: url('#{$cu-styles-root}window/default/images/bottom-left-footer.png') no-repeat bottom left,
      url('#{$cu-styles-root}window/default/images/bottom-right-footer.png') no-repeat bottom right,
      url('#{$cu-styles-root}window/default/images/bottom-background.png') no-repeat bottom center / 100% 49px;
    }

    &:before {
      margin-top: 4px;
      margin-bottom: 4px;
    }

  }

  // Background Colours

  // Default Colours

  @include cu-window-header-bg(true) {
    @include background(
      linear-gradient(to bottom, #0e0e0e 0%, #373737 50%, #373737 50%, #272727 50%, #272727 50%, #0c0c0c 100%)
    );
  }
  @include cu-window-footer-bg(true) {
    @include background($color-dark);
  }
  @include cu-window-content-bg(false, $main-background);


  // Red

  .cu-window-bg-red {
    @include cu-window-header-bg {
      background: linear-gradient(to bottom, lighten($color-red-light, 10%) 0%, $color-red-light 50%, $color-red 50%, $color-red-dark 100%);
    }
    @include cu-window-footer-bg {
      background: $color-red;
    }
  }
  @include cu-window-content-bg(
    cu-window-bg-red,
    linear-gradient($color-red, $color-red)
  );

  // Green

  .cu-window-bg-green {
    @include cu-window-header-bg {
      @include background(
        linear-gradient(to bottom, $color-green-light 0%, $color-green 50%, $color-green-dark 50%, darken($color-green-dark, 5%) 100%)
      );
    }
    @include cu-window-footer-bg {
      @include background($color-green-dark);
    }
  }
  @include cu-window-content-bg(
    cu-window-bg-green,
    linear-gradient($color-green, $color-green)
  );

  // Blue

  .cu-window-bg-blue {
    @include cu-window-header-bg {
      @include background(
        linear-gradient(to bottom, lighten($color-blue-light, 10%) 0%, $color-blue-light 50%, $color-blue 50%, $color-blue-dark 100%)
      );
    }
    @include cu-window-footer-bg {
      @include background($color-blue-dark);
    }
  }
  @include cu-window-content-bg(
    cu-window-bg-blue,
    linear-gradient($color-blue, $color-blue)
  );

  // Yellow

  .cu-window-bg-yellow {
    @include cu-window-header-bg {
      @include background(
        linear-gradient(to bottom, $color-yellow 0%, darken($color-yellow, 10%) 50%, darken($color-yellow-dark, 10%) 50%, darken($color-yellow-dark, 20%) 100%)
      );
    }
    @include cu-window-footer-bg {
      @include background($color-yellow-dark);
    }
  }
  @include cu-window-content-bg(
    cu-window-bg-yellow,
    linear-gradient($color-yellow, $color-yellow)
  );

  // Brown

  .cu-window-bg-brown {
    @include cu-window-header-bg {
      @include background(
        linear-gradient(to bottom, $color-brown-light 0%, $color-brown 50%, $color-brown-dark 50%, darken($color-brown-dark, 5%) 100%)
      );
    }
    @include cu-window-footer-bg {
      @include background($color-brown-dark);
    }
  }
  @include cu-window-content-bg(
    cu-window-bg-brown,
    linear-gradient($color-brown, $color-brown)
  );

  // Canvas

  @include cu-window-content-bg(
    cu-window-bg-canvas,
    url('#{$cu-styles-root}window/images/canvas-effect.png')
  );

  // Title

  .cu-window-title {
    @include cu-font-cinzel();
    @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 10px, $color: #000000);
    width: 100%;
    text-align: center;
    font-weight: 600;
    padding-bottom: 3px;
  }

  // Action Buttons

  .cu-window-actions {
    position: absolute;
    right: 14px;
    top: 9px;
  }

  .cu-window-footer {
    .cu-window-actions {
      right: 5px;
      top: 13px;
    }
  }

  .cu-window-action {
    font-size: $font-size-xl;
    @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 5px, $color: #000000);
    color: darken($color-gray-lightest, 10%);
    width: 12px;
    height: 17px;
    text-align: center;
    line-height: 17px;
    cursor: pointer;
    display: inline-block;
    position: relative;
    top: -1px;
    &:before {
      position: absolute;
      left: 0;
    }
    &:hover {
      color: $color-gray-lightest;
    }
  }

  .cu-window-close {
    @extend .cu-window-action;
    &:before {
      content: "\00D7";
    }
    &:hover {
      @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 5px, $color: $color-red);
    }
  }

  .cu-window-minimize {
    @extend .cu-window-action;
    &:before {
      content: "\2212";
    }
    &:hover {
      @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 5px, $color: $color-blue);
    }
  }

  .cu-window-maximize {
    @extend .cu-window-action;
    &:before {
      content: "\002B";
    }
    &:hover {
      @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 5px, $color: $color-blue);
    }
  }

  .cu-window-down-arrow {
    @extend .cu-window-action;
    &:before {
      content: "\25BC";
      font-size: 0.75rem;
    }
    &:hover {
      @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 5px, $color: $color-blue);
    }
  }

  .cu-window-up-arrow {
    @extend .cu-window-action;
    &:before {
      content: "\25B2";
      font-size: 0.75rem;
    }
    &:hover {
      @include cu-text-shadow($hShadow: 0, $vShadow: 0, $blurRadius: 5px, $color: $color-blue);
    }
  }

}
