@use '../core/tokens/token-utils';
@use './m3-datetimepicker';

$fallbacks: m3-datetimepicker.get-tokens();

$clock-min-size: 224px !default;
$clock-margin: 12px !default;
$clock-cell-size: 14.1666% !default;

.mtx-clock {
  position: relative;
  display: block;
  min-width: $clock-min-size;
  margin: $clock-margin;
  box-sizing: border-box;
  user-select: none;
  touch-action: none;
  font-size: token-utils.slot(datetimepicker-clock-text-size, $fallbacks);
}

.mtx-clock-wrapper {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 100%;
  border-radius: 50%;
  background-color: token-utils.slot(datetimepicker-clock-dial-background-color, $fallbacks);
}

.mtx-clock-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3%;
  height: 3%;
  margin: -1.5%;
  border-radius: 50%;
  background-color: token-utils.slot(datetimepicker-clock-hand-background-color, $fallbacks);
}

.mtx-clock-hand {
  position: absolute;
  inset: 0;
  width: 2px;
  margin: 0 auto;
  transform-origin: bottom;
  background-color: token-utils.slot(datetimepicker-clock-hand-background-color, $fallbacks);

  &::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -3px; // 8px - 2px / 2
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: token-utils.slot(datetimepicker-clock-hand-background-color, $fallbacks);
  }
}

.mtx-clock-hours,
.mtx-clock-minutes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: 350ms;
  transform: scale(1.2);

  &.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
  }
}

.mtx-clock-minutes {
  transform: scale(.8);
}

.mtx-clock-cell {
  position: absolute;
  display: flex;
  width: $clock-cell-size;
  height: $clock-cell-size;
  justify-content: center;
  box-sizing: border-box;
  border-radius: 50%;
  align-items: center;
  cursor: pointer;
  color: token-utils.slot(datetimepicker-clock-cell-text-color, $fallbacks);

  &.mtx-clock-cell-selected {
    color: white;
    background-color: token-utils.slot(datetimepicker-clock-hand-background-color, $fallbacks);
  }

  &:not(.mtx-clock-cell-selected, .mtx-clock-cell-disabled):hover {
    background-color: token-utils.slot(datetimepicker-clock-cell-hover-state-background-color, $fallbacks);
  }

  &.mtx-clock-cell-disabled {
    pointer-events: none;
    color: token-utils.slot(datetimepicker-clock-cell-disabled-state-text-color, $fallbacks);
  }
}
