/* DatePicker (built here, as the birth date's prototype draws it): a date in one field of three segments, day, month and year,
   with the calendar button at its end, set off by a hairline. The field's look is TextField's, through its classes; the
   segment holding the focus has a soft turquoise highlight, one in error a red one, and the whole field's border turns red.
   Under it one line: the helper, the date read back in words with a check, or the error. The calendar is a sheet in a native
   dialog over the dimmed page (the app's modal: a bottom sheet on a phone, a card on a desktop), with a chip for each decade
   above the Air Datepicker calendar (AirDatepicker.css). Without JavaScript the native date input shows; with it
   (`data-enhanced`) the segments show. Tokens only. */
.wi-date-picker__field[hidden],
.wi-date-picker[data-enhanced] .wi-date-picker__fallback {
  display: none;
}
.wi-date-picker .wi-date-picker__field {
  gap: var(--space-0-5);
  /* As tall empty as with its Clear button, which shows once it holds something: the field never changes height. */
  min-height: calc(var(--size-button-md) + 2 * var(--border-1));
  padding-block: 0;
  padding-inline: calc(var(--wi-field-padding-inline, var(--space-4)) - var(--space-0-5)) var(--space-1);
  cursor: text;
}
.wi-date-picker__segment {
  box-sizing: border-box;
  flex: none;
  min-width: 0;
  padding: var(--space-1) var(--space-0-5);
  font: inherit;
  font-size: var(--wi-field-font-size, var(--font-size-base));
  line-height: var(--wi-field-line-height, var(--font-line-height-base));
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  outline: none;
}
.wi-date-picker__segment::placeholder {
  color: var(--text-tertiary);
}
.wi-date-picker__segment--day,
.wi-date-picker__segment--month {
  width: 2.1em;
}
.wi-date-picker__segment--year {
  width: 3.4em;
}
.wi-date-picker__segment:focus {
  background: var(--background-accent-subtle);
  box-shadow: inset 0 0 0 var(--border-2) var(--brand-secondary-bg);
}
.wi-date-picker__segment[data-invalid] {
  background: var(--feedback-error-bg);
  box-shadow: inset 0 0 0 var(--border-2) var(--feedback-error-border);
}
.wi-date-picker__separator {
  padding-inline: var(--space-0-5);
  font-size: var(--wi-field-font-size, var(--font-size-base));
  color: var(--text-tertiary);
  user-select: none;
}
.wi-date-picker__fill {
  flex: 1;
  align-self: stretch;
}

/* The Clear button and the calendar button end the field: a round hover each, a hairline on the calendar's left. */
.wi-date-picker__clear,
.wi-date-picker__trigger {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--size-button-md);
  height: var(--size-button-md);
  padding: 0;
  color: var(--text-secondary);
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.wi-date-picker__clear[hidden] {
  display: none;
}
.wi-date-picker__clear[data-hovered],
.wi-date-picker__trigger[data-hovered],
.wi-date-picker__trigger[aria-expanded="true"] {
  color: var(--text-primary);
  background: var(--background-sunken);
}
.wi-date-picker__clear[data-focus-visible],
.wi-date-picker__trigger[data-focus-visible] {
  outline: none;
  box-shadow: var(--focus-ring);
}
.wi-date-picker__clear svg,
.wi-date-picker__trigger svg {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
}
.wi-date-picker__divider {
  position: absolute;
  inset-block: var(--space-2);
  inset-inline-start: calc(-1 * var(--space-0-5));
  width: var(--border-1);
  background: var(--border-default);
}

/* The line under the field keeps its height whatever it says, so the page below it never moves. */
.wi-date-picker .wi-date-picker__helper {
  min-height: var(--font-line-height-sm);
  font-size: var(--font-size-sm);
  line-height: var(--font-line-height-sm);
}
.wi-date-picker__helper [hidden] {
  display: none;
}
.wi-date-picker__readback {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--feedback-success-fg);
  font-weight: var(--font-weight-medium);
}
.wi-date-picker__readback svg {
  flex: none;
  width: var(--size-icon-xs);
  height: var(--size-icon-xs);
}

