@import 'events.css';

:root {
  --insensitive-fg-color: color-mix(in srgb, var(--window-fg-color) 50%, transparent);

  --focus-ring-transition:
    outline-color 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
    outline-width 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
    outline-offset 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --focus-ring-color: rgb(from var(--accent-color) r g b / var(--dim-opacity));
}

/* Header labels */
calendar-view {
  font-size: 10pt;
}

calendar-view box.header label {
  opacity: var(--dim-opacity);
}

calendar-view.current,
weekgrid.current {
  background-color: rgb(from var(--accent-bg-color) r g b / 30%);
}

calendar-view:selected {
  color: var(--accent-color);
  font-weight: bold;
}

popover.alarms modelbutton {
  outline: 0 solid transparent;
  outline-offset: 3px;
  transition: var(--focus-ring-transition);
  padding-top: 2px;
  padding-bottom: 2px;
}

popover.alarms modelbutton:focus:focus-visible {
  outline-color: var(--focus-ring-color);
  outline-width: 2px;
  outline-offset: -2px;
}

/* Quick Add Popover */
popover.quick-add-popover > contents {
  padding: 0;
}

/* Event Popover */
popover.event-popover,
popover.event-popover > contents {
  padding: 0;
}

/* calendar popover */
.calendar-list {
  background-color: transparent;
}

.calendar-list > row {
  background-color: transparent;
  border-radius: 10px;
}

.calendar-list > list {
  border-radius: 4px;
}

list.compact > row > box.header {
  margin-left: 9px;
  margin-right: 4.5px;
  border-spacing: 4.5px;
  min-height: 37.5px;
}

entry.compact > text {
  min-height: 24px;
  padding: 12px 6px;
  border-radius: 12px;
}

/* values copied from libadwaita */
.calendars-list > row:selected {
  background-color: transparent;
}

.calendars-list > row:selected:hover {
  background-image: image(color-mix(in srgb, currentColor 3%, transparent));
}

.calendars-list > row:selected:active {
  background-image: image(color-mix(in srgb, currentColor 8%, transparent));
}

/* Date chooser */

/* month/year controls */

datechooser navigator {
  /* add some space between the two controls */
  margin-right: 6px;
  margin-left: 6px;
  margin-bottom: 6px;

  outline: 0 solid transparent;
  border-radius: 9px;
  outline-offset: 6px;
  transition: var(--focus-ring-transition);
}

datechooser navigator:focus:focus-visible {
  outline-color: var(--focus-ring-color);
  outline-width: 2px;
  outline-offset: 0px;
}

datechooser navigator label {
  font-weight: bold;
}

datechooser navigator button {
  padding: 0;
  outline: unset;
}

/* week numbers, with a style resembling GNOME Shell's */
datechooser .weeknum {
  --padding: 4px;
  --base-color: var(--insensitive-fg-color);

  --_border-width: var(--border-width, 0px);
  --_padding: calc(var(--padding) - var(--_border-width));

  font-size: smaller;
  font-weight: bold;
  margin: 6px;
  padding: var(--_padding);
  border: var(--_border-width) solid rgb(from currentColor r g b / 50%);
  border-radius: 5px;
  background-color: rgb(from var(--base-color) r g b / 5%);
  color: var(--base-color);
}
/* high contrast */
@media (prefers-contrast: more) {
  datechooser .weeknum {
    --border-width: 1px;
    --base-color: var(--window-fg-color);
  }
}

/* day names */
datechooser .weekday {
  color: var(--insensitive-fg-color);
  font-size: smaller;
  font-weight: bold;
}

/* days */
datechooser button.day {
  font-size: 10pt;
  font-weight: normal;
  min-height: 26px;
  min-width: 26px;
  margin: 2px;
  padding: 3px;
  transition: none;
}

datechooser button.day dot {
  background-color: var(--window-fg-color);
  border-radius: 50%;
  min-height: 3px;
  min-width: 3px;
}

datechooser button.day:selected dot {
  background-color: var(--accent-fg-color);
}

datechooser button.day.non-workday {
  color: var(--insensitive-fg-color);
}

