/* Date/Time Menu */

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

%calendar-item {
  margin: 0;
  border: 0;
  border-radius: $corner-radius;

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

  &:focus {
    background-color: overlay("focus", $on-surface);
  }

  &:hover {
    background-color: overlay("hover", $on-surface);
  }

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

.clock-display-box {
  spacing: 0;

  .clock {
    padding-left: $panel-button-hpadding;
    padding-right: $panel-button-hpadding;
  }
}

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

// Calendar menu side column
.datemenu-calendar-column {
  spacing: $calendar-column-spacing;
  padding: 0;
  border: 0 solid divider($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: $calendar-column-spacing;
    margin: $calendar-column-margin;
  }
}

.events-section-title {
  @extend %calendar-item;
  min-height: $menuitem-size - 8px * 2;
  padding: 8px;
  color: hint($on-surface) !important;
  font-weight: bold;
}

/* today button (the date) */
.datemenu-today-button {
  @extend %calendar-item;
  margin: $calendar-column-margin;
  min-height: $menuitem-size * 2 - 8px * 2;
  padding: 8px;

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

  // date label
  .date-label {
    @include type(headline5);
  }
}

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

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

    &:focus {
      background-color: overlay("focus", $on-surface);
    }
  }

  // prev/next month icons
  @if $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: $duration;
    width: $menuitem-size;
    height: $menuitem-size;
    margin: 2px;
    border-radius: $menuitem-size / 2;
    background-color: transparent;
    color: hint($on-surface);

    &:focus {
      background-color: overlay("focus", $on-surface);
    }

    &:hover {
      background-color: overlay("hover", $on-surface);
    }

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

  .calendar-day-base {
    transition-duration: $duration;
    width: $menuitem-size;
    height: $menuitem-size;
    margin: 2px;
    padding: 0;
    border: 0;
    border-radius: $menuitem-size / 2;
    @include type(caption);
    font-feature-settings: "tnum";
    text-align: center;

    &:focus {
      background-color: overlay("focus", $on-surface);
    }

    &:hover {
      background-color: overlay("hover", $on-surface);
    }

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

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

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

      &:focus {
        background-color: overlay("focus", $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 hint($on-surface);
    background-color: rgba($surface-z8, .01); // to draw box-shadow
    color: inherit;
    font-weight: normal;

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

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

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

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

      &,
      &:hover,
      &:focus {
        background-color: $primary;
        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: disabled-hint($on-surface) !important;
  }

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

    @if $version < 3.38 {
      height: $menuitem-size - 7px;
      padding: 7px 0 0;
    }
  }
}

@if $version >= 3.38 {
  /* Events */
  .events-button {
    @extend %calendar-item;
    min-height: $menuitem-size * 2 - 8px * 2;
    padding: 8px;

    .events-box {
      spacing: 8px;
    }

    .events-list {
      spacing: 8px;
    }

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

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

/* World clocks */
.world-clocks-button {
  @extend %calendar-item;
  min-height: $menuitem-size - 8px * 2;
  padding: 8px;

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

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

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

  // timezone time
  .world-clocks-time {
    color: hint($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: disabled($on-surface);
    font-size: 1em;
    font-feature-settings: "tnum";
  }
}

/* Weather */
.weather-button {
  @extend %calendar-item;
  min-height: $menuitem-size * 2 - 8px * 2;
  padding: 8px;

  .weather-box {
    spacing: 0.4em;
  }

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

  .weather-header {
    color: hint($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: hint($on-surface);
    @include type(caption);
    font-feature-settings: "tnum";
  }

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

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