/*!
_mixins.scss
Source file (relative to compiled *.css file): ./scss/_mixins.scss

This file is included in PhotoBerry Studio. For licensing and copyright notices, please see ../../license.txt (relative to *.css file) or ../../../license.txt (relative to *.scss file).
*/


/* -------- Mixins -------- */

@mixin h1() {
  font-size   : 19px;
  font-weight : 600;
  color       : $text-primary;
  }

@mixin h3() {
  font-size   : 16px;
  font-weight : 600;
  color       : $text-primary;
  }

@mixin label() {
  font-size   : 13px;
  font-weight : 500;
  color       : $text-primary;
  }

/*
  $size - small, medium, large
  $type - primary, secondary, remove, text
  $icon - true or false
 */
@mixin button($type: primary, $size: medium, $icon: false) {

  cursor      : pointer;

  // reset defaults
  box-shadow  : unset;
  text-shadow : unset;
  min-height  : unset;
  text-decoration: unset;
  text-transform: unset;

  &:focus {
    box-shadow : unset;
    outline    : unset;
    }

  &:disabled, &:disabled:hover {
    color: #fff;
    background-color: $gray-2;
    border-color: $gray-2;
    cursor: not-allowed;
    border-radius: 3px;
    }

  @if $icon == false {

    & {
      display       : inline-block;
      box-sizing    : border-box;
      vertical-align: middle;
      font-family   : $font;
      border-radius : 5px;
      border-style  : solid;
      border-width  : 1px;
      line-height   : 1em;
      cursor        : pointer;
      font-weight: 500;
      }

      @if $size == "very-small" {
        &, &:hover {
          min-width : unset;
          font-size   : 12px;
          padding     : 9px 10px;
          }
        } @else if $size == "small" {
        &, &:hover {
          font-size : 12px;
          min-width : 80px;
          padding     : 9px 10px;
          }
        } @else if $size == "medium" {
        &, &:hover {
          font-size : 14px;
          min-width : 100px;
          padding   : 12px 30px;
          }
        } @else if $size == "large" {
        &, &:hover {
          font-size : 14px;
          min-width : 130px;
          padding   : 12px 30px;
          }
        }

      @if $type == "primary" {

        &, &:hover, &:focus, &:active, &:not(:hover):not(:active):not(.has-background):not(:disabled) {
          color            : #fff;
          background-color : $primary-color;
          border-color     : $primary-color;
          }

        } @else if $type == "secondary" {
        &, &:hover, &:focus, &:active {
          background-color : $gray-1;
          color            : $text-primary;
          border-color     : $gray-2;
          border-radius: 3px;
          font-weight: bold;
          }
        }

    } @else if $icon == true {

      & {
        border-radius       : 3px;
        background-color    : #fff;
        color               : $gray-3;
        font-size           : 0;
        background-repeat   : no-repeat;
        background-position : center;
        display             : inline-block;
        vertical-align      : top;
        padding: 0;
        }

      &:not(:hover):not(:active):not(.has-background) {
        background-color    : #fff;
        color               : $gray-3;
      }

      &:hover {
        font-family      : $font;
        border-radius    : 5px;
        }

      &:focus {
        background-color    : #fff;
        background-repeat   : no-repeat;
        background-position : center;
        box-shadow          : unset;
        outline             : unset;
        }

      &:focus-visible {
        outline-color : $gray-2;
        }

      &:active {
        background-color    : $gray-2;
        border-color        : unset;
        background-repeat   : no-repeat;
        background-position : center;
        }

      & {
        @if $type == primary {
          box-shadow          : unset;

          &:focus, &:hover {
            box-shadow          : unset;
            color            : $text-primary;
            background-color: $gray-1;
            }
          &:focus {
            color               : $text-primary;
            }
        }
        @if $type == secondary {
          box-shadow: none;
          border: 1px solid $gray-3;

          &:focus, &:hover {
            border: 1px solid $gray-3;
            }
          &:focus {
            color               : $gray-3;
            }

        }
      }

      & {
        @if $size == very-small {
          width           : 20px;
          height          : 20px;
          background-size : 18px;
          }
        @if $size == small {
          width           : 30px;
          height          : 30px;
          background-size : 18px;
          }
        @if $size == medium {
          width           : 36px;
          height          : 36px;
          background-size : 18px;
          }
        @if $size == large {
          width           : 40px;
          height          : 40px;
          background-size : 22px;
          }
        }
    }

  }


