
$dash_background_color: if($variant == 'light', rgba($panel_bg, $panel_opacity), rgba($panel_bg, $panel_opacity + 0.1));
$dash_placeholder_size: 32px;
$dash_padding: $base_padding + 4px; // 10px
$dash_spacing: round($base_padding / 4);
$dash_bottom_margin: $base_margin * 4;
$dash_border_radius: $dash_radius;

// Stock
$dock_side_margin: $dash_bottom_margin / 4;
$dock_fixed_inner_margin: $dock_side_margin;

// Adapted to $dock_bottom_margin

@function shrink($val) {
    @return round($val / 4);
}

@function opposite($val) {
    @return map-get(
        (
            left: right,
            right: left,
            top: bottom,
            bottom: top,
        ),
        $val
    );
}

$osd_fg_color: #eeeeec;

@each $side in bottom, top, left, right {
    #dashtodockContainer.#{$side} {
        #dash {
            margin: 0;
            padding: 0;
            padding-#{$side}: $dash_padding;
            padding-#{opposite($side)}: $dash_padding;

            .dash-background {
                margin: 0;
                margin-#{$side}: $dock_side_margin;
                padding: $dash_padding;
            }

            .dash-separator {
                @if $side == top or $side == bottom {
                    margin-bottom: 0;
                } @else {
                    height: 1px;
                    margin: ($dash_spacing + ($dash_padding / 2)) 0;
                    background-color: transparentize($osd_fg_color, 0.7);
                }
            }

            .dash-item-container {
                .app-well-app,
                .show-apps {
                    padding: $dash_spacing;
                    padding-#{$side}: $dash_padding + $dock_side_margin;
                    padding-#{opposite($side)}: $dash_padding;
                }
            }
        }

        &.shrink {
            #dash {
                .dash-background {
                    margin-#{$side}: shrink($dock_side_margin);
                    padding: shrink($dash_padding);
                    border-radius: $dash_border_radius - $dash_padding + shrink($dash_padding);
                }

                #dashtodockDashContainer {
                    padding: shrink($dash_padding);
                }

                .dash-item-container {
                    .app-well-app,
                    .show-apps {
                        padding: shrink($dash_spacing);
                        padding-#{$side}: shrink($dash_padding + $dock_side_margin);
                        padding-#{opposite($side)}: shrink($dash_padding);
                    }
                }
            }

            &.fixed {
                #dash {
                    .dash-background {
                        margin-#{opposite($side)}: shrink($dock_fixed_inner_margin);
                    }

                    .dash-item-container {
                        .app-well-app,
                        .show-apps {
                            padding-#{opposite($side)}: shrink($dash_padding + $dock_fixed_inner_margin);
                        }
                    }
                }
            }
        }

        &.fixed {
            #dash {
                .dash-background {
                    margin-#{opposite($side)}: $dock_fixed_inner_margin;
                }

                .dash-item-container {
                    .app-well-app,
                    .show-apps {
                        padding-#{opposite($side)}: $dash_padding + $dock_fixed_inner_margin;
                    }
                }
            }
        }
    }
}

@each $side in bottom, top, left, right {
    #dashtodockContainer.extended.#{$side} {
        #dash {
            margin: 0;
            padding: 0;

            .dash-background {
                margin: 0;
                margin-#{$side}: 0 !important;
                border-radius: 0;
                padding: 0;
                padding-#{$side}: $dash_padding;
                padding-#{opposite($side)}: $dash_padding;
            }

            #dashtodockDashContainer {
                padding: $dash_padding;
                padding-#{$side}: 0;
                padding-#{opposite($side)}: 0;
            }

            .dash-item-container {
                .app-well-app,
                .show-apps {
                    padding: $dash_spacing;
                    padding-#{$side}: $dash_padding;
                    padding-#{opposite($side)}: $dash_padding;
                }

                .show-apps {
                    @if $side == top or $side == bottom {
                        margin-left: $dash_padding;
                    } @else {
                        margin-top: $dash_padding;
                    }
                }
            }
        }

        &.shrink {
            #dash {
                .dash-background {
                    margin: 0;
                    margin-#{$side}: 0 !important;
                    border-radius: 0;
                    padding: 0;
                    padding-#{$side}: shrink($dash_padding - $dash_spacing);
                    padding-#{opposite($side)}: shrink($dash_padding - $dash_spacing);
                }

                #dashtodockDashContainer {
                    padding: shrink($dash_padding - $dash_spacing);
                    padding-#{$side}: 0;
                    padding-#{opposite($side)}: 0;
                }

                .dash-item-container {
                    .app-well-app,
                    .show-apps {
                        padding: shrink($dash_spacing);
                        padding-#{$side}: shrink($dash_padding);
                        padding-#{opposite($side)}: shrink($dash_padding);
                    }

                   .show-apps {
                        @if $side == top or $side == bottom {
                            margin-left: shrink($dash_spacing);
                        } @else {
                            margin-top: shrink($dash_spacing);
                        }
                    }
                }
            }
        }

        &.shrink.fixed {
            #dash {
                .dash-background {
                    margin-#{opposite($side)}: 0;
                }
            }
        }
    }
}

