/**
 * Convert a font size to a dynamic font size.
 * Fonts that participate in Dynamic Type should use
 * dynamic font sizes.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param unit (optional) - The unit to convert to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * Convert a font size to a dynamic font size but impose
 * a maximum font size.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
 * @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * Convert a font size to a dynamic font size but impose
 * a minimum font size.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
 * @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * Convert a font size to a dynamic font size but impose
 * maximum and minimum font sizes.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
 * @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
 * @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * A heuristic that applies CSS to tablet
 * viewports.
 *
 * Usage:
 * @include tablet-viewport() {
 *   :host {
 *     background-color: green;
 *   }
 * }
 */
/**
 * A heuristic that applies CSS to mobile
 * viewports (i.e. phones, not tablets).
 *
 * Usage:
 * @include mobile-viewport() {
 *   :host {
 *     background-color: blue;
 *   }
 * }
 */
:host {
  /**
   * @prop --background: The primary background of the datetime component.
   * @prop --background-rgb: The primary background of the datetime component in RGB format.
   * @prop --title-color: The text color of the title.
   *
   * @prop --wheel-highlight-background: The background of the highlight under the selected
   * item when using a wheel style layout, or in the month/year picker for grid style layouts.
   * @prop --wheel-highlight-border-radius: The border radius of the highlight under the selected
   * item when using a wheel style layout, or in the month/year picker for grid style layouts.
   * @prop --wheel-fade-background-rgb: The color of the gradient covering non-selected items
   * when using a wheel style layout, or in the month/year picker for grid style layouts. Must
   * be in RGB format, e.g. `255, 255, 255`.
   */
  display: flex;
  flex-flow: column;
  background: var(--background);
  overflow: hidden;
}

:host(.datetime-size-fixed) {
  width: auto;
  height: auto;
}

:host(.datetime-size-fixed:not(.datetime-prefer-wheel)) {
  max-width: 350px;
}

/**
 * This ensures that the picker is appropriately
 * sized and never truncates the text.
 */
:host(.datetime-size-fixed.datetime-prefer-wheel) {
  min-width: 350px;
  max-width: max-content;
}

:host(.datetime-size-cover) {
  width: 100%;
}

:host .calendar-body,
:host .datetime-year {
  opacity: 0;
}

:host(:not(.datetime-ready)) .datetime-year {
  position: absolute;
  pointer-events: none;
}

:host(.datetime-ready) .calendar-body {
  opacity: 1;
}

:host(.datetime-ready) .datetime-year {
  display: none;
  opacity: 1;
}

/**
 * Changing the physical order of the
 * picker columns in the DOM is added
 * work, so we just use `order` instead.
 *
 * The picker automatically configures
 * the text alignment, so when switching
 * the order we need to manually switch
 * the text alignment too.
 */
:host .wheel-order-year-first .day-column {
  order: 3;
  text-align: end;
}

:host .wheel-order-year-first .month-column {
  order: 2;
  text-align: end;
}

:host .wheel-order-year-first .year-column {
  order: 1;
  text-align: start;
}

/**
 * This allows the calendar to take
 * up 100% of the remaining height.
 * On iOS, if there are more than
 * 5 rows of dates, the dates should
 * be resized to fit into this
 * container.
 */
:host .datetime-calendar,
:host .datetime-year {
  display: flex;
  flex: 1 1 auto;
  flex-flow: column;
}

:host(.show-month-and-year) .datetime-year {
  display: flex;
}

:host(.show-month-and-year) .calendar-next-prev,
:host(.show-month-and-year) .calendar-days-of-week,
:host(.show-month-and-year) .calendar-body,
:host(.show-month-and-year) .datetime-time {
  display: none;
}

:host(.month-year-picker-open) .datetime-footer {
  display: none;
}

:host(.datetime-disabled) {
  pointer-events: none;
}
:host(.datetime-disabled) .calendar-days-of-week,
:host(.datetime-disabled) .datetime-time {
  opacity: 0.4;
}