@mixin buttonRemove() {
  font-family      : $font;
  border-radius    : 5px;
  background-color : #fff;
  color            : $accent-red!important;
  border           : 1px solid $accent-red!important;
  cursor           : pointer;
  text-align       : center;
  background-image    : url("../img/icons/delete-red.svg");
  background-repeat   : no-repeat;
  background-size     : 16px;
  background-position : 5px center;
  line-height         : 1em;
  font-size   : 12px;
  font-weight : 500;
  padding     : 11px 10px 11px 25px;

  // reset defaults
  box-shadow       : unset;
  text-shadow      : unset;
  min-height       : unset;

  &:hover {
    font-family      : $font;
    border-radius    : 5px;
    background-color : $accent-red!important;
    border           : 1px solid $accent-red!important;
    color            : #fff!important;
    padding     : 11px 10px 11px 25px;
    background-image : url("../img/icons/delete-white.svg");
    background-size     : 16px;
    background-position : 5px center;
    }

  &:focus,  &:active  {
    color      : $gray-6!important;
    border     : 1px solid $gray-6!important;
    box-shadow : unset;
    outline    : unset;
    background-color : transparent!important;
    background-image : url("../img/icons/gray/delete.svg");
    background-repeat   : no-repeat;
    background-size     : 16px;
    background-position : 5px center;
    }
  }

@mixin buttonText() {
  font-family      : $font;
  color            : $primary-color;
  border-radius    : unset;
  background-color : unset;
  border           : unset;
  line-height      : 1.1em;
  cursor           : pointer;
  font-size        : 13px;
  font-weight      : 500;
  padding          : 0;
  // reset defaults
  box-shadow       : unset;
  text-shadow      : unset;
  min-height       : unset;

  &:hover {
    border-radius    : unset;
    background-color : unset;
    border           : unset;
    color            : $text-primary;
    padding          : 0;
    }

  &:focus, &:active , &:not(:hover):not(:active):not(.has-background) {
    background-color   : unset;
    border-color : $primary-color;
    color        : $primary-color;
    }

  &:focus {
    box-shadow : unset;
    outline    : unset;
    }

  }

@mixin dropdown() {
  position : relative;

  > ul {
    position         : absolute;
    top              : 25px;
    padding          : 0;
    background-color : #fff;
    border           : 2px solid $gray-2;
    border-radius    : 5px;
    width            : 150px;
    list-style: none;
    z-index: 999;
    }

  li {
    padding       : 0;
    margin-bottom : 0;

    &:not(:last-of-type) {
      border-bottom : 1px solid $gray-2;
      }

    a {
      color      : $text-primary;
      width      : 100%;
      display    : block;
      padding    : 10px 10px;
      box-sizing : border-box;
      }

    a:hover {
      color            : $primary-color;
      background-color : $background-color;
      }
    }
  }

@mixin container($border: false, $boxShadow: false) {
  border-radius    : 5px;
  background-color: #fff;

  @if $border==true {
    border: 1px solid $gray-2
    }

  @if $boxShadow==true {
    box-shadow: $box-shadow-light
    }
  }

@mixin input() {
  background-color : #fff;
  border           : 1px solid $gray-2;
  font-size        : 12px;
  min-height       : 34px;
  line-height: 1.3em;
  border-radius    : 3px;
  font-family: $font;
  color: $text-primary;

  &:focus {
    border     : 1px solid $gray-2;
    box-shadow : unset;
    }
  &:focus-visible {
    outline: none;
    }
  }

@mixin select() {
  background-color    : #fff;
  border              : 1px solid $gray-2;
  font-size           : 12px;
  min-height          : 34px;
  border-radius       : 3px;
  background-image    : url(../img/icons/black/expand_more.svg);
  background-repeat   : no-repeat;
  background-size     : 22px 22px;
  background-position : right 5px top 55%;
  line-height: 1.3em;

  &:focus {
    border     : 1px solid $gray-2;
    box-shadow : unset;
    }

  &:hover {
    color : $primary-color;
    border     : 1px solid $gray-2;
    }
  }

