/**
 * @license EUPL-1.2+
 * Copyright Gemeente Amsterdam
 */

@use "../../common/resets" as *;
@use "../../common/text-rendering" as *;

.ams-time-input {
  @include reset-input;

  background-color: var(--ams-time-input-background-color);
  border-color: var(--ams-time-input-border-color);
  border-style: var(--ams-time-input-border-style);
  border-width: var(--ams-time-input-border-width);
  box-sizing: border-box;
  color: var(--ams-time-input-color);
  font-family: var(--ams-time-input-font-family);
  font-size: var(--ams-time-input-font-size);
  font-weight: var(--ams-time-input-font-weight);

  // Reset inline size of 10em set by Android devices.
  inline-size: auto;
  line-height: var(--ams-time-input-line-height);

  // Set min block size for iOS, otherwise an empty box is a lot smaller than a filled one.
  min-block-size: calc(
    (var(--ams-time-input-font-size) * var(--ams-time-input-line-height)) + 2 * var(--ams-time-input-padding-block)
  );

  // Set min inline size for iOS, so the size is closer to the filled in size.
  min-inline-size: calc(4ch + (2 * var(--ams-time-input-padding-inline)));
  outline-offset: var(--ams-time-input-outline-offset);
  padding-block: var(--ams-time-input-padding-block);
  padding-inline: var(--ams-time-input-padding-inline);
  touch-action: manipulation;

  @include text-rendering;

  // Reset padding on webkit time edit fields to override the value of 1px in the UA stylesheet.
  &::-webkit-datetime-edit,
  &::-webkit-datetime-edit-ampm-field,
  &::-webkit-datetime-edit-fields-wrapper,
  &::-webkit-datetime-edit-hour-field,
  &::-webkit-datetime-edit-millisecond-field,
  &::-webkit-datetime-edit-minute-field,
  &::-webkit-datetime-edit-second-field {
    padding-block: 0;
  }
}

// This changes the default calendar icon on Chromium browsers only
.ams-time-input::-webkit-calendar-picker-indicator {
  appearance: none;
  background-image: var(--ams-time-input-calendar-picker-indicator-background-image);
  cursor: var(--ams-time-input-calendar-picker-indicator-cursor);
}

.ams-time-input:hover::-webkit-calendar-picker-indicator {
  background-image: var(--ams-time-input-hover-calendar-picker-indicator-background-image);
}

.ams-time-input:disabled {
  color: var(--ams-time-input-disabled-color);
  cursor: var(--ams-time-input-disabled-cursor);
}

.ams-time-input:not(:disabled):invalid,
.ams-time-input:not(:disabled)[aria-invalid="true"] {
  border-color: var(--ams-time-input-invalid-border-color);
}

.ams-time-input:not(:disabled):hover {
  box-shadow: var(--ams-time-input-hover-box-shadow);
}

.ams-time-input:not(:disabled):invalid:hover,
.ams-time-input:not(:disabled)[aria-invalid="true"]:hover {
  border-color: var(--ams-time-input-invalid-hover-border-color);
  box-shadow: var(--ams-time-input-invalid-hover-box-shadow);
}