#dashtodockContainer.top.shrink #dash .dash-background {
    margin-top: 4px;
    margin-bottom: 0;
}

#dashtodockContainer.straight-corner #dash .dash-background,
#dashtodockContainer.shrink.straight-corner #dash .dash-background {
    border-radius: 0px;
}

/* Scrollview style */
.bottom #dashtodockDashScrollview,
.top #dashtodockDashScrollview {
    -st-hfade-offset: 24px;
}

.left #dashtodockDashScrollview,
.right #dashtodockDashScrollview {
    -st-vfade-offset: 24px;
}

#dashtodockContainer.running-dots .dash-item-container > StButton,
#dashtodockContainer.dashtodock .dash-item-container > StButton {
    transition-duration: 250;
    background-size: contain;
}

/* Running and focused application style */

#dashtodockContainer.running-dots .app-well-app.running > .overview-icon,
#dashtodockContainer.dashtodock .app-well-app.running > .overview-icon {
    background-image: none;
}

#dashtodockContainer.running-dots .app-well-app.focused .overview-icon,
#dashtodockContainer.dashtodock .app-well-app.focused .overview-icon {
    background-color: rgba(238, 238, 236, 0.2);
}

#dashtodockContainer.dashtodock #dash .dash-background {
    background: $dash_background_color;
    border-width: 0;
}

#dashtodockContainer.dashtodock .progress-bar {
    /* Customization of the progress bar style, e.g.:
      -progress-bar-background: rgba(0.8, 0.8, 0.8, 1);
      -progress-bar-border: rgba(0.9, 0.9, 0.9, 1);
    */
}

#dashtodockContainer.top #dash .placeholder,
#dashtodockContainer.bottom #dash .placeholder {
    width: $dash_placeholder_size;
    height: 1px;
}

/*
 * This is applied to a dummy actor. Only the alpha value for the background and border color
 * and the transition-duration are used
 */
#dashtodockContainer.dummy-opaque {
    background-color: rgba(0, 0, 0, 0.8);
    border-color: rgba(0, 0, 0, 0.4);
    transition-duration: 300ms;
}

/*
 * This is applied to a dummy actor. Only the alpha value for the background and border color
 * and the transition-duration are used
 */
#dashtodockContainer.dummy-transparent {
    background-color: rgba(0, 0, 0, 0.2);
    border-color: rgba(0, 0, 0, 0.1);
    transition-duration: 500ms;
}

#dashtodockContainer .number-overlay {
    color: rgba(255, 255, 255, 1);
    background-color: rgba(0, 0, 0, 0.8);
    text-align: center;
}

#dashtodockContainer .notification-badge {
    color: rgba(255, 255, 255, 1);
    background-color: rgba(255, 0, 0, 1);
    padding: 0.2em 0.5em;
    border-radius: 1em;
    font-weight: bold;
    text-align: center;
    margin: 2px;
}

#dashtodockPreviewSeparator.popup-separator-menu-item-horizontal {
    width: 1px;
    height: auto;
    border-right-width: 1px;
    margin: 32px 0px;
}

.dashtodock-app-well-preview-menu-item {
    padding: 1em 1em 0.5em 1em;
}

#dashtodockContainer .metro .overview-icon {
    border-radius: 0px;
}

#dashtodockContainer.bottom .metro.running2.focused,
#dashtodockContainer.bottom .metro.running3.focused,
#dashtodockContainer.bottom .metro.running4.focused,
#dashtodockContainer.top .metro.running2.focused,
#dashtodockContainer.top .metro.running3.focused,
#dashtodockContainer.top .metro.running4.focused {
    background-image: url("./media/highlight_stacked_bg.svg");
    background-position: 0px 0px;
    background-size: contain;
}

#dashtodockContainer.left .metro.running2.focused,
#dashtodockContainer.left .metro.running3.focused,
#dashtodockContainer.left .metro.running4.focused,
#dashtodockContainer.right .metro.running2.focused,
#dashtodockContainer.right .metro.running3.focused,
#dashtodockContainer.right .metro.running4.focused {
    background-image: url("./media/highlight_stacked_bg_h.svg");
    background-position: 0px 0px;
    background-size: contain;
}