@mixin radio(){
    position: absolute;
    opacity: 0;
    left: 0;
    top: 50%;
    transform: translateY(-50%);

    & + ::before {
      content: "";
      background: $background-color;
      border-radius: 100%;
      border: 1px solid darken($background-color, 25%);
      display: inline-block;
      width: 18px;
      height: 18px;
      position: absolute;
      left: 0;
      top: 50%;
      transform: translateY(-50%);
      vertical-align: middle;
      cursor: pointer;
      text-align: center;
      transition: all 250ms ease;
      opacity: 1;
      }

    &:checked + ::before {
      background-color: $primary-color;
      box-shadow: inset 0 0 0 4px $background-color;
      }

    &:focus + ::before {
      outline: none;
      border-color: $primary-color;
      }

    &:disabled + ::before {
      box-shadow: inset 0 0 0 4px $background-color;
      border-color: darken($background-color, 25%);
      background: darken($background-color, 25%);
      }
  }

// Checkbox mixin
@mixin checkboxInput() {
  -webkit-appearance : none;
  background-color   : #fff;
  box-shadow         : none;
  border             : 1px solid $gray-2;
  border-radius      : 3px;
  height             : 20px;
  width              : 20px;
  margin             : 0 10px 0 0;
  vertical-align     : middle;
  cursor             : pointer;
  -webkit-transition : background .15s, box-shadow .1s;
  transition         : background .15s, box-shadow .1s;

  &:before {
    margin              : 0;
    width               : 18px;
    height              : 18px;
    float               : none;
    text-align          : center;
    padding-left        : 0;
    display             : block;
    background-size     : 11px 11px;
    content             : "";
    background-repeat   : no-repeat;
    background-position : center;
    }

  &:after {
    display: none;
  }

  &:hover {
    box-shadow : $box-shadow-light;
    outline    : none;
    }


  &:hover:not(:checked):before {
    background-image : url("../img/icons/gray/check.svg");
    }

  &:focus {
    box-shadow : $box-shadow-light;
    outline    : none;
    }

  &:checked {
    background-color : $primary-color;
    box-shadow       : none;
    border           : 1px solid $primary-color;

    &:before {
      background-image : url("../img/check.svg");
      }
    }

  &[disabled] {
    background-color : $gray-3;
    box-shadow       : none;
    opacity          : .3;
    cursor           : not-allowed;
    }
  }

@mixin overlay(){
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    margin-top: 0;

  > div {
    background-color: $background-color;
    margin: 10% auto;
    padding: 35px 20px;
    border: 1px solid $gray-1;
    width: 80%;
    max-width: 700px;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    box-sizing: border-box;

    @media (max-width: 481px) {
      width: 95%;
      margin-top: 5%;
      min-height: 80vh;
      padding-top: 50px;
      }

    h2 {
      font-size: 18px;
      text-align: center;
      font-weight: bold;
      margin-bottom: 30px;
      }

    .photoberry-studio-dialog-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      justify-content: center;
      margin-bottom: 5px;

      .cancel {
        @include button(secondary, small);
        }

      .submit {
        @include button(primary, small);
        }
      }
    }

  }

@mixin photoberry-gallery-item-overlay-base() {
  opacity : 1;
  z-index : 993;
  }

@mixin photoberry-gallery-item-top-gradient() {
  @include photoberry-gallery-item-overlay-base();
  background : linear-gradient(to bottom,
          rgba(0, 0, 0, 0.5) 0%,
          rgba(0, 0, 0, 0.2) 10%,
          rgba(0, 0, 0, 0.05) 20%,
          transparent 40%);
  }

@mixin photoberry-gallery-item-bottom-gradient() {
  @include photoberry-gallery-item-overlay-base();
  background : linear-gradient(to top,
          rgba(0, 0, 0, 0.5) 0%,
          rgba(0, 0, 0, 0.12) 40%,
          transparent 65%);
  }

