// based css:
// https://github.com/solus-project/budgie-desktop/tree/master/src/theme

/******************
 * Budgie Desktop *
 ******************/
// Container for both the "panel" area and the shadow. Wise to keep
// this transparent..
.budgie-container { background-color: transparent; }

.budgie-settings-window buttonbox.inline-toolbar {
  border-style: none none solid;

  button {
    border-radius: $corner-radius;
    -gtk-outline-radius: $corner-radius;

    @extend %simple_flat_button;
  }
}

.budgie-popover {
  border-style: solid;
  border-width: 1px;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.3);
  border-radius: $corner-radius + 1px;
  box-shadow: $shadow-2;
  background-color: $surface;

  .container { padding: 2px; }

  border { border: none; }

  list { background-color: transparent; }

  row {
    padding: 0;

    &:hover { box-shadow: none; }
  }

  button.flat:not(.image-button) {
    min-height: $menuitem-size;
    padding: 0 8px;
    color: $text;
    font-weight: normal;

    &:disabled { color: $text-disabled; }
  }

  &.budgie-menu {
    .container { padding: 0; }

    .sidebar,
    scrollbar,
    entry.search { background-color: transparent; }

    entry.search {
      border-bottom: 1px solid $divider;
      border-image: none;
      border-radius: 0;
      box-shadow: none;
      font-size: 120%;
    }

    button.flat:not(.image-button) {
      @extend row.activatable;

      min-height: 32px;
      padding: 0 8px;
      border-radius: 0;

      &:checked { @extend %selected_items; }

      &:checked:disabled { background-color: transparent; } // remove pointless indicator
    }
  }

  &.user-menu {
    .container { padding: 8px; }

    separator { margin: 4px 0; }
  }

  &.sound-popover {
    separator { margin: 3px 0; }
  }

  &.night-light-indicator {
    .container { padding: 8px; }
  }

  &.places-menu {
    .container { padding: 8px; }

    // FIXME: untested
    .message-bar {
      // margin-bottom: 4px;
    }

    .name-button {
      image {
        &:dir(ltr) { margin-right: 8px - 5px; }
        &:dir(rtl) { margin-left: 8px - 5px; }
      }
    }

    .unmount-button {
      margin: ($menuitem-size - $small-size) / 2;
      padding: 0;
    }

    .places-section-header {
    }

    .places-list:not(.always-expand) {
      margin-top: 4px;
      padding-top: 4px;
      border-top: 1px solid $divider;
    }

    // FIXME: untested
    .unlock-area {
      entry {
      }

      button {
      }
    }

    // use such sizes for consistency with other hard-coded dim-label sizes
    .alternative-label {
      padding: 3px;
      font-size: 15px;
    }
  }

  &.workspace-popover {
    .container { padding: 8px; }

    separator { margin: 4px 0; }

    flowboxchild { padding: 0; }
  }
}

// FIXME: workspace has unnecessary/unknown margin
.workspace-switcher {
  .workspace-layout {
    border: 0 solid on($panel, divider);

    .top &,
    .bottom & {
      &:dir(ltr) { border-left-width: 1px; }

      &:dir(rtl) { border-right-width: 1px; }
    }

    .left &,
    .right & { border-top-width: 1px; }
  }

  .workspace-item,
  .workspace-add-button {
    border: 0 solid on($panel, divider);

    .top &,
    .bottom & {
      &:dir(ltr) { border-right-width: 1px; }

      &:dir(rtl) { border-left-width: 1px; }
    }

    .left &,
    .right & { border-bottom-width: 1px; }
  }

  .workspace-item {
    transition: $transition;

    &.current-workspace { background-color: $overlay-checked; }
  }

  .workspace-add-button {
    &:hover { box-shadow: none; }

    &:active { background-image: none; }

    &:active image { margin: 1px 0 -1px; }
  }

  .workspace-icon-button {
    .budgie-panel & { // to overwrite the .budgie-panel button style below
      min-height: 24px;
      min-width: 24px;
      padding: 0;
      border-radius: $corner-radius;
    }
  }
}

// Menu Button
button.budgie-menu-launcher {
  // padding: 0 2px;
}

// Raven Trigger
button.raven-trigger {
  // padding: 0 4px;
}

// Panel
.budgie-panel {
  transition: background-color $duration $ease-out;
  background-color: $panel;
  color: on($panel, secondary);
  font-weight: 500;

  &.transparent { background-color: $scrim; }

  button {
    @extend %flat_button;
    @extend %button_selected.flat;

    min-height: 16px;
    min-width: 16px;
    padding: 0;
    border-radius: 0;
  }

  &.horizontal button { padding: 0 4px; }

  &.vertical button { padding: 4px 0; }

  separator { background-color: on($panel, track); }

  // used to indicate unread notifications
  .alert { color: $destructive; }

  // End Section needs to be fancy
  .end-region {
    // background-color: rgba(0,0,0,0.2);
  }

  // budgie-pixel-saver-applet
  .titlebar:not(headerbar) {
    min-height: 0;
    padding: 0;
    box-shadow: none;
    background-color: transparent;
    color: on($panel);

    button:not(.suggested-action):not(.destructive-action) {
      color: on($panel, secondary);

      &:hover,
      &:active { color: on($panel); }
    }
  }

  // Tasklist
  #tasklist-button {
    padding: 0 4px;

    @extend %underscores;
  }

  &.vertical #tasklist-button { min-height: 32px; }

  // Icon Tasklist
  button.flat.launcher {
    padding: 0;

    @extend %underscores;

    // for indicator colors
    &:not(:checked) {
      color: on($panel, disabled);

      &:hover, &:active { color: on($panel, secondary); }

      &:disabled { color: on($panel, secondary-disabled); }
    }
  }

  .unpinned button.flat.launcher,
  .pinned button.flat.launcher.running { @extend %underscores:checked; }
}