datechooser button.day:selected {
  background-color: var(--accent-bg-color);
  color: var(--accent-fg-color);
  font-weight: bold;
}

datechooser button.day.today {
  color: var(--accent-color);
}

datechooser button.day.today dot {
  background-color: var(--accent-color);
}

datechooser button.day.today:selected {
  background-color: var(--accent-bg-color);
  color: var(--accent-fg-color);
}

datechooser button.day.today:selected dot {
  background-color: var(--accent-fg-color);
}

datechooser button.day.other-month:not(:hover),
datechooser button.day.other-month:backdrop {
  color: rgb(from currentColor r g b / 50%);
}

datechooser button.day.other-month:not(:hover) dot,
datechooser button.day.other-month:backdrop dot {
  background-color: rgb(from currentColor r g b / 50%);
}

datechooser button.day.other-month:hover:not(:backdrop) {
  color: var(--insensitive-fg-color);
}

datechooser button.day.other-month:hover:not(:backdrop) dot {
  background-color: var(--insensitive-fg-color);
}

label.month-name {
  font-size: 16pt;
  font-weight: bold;
  color: var(--accent-color);
  padding: 12px;
}

/* Week View CSS */

weekhourbar > label {
  font-size: 10pt;
  padding: 4px 6px;
}

.week-main-content {
  border: 0 solid var(--border-color);
  border-width: 1px 0;
}

weekgrid > widget.now-strip {
  background-color: rgb(from var(--accent-bg-color) r g b / 80%);
  margin: 0 0 0 1px;
  min-height: 2px;
}

weekgrid.dnd, .week-header.dnd {
  background-color: rgb(from var(--accent-bg-color) r g b / 25%);
}

weekheader > selection,
weekgrid > selection,
weekheader > droptarget,
weekgrid > droptarget {
  background-color: rgb(from var(--accent-bg-color) r g b / 25%);
  border-radius: 6px;
  margin: 2px 0 1px 2px;
}

button.week-header-expander:checked image {
  transform: rotateZ(180deg);
  transition: 200ms;
}

/*
 * Month cell
 */

monthcell {
  --bg-color: rgb(from var(--window-fg-color) r g b / 0);
  --separator-color: rgb(from var(--border-color) r g b / calc(alpha + 7.5%));

  box-shadow:
    0 -1px var(--border-color),
    var(--offset) 0 var(--border-color);
  transition:
    background-color 200ms,
    var(--focus-ring-transition);
  background-color: var(--bg-color);
  outline: 0 solid transparent;
  outline-offset: 4px;
}

monthcell .overflow {
  border-radius: 6px;
}

monthcell .day-label {
  border-radius: 6px;
  padding: 0px 6px 0px 6px;
}

/* First day of month */
monthcell label.first-day {
  font-weight: 700;
  color: white;
  background-color: var(--dark-2);
}

@media (prefers-color-scheme: dark) {
  monthcell label.first-day {
    color: black;
    background-color: var(--light-3);
  }
}

/* Today */
monthcell.today label.day-label {
  font-weight: 700;
  color: var(--accent-fg-color);
  background-color: var(--accent-bg-color);
}

monthcell:hover {
  background-color: rgb(from var(--bg-color) r g b / calc(alpha + 3.75%));
}

monthcell:focus:focus-visible {
  outline-color: var(--focus-ring-color);
  outline-width: 2px;
  outline-offset: -2px;
}

/* Selected */
monthcell:selected {
  background-color:
    color-mix(in srgb-linear, var(--bg-color) 82.5%, var(--accent-bg-color));
}

monthcell:hover:selected {
  background-color:
    color-mix(in srgb-linear, var(--bg-color) 77.5%, var(--accent-bg-color));
}

monthcell:selected label.day-label {
  font-weight: bold;
}

/* Button */
monthcell button {
  font-weight: normal;
  padding: 0 4px;
  border-radius: 0;
  border-bottom: none;
  border-right: none;
}

/* Separators */
monthcell:dir(ltr) {
  --offset: -1px;
}