@mixin photoberry-gallery-item-combined-gradient() {
  @include photoberry-gallery-item-overlay-base();
  background : linear-gradient(to bottom,
          rgba(0, 0, 0, 0.5) 0%,
          rgba(0, 0, 0, 0.2) 10%,
          rgba(0, 0, 0, 0.05) 20%,
          transparent 40%),
          linear-gradient(to top,
          rgba(0, 0, 0, 0.5) 0%,
          rgba(0, 0, 0, 0.12) 40%,
          transparent 65%);
  }

@mixin photoberry-gallery-item-interactions($checked-link-overflow: false) {
  .photoberry-gallery-items > li {
    visibility:  hidden;
    opacity: 0;
    transition: opacity 0.5s ease-out;

    a {
      position   : relative;
      transition : transform 0.3s ease;
      }

    a:before {
      position   : absolute;
      display    : block;
      content    : "";
      width      : 100%;
      height     : 100%;
      top        : 0;
      left       : 0;
      opacity    : 0;
      transition : opacity 0.5s ease;
      background : transparent;
      }

    input[type="checkbox"] {
      position   : absolute;
      top        : 10px;
      left       : 10px;
      opacity    : 0;
      transition : opacity 0.3s ease;
      z-index    : 999;
      @include checkboxInput();

      & {
        border-color : #fff;
        }

      &:before {
        width  : 18px;
        height : 18px;
        }
      }

    ul.photoberry-studio-item-actions {
      position   : absolute;
      bottom     : 0;
      right      : 0;
      text-align : right;
      opacity    : 0;
      display    : block;
      padding    : 10px;
      box-sizing : border-box;
      transition : opacity 0.5s ease;

      > li {
        display : inline-block;

        &:not(:last-of-type) {
          margin-right : 2px;
          }
        }

      li button {
        @include button(primary, small, true);
        }

      li.photoberry-studio-action-comment button {
        background-image : url("../img/icons/gray/comment-border.svg");
        }

      li.photoberry-studio-action-favorite button {
        background-image : url("../img/icons/gray/favorite-border.svg");
        }
      }

    @media (hover: hover) and (pointer: fine) {
      &:hover {
        ul.photoberry-studio-item-actions {
          opacity : 1;
          }

        input[type="checkbox"] {
          opacity : 1;
          }
        }

      &:hover:has(.photoberry-studio-item-actions):not(:has(input[type="checkbox"])) a:before {
        @include photoberry-gallery-item-bottom-gradient();
        }

      &:hover:has(input[type="checkbox"]):not(:has(.photoberry-studio-item-actions)) a:before {
        @include photoberry-gallery-item-top-gradient();
        }

      &:hover:has(input[type="checkbox"]):has(.photoberry-studio-item-actions) a:before {
        @include photoberry-gallery-item-combined-gradient();
        }
      }

    @media (hover: none) {
      &:has(input[type="checkbox"]) input[type="checkbox"] {
        opacity : 1;
        }

      &:has(.photoberry-studio-item-actions) ul.photoberry-studio-item-actions {
        opacity : 0.75;
        }

      &:has(input[type="checkbox"]):not(:has(.photoberry-studio-item-actions)) a:before {
        @include photoberry-gallery-item-top-gradient();
        }

      &:has(.photoberry-studio-item-actions):not(:has(input[type="checkbox"])) a:before {
        @include photoberry-gallery-item-bottom-gradient();
        }

      &:has(input[type="checkbox"]):has(.photoberry-studio-item-actions) a:before {
        @include photoberry-gallery-item-combined-gradient();
        }

      &:focus-within ul.photoberry-studio-item-actions {
        opacity : 1;
        }
      }

    &:has(input:checked) {
      background-color : #f3f1fe;

      a:before {
        opacity : 0;
        }

      a {
        transform     : scale(0.9);
        border-radius : 10px;

        @if $checked-link-overflow {
          overflow : hidden;
          }
        }

      input[type="checkbox"] {
        opacity : 1;
        }
      }
    }

  .photoberry-gallery-items.photoberry-loaded > li {
    visibility: visible;
    opacity: 1;
    }
  }

.photoberry-studio-hidden {
  display : none !important
}

@keyframes photoberry-studio-rotation {
  0% {
    transform : rotate(0deg);
    }
  100% {
    transform : rotate(359deg);
    }
  }