%underscores {
  @each $pos, $b_pos, $b_wid in (top,    center calc(1px),        2 0 0 0 / 2px 0 0 0),
                                (bottom, center calc(100% - 1px), 0 0 2 0 / 0 0 2px 0),
                                (left,   calc(1px) center,        0 0 0 2 / 0 0 0 2px),
                                (right,  calc(100% - 1px) center, 0 2 0 0 / 0 2px 0 0) {
    .#{$pos} & {
      & {
        border-image: radial-gradient(circle closest-corner at #{$b_pos},
                                      currentColor 0%,
                                      transparent 0%)
                                      0 0 0 0 / 0 0 0 0;
      }

      &:checked {
        border-image: radial-gradient(circle closest-corner at #{$b_pos},
                                      currentColor 100%,
                                      transparent 0%)
                                      #{$b_wid};
      }
    }
  }
}

frame.raven-frame > border {
  border-style: none;
  box-shadow: $shadow-4;
}

$pos_list: ((top, bottom), (bottom, top), (left, right), (right, left));

@each $pos, $b_pos in $pos_list {
  // Panel borders
  // .#{$pos} .budgie-panel { border-#{$b_pos}: 1px solid $frame; }

  // Raven borders
  .#{$pos} frame.raven-frame > border {
    margin-#{$b_pos}: 32px;
    // border-#{$b_pos}: 1px solid $frame;
  }

  // Shadows
  // .#{$pos} .shadow-block { background-image: linear-gradient(to $b_pos, $frame, transparent); }
}

// Raven
.raven {
  background-color: $surface;

  > box { margin-bottom: -10px; } // remove extra space between box and .raven-header.bottom

  stackswitcher.linked > button {
    @extend %flat_button;

    border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                  $primary 0%,
                                  transparent 0%)
                                  0 0 0 / 0 0 0px;
    border-radius: 0;

    &:checked {
      border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                    $primary 100%,
                                    transparent 0%)
                                    0 0 2 / 0 0 2px;
      background-color: transparent;
    }
  }

  .raven-header {
    min-height: $medium-size;
    padding: 3px;

    &.top {
      padding: 0;
      border-bottom: 1px solid $divider;

      stackswitcher button {
        margin: -4px 0 -5px; // remove unwanted vertical margins
        padding: 0 16px;
        min-height: $large-size;
      }
    }

    &.bottom { border-top: 1px solid $divider; }
  }

  stack {
    .raven-header { margin-top: -6px; } // remove extra space in Notifications stack

    scrolledwindow .raven-header { margin-top: -8px; } // remove extra spaces in Applets stack
  }

  .expander-button { @extend %circular_button; }

  .raven-background {
    border-style: solid none;
    border-width: 1px;
    border-color: $divider;
    background-color: $base;

    // &.middle { border-bottom-style: none; } // applet background between two headers

    > overlay > widget > image { color: $divider; }
  }

  scrolledwindow.raven-background { border-bottom-style: none; }

  .powerstrip button {
    margin: 2px 0 1px;
    padding: ($large-size - 24px) / 2;
  }

  .option-subtitle { font-size: smaller; }
}

// Calendar
calendar.raven-calendar {
  // padding: 3px;
  border-style: none;
  background-color: transparent;

  &:selected {
    @extend %selected_items;

    border-radius: $corner-radius;
  }
}

// MPRIS Applet
.raven-mpris {
  background-color: $scrim;
  color: on($scrim);

  label { min-height: 24px; }

  button.image-button {
    padding: ($large-size - 24px) / 2;

    @extend %button_selected.flat;
  }
}

// Notifications
.budgie-notification-window { background-color: transparent; }

.budgie-notification {
  .notification-title { font-size: 120%; }

  .notification-body { @extend .dim-label; }
}

// On Screen Display in Budgie
.budgie-osd-window {
  @extend .budgie-notification-window;
}

// Internal part of the OSD
.budgie-osd {
  .budgie-osd-text { font-size: 120%; }
}

// Alt+tab switcher in Budgie
.budgie-switcher-window {
  @extend .budgie-notification-window;
}

// Internal part of the Switcher
.budgie-switcher {
  @extend .budgie-notification;
}

.drop-shadow {
  margin: 5px 9px;
  padding: 3px;
  border-radius: $corner-radius;
  box-shadow: $shadow-2, inset 0 1px highlight($surface);
  background-color: $surface;

  button { @extend %simple_flat_button; }

  .linked > button { border-radius: $corner-radius; }
}

%budgie_dialog {
  border-radius: $corner-radius;
  box-shadow: inset 0 1px highlight($surface);
  background-color: $surface;

  decoration { border-radius: $corner-radius; }
}

// Session Dialog
.budgie-session-dialog {
  @extend %budgie_dialog;

  label:not(:last-child),
  .dialog-title { font-size: 120%; }

  .linked.horizontal > button {
    padding: 8px 16px;
    border-top: 1px solid $divider;
    border-radius: 0;

    @extend %simple_flat_button;

    &:first-child { border-bottom-left-radius: $corner-radius; }

    &:last-child { border-bottom-right-radius: $corner-radius; }
  }
}

// PolKit Dialog
.budgie-polkit-dialog {
  @extend %budgie_dialog;

  .message { color: $text-secondary; }

  .failure { color: $destructive; }
}

// Run Dialog
.budgie-run-dialog {
  @extend %budgie_dialog;

  background-color: $base;

  entry.search {
    font-size: 120%;
    padding: $container-padding 8px + $container-padding;
    border-image: none;
    box-shadow: none;
    background-color: transparent;
  }

  list .dim-label { opacity: 1; }

  scrolledwindow { border-top: 1px solid $divider; }
}