monthcell:dir(rtl) {
  --offset: 1px;
}

monthcell.separator-top {
  box-shadow:
    0 -1px rgb(from var(--separator-color) r g b / calc(alpha * 2)),
    var(--offset) 0 var(--border-color);
}

monthcell.separator-top.separator-side {
  box-shadow:
    0 -1px var(--separator-color),
    var(--offset) 0 var(--separator-color),
    var(--offset) -1px var(--separator-color);
}

/*
 * Month row
 */

calendar-view.month-view {
  --raised-shade-color-base:
    color-mix(in srgb, var(--headerbar-shade-color) 50%, transparent);

  box-shadow:
    inset 0 -1px var(--raised-shade-color, var(--raised-shade-color-base)),
    inset 0 -2px 4px var(--raised-shade-color-base);
}
/* high contrast */
@media (prefers-contrast: more) {
  calendar-view.month-view {
    --raised-shade-color: var(--border-color);
    --raised-shade-color-base: transparent;
  }
}

calendar-view.month-view > box.month-header {
  padding-bottom: 6px;
  box-shadow:
    0 1px var(--raised-shade-color, var(--raised-shade-color-base)),
    0 2px 4px var(--raised-shade-color-base);
}

/*
 * Month popover
 */

monthpopover > box {
  margin: 4px;
  padding: 12px;
  background-color: var(--popover-bg-color);
}

.notes-section box > textview {
  border-radius: 8px;
  padding: 8px;
}

.notes-section box > textview > text {
  background: none;
}

/* Agenda View CSS */

agenda-view listview > row {
  background: none;
}

agenda-view agendaviewdayrow {
  margin-left: 9px;
  margin-right: 9px;
  margin-bottom: 3px;
}

agenda-view agendaviewdayrow > box > label {
  padding: 6px 0;
}

agenda-view agendaviewdayrow list > row,
agenda-view agendaviewdayrow list > label {
  border-radius: 6px;
  background: none;
}

.sidebar-pane agenda-view .background {
  background: none;
  color: inherit;
}

label.no-events {
  font-style: italic;
}

/*
 * Search
 */

searchbutton > popover > arrow {
  background: none;
  border: none;
}

searchbutton > popover listview > row:selected {
  background-color: rgb(from var(--accent-bg-color) r g b / 11%);
}
/* dark mode */
@media (prefers-color-scheme: dark) {
  searchbutton > popover listview > row:selected {
    background-color: rgb(from var(--accent-bg-color) r g b / 20%);
  }
}

/*
 * Month selector
 */

datechooser {
  padding: 6px;
}

datechooser .current-week {
  background: rgb(from currentColor r g b / 10%);
  color: var(--headerbar-fg-color);
  border-radius: 9px;
}

menubutton stack > box {
  border-spacing: 4px;
}

/*
 * Sync Indicator
 */

syncindicator {
  padding: 6px;
}

/*
 * Calendar list-style
 */

/* per https://gitlab.gnome.org/GNOME/libadwaita/-/blob/1ff329681652fa99ecac89092d7639063a5972cc/src/stylesheet/widgets/_menus.scss */
.calendar-list check {
  min-width: 14px;
  min-height: 14px;
  -gtk-icon-size: 14px;
  padding: 2px;
  background: none;
  box-shadow: none;
  color: inherit;
}

/*
 * Styles for the drop overlay.
 * From Amberol https://gitlab.gnome.org/World/amberol/-/blob/0dd6250ffd294b14532c428dcb76ae42086a5923/src/gtk/style.css
 */

/* Removes the default style */
.drop-target:drop(active) {
  box-shadow: none;
}

/* Custom style for the drop overlay area */
.drop-overlay-area {
  padding: 32px;
  color: var(--accent-fg-color);
  background-color: rgb(from var(--accent-bg-color) r g b / 50%);
}

.blurred {
  filter: blur(6px);
}

/* Participants section of the event editor dialog */
.participants-count-label {
   border-radius: 12px;
   background-color: color-mix(in srgb, currentColor 10%, transparent);
   padding: 6px 9px;
}
