/* Date/Time Menu */

@use "../../../../theme";
@use "../../../../theme-color";
@use "../../gnome-shell";
@use "../../typography";

$column-spacing: 8px;
$column-margin: 0 8px;

@mixin item {
  margin: 0;
  border: 0;
  border-radius: theme.$corner-radius;

  &,
  &:focus,
  &:hover,
  &:active {
    border-color: transparent;
    box-shadow: none;
    background-color: transparent;
    color: inherit;
    text-shadow: none;
    icon-shadow: none;
    transition-duration: theme.$state-duration;
  }

  &:focus {
    background-color: theme-color.focus-overlay(theme-color.$on-surface);
  }

  &:hover {
    background-color: theme-color.hover-overlay(theme-color.$on-surface);
  }

  &:active {
    background-color: theme-color.pressed-overlay(theme-color.$on-surface);
    transition-duration: theme.$ripple-duration;
  }
}

// overall menu
#calendarArea {
  padding: 8px 16px;
}

// Calendar menu side column
.datemenu-calendar-column {
  spacing: $column-spacing;
  padding: 0;
  border: 0 solid theme-color.divider(theme-color.$on-surface);

  &:ltr {
    margin-right: 0;
    border-left-width: 0;
  }

  &:rtl {
    margin-left: 0;
    border-right-width: 0;
  }

  .datemenu-displays-section {
    padding-bottom: 0;
  }

  .datemenu-displays-box {
    spacing: $column-spacing;
    margin: $column-margin;
  }
}

.events-section-title {
  @include item;
  min-height: theme.$menu-item-height - 8px * 2;
  padding: 8px;
  color: theme-color.hint(theme-color.$on-surface) !important;
  font-weight: bold;
}

/* today button (the date) */
.datemenu-today-button {
  @include item;
  margin: $column-margin;
  min-height: theme.$menu-item-height * 2 - 8px * 2;
  padding: 8px;

  // weekday label
  .day-label {
    font-weight: normal;
    font-size: 1em;
  }

  // date label
  .date-label {
    @include typography.headline5;
  }
}

/* Calendar */
.calendar {
  @include item;
  margin: $column-margin;
  margin-bottom: 0;
  padding: 0;

  // month
  .calendar-month-label {
    transition-duration: theme.$state-duration;
    min-height: theme.$menu-item-height - 6px * 2;
    margin: 2px;
    padding: 6px 8px;
    border-radius: theme.$corner-radius;
    color: inherit;
    font-weight: bold;
    text-align: center;

    &:focus {
      background-color: theme-color.focus-overlay(theme-color.$on-surface);
    }
  }

  // prev/next month icons
  @if gnome-shell.$version >= 3.32 {
    .calendar-change-month-back StIcon,
    .calendar-change-month-forward StIcon {
      icon-size: 16px;
    }
  } @else {
    .calendar-change-month-back {
      background-image: url("assets/calendar-arrow-left.svg");

      &:rtl {
        background-image: url("assets/calendar-arrow-right.svg");
      }
    }

    .calendar-change-month-forward {
      background-image: url("assets/calendar-arrow-right.svg");

      &:rtl {
        background-image: url("assets/calendar-arrow-left.svg");
      }
    }
  }

  .pager-button {
    transition-duration: theme.$state-duration;
    width: theme.$menu-item-height;
    height: theme.$menu-item-height;
    margin: 2px;
    border-radius: theme.$menu-item-height / 2;
    background-color: transparent;
    color: theme-color.hint(theme-color.$on-surface);

    &:focus {
      background-color: theme-color.focus-overlay(theme-color.$on-surface);
    }

    &:hover {
      background-color: theme-color.hover-overlay(theme-color.$on-surface);
    }

    &:active {
      background-color: theme-color.pressed-overlay(theme-color.$on-surface);
      transition-duration: theme.$ripple-duration;
    }
  }

  .calendar-day-base {
    transition-duration: theme.$state-duration;
    width: theme.$menu-item-height;
    height: theme.$menu-item-height;
    margin: 2px;
    padding: 0;
    border: 0;
    border-radius: theme.$menu-item-height / 2;
    @include typography.caption;
    font-feature-settings: "tnum";
    text-align: center;

    &:focus {
      background-color: theme-color.focus-overlay(theme-color.$on-surface);
    }

    &:hover {
      background-color: theme-color.hover-overlay(theme-color.$on-surface);
    }

    &:active {
      transition-duration: theme.$ripple-duration;
      border-color: transparent;
      background-color: theme-color.pressed-overlay(theme-color.$on-surface);
      color: inherit;
    }

    &:selected {
      border-color: transparent;
      background-color: theme-color.$primary !important;
      color: theme-color.$on-primary !important;
      font-weight: 500 !important;
    }

    // day of week heading
    &.calendar-day-heading {
      width: theme.$menu-item-height;
      height: theme.$menu-item-height - 7px;
      margin-top: 2px;
      padding: 7px 0 0;
      border-radius: theme.$menu-item-height / 2;
      background-color: transparent;
      color: theme-color.disabled(theme-color.$on-surface);
      @include typography.caption;
      font-weight: bold;
      text-align: center;

      &:focus {
        background-color: theme-color.focus-overlay(theme-color.$on-surface);
      }
    }
  }

   //border collapse hack - see calendar.js
  .calendar-day {
    border-width: 0;
  }

  .calendar-day-top {
    border-top-width: 0;
  }

  .calendar-day-left {
    border-left-width: 0;
  }

  .calendar-work-day {
  }

  .calendar-nonwork-day {
    color: inherit;
  }

  // Today
  .calendar-today {
    border: 0;
    box-shadow: inset 0 0 0 1px theme-color.hint(theme-color.$on-surface);
    background-color: rgba(theme-color.$surface-z8, .01); // to draw box-shadow
    color: inherit;
    font-weight: normal;

    &:focus {
      background-color: theme-color.focus-overlay(theme-color.$on-surface);
      color: inherit;
    }

    &:hover {
      background-color: theme-color.hover-overlay(theme-color.$on-surface);
      color: inherit;
    }

    &:active {
      &,
      &:hover,
      &:focus {
        background-color: theme-color.pressed-overlay(theme-color.$on-surface);
        color: inherit;
      }
    }

    &:selected {
      box-shadow: inset 0 0 0 1px transparent;

      &,
      &:hover,
      &:focus {
        background-color: theme-color.$primary;
        color: theme-color.$on-primary;
      }
    }
  }

  .calendar-day-with-events {
    background-image: url("assets/calendar-event.svg");

    &,
    &.calendar-work-day {
      color: inherit;
      font-weight: normal;
    }
  }

  .calendar-other-month-day {
    color: theme-color.disabled-hint(theme-color.$on-surface) !important;
  }

  .calendar-week-number {
    width: theme.$menu-item-height;
    height: theme.$menu-item-height;
    margin: 2px;
    border-radius: theme.$menu-item-height / 2;
    background-color: transparent;
    color: theme-color.disabled(theme-color.$on-surface);
    font-weight: bold;
    font-size: 1em;
    text-align: center;

    @if gnome-shell.$version < 3.38 {
      height: theme.$menu-item-height - 7px;
      padding: 7px 0 0;
    }
  }
}