/* The sheet: the modal's overlay and card, narrower. A bottom sheet on a phone (`wi-sheet-on-phone`, Sheet.css: its grip, its
   motion, dragged down to close by sheet_controller.js), a card of 25rem centered on a wider screen. Its head is
   SheetHeadComponent's, a little tighter, with the card's base-size title on a wider screen. */
.wi-date-picker .wi-date-picker__sheet {
  display: flex;
  flex-direction: column;
}
.wi-date-picker .wi-date-picker__head {
  padding-bottom: var(--space-0-5);
}
@media (min-width: 768px) {
  .wi-date-picker .wi-date-picker__sheet {
    max-width: 25rem;
    padding: var(--space-3) var(--space-3) var(--space-4);
  }
  .wi-date-picker__head .wi-sheet__title {
    font-size: var(--font-size-base);
    line-height: var(--font-line-height-base);
  }
  /* The card's page dim (a sheet on a phone has Sheet.css's). */
  .wi-date-picker .wi-native-dialog[open] .wi-date-picker__overlay {
    animation: wi-sheet-dim 0.2s ease-out both;
  }
  .wi-date-picker .wi-native-dialog[data-closing] .wi-date-picker__overlay {
    animation: wi-sheet-undim 0.2s ease-in both;
  }
}
.wi-date-picker__decades,
.wi-date-picker__quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-1) var(--space-3);
}
.wi-date-picker__chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--size-control-sm);
  padding: var(--space-1) var(--space-3);
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  background: var(--background-surface);
  border: var(--border-1) solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
}
.wi-date-picker__chip[data-hovered] {
  background: var(--background-accent-subtle);
  border-color: var(--border-strong);
}
.wi-date-picker__chip[data-focus-visible] {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* A calendar to tap: its days are as tall as a control. */
.wi-date-picker__calendar .air-datepicker-body--cells {
  grid-auto-rows: var(--size-control-md);
}
.wi-date-picker__calendar .air-datepicker-cell {
  font-size: var(--font-size-base);
  border-radius: var(--radius-full);
}
.wi-date-picker__calendar .air-datepicker-nav--title,
.wi-date-picker__calendar .air-datepicker-nav--action {
  min-width: var(--size-control-md);
  min-height: var(--size-control-md);
  border-radius: var(--radius-full);
}

/* A range (`range`): the panel of the days filter. Two fields, From and To, side by side (one above the other on a phone), each
   its own TextField-like field with its Clear button; only an error line under them; a quiet button that opens the calendar,
   the quick ranges' chips, and a footer. The calendar (below) has its days as tall as a button (44px), the days of the range
   on the accent with its first and last day rounded, and a footer of Clear and Apply. */
.wi-date-picker__side-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.wi-date-picker__side-field {
  min-width: 0;
}
.wi-date-picker--range .wi-date-picker__helper {
  min-height: 0;
}
.wi-date-picker__shortcuts {
  display: grid;
  justify-items: start;
  gap: var(--space-1);
  margin-top: var(--space-1);
}
/* The quiet button of the panel and of the calendar's head on a phone: a link-coloured text button with its icon. */
.wi-date-picker__calendar-button,
.wi-date-picker__back {
  align-items: center;
  font: inherit;
  font-weight: var(--font-weight-semibold);
  color: var(--text-link);
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.wi-date-picker__calendar-button[data-hovered],
.wi-date-picker__calendar-button[aria-expanded="true"],
.wi-date-picker__back[data-hovered] {
  background: var(--background-sunken);
}
.wi-date-picker__calendar-button[data-focus-visible],
.wi-date-picker__back[data-focus-visible] {
  outline: none;
  box-shadow: var(--focus-ring);
}
.wi-date-picker__calendar-button {
  display: inline-flex;
  gap: var(--space-1);
  min-height: var(--size-button-sm);
  margin-inline-start: calc(-1 * var(--space-2));
  padding: 0 var(--space-2);
  font-size: var(--font-size-sm);
}
.wi-date-picker__calendar-button svg {
  width: var(--size-icon-sm);
  height: var(--size-icon-sm);
}
/* The panel's footer: Clear while a day is set (it is `hidden` otherwise), and on a phone Apply, which sends the days the
   fields hold. */
.wi-date-picker__actions .wi-date-picker__action {
  flex: none;
}
/* Apply is the form's submit button: on a desktop the days are sent by the script as they are final, so it shows on a phone
   only. Without JavaScript the native date fields show, Apply with them, and what only the script does (the calendar, the
   quick ranges, Clear) stays away. */
.wi-date-picker[data-enhanced] .wi-date-picker__submit {
  display: none;
}
.wi-date-picker:not([data-enhanced]) .wi-date-picker__actions {
  display: flex;
}
.wi-date-picker:not([data-enhanced]) .wi-date-picker__shortcuts,
.wi-date-picker:not([data-enhanced]) .wi-date-picker__actions .wi-date-picker__action:not(.wi-date-picker__submit) {
  display: none;
}
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-body--cells {
  grid-auto-rows: var(--size-button-md);
}
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-nav--title,
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-nav--action {
  min-width: var(--size-button-md);
  min-height: var(--size-button-md);
}
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-cell.-in-range- {
  border-radius: 0;
}
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-cell.-range-from- {
  border-radius: var(--radius-full) 0 0 var(--radius-full);
}
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-cell.-range-to- {
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-cell.-range-from-.-range-to-,
.wi-date-picker--range .wi-date-picker__calendar .air-datepicker-cell.-selected-:not(.-in-range-) {
  border-radius: var(--radius-full);
}
/* The footers of the panel and of the calendar: their buttons under a hairline. */
.wi-date-picker__actions,
.wi-date-picker__calendar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: var(--border-1) solid var(--border-default);
}
.wi-date-picker__actions[hidden] {
  display: none;
}
.wi-date-picker__action {
  flex: 1;
  min-height: var(--size-button-md);
  padding: var(--space-1) var(--space-4);
  font: inherit;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  background: var(--background-surface);
  border: var(--border-1) solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
}
.wi-date-picker__action--primary {
  color: var(--text-on-brand);
  background: var(--brand-secondary-bg);
  border-color: var(--brand-secondary-bg);
}
.wi-date-picker__action:disabled {
  opacity: 0.45;
  cursor: default;
}
.wi-date-picker__action[data-focus-visible] {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (max-width: 767.98px) {
  .wi-date-picker__segment--year {
    width: 3.2em;
  }
  /* A row of chips to swipe sideways: nothing wraps. */
  .wi-date-picker__decades {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .wi-date-picker__decades::-webkit-scrollbar {
    display: none;
  }
  /* The panel: its fields one above the other, Apply beside Clear (both as tall as a finger), the quick ranges wrapping. */
  .wi-date-picker__side-fields {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .wi-date-picker__actions[hidden] {
    display: flex; /* with no day set, Apply alone */
  }
  .wi-date-picker__actions .wi-date-picker__action,
  .wi-date-picker__submit {
    flex: 1;
  }
  .wi-date-picker[data-enhanced] .wi-date-picker__submit {
    display: revert;
  }
  /* The calendar over the panel: the way out is "back" (the label), not a ×. */
  .wi-date-picker__back {
    display: inline-flex;
    gap: var(--space-0-5);
    min-height: var(--size-button-md);
    padding: 0 var(--space-2) 0 var(--space-1);
  }
  .wi-date-picker__back svg {
    width: var(--size-icon-md);
    height: var(--size-icon-md);
  }
  .wi-date-picker--range .wi-date-picker__head .wi-sheet__close {
    display: none;
  }
  .wi-date-picker--range .wi-date-picker__head .wi-sheet__title {
    flex: 1;
    text-align: center;
    margin-inline-end: var(--size-button-md);
  }
}