:host(.datetime-readonly) {
  pointer-events: none;
  /**
   * Allow user to navigate months
   * while in readonly mode
   */
  /**
   * Disabled buttons should have full opacity
   * in readonly mode
   */
}
:host(.datetime-readonly) .calendar-action-buttons,
:host(.datetime-readonly) .calendar-body,
:host(.datetime-readonly) .datetime-year {
  pointer-events: initial;
}
:host(.datetime-readonly) .calendar-day[disabled]:not(.calendar-day-constrained),
:host(.datetime-readonly) .datetime-action-buttons ion-button[disabled] {
  opacity: 1;
}

/**
 * Title should not wrap
 * to the next line and should
 * show ellipsis instead.
 */
:host .datetime-header .datetime-title {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

:host .datetime-action-buttons.has-clear-button {
  width: 100%;
}

:host .datetime-action-buttons ion-buttons {
  display: flex;
  justify-content: space-between;
}

/**
 * The confirm and clear buttons are grouped in a
 * container so that they appear on the end opposite
 * of the cancel button.
 * We use display: flex so that the
 * wrapper only takes up as much
 * height as it needs.
 */
.datetime-action-buttons .datetime-action-buttons-container {
  display: flex;
}

/**
 * Date/Year button should be on
 * the opposite side of the component
 * as the Next/Prev buttons
 */
:host .calendar-action-buttons {
  display: flex;
  justify-content: space-between;
}

:host .calendar-action-buttons ion-button {
  --background: transparent;
}

:host .calendar-days-of-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

.calendar-days-of-week .day-of-week {
  /**
   * Center the days of the week within each cell
   * if the container size is changed as a result
   * of Dynamic Type.
   */
  -webkit-margin-start: auto;
  margin-inline-start: auto;
  -webkit-margin-end: auto;
  margin-inline-end: auto;
  margin-top: 0;
  margin-bottom: 0;
}

:host .calendar-body {
  /**
   * Show all calendar months inline
   * and allow them to take up 100% of
   * the free space. Do not use CSS Grid
   * here as there are issues with nested grid
   * on older browsers.
   */
  display: flex;
  flex-grow: 1;
  scroll-snap-type: x mandatory;
  /**
   * Need to explicitly set overflow-y: hidden
   * for older implementations of scroll snapping.
   */
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-width: none;
  /**
   * Hide blue outline on calendar body
   * when it is focused.
   */
  outline: none;
}

:host .calendar-body .calendar-month {
  display: flex;
  flex-flow: column;
  /**
   * Swiping should snap to at
   * most one month at a time.
   */
  scroll-snap-align: start;
  scroll-snap-stop: always;
  flex-shrink: 0;
  width: 100%;
}

:host .calendar-body .calendar-month-disabled {
  /**
   * Disables swipe gesture snapping for scroll-snap containers
   */
  scroll-snap-align: none;
}

/**
 * Hide scrollbars on Chrome and Safari
 */
:host .calendar-body::-webkit-scrollbar {
  display: none;
}

:host .calendar-body .calendar-month-grid {
  /**
   * Create 7 columns for
   * 7 days in a week.
   */
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

:host .calendar-day-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

/**
 * Center the day text vertically
 * and horizontally within its grid cell.
 */
.calendar-day {
  border-radius: 50%;
  -webkit-padding-start: 0px;
  padding-inline-start: 0px;
  -webkit-padding-end: 0px;
  padding-inline-end: 0px;
  padding-top: 0px;
  padding-bottom: 0px;
  -webkit-margin-start: 0px;
  margin-inline-start: 0px;
  -webkit-margin-end: 0px;
  margin-inline-end: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  background: none;
  color: currentColor;
  font-family: var(--ion-font-family, inherit);
  cursor: pointer;
  appearance: none;
  z-index: 0;
}

:host .calendar-day[disabled] {
  pointer-events: none;
  opacity: 0.4;
}

.calendar-day:not(.calendar-day-adjacent-day):focus {
  background: rgba(var(--ion-color-base-rgb), 0.2);
  box-shadow: 0px 0px 0px 4px rgba(var(--ion-color-base-rgb), 0.2);
}

:host .datetime-time {
  display: flex;
  justify-content: space-between;
}

:host(.datetime-presentation-time) .datetime-time {
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
  padding-bottom: 0;
}

:host ion-popover {
  --height: 200px;
}

:host .time-header {
  display: flex;
  align-items: center;
}

:host .time-body {
  border-radius: 8px;
  -webkit-padding-start: 12px;
  padding-inline-start: 12px;
  -webkit-padding-end: 12px;
  padding-inline-end: 12px;
  padding-top: 6px;
  padding-bottom: 6px;
  display: flex;
  border: none;
  background: var(--ion-color-step-300, var(--ion-background-color-step-300, #edeef0));
  color: var(--ion-text-color, #000);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  appearance: none;
}

:host .time-body-active {
  color: var(--ion-color-base);
}

:host(.in-item) {
  position: static;
}

:host(.show-month-and-year) .calendar-action-buttons .calendar-month-year-toggle {
  color: var(--ion-color-base);
}

.calendar-month-year {
  min-width: 0;
}

.calendar-month-year-toggle {
  font-family: inherit;
  font-size: inherit;
  font-style: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-decoration: inherit;
  text-indent: inherit;
  text-overflow: inherit;
  text-transform: inherit;
  text-align: inherit;
  white-space: inherit;
  color: inherit;
  position: relative;
  border: 0;
  outline: none;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}
.calendar-month-year-toggle::after {
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  position: absolute;
  content: "";
  opacity: 0;
  transition: opacity 15ms linear, background-color 15ms linear;
  z-index: -1;
}
.calendar-month-year-toggle.ion-focused::after {
  background: currentColor;
}
.calendar-month-year-toggle:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.calendar-month-year-toggle ion-icon {
  -webkit-padding-start: 4px;
  padding-inline-start: 4px;
  -webkit-padding-end: 0;
  padding-inline-end: 0;
  padding-top: 0;
  padding-bottom: 0;
  flex-shrink: 0;
}

.calendar-month-year-toggle #toggle-wrapper {
  display: inline-flex;
  align-items: center;
}

ion-picker {
  --highlight-background: var(--wheel-highlight-background);
  --highlight-border-radius: var(--wheel-highlight-border-radius);
  --fade-background-rgb: var(--wheel-fade-background-rgb);
}

/**
 * Convert a font size to a dynamic font size.
 * Fonts that participate in Dynamic Type should use
 * dynamic font sizes.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param unit (optional) - The unit to convert to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * Convert a font size to a dynamic font size but impose
 * a maximum font size.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
 * @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * Convert a font size to a dynamic font size but impose
 * a minimum font size.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
 * @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * Convert a font size to a dynamic font size but impose
 * maximum and minimum font sizes.
 * @param size - The initial font size including the unit (i.e. px or pt)
 * @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
 * @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
 * @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
 * convert to a unit other than $baselineUnit.
 */
/**
 * A heuristic that applies CSS to tablet
 * viewports.
 *
 * Usage:
 * @include tablet-viewport() {
 *   :host {
 *     background-color: green;
 *   }
 * }
 */
/**
 * A heuristic that applies CSS to mobile
 * viewports (i.e. phones, not tablets).
 *
 * Usage:
 * @include mobile-viewport() {
 *   :host {
 *     background-color: blue;
 *   }
 * }
 */
:host {
  --background: var(--ion-color-step-100, var(--ion-background-color-step-100, #ffffff));
  --title-color: var(--ion-color-contrast);
}

:host .datetime-header {
  -webkit-padding-start: 20px;
  padding-inline-start: 20px;
  -webkit-padding-end: 20px;
  padding-inline-end: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  background: var(--ion-color-base);
  color: var(--title-color);
}

:host .datetime-header .datetime-title {
  font-size: 0.75rem;
  text-transform: uppercase;
}

:host .datetime-header .datetime-selected-date {
  margin-top: 30px;
  font-size: 2.125rem;
}

:host .calendar-action-buttons ion-button {
  --color: var(--ion-color-step-650, var(--ion-text-color-step-350, #595959));
}

.calendar-month-year-toggle {
  -webkit-padding-start: 20px;
  padding-inline-start: 20px;
  -webkit-padding-end: 16px;
  padding-inline-end: 16px;
  padding-top: 12px;
  padding-bottom: 12px;
  min-height: 48px;
  background: transparent;
  color: var(--ion-color-step-650, var(--ion-text-color-step-350, #595959));
  z-index: 1;
}
.calendar-month-year-toggle.ion-focused::after {
  opacity: 0.04;
}

.calendar-month-year-toggle ion-ripple-effect {
  color: currentColor;
}

@media (any-hover: hover) {
  .calendar-month-year-toggle.ion-activatable:not(.ion-focused):hover::after {
    background: currentColor;
    opacity: 0.04;
  }
}
:host .calendar-days-of-week {
  -webkit-padding-start: 10px;
  padding-inline-start: 10px;
  -webkit-padding-end: 10px;
  padding-inline-end: 10px;
  padding-top: 0px;
  padding-bottom: 0px;
  color: var(--ion-color-step-500, var(--ion-text-color-step-500, gray));
  font-size: 0.875rem;
  line-height: 36px;
}

:host .calendar-body .calendar-month .calendar-month-grid {
  -webkit-padding-start: 10px;
  padding-inline-start: 10px;
  -webkit-padding-end: 10px;
  padding-inline-end: 10px;
  padding-top: 4px;
  padding-bottom: 4px;
  /**
   * Calendar on MD will show an empty row
   * if not enough dates to fill 6th row.
   * Calendar on iOS fits all dates into
   * a fixed number of rows and resizes
   * if necessary.
   */
  grid-template-rows: repeat(6, 1fr);
}

:host .calendar-day {
  width: 42px;
  min-width: 42px;
  height: 42px;
  font-size: 0.875rem;
}

/**
 * Day that today but not selected
 * should have ion-color for text color.
 */
:host .calendar-day.calendar-day-today {
  border: 1px solid var(--ion-color-base);
  color: var(--ion-color-base);
}

/**
 * Day that is not today but
 * is selected should have ion-color for
 * text color and be bolder.
 */
:host .calendar-day.calendar-day-active,
:host .calendar-day.calendar-day-adjacent-day.calendar-day-active {
  color: var(--ion-color-contrast);
}

.calendar-day.calendar-day-active,
.calendar-day.calendar-day-active:focus {
  border: 1px solid var(--ion-color-base);
  background: var(--ion-color-base);
}

:host .calendar-day.calendar-day-adjacent-day {
  color: var(--ion-color-step-500, var(--ion-text-color-step-500, gray));
}

:host .datetime-time {
  -webkit-padding-start: 16px;
  padding-inline-start: 16px;
  -webkit-padding-end: 16px;
  padding-inline-end: 16px;
  padding-top: 8px;
  padding-bottom: 8px;
}

:host .time-header {
  color: var(--ion-color-step-650, var(--ion-text-color-step-350, #595959));
}

/**
 * Add some margin when only selecting month/year
 * otherwise layout will too constricted.
 */
:host(.datetime-presentation-month) .datetime-year,
:host(.datetime-presentation-year) .datetime-year,
:host(.datetime-presentation-month-year) .datetime-year {
  margin-top: 20px;
  margin-bottom: 20px;
}

:host .datetime-buttons {
  -webkit-padding-start: 10px;
  padding-inline-start: 10px;
  -webkit-padding-end: 10px;
  padding-inline-end: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}