@if gnome-shell.$version >= 3.38 {
  /* Events */
  .events-button {
    @include item;
    min-height: theme.$menu-item-height * 2 - 8px * 2;
    padding: 8px;

    .events-box {
      spacing: 8px;
    }

    .events-list {
      spacing: 8px;
    }

    .events-title {
      color: theme-color.hint(theme-color.$on-surface);
      font-weight: bold;
      margin-bottom: 0;
    }

    .event-time {
      color: theme-color.hint(theme-color.$on-surface);
      @include typography.caption;
      font-feature-settings: "tnum";
    }
  }
}

/* World clocks */
.world-clocks-button {
  @include item;
  min-height: theme.$menu-item-height - 8px * 2;
  padding: 8px;

  .world-clocks-grid {
    spacing-rows: .4em;
    spacing-columns: .8em;
  }

  // title
  .world-clocks-header {
    color: theme-color.hint(theme-color.$on-surface);
    font-weight: bold;
  }

  // city label
  .world-clocks-city {
    color: inherit;
    font-weight: normal;
    font-size: 1em;
  }

  // timezone time
  .world-clocks-time {
    color: theme-color.hint(theme-color.$on-surface);
    font-weight: normal;
    font-size: 1em;
    font-feature-settings: "tnum";
    text-align: right;

    &:ltr {
      text-align: right;
    }

    &:rtl {
      text-align: left;
    }
  }

  // timezone offset label
  .world-clocks-timezone {
    color: theme-color.disabled(theme-color.$on-surface);
    font-size: 1em;
    font-feature-settings: "tnum";
  }
}

/* Weather */
.weather-button {
  @include item;
  min-height: theme.$menu-item-height * 2 - 8px * 2;
  padding: 8px;

  .weather-box {
    spacing: 0.4em;
  }

  .weather-header-box {
    spacing: 8px;
  }

  .weather-header {
    color: theme-color.hint(theme-color.$on-surface);
    font-weight: bold;

    &.location {
      font-weight: normal;
      font-size: 1em;
    }
  }

  .weather-grid {
    spacing-rows: .4em;
    spacing-columns: .8em;
  }

  .weather-forecast-time {
    padding-top: 0;
    padding-bottom: 0;
    color: theme-color.hint(theme-color.$on-surface);
    @include typography.caption;
    font-feature-settings: "tnum";
  }

  .weather-forecast-icon {
    icon-size: 32px;
  }

  .weather-forecast-temp {
    font-weight: bold;
  }
}
