/*
 *  This file is part of adapta-gtk-theme
 *
 * Copyright (C) 2016-2018 Tista <tista.gma500@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

//
// Drawing mixins
//

// generic drawing of more complex things

// provide font size in rem, with px fallback
$ref_size: 13.33;

@mixin fontscaling($size: $ref_size) {
  font-size: round( $size * 72 / 96 * 10 ) / 10 + pt;
}


//
// shadows
//

$z-depth-1: 0 1px 2px rgba(0, 0, 0, 0.28);
$z-depth-2: 0 2.5px 4.5px rgba(0, 0, 0, 0.34);
$z-depth-3: 0 4.5px 5.5px rgba(0, 0, 0, 0.38);
$z-depth-4: 0 10px 14px rgba(0, 0, 0, 0.44);
$z-depth-5: 0 14px 19px rgba(0, 0, 0, 0.50);

// replacement of the 'none'
$empty_shadow: 0 0 transparent;


//
// tiransition timing
//

$slope_slow: cubic-bezier(0.0, 0.0, 0.2, 1.0);
$slope_medium: cubic-bezier(0.4, 0.0, 0.2, 1.0);
$slope_quick: cubic-bezier(0.4, 0.0, 0.6, 1.0);

$duration_long: 0.4s;
$duration_medium: 0.15s; // 0.2s seems too slow
$duration_short: 0.1s;


//
// entries
//

@mixin entry($t, $fc:$selected_bg_color) {
//
// Entries drawing function
//
// $t: entry type
// $fc: focus color
//
// possible $t values:
// normal, focus, hover, insensitive,
// osd-normal, osd-focus, osd-insensitive
//
  @if $t == normal {
    border-color: transparent;
    background-color: $hidden_fill_color;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color, $fc,
                                                         $outline_fill_color);
  }
  @if $t == focus {
    border-color: transparent;
    box-shadow: inset 0 -2px if($fc!=$selected_bg_color, $fc,
                                                         $selected_bg_color);
  }
  @if $t == hover {
    border-color: transparent;
    box-shadow: inset 0 -2px if($fc!=$selected_bg_color, $fc,
                                                         $outline_fill_color);
  }
  @if $t == insensitive {
    border-color: transparent;
    color: $insensitive_fg_color;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color,
                                $fc,
                                $insensitive_outline_fill_color);
  }
  @if $t == osd-normal {
    border-color: transparent;
    background-color: $hidden_fill_color;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color,
                                $fc,
                                $osd_outline_fill_color);
  }
  @if $t == osd-focus {
    border-color: transparent;
    background-color: $hidden_fill_color;
    color: $selected_fg_color;
    caret-color: $selected_fg_color;
    box-shadow: inset 0 -2px if($fc!=$selected_bg_color, $fc,
                                                         $selected_bg_color);
  }
  @if $t == osd-insensitive {
    border-color: transparent;
    background-color: $hidden_fill_color;
    color: $insensitive_osd_fg_color;
    box-shadow: inset 0 -1px if($fc!=$selected_bg_color,
                                 $fc,
                                 $insensitive_osd_outline_fill_color);
  }
}


//
// buttons
//

@mixin button($t, $c:$bg_color, $tc:$fg_color) {
//
// Button drawing function
//
// $t:    button type,
// $c:    base button color for colored* types
// $tc:   optional text color for colored* types
//
// possible $t values:
// normal, hover, active, insensitive, undecorated,
// flat-normal, flat-hover, flat-active, flat-insensitive,
// undecorated
//
  @if $t == normal {
  //
  // normal button
  //
    border-color: transparent;
    border-top: 1px solid $borders_highlight;
    color: if($tc!=$fg_color, $tc, $secondary_fg_color);
    background-color: $c;
    box-shadow: $z-depth-1;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == focus {
  //
  // focused button
  //
    color: $fg_color;
    background-color: $c;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }

  @else if $t == hover {
  //
  // hovered button
  //
    border-color: transparent;
    border-top: 1px solid $borders_highlight;
    color: if($tc!=$fg_color, $tc, $fg_color);
    background-color: $c;
    box-shadow: $z-depth-2;
    text-shadow: none;
    icon-shadow: none;

  }
  @else if $t == active {
  //
  // pushed button
  //
    border-color: transparent;
    border-top: 1px solid $borders_highlight;
    color: if($tc!=$fg_color, $tc, $selected_fg_color);
    background-color: $c;
    box-shadow: $z-depth-2;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == insensitive {
  //
  // insensitive button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $insensitive_secondary_fg_color);
    background-color: if($c!=$bg_color,
                         $c,
                         shellopacity($insensitive_secondary_fg_color, 0.12));
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == flat-normal {
  //
  // normal flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $secondary_fg_color);
    background-color: transparent;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == flat-focus {
  //
  // focused flat button
  //
    color: $fg_color;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }

  @else if $t == flat-hover {
  //
  // hovered flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $fg_color);
    background-color: if($c!=$bg_color, $c, $semi_fill_color);
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;

  }
  @else if $t == flat-active {
  //
  // pushed flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $selected_fg_color);
    background-color: if($c!=$bg_color, $c, $fill_color);
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == flat-insensitive {
  //
  // insensitive flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $insensitive_secondary_fg_color);
    background-color: transparent;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == osd-normal {
  //
  // osd flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $osd_secondary_fg_color);
    background-color: transparent;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == osd-focus {
  //
  // focused osd flat button
  //
    color: $osd_fg_color;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }

  @else if $t == osd-hover {
  //
  // hovered osd flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $osd_fg_color);
    background-color: if($c!=$bg_color, $tc, $osd_semi_fill_color);
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;

  }
  @else if $t == osd-active {
  //
  // pushed osd flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $selected_fg_color);
    background-color: if($c!=$bg_color, $tc, $osd_fill_color);
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == osd-insensitive {
  //
  // insensitive osd flat button
  //
    border-color: transparent;
    color: if($tc!=$fg_color, $tc, $insensitive_osd_secondary_fg_color);
    background-color: transparent;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
  @else if $t == undecorated {
  //
  // reset
  //
    color: inherit;
    background-color: transparent;
    border-color: transparent;
    box-shadow: $empty_shadow;
    text-shadow: none;
    icon-shadow: none;
  }
}